LemmaEOF

Your favorite chubby cuddlebot

Hey! I'm Lemma, and I'm a chubby queer robot VTuber who both makes and plays games on stream! I also occasionally write short stories and tinker with other projects, so keep an eye out! See you around~

Chubbyposting and IRL NSFW alt: @cuddlebot

name-color: #39B366



tef
@tef

crabby is a language, like c++, offers zero cost abstractions. unlike c++, crabby has linear and affine types, and there's a single ownership model for data, enforced by the compiler. crabby even has a macro system, too.

for some reason, crabby is very popular with both socialists who like the gift economy, and libertarians who really like bitcoin, but i digress, i really want to talk about the zero cost abstractions bit, but first let me talk about qt


to say "qt is a cross platform gui c++ library" is to misunderstand qt. it's more than just a library, or even a framework, it's a whole runtime.

there's strings, lists, and other collections, there's an event loop and message framework, and a network io library that's tightly integrated. there's a metaobject library that provides reflection, amongst other things, and there's also a gui library that even has a web browser component. this is why qt is so big.

when you use qt in a project, the actual language you're using with it doesn't matter as much. it'll be easier to work with other qt projects than ones written in the same language, as their code will also be full of QStrings and QLists and QFiles

in some ways, this is a showcase of zero cost abstraction in C++. you can build a wholly new language runtime, if you need it, and there isn't a performance overhead for doing it your own way either.

on the other hand, maybe qt could have been written in something like java, and might have been a bit less work. there's an object system, there's reflection, there's even common types for iterators and observers and collections that all work together. qt wouldn't have needed to implement the universe if most of it was set out in the standard library.

anyway, enough about qt, let's go back to crabby.

let's think about a world where qt was implemented in crabby, not c++: ahhh. we could enforce ownership on qwidget dom trees, we could use macros instead of a preprocessor to annotate objects, and maybe we could even use async and await for the event loop and message processing. lovely.

since crabby also touts zero cost abstractions, our crabby runtime wouldn't be at any major disadvantage to a c++ version. strike one up for the crabby strike force. pew pew. just one small detail to note:

much like the c++ version, the zero cost abstractions are only being used to provide features that you can take for granted in other languages: like objects or reflection. if crabby provided those features out of the box, qt wouldn't really need much in the way of the zero cost abstractions.

still, the idea of rewriting qt in crabby isn't half bad. writing safe components in a larger framework is one of the places where crabby has made an impact before. crabby doesn't come with an object system or reflection, because it's more often than not, embedded into a larger system with it's own rules and ideas about how those things work.

