Skip to content

Comment on Why C++ is not my favourite languageparent

Comments

C++ hits a certain sweet spot. In some cases - whether you like it or not - it's just the right tool for the job. Two examples I can think of are:

* VM implementations (I mentioned Factor, but also HotSpot, Microsoft's CLR, SquirrelFish, TraceMonkey, V8 and Opera's Carakan are all high-performance VMs written in C++ (x). Note also that all major layout engines are written in C++. Complex but fast and highly-tuned beasts)

* Production rendering. PRMan, MentalRay and pretty much every other renderer in day-to-day use on film and video post-production are written in C++.

People who write these systems care deeply about performance. They'll dip into assembly when they have to. While fast, C won't cut it because in these cases, it doesn't give you enough abstraction to avoid making your code a mess (strong typing, operator overloading and templates in particular, but also virtual method dispatch)*. I'm sure if you ask them, they'd tell you that they'd love to use something nicer and more modern. But it doesn't yet exist.

This is not to say that C++ is the right tool for writing web applications, or even the average desktop application, or even - increasingly these days - games. But somebody needs to write the stack underneath, and that stack needs to be fast.

(x) note Mono as an example of a VM that sticks with C. But it contains a lot of object-oriented shennanigans that probably could be better expressed in C++, and the core developers came from a strong C culture.

How about D? A friend of mine uses it as a better C++ for mathematical programming (optimization, graphs and so on).

Perhaps nobody would have invented C++ if D would have come earlier.

Yes, D shows a great deal of promise. Maybe I'm short-sighted, but at the moment it's the only language I can see being a viable replacement for what C++ does well. D was invented by Walter Bright, after he had written a C++ compiler (and somehow kept his marbles). I think it was his take on a better C++. Quite a few other clever people have jumped on board to help with the design since.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.