r/ProgrammerHumor • • 1d ago

Meme itSucksToBeACompilerDev

Post image
1.7k Upvotes

85 comments sorted by

684

u/Lowmax2 1d ago

I just assumed a compilers are an act of God and no mortal could possibly create one.

308

u/Ultra_HR 1d ago

unless you are Terry A. Davis, who was sent by god himself to do exactly that

74

u/lomberd2 1d ago

They are in my walls. I can hear them

26

u/sawkonmaicok 1d ago

You fucking drive them over.

17

u/CarlCarlton 1d ago

"Is this too much voodoo that... This is the op... This... There is... This is voodoo. The question is, is this too much, and that's... This is the hardest question you could ever face in programming. This right here is the hardest question. Right here. Right here is the hardest question in programming. Is this too much voodoo for the next 10 centuries, as... for God's official temple."

112

u/No-Association2297 1d ago

I have formal training in compilers from a master's degree on a track that revolves around compilation/verification/proofs (programming technology), it's the most eye opening thing you can do I swear. I kid you not, it got me deeply into literature and philosophy because holy fuck you start seeing patterns everywhere

55

u/HRApprovedUsername 1d ago

I mean so can studying anything. It’s almost like our monkey brains want to make patterns

12

u/metaglot 1d ago

pareidolia has entered the chat

14

u/Bakoro 21h ago

Education has a tendency to spark curiosity, but I've never heard of someone reading literature or history losing their shit and running off to learn linear algebra.

I've studied art, music, philosophy, history of various kinds, various kinds of engineering, mathematics, computer science, physics, chemistry...

Mathematics, physics, and computer science hits different.
That stuff for-real changes the whole brain, and if you get deep in it, the world starts looking different.

I don't know how to describe it, but when I was studying heavily I could feel my mind stretching and bending, and contorting. My sleep would be troubled, and sometimes I wouldn't have dreams in the normal dream way, I'd be in a floating dark space for what felt like days.

Practicing an instrument is the only thing that comes even close to heavy mathematics and algorithms.
After days of practicing, I might have a rough night and wake up with a jump in ability, but with math and computer science, I'd be having straight-up epiphanies to the point that I understand how religious people must feel about divine revelation.

4

u/overkill 19h ago

I can still remember vividly waking up in the middle of the night with a realisation about static objects in C++, and being excited that something had clicked.

This is coming from a math-heavy background, but not a computer science one. But it really gets fun when you start looking at the physical layers of computing and thinking about how you could build a simple but also very slow CPU using the pipes in your walls and a large body of elevated water.

2

u/HRApprovedUsername 10h ago

Just because you haven’t heard of it doesn’t mean it hasn’t happened. Those are all logic-based, so of course once you start breaking things down, do you see it everywhere. There’s actually a similar literature phenomenon, where you learn a new word or phrase and you suddenly start seeing it everywhere. You little monkey brain just likes making patterns. They’re not special.

2

u/MoreDimension5963 16h ago

I understand how religious people must feel about divine revelation.

People look at me very weirdly when I say that I feel an almost religious divinity to mathematics, yet you've described it perfectly! ❤️

1

u/StaticCoder 9h ago

Huh. I have extremely similar training and still think most philosophy is just people calling each other wrong with no evidence.

50

u/definitely_not_tina 1d ago

My university required us to implement a simple one as part of our curriculum.

41

u/ShakaUVM 1d ago

Yeah it used to be pretty standard CS curriculum. Less common these days.

It's not hard exactly but it can be very frustrating when you have an ambiguous grammar and it's time consuming to add all the stuff in

24

u/SundayKiefBowls 1d ago

echo file | gcc

That was so easy. What's with kids these days? Are they stupid?

13

u/MissinqLink 1d ago

imo the hardest part is having multiple compile target architectures. Just compiling to one instruction set isn’t too bad.

1

u/Jbolt3737 8h ago

Wait a second... we're the programmers, we can just decide anything that isn't x86 is too hard to write code for and never make compilers target anything else again! It's genius

2

u/BlobAndHisBoy 23h ago

The most frustrating part about my compilers course was the professor forced us to write all our own data structures. I spent more time writing and debugging data structures that I already understood from my data structures class the semester prior than I did learning and implementing a compiler.

8

u/Allen_Koholic 1d ago

I had to do mine in a class that was also an intro to C. And bash. And Linux. I remember it not being all that bad, so I assume I did an absolutely awful job.

-7

u/Ok_Meringue_6196 1d ago

Same, and I'm proud to say I passed with very little help from AI, chatgpt was the only one back then and it was very weak

24

u/metaglot 1d ago

Writing a c++ compiler is definitely not trivial, but if you invent a simple language and try and write a compiler for it, you will realize its not so terrible. But obviously again, a c++ compiler is not a starter project ;)

22

u/Rabbitical 1d ago

I'm working on my C+++ compiler, where every ++ token encountered in the source increments the language being parsed

7

u/metaglot 1d ago

