"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."
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
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.
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.
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.
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
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.
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.
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 ;)
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?
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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)
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.
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.
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)
It's the truth. Common Lisp has great performance compared to most languages and is incredibly smooth sailing for implementing parsers, interpreters, etc.
684
u/Lowmax2 1d ago
I just assumed a compilers are an act of God and no mortal could possibly create one.
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.
80
u/OmegaPoint6 1d ago
Its fine, they enjoy it
18
u/StochasticTinkr 1d ago
Volume 1
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
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.
3
u/Marisa_osi_JP 1d ago
C++ sucks. C is still fine.
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 •
Compilers should be written more often in high level languages. They don't have the same performance requirements as interpreters.