this post was submitted on 16 Sep 2025
290 points (97.1% liked)

Programmer Humor

26608 readers
1778 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] edinbruh@feddit.it 69 points 1 week ago (1 children)

That's like... It's purpose. Compilers always have a frontend and a backend. Even when the compiler is entirely made from scratch (like Java or go), it is split between front and backend, that's just how they are made.

So it makes sense to invest in just a few highly advanced backends (llvm, gcc, msvc) and then just build frontends for those. Most projects choose llvm because, unlike the others, it was purpose built to be a common ground, but it's not a rule. For example, there is an in-developement rust frontend for GCC.

[–] Kazumara@discuss.tchncs.de 20 points 1 week ago (2 children)

that’s just how they are made.

Can confirm, even the little training compiler we made at Uni for a subset of Java (Javali) had a backend and frontend.

I can't imagine trying to spit out machine code while parsing the input without an intermediary AST stage. It was complicated enough with the proper split.

[–] BuboScandiacus@mander.xyz 13 points 1 week ago

I can imagine;

[–] LeFantome@programming.dev 10 points 1 week ago (1 children)

I have built single pass compilers that do everything in one shot without an AST. You are not going to get great error messages or optimization though.

[–] Kazumara@discuss.tchncs.de 3 points 1 week ago

Oh! Okay, that's interesting to me! What was the input language? I imagine it might be a little more doable if it's closer to hardware?

I don't remember that well, but I think the object oriented stuff with dynamic dispatch was hard to deal with.

[–] LeFantome@programming.dev 48 points 1 week ago* (last edited 1 week ago) (3 children)

GCC is adding cool new languages too!

They just recently added COBOL and Modula-2. Algol 68 is coming in GCC 16.

Honestly, now that I can see the "business productivity" through-line from COBOL, to BASIC, and most recently, Python, I should probably just learn COBOL.

[–] parlaptie@feddit.org 65 points 1 week ago (2 children)
[–] LeFantome@programming.dev 16 points 1 week ago* (last edited 1 week ago) (3 children)

I guess I should have put a /s but I thought it was pretty obvious. The 68 in Algol 68 is 1968. COBOL is from 1959. Modula-2 is from 1977.

My point exactly was that all the hot new languages are built with LLVM while the “new” language options on GCC are languages from the 50’s, 60’s, and 70’s.

I am not even exaggerating. That is just what the projects look like right now.

[–] brotundspiele@sh.itjust.works 5 points 1 week ago

If Algol68 is from 1968, shouldn't Modula-2 be from 1898?

[–] sukhmel@programming.dev 4 points 1 week ago (1 children)

I would guess those languages are added for preservation and compatibility reasons, and it's also an important thing

[–] LeFantome@programming.dev 2 points 1 week ago

I think some are getting used actually, particularly COBOL. I think Modula-2 still gets used in some embedded contexts. But these languages are not exactly pushing the state-of-the-art.

Algol 68 is interesting. It is for sure just for academic and academic enthusiast purposes. Historical and educational value only as you say.

load more comments (1 replies)
[–] Skullgrid@lemmy.world 9 points 1 week ago

It's new to gcc!

[–] davidagain@lemmy.world 4 points 1 week ago
BEGIN    
    BEGIN
        Wow, 
        Modula 2! 
    END;    
    I remember Modula 2.
END.
[–] davidagain@lemmy.world 33 points 1 week ago (2 children)

Great optimisation, awwwful compile times.

[–] davidagain@lemmy.world 23 points 1 week ago (2 children)

New kid on the block, roc, has it right by splitting application code from "platform"/framework code, precompiling and optimising the platform, then using their fast surgical linker to sew the app code to the platform code.

Platforms are things like cli program, web server that kind of thing. Platforms provide an interface of domain specific IO primitives and handle all IO and memory management, and they also specify what functions app code must supply to complete the program.

It's pretty cool, and they're getting efficiency in the area of systems programming languages like C and Rust, but with none of the footguns of manual memory management, no garbage collection pauses, but yet also no evil stepparent style borrow checker to be beaten by. They pay a lot of attention to preventing cache misses and branch prediction failures, which is his they get away with reference counting and still being fast.

A note of caution: I might sound like I know about it, but I know almost nothing.

[–] CanadaPlus@lemmy.sdf.org 10 points 1 week ago* (last edited 1 week ago) (1 children)

That sounds pretty great. My impression is that relatively little code actually runs that often.

but with none of the footguns of manual memory management, no garbage collection pauses, but yet also no evil stepparent style borrow checker to be beaten by.

That part sounds implausible, though. What kind of memory management are they doing?

[–] davidagain@lemmy.world 7 points 1 week ago* (last edited 1 week ago) (2 children)

Reference counting.

They pay a lot of attention to preventing cache misses and branch prediction failures, which is how they get away with reference counting and still being fast.

[–] CanadaPlus@lemmy.sdf.org 10 points 1 week ago (17 children)

Oh, you just mean it's a kind of garbage collection that's lighter on pauses. Sorry, I've had the "my pre-Rust pet language already does what Rust does" conversation on here too many times.