malbolge vibes

8

u/tropicbrownthunder 1d ago

Probably you need to write your compiler for your new language in C or C++ anyways

2

u/metaglot 1d ago

Yeah, you can't really write a compiler in a language that doesn't exist (i know, assembly). But isn't at least partly a goal of (most) compiled languages to become self-hosting?

3

u/drnfc 21h ago

I mean you can write your bootstrap compiler in almost anything. Rust used ocaml iirc. You can then rewrite your compiler in your language and compile that.

1

u/Realistic-Safety-565 2h ago

You can write compiler for your language in your language... just won't be able to compile it ;).

4

u/jackinsomniac 20h ago

Such is known as Dark Wizardry, similar to writing GPU drivers. Very similar to Deep Wizardry, like people who write filesystem or database software.

From the guy who wrote 'A story about magic', although it seems like there's a lot less content on his site than before.

1

u/Antervis 1d ago

Well, considering how many people dedicate their lives to writing compilers across several last decades and industries, it should be pretty obvious that indeed, no single mortal man would have the lifespan to write a compiler.

1

u/EuenovAyabayya 1d ago

I mean, once you compile anything else to C, you're basically done. /s

1

u/Jbolt3737 8h ago

I've been trying to ascend to godhood for a while now

•

u/franticcreator7316 4m ago

Fancy text transformers built by folks who forgot what the sun looks like.

0

u/Brambletail 1d ago

I hope this is a joke

242

u/New_Salamander_4592 1d ago

while prowling through C++ standard libraries my favorite discovery was std::get_money. not only is that a funny name but its also seemingly the most useless standard library function?

like it just parses numbers out of a string that lists currency, stripping away any currency symbols or instances of USD, notable without retaining how many cents were listed. so 1.99 becomes 199. So I guess it has to assume all numbers listed also come with at least .00 for the cents place? just a very... odd function to have in a standard library.

139

u/RiskyPenetrator 1d ago

Funnily enough this approach of converting floats to ints for finance systems is standard.

Its done because floating point math can cause issues when processing payments so its more secure to store values in their lowest denomination along side an exponent and apply the exponent upon use in UI or reporting tools.

I suspect whoever added it was designing these systems.

110

u/atomic_redneck 1d ago

The COBOL language designers solved this problem by doing calculations in packed decimal (binary coded decimal). However, in the process of solving this problem they introduced another problem: you have to program in COBOL.

11

u/EuenovAyabayya 1d ago

...unless the COBOL has an API that you can call from anything else...

5

u/QuaternionsRoll 20h ago

1

u/atomic_redneck 5h ago

Neat. I retired in 2022 and have not been keeping up with the standard.

2

u/-Memnarch- 16h ago

Delphi has a dedicated type for this, too. It's called Currency. In TSQL/MS SQL Server there is Money and SmallMoney.

36

u/EuenovAyabayya 1d ago

std::get_money.

must code std:fuck_bitches just for completeness

14

u/interyx 1d ago

I think it makes sense. In any application where you're actually doing calculations on money it's integer math, so it has to be converted to cents before it's usable.

11

u/xSTSxZerglingOne 23h ago edited 22h ago

I worked in the financial industry as a back-end software engineer. All money totals were listed as a long integer, a 64 bit integer, in cents. The decimal was added on the front-end. It makes sense. Floats and doubles are weird.

22

u/Lowmax2 1d ago

Yea that definitely sounds like a C++ feature alright

Part of the reason I abandoned it for C once you realize you don't need any of those features 😂

(im a firmware engineer for context)

4

u/reallokiscarlet 1d ago

You thinkin what I'm thinkin?

7

u/solaris_var 1d ago

If you think std::atoi and std::atof are useless, then yes this is useless. Otherwise it's a godsend.

However, I do agree that it being part of the stdlib is questionable. I guess finance people had some leeway in the committee

9

u/Excession638 1d ago edited 1d ago

std::atoi has undefined behaviour if the number in the string doesn't fit in an int. It's worse than useless, and should never be used over std::strtol or similar more modern functions.

80

u/OmegaPoint6 1d ago

Its fine, they enjoy it

5

u/gerbosan 1d ago

Keith comes to my mind. 😅

18

u/StochasticTinkr 1d ago

Volume 1

8

u/TheTerrasque 1d ago

Abridged version

90

u/elmanoucko 1d ago

people think AI implementing entire math textbook in LEAN to build upon is impressive, but the real AGI moment will be when they'll implement the current C++ standard, argue for hours with a comitee and end up creating their own better dialect instead

38

u/shrodikan 1d ago

It's interesting to think about the ideal programming language for LLMs.

-9

u/Blue_Moon_Lake 1d ago

The ideal programming language for LLM is a high level (mostly functional) script so going from English to code or code to English is almost transparent.

1

u/shrodikan 5h ago

I lean towards compilation. AIs do well with acceptance criteria that compilers implicitly give. It's why I use Rust as it is the most compiler-strict.

15

u/Mammoth_Molasses_927 1d ago

C++ definitely didn't become a better language with all the changes through the years. So much garbage they added. That's mostly why Rust and other languages are getting its space.

7

u/StaticCoder 22h ago

I will strongly disagree with that conclusion. Rust is making progress because, despite (not because of) updates to the language, memory safety issues are still prevalent. And because compatibility is paramount, there's only so much that can be done.

I will also disagree that it didn't become a better language, though that's definitely more subjective.

7

u/meneldal2 21h ago

C++ got a fair bit of improvements, but you would need to kill off about half the committee to get something really good. First who needs to go is IBM and National bodies, so much time wasted arguing about removing trigraphs nobody using modern C++ cares about.

You have to accept there will be some breaking changes for the sake of the language not becoming some hellscape worse than C++CLI.

2

u/HovercraftNo7372 22h ago

sure... rust is getting its space... where? C++ (and C) are still king for embedded systems, or safety critical systems - not rust.

listen, rust has its perks. its a great language, i like it. i think taking cognitive load off of devs is great. however, writing safe c++ was always possible. many of tools have been developed in c++ to help with some of the safety issues of c, and even then we have static analysis tools, etc to help with finding issues.

30

u/Groostav 1d ago

Lol I wish.

The problem with cpp isn't that it's overly defined it's that it isn't fully defined.

There's a mountain of places where "you know what I mean"isms exist in the language.

The classics are the dangling else and the '>>' operator. But there are loads more of ill-defined things in the cpp language that basically compiler authors have to decide: what did we do historically, what do gcc, clang and msvc do, and try to muddle through with a compromise.

5

u/StaticCoder 22h ago

What about the dangling else and the >> operator is not well specified in the current standard? This isn't 1998

4

u/StaticCoder 22h ago

This being said, I will acknowledge that no known compiler follows any version the standard exactly. They all have extensions and/or bugs that code ends up relying on.

1

u/Groostav 9h ago

If you are a library author in 2026 you may still choose to close a template with > > (note the space, ie T1<T2<T3> >) because in 2026 you are still not certain your boreland users will parse your headers correctly.

This is still very much a live problem.

Boost, targeting cpp03, still does this.

1

u/StaticCoder 9h ago

Sure that's a problem for some code. But it's not the (current) standard's fault, nor is it an issue for compiler writers (which do sometimes have the opposite problem of having to parse code that doesn't conform to newer standards)

By the way this might be relevant: https://6826.csail.mit.edu/2019/papers/coverity.pdf

1

u/StaticCoder 9h ago

Also I don't think this was ever ill-defined. Annoying for code writers sure (see also most vexing parse), but well-defined, and not really an issue for compiler writers.

1

u/Groostav 2h ago

I don't know what to tell you. The language says '>>' is sometimes a template closing, sometimes the shift right operator. The lexer can't know without parser context meaning you can't express its lexical rules in standard BNF. It's "you know what I mean". Different compilers implemented it differently until cpp11. It's not properly defined and there is no formal cpp grammar.

1

u/StaticCoder 1h ago edited 1h ago

https://eel.is/c++draft/temp.names#8

Of course the C++ grammar is context-dependent, which is super annoying, but that's not the same as not well defined. By comparison, Rust is very much not well defined, though at the semantic rather than syntactic level (I don't remember seeing not-well-defined syntax in Rust, though it might be there)

1

u/Groostav 18m ago

Dude: different compilers correctly do different things with the same text.

What does "not fully defined" mean if not that?

And what does Widget w(Timer()); do?

3

u/Marisa_osi_JP 1d ago

C++ sucks. C is still fine.

3

u/aieidotch 23h ago

and obj-c

3

u/Fit_Day375 21h ago

Let me introduce you. Objective-C++

2

u/aieidotch 21h ago

:) please no

1

u/hoangpham133 1d ago

and by the time she reaches the last page the committee has already shipped the next edition

1

u/StaticCoder 22h ago

Good news: most of the standard describes the library!

1

u/Initial-Jaguar6230 21h ago

Image creating compiler without any standards

1

u/LeDYoM 17h ago

I dont understand why "it sucks". This looks fun.

0

u/Prior-Perspective-61 19h ago

It sucks to be a C++ compiler dev, writing a compiler for your own programming language... Also sucks, but at least you define this standard 🤣

-36

u/Kadabrium 1d ago • Bravo

Compilers should be written more often in high level languages. They don't have the same performance requirements as interpreters.

28

u/rinart73 1d ago

Have you ever compiled a big C++ project?

-12

u/Kadabrium 1d ago

A beta version of clang that i needed to run my reflective brainfuck interpreter took maybe half an hour. Does that count as big

24

u/SaneLad 1d ago

Right to jail.

-4

u/AWonderingWizard 1d ago

It's the truth. Common Lisp has great performance compared to most languages and is incredibly smooth sailing for implementing parsers, interpreters, etc.