r/ProgrammerHumor • • 2d ago

Meme itSucksToBeACompilerDev

Post image
2.0k Upvotes

101 comments sorted by

791

u/Lowmax2 2d ago

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

367

u/Ultra_HR 2d ago

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

91

u/lomberd2 2d ago

They are in my walls. I can hear them

31

u/sawkonmaicok 2d ago

You fucking drive them over.

22

u/CarlCarlton 2d 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."

127

u/No-Association2297 2d 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

64

u/HRApprovedUsername 2d ago

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

13

u/metaglot 2d ago

pareidolia has entered the chat

20

u/Bakoro 2d 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.

10

u/overkill 2d 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.

4

u/HRApprovedUsername 1d 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.

3

u/MoreDimension5963 1d 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! ❤️

3

u/tiajuanat 1d ago

German is specifically like Haskell, as you curry verbs.

2

u/frsbrzgti 10h ago

Linguistics

1

u/StaticCoder 1d ago

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

28

u/metaglot 2d 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 ;)

24

u/Rabbitical 2d ago

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

9

u/metaglot 2d ago

malbolge vibes

8

u/tropicbrownthunder 2d ago

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

2

u/metaglot 2d 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?

5

u/drnfc 2d 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.

4

u/Realistic-Safety-565 1d ago

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

3

u/metaglot 1d ago

The problem hosts itself.

51

u/definitely_not_tina 2d ago

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

42

u/ShakaUVM 2d 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 2d ago

echo file | gcc

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

14

u/MissinqLink 2d ago

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

2

u/Jbolt3737 1d 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

1

u/conundorum 6h ago

I'm surprised that you don't have a team that specialises in each target architecture, and a frontend that converts the language into an interim form. Frontend team is responsible for tokenising to mid-end, and architecture teams are responsible for writing a backend that compiles from mid-end tokens to their architecture.

1

u/MissinqLink 3h ago

Where do I get teams for these things? Only compilers I’m writing are hobby projects.

3

u/BlobAndHisBoy 2d 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.

9

u/Allen_Koholic 2d 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.

-8

u/Ok_Meringue_6196 2d 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

4

u/jackinsomniac 2d 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.

2

u/Antervis 2d 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.

2

u/EuenovAyabayya 2d ago

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

2

u/conundorum 6h ago

You jest, but you're not wrong. Anything that can cross-compile into C gets all the expertise of the gcc & clang teams. (And the MSVC team, too, but their C still lags a bit behind their C++, IIRC.)

2

u/Jbolt3737 1d ago

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

1

u/franticcreator7316 1d ago

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

0

u/Brambletail 2d ago

I hope this is a joke

275

u/New_Salamander_4592 2d 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.

165

u/RiskyPenetrator 2d 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.

130

u/atomic_redneck 2d 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.

17

u/EuenovAyabayya 2d ago

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

7

u/QuaternionsRoll 2d ago

1

u/atomic_redneck 1d ago

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

3

u/-Memnarch- 1d ago

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

44

u/EuenovAyabayya 2d ago

std::get_money.

must code std:fuck_bitches just for completeness

16

u/interyx 2d 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.

15

u/xSTSxZerglingOne 2d ago edited 2d 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 2d 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 2d ago

You thinkin what I'm thinkin?

6

u/solaris_var 2d 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

11

u/Excession638 2d ago edited 2d 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.

1

u/conundorum 6h ago

To be fair, atoi() is inherited from C, and not allowed to change its behaviour for C++. You can smoothly replace it with std::stoi() in all cases, to my understanding.

(Though, that said, you still want to verify the data beforehand, always use stoll() or strtoll(), or control the data format yourself so you can mandate integer size yourself.)

1

u/Excession638 6h ago

For stoi you need a std::string which may mean needing to copy first, which will do bad things to performance.

If std::string_view had been added from the start these problems wouldn't be as bad, but without it and std::span C++ was stuck using raw pointers for far too long.

1

u/conundorum 6h ago

Makes sense, it moves a fixed-point value into integer space to avoid floating-point rounding errors.