crabby is was designed around building components and [hold up i'm just getting a text message] i've been informed that many people now assert crabby to be a language for application development and there's at least two competing event loops wait no there's a new one on the front page of hacker news. no idea how many json libraries.

anyway, my point is this:

zero cost abstractions make sense when people are building runtimes in your language, and zero cost abstractions make sense when you're embedding your language into a larger system, but sometimes when you cut out a feature, you'll end up with fifteen different incompatible ones in the gap.

c++ spawned a thousand object and event systems and it's highly likely that crabby users will tread the same path, footstep by footstep.

i really do wish rust came with some opt-in reflection and object models, but then again, it's kinda funny that when a language is proud of not having a feature, the first thing any serious user does is add it back in.

either way, i'm glad qt could be implemented in c++, but i'm even happier that i can use qt in a language that isn't c++


You must log in to comment.

in reply to @tef's post:

I think perhaps one interesting way to think about it, is that writing the platform stuff there is very costly. In a different hypothetical language called GroundSquirrel, with huge corporate investment, building all those layers of abstractions is a relatively achievable goal. But writing half of Qt in addition to writing a whole new language is pretty daunting, and there's potential that nobody will use it because it makes the wrong decisions or is perceived badly.

I think this kind of impacts things like GC as well. It's not trivial to write a state of the art GC, and making that part of your language environment load bearing puts a huge burden on your ability to execute for lots of people's use-cases.

I think perhaps one interesting way to think about it, is that writing the platform stuff there is very costly.

Yep, which is why i'd like to pay once, rather than every time I use a langauge

I think this kind of impacts things like GC as well.

Sure, but adding things like reflection makes GC easier.

I really like a lot of Rust's design features but I'm slightly put off by it being a systems language, since I've been a Java developer for more than a decade and find Java's object system to really work for the problems I want to solve, and how I want to solve them. Alas. I am in many ways blessed for never having to deal with C++

I really want Java but without nulls and with Rust's compiler

Maybe it's just because I'm not as deep into app dev land, but isn't Kotlin like half of that? Pls correct me if I'm wrong here, I have pretty limited exposure to it and it doesn't come up as much in "PL nerd discourse"

Kotlin is fine, but it just looks and works more like TypeScript or Python, but doesn't actually add the kinds of safety features I'm looking for.

But i should probably try Kotlin, I might like things about it, but it's syntax is sometimes a bit too idiomatic for my tastes.

I’ve been in the JVM for about a decade and think Kotlin solves or at least soothes a lot of ugliness of Java and let’s you add wanted compile time guarantees with nice patterns, like the when match expression opens up a lot of doors for application or library writers. I’ve written a few Kotlin libraries at work that I don’t think would have been anywhere as nice in Java, and has spared my peers a lot of foot guns. Data classes, when keyword, some functional chaining with “let”, “also” etc, expressions being allowed on the right side of assignment operators etc.

I can have way less unnecessary branches as a result

All this to say: the water is fine, come on in!

Not to be all on the Swift team but “Rust with strong opinions about object and reflection models [and ABI]” is pretty much Swift once some more of the ownership model lands.

Ironically that means I’d personally be better off with Rust in some ways since I am implementing a runtime/stdlib and as you point out it excels in that domain.

“Rust with strong opinions about object and reflection models [and ABI]” is pretty much Swift once some more of the ownership model lands.

pretty much, and i'd wager it's probably easier to take the object model out of swift, than it is to add an object model back in to rust

well, a similar amount of compiler work, but at least one of these means people use compatible options

(help I'm a young developer do you mean QuickTime or some other thing when you say qt)

Also, as for why a lot of people my age like Rust: like 80% of it is that it's a non-strictly-functional language with powerful functional features that's fast and lets you use a sensible sum type.

A lot of us also grew up with a strong hatred for Java in one way or another. It's kind of viewed as "the nightmare language" and anything that feels like an answer to it is something we flock to

Also, basically every dev my age seems to be a weird libertarian or a socialist, there don't seem to be many "normie libs" or even "normie conservatives" among the young devs anymore. I think that explains at least some of the observed popularity among those groups.

@tef means the Qt Framework, which back in the day (by which I mean 1995) was one of the first cross-platform Linux/Windows widget toolkits. It was/is the UI framework used by KDE, one of the first comprehensive desktop environments for Linux. (The other toolkit and corresponding desktop environment were/are GTK and GNOME.) Qt has expanded over time as @tef mentioned and now has a comprehensive runtime environment including, uh, wow, networking, and ... looks like distributed task graphs? ... and a distributed build system? ... well, it's got 30+ years of feature accumulation, definitely a "mature" piece of software.

Wikipedia has a decent history section.

Java is maligned for a ton of reasons but the main reason is also it’s strength: it’s boring and unsexy. I’m at a point in my career now where I love boring. Boring is less likely to page me off hours, boring is easier to test, boring is easier to mentor others about, boring is easy to prescribe solutions about. Java and the JVM solve a ton of operational and observability headaches as well in a lot of business contexts.

I think until you work a lot of boring “real world jobs” in boring areas like e-commerce sites or goofy b2b contexts, you will struggle to see its appeal and have yet to experience the fear of opening some weird python repo written in a long dead trend framework.

Learn to love Java as just another tool in your belt imo. I cut my teeth on C/C++ and hated Java forever and now see how silly and small minded that was. Now I’m a little hobby rust goblin who makes money in boring Java/Kotlin

In my experience the hate for Java comes down to it being really annoying to work with (even in an enterprise context, which is most of my dev experience). Most of us learned on Python (because it's easy) or Java (because it's what AP computer science and a ton of intro college courses use). Like, it's not about the "boringness" of the code; if it was just that everyone would hold the same disdain for C#.

I haven't seen anyone make complaints similar about Kotlin and everyone appreciates what the JVM is doing, they just hate the actual language itself.

I also personally (and this is just because I went to school at a university that literally fired all of its object-oriented-language PL people) really kind of hate objects as the core thing you're working with and Java forces you to engage with those systems where C++ wouldn't.

If C# was as ubiquitous I do think people would have the same disdain for it! I’ve encountered those who do.

I’m a big Kotlin fan and don’t miss Java, to be clear. But using Java in common enterprise contexts like Spring could be “ok”

I had written a big ol idiot nerd post trying to sorta break this down more but I thought of a better summary and chose to delete it.

edit: fuck i wrote another big idiot nerd post. i just need people to understand that with enough time, most people i hope come to realize java's syntax problems and some of its little warts are the least of your problems in the wide wide world of real world software, and it often becomes a very attractive solution when you balance all the factors at play

I've written software in a lot of professional contexts, python for web, python for embedded, embedded-C for custom HALs and part-testers, Java7 for frontend (android), framework-less Java 8+ for high throughput distributed services, frameworky ancient Java (old Spring, old repos), Kotlin in modern Spring (even 3.x recently! woo!), Akka stuff, I'm a Kotlin coroutines nerd and have had to regrettably get good Java Reactor, etc.

All this to say that in all situations I've been in, there really wasn't a better actual alternative to Java. And in many situations I came across, the business solution started as Python, but between GIL and all the python ecosystem problems, Java was chosen as the only viable "next big step" for that business context and ended up remaining so for eternity.

Are we going to write business backend software in C++? fuck no, nightmare. I mean you could but good luck affording high quality staff who can do this without just causing problems. Are we gonna do it in RoR? Similar problems to python with diminishing returnsin pure backend contexts, hard pass. Python? Obviously no, does not scale well, and the weird monkeypatching people do to try and get around GIL stuff isn't a great solution. Go? Rob Pike designed it because he, in his own words, felt that people were too stupid to write good code in more complex languages and needed a dumb little hand holdy replacement, and it still has ended up kinda sucking as time goes on and is rotting with ecosystem problems and repeating mistakes they tried to avoid (half baked generics, still a GC'd language with some tradeoffs that implies etc)

C#? C# is fine, I've written tons of C#, but .NET/Mono don't really have the same head-start the Java world did for "real world" frameworks, it wouldn't be a bad choice, LINQ is great, even better if you're, say, in Azure doing lots of cloud stuff there.

I've come across some teams that really pushed hard to get node.js BE codebases up and running in a mature manner, but it's still young and it feels like a new fad-framework is born every year, and typescript increasingly just feels like it's re-learning lessons the "boring" languages did a long time ago with types and guards and static-analysis-friendly design choices, why not just write Kotlin at this point? There is some good hiring potential here though!

All this to say that when you are in a situation where you need to make a business happy, quickly, and need to write a bunch of resilient, testable, scalable serverside logic, with frameworks that are going to actually work and do so for years and years.. Most roads lead to at least strongly considering JVM oriented approaches, and the alternatives don't have crazy good benefits when you get into the brass tacks of all the business concerns (team compositions and transferability, hire-ability, pay, ready-made libraries for your cloud architecture, etc).

In "real world" situations, my "nightmare language" to stumble across has become things like Python, weirdly composed node.js repos where I know im about to a bunch of time fighting weird npm issues and the trendy test framework they use has been out of date for a year and doesn't work unless you do XYZ, or a ruby repo whose env setup is out of date and ruby gems is pissed about some random dep that depends on some os feature that my laptop no longer supports, etc. 99% of the time in every JVM job I've had, I can download a JDK, set my JAVA_HOME, install a JetBrain IDE, clone one of the MANY java repos, and just open it.

I've found js dev to be mostly ok when you're limited to a monorepo or two and don't need to risk every repo being it's own setup journey, but I've found Java/Kotlin/JVM to be remarkably consistent development experience in BE ecosystems where we have literally had 70+ active microservice repos that all have a deployment of some kind. I cant imagine this going well as well as it does in any other language but maybe rust or C#.

I will say: a lot of the uglyness I've encountered with both Qt and it's architectural cousin Gtk/Glib, fundamentally stems from allowing objects to exist. The DOM does not require garbage collection or C++/Glib style inheritance; it is a tree and thus can be dealt with simply using ownership and heap allocation. It would not be absurd to write a GUI Toolkit that:

  1. never even tries to do "synchronous" event dispatch, where the UI service task hangs on some controller code
  2. never garbage collects, requiring the view and model to be a DAG and simply using reference counting
  3. Doesn't do reflection, except through (a) an interface to machine-generate a grammar and parser for the UI/model specification DSL and (b) a model-state snapshot system that enforces consistency.

This would weaken the Qt/GTK model somewhat, because you'd lose the ability to write graphical GUI builders and would be forced to accept performance overhead with every signal dispatch, but those features also showcase a lot of the nightmare potential of the DIY object systems. I'd call it a net win.

  1. this doesn't happen in qt??? well, not intentionally

qt is event based, as in the "apartment threading" or "async/await" sense, so yes, if you run a blocking operation in the main thread, the main thread gets blocked

  1. qt has parent child mapping so deallocating root of dom deallocates the rest of the widget tree. it isn't garbage collected, it's almost arena based

  2. ah, alas, but that's not what reflection is used for in qt, or gtk

for qt it's used for things like "ensuring you can cast", or extracting debugging information, and in general, run time type information does end up sticking around in any language, the only question is how much

This would weaken the Qt/GTK model somewhat, because you'd lose the ability to write graphical GUI builders

i'm not sure why having an unmanaged dom tree on the heap stops you from serializing and deserialzing it either