Hacker News new | ask | show | jobs
by danielovichdk 1375 days ago
Most beautiful cpp code I have seen in many years
2 comments

I was just about to make this same exact comment! I was half way down the page and thought, "Wait... What language is this again?" I had to scroll back up to confirm.
Clean and readable, more like C than meta filled C++ with templates.
Nah, it’s just having professional coding and review standards that are very heavily enforced. This particular code is also aided by being fairly simple in function of course. In my experience C code is generally worse than C++, as a lot of what large C projects do is stuff that C++ does automatically, and with more safety.

That said for the most squirrely code in webkit you need to look to JSC where the perf critical and machine abusing code is stuck (though obviously minimized as much as possible). My most terrible contribution there is the parser which uses macros and templates together (parsing JS is extremely perf critical in real world page loading because the parser often has to deal with megs of code, all of which has to be parsed before you can consider executing it and in many places page loading is blocked on said execution)

Probably because it’s mostly if statements, neat functions and string translation.
It's almost as if the reason C++ can suck is actually because most developers write code that's incomprehensible.