Honestly, if anything, I'm surprised that it doesn't become 1990 for rounding. (Get monetary value, to tenths of a cent. Different locales would allow different units, but it always goes to a tenth of the locale's smallest unit.) That would move the value into integer space just as cleanly, but also leave room for rounding to the nearest cent if necessary.

83

u/OmegaPoint6 2d ago

Its fine, they enjoy it

6

u/gerbosan 2d ago

Keith comes to my mind. 😅

20

u/StochasticTinkr 2d ago

Volume 1

11

u/TheTerrasque 2d ago

Abridged version

97

u/elmanoucko 2d 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

40

u/shrodikan 2d ago

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

-9

u/Blue_Moon_Lake 2d 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 1d 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.

16

u/Mammoth_Molasses_927 2d 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.

11

u/StaticCoder 2d 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.

9

u/meneldal2 2d 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.

4

u/HovercraftNo7372 2d 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.

3

u/conundorum 6h ago

Rust is starting to take C++'s place in areas where memory safety is critical, like military code. Though that's more because most C++ programmers are bad at actually managing memory correctly than because Rust is a better language, really; Rust's single biggest claim to fame is that it won't let memory bugs compile, which means that programmer competence (or lack thereof) is less of an issue.

Rust still doesn't beat C++ in performance (they can both be equally memory safe if you code perfectly, and I believe C++ still optimises better), and isn't actually a safer language. It's just that it's better at complaining about unsafe code.

1

u/HovercraftNo7372 5h ago

I am a C++ programmer - my question was more aimed at the claim that rust is starting to get space.

I do not know of many professional companies who hire rust devs in traditional C++ spaces such as avionics, automobiles, high frequency trading, medical devices, defense, game development, etc.

I have no problem with Rust, really.

34

u/Groostav 2d 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.

7

u/StaticCoder 2d ago

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

8

u/StaticCoder 2d 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.

2

u/Groostav 1d 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.

2

u/StaticCoder 1d 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 1d 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.

2

u/Groostav 1d 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.

2

u/StaticCoder 1d ago edited 1d 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)

2

u/Groostav 1d 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/StaticCoder 1d ago

What's an example of correctly doing different things (in a way the standard doesn't explicitly allow to something different, i.e. implementation-defined behavior)?

And yes this must be parsed as declaring a function w taking an unnamed function-typed parameter. It's not up to interpretation. The most vexing part is vexing, but well specified.

2

u/conundorum 6h ago

Technically, "implementation-defined" counts as "well-defined", under the grounds that "the behaviour of this code is determined by your compiler, and may differ from compiler to compiler" is clear and easy to understand.

Well-defined doesn't necessarily mean "helpful" or "must always behave this way specifically", for better and for worse. It just means that the behaviour is knowable and clearly stated, and "implementation-defined" technically fits that bill. Well-defined is the opposite of undefined, not the opposite of implementation-defined.

3

u/hoangpham133 2d ago

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

3

u/StaticCoder 2d ago

Good news: most of the standard describes the library!

3

u/LeDYoM 1d ago

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

2

u/Initial-Jaguar6230 2d ago

Image creating compiler without any standards

2

u/fanky10_g 1d ago

I made a simple compiler once, no big deal. It's like everything, it looks complex until you get into the shit and figure it out

2

u/conundorum 6h ago

Also true the other way around. Parts of the C++ standard were literally decided by 1) the gcc implementation forcing their hand, and 2) Microsoft wanting to backport something from C++/CLI into C++. I think clang might've had some influence, too, and maybe ICC, but I can't say for certain.

4

u/Marisa_osi_JP 2d ago

C++ sucks. C is still fine.

4

u/aieidotch 2d ago

and obj-c

5

u/Fit_Day375 2d ago

Let me introduce you. Objective-C++

3

u/aieidotch 2d ago

:) please no

1

u/Prior-Perspective-61 2d 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 2d ago • Bravo

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

29

u/rinart73 2d ago

Have you ever compiled a big C++ project?

-12

u/Kadabrium 2d 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 2d ago

Right to jail.

2

u/conundorum 6h ago

A language isn't competent until you can write its compiler in it.

-4

u/AWonderingWizard 2d ago

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