Hacker News new | ask | show | jobs
by javadyan 5247 days ago
Any useful language is a freaking enormous ball of mud. Bjarne said: there are only two kinds of languages - the ones people complain about and the ones nobody uses.
3 comments

I can not think of a cognitively bigger language than C++. And I mean language, not library set or anything like that, but literally, what the syntactic constructs are, how they are defined, and in particular how they end up interacting with each other. I often wonder how many of the C++ defenders could actually answer detailed questions about it, or how much of the code they write would actually deeply, deeply surprise them with what memory allocation bugs are lurking, how much indirection there really is, or how many implicit copies of things they are making if they really took the time to step through the assembly language version. Or how many of them could bang out a decently accurate summary of the new official memory model, let alone how it might interact with all of the other features of C++. Or for real bonus points, successfully use it without introducing enormous numbers of things that are, technically, errors, but it so happens you never run into them at runtime.

Non-zero, I'm sure, but I bet single-digit percentages, tops. Except that last one, which I'd put money on sub-1%.

What are the odds that C++, as a fairly extreme outlier, is actually closer to optimal for the general purpose tasks it is used for than all the other languages?

You can replace C++ with almost any other mainstream language in the above paragraph and it would still hold true. Problem is, contemporary general-purpose languages are used for such a wide range of different tasks that it is simply impossible for them not to be complex (syntactically or in terms of runtime envoronment). And yes you can hide complexity behind abstractions (which our programming languages successfully do), but you cannot really eliminate it. And despite all that I see more real-world applications written in "horrible" languages like C++ or Java than in "elegant" languages like Common Lisp.
I can write Java code that will not surprise me with unexpected copies, contain huge memory problems (GC does have edge cases, but if you throw that in I will throw in "non-trivial memory management in C++ when 'just use a smart pointer' doesn't work" and you don't come out ahead at all), or surprise me greatly with the memory model. It doesn't have a huge syntax, and the language doesn't get 50% bigger on every release of the syntax. Many Java programmers can answer questions that go quite deep into how Java works.

I don't like or use Java, and it isn't perfect by any means. My point is just how far I didn't have to go down the list of "mainstream languages" before your claim is completely false. C++ is an outlier.

C also has the memory leaking issue, but the rest is false as well. Though in the memory model case it's by virtue of not having one.

And that's sticking with a very generous-for-you interpretation of "mainstream". If I'm allowed to dip down to Python or something you're even worse off.

All I can say is, I can write C++ code that will not surprise me with unexpected copies, contain huge memory problems, or surprise me greatly with the memory model.Stop whining and learn to use your tools, goddamit.
Stroustrup is right, but that doesn't prove your point. Every language will have detractors, but not every language will be the target of every particular complaint. Lua, for example, is a useful language and it has largely avoided being a ball of mud.

Naturally, that minimalism brings its own set of issues and complaints. But the point is, you don't need to be as much of a ball of mud as C++ in order to be useful or successful. I think a lot of language partisans, and C++ partisans in particular, point to Stroustrup's quote as an excuse for their language's warts. It's true that no language can ever be perfect, but that doesn't mean that all complaints are without merit and unworthy of attention and consideration.

I can't remember the source, but I'm sure I read somewhere that programming languages are either too large or too small...