[–] BatmanAoD@programming.dev 8 points 1 week ago (1 children)

To be fair, the drop/dealloc "pause" is very different from what people usually mean when they say "garbage collection pause", i.e. stop-the-world (...or at least a slice of the world).

[–] CanadaPlus@lemmy.sdf.org 2 points 1 week ago (1 children)

Yeah, it might be better, I don't actually know. It's not as novel as OP maybe thinks it is, though.

[–] BatmanAoD@programming.dev 3 points 1 week ago (1 children)

That's fair; Python, Swift, and most Lisps all use or have previously used reference-counting. But the quoted sentence isn't wrong, since it said no "garbage collection pauses" rather than "garbage collection."

[–] CanadaPlus@lemmy.sdf.org 4 points 1 week ago* (last edited 1 week ago)

Yes, I read or interpreted that wrong at first.

[–] firelizzard@programming.dev 2 points 1 week ago (2 children)

Garbage collection is analyzing the heap and figuring out what can be collected. Reference counting requires the code to increment or decrement a counter and frees memory when the counter hits zero. They’re fundamentally different approaches. Also reference counting isn’t necessarily automatic, Objective-C had manual reference counting since day one.

[–] BatmanAoD@programming.dev 6 points 1 week ago

"Garbage collection" is ambiguous, actually; reference counting is traditionally considered a kind of "garbage collection". The type you're thinking of is called "tracing garbage collection," but the term "garbage collection" is often used to specifically mean "tracing garbage collection."

[–] CanadaPlus@lemmy.sdf.org 3 points 1 week ago (1 children)

It's still mentioned as one of the main approaches to garbage collection in the garbage collection Wikipedia article.

[–] firelizzard@programming.dev 1 points 1 week ago (1 children)

Ok, I concede the point, “garbage collection” technically includes reference counting. However the practical point remains - reference counting doesn’t come with the same performance penalties as ‘normal’ garbage collection. It has essentially the same performance characteristics of manual memory management because that’s essentially what it’s doing.

[–] CanadaPlus@lemmy.sdf.org 2 points 1 week ago* (last edited 1 week ago) (1 children)

That may well be. I'd say I understand the basic concepts, but people in this thread have more detail on the specifics and how they work out in practice than me.

It does make me wonder why everyone hasn't been doing it, if there's no drawbacks, though.

[–] firelizzard@programming.dev 1 points 1 week ago (1 children)

It is being used. Objective-C (used for macOS and iOS apps) has used reference counting since the language was created. Originally it was manual, but since 2011 it's been automatic by default. And Swift (which basically replaced Objective-C) only supports ARC (does not support manual reference counting). The downside is that it doesn't handle loops so the programmer has to be careful to prevent those. Also, the compiler has to insert reference increment and decrement calls, and that's a significant engineering challenge for the compiler designers. Rust tracks ownership instead of references, but that means it's compiler is even more complicated. Rust's system is a little bit like compile-time reference counting, but that's not really accurate. Apparently Python, Pearl, and PHP use reference counting, plus tracing GC (aka 'normal' GC) in Python and PHP to handle cycles. So your implicit statement/assumption that reference counting is not widely used is false. Based on what I can find online, Python and JavaScript are by far the most used languages today and are roughly equal, so in that respect reference counting GC is equally or possibly more popular than pure tracing GC.

[–] CanadaPlus@lemmy.sdf.org 1 points 1 week ago* (last edited 1 week ago) (2 children)

Everyone doing it was a critical distinction there. OP is making it sound like there's literally no drawbacks. If that was so, I'm pretty sure tracing would have long since died out. It has come up that a lot of languages do use it elsewhere in the thread.

Which is another reason I'm not so sure Roc is the answer we've all been waiting for. Then again, the first few Rust proponents would have sounded the same way.

load more comments (2 replies)
load more comments (15 replies)
[–] frezik@lemmy.blahaj.zone 3 points 1 week ago (1 children)

I wish more languages used ref counting. Yes, it has problems with memory cycles, but it's also predictable and fast. Works really well with immutable data.

[–] davidagain@lemmy.world 3 points 1 week ago (2 children)

Roc uses immutable data by default. It performs opportunistic in-place mutation when the reference count will stay 1 (eg this code would satisfy the borrow checker without cloning or copying if it were rust - static code analysis).

load more comments (2 replies)
[–] lena@gregtech.eu 13 points 1 week ago (2 children)

Yeah, I think Go's compiler is so fast partially because it doesn't use LLVM

[–] firelizzard@programming.dev 5 points 1 week ago

TinyGo isn’t that much slower and it uses LLVM

[–] davidagain@lemmy.world 2 points 1 week ago

That would work!

[–] tatterdemalion@programming.dev 12 points 1 week ago (1 children)

Isn't Zig working on their own backend?

Also, pretty excited about the cranelift project.

[–] vpol@feddit.uk 7 points 1 week ago (1 children)

Yes, and it’s now default for x86_64

[–] brucethemoose@lemmy.world 14 points 1 week ago

I'll make my own LLVM, with blackjack and hookers.

load more comments
view more: next ›