4 ms·
> I've since moved on to languages that weren't full of problems like this I think you mean aren't full of those problems yet. :) There's a lot of nasty corne
by munificent 10y ago
> I've since moved on to languages that weren't full of problems like this
I think you mean aren't full of those problems yet. :)
There's a lot of nasty corners in C++ but almost all of them are because it effectively has 40 years of wild success. (I say 40 because C++ inherits C's baggage and success.)
It's totally reasonable to pick a younger language with fewer warts. Become an expert in it! Be productive! Ship lots of apps.
Then, one day, decades and several versions hence, you may find yourself now dealing with all of the warts that language has accrued over time. At this point, you're too invested in it to jump ship. The marginal cost of learning a new corner case is smaller than the cost to start over from scratch and learn 2046's new hot language.
Alas, expertise is hard. Everything you learn makes you better at X but slightly disincentivizes you to learn Y, which may not even exist yet.
- seanwilson 10y ago> Then, one day, decades and several versions hence, you may find yourself now dealing with all of the warts that language has accrued over time. What languages are getting even close to being as bad as C++ in this respect though? Java, Python and JavaScript have been around for a while now for example and they seem more opinionated in a way that stops too many warts from appearing. C++ has undefined and compiler dependent behaviour in the core of its design which I think is the real problem. Its complexity just multiplies at an exponential rate as more features and undefined behaviour is introduced.
- nv-vn 10y agoC# maybe? The amount of features in it is very rapidly nearing those of C++.
- sqeaky 10y agoMost languages have Undefined and Implementation specific behavior. Few languages have so carefully specified their undefined behavior as C++ though.
- seanwilson 10y agoAny examples? My experience is you will frequently be bitten by undefined behaviour in C++ if you don't know the rules well but this is very rare in other languages. It's rare you're going to get a segfault or the whole program crashing in languages like Python, Java and JavaScript.
- firethief 10y agoThose languages all have heavy runtime environments; if a segfault occurs it's an interpreter bug. Whether the mistakes you can make are a result of "undefined behavior" is a different question whether from the consequences of a mistake are an abrupt termination, or an abrupt termination with a helpful error message.
- sqeaky 10y agoThis is how it works in Ruby. In the CRuby/MRI interpretter when a segfault happens it calls the #to_s method on the current execution context, to get the some memory address and technical details. Ruby happens to be flexible enough that you can override that method. Then you can call whatever you want and you have effectly "recovered" from a segfault. The parser is totally in an inconsistent state and could crash at any moment for any reason but it works often enough people have done it live in front of audiences for talks. It is not officially specified that I am aware of that overloading #to_s on anything allows recovering of segfaults it is intended for converting things to_strings. For more on what I mean start reading the Ruby standard, which was about 1,500 pages last I checked. Then check the C++ standard which is about 3,000 for C++11 and then another 2,500 for the standard library. C++ with its standard library is much smaller than Ruby (in terms of the functionality provided) but has at least 3 times the specificity.
- blub 10y agoInteresting post. Small comment: the C++11 standard has about 1300 pages, not 5500, thank goodness.
- mvf0 10y agoI would argue that there are rabbit holes in Haskell that can lead to baroque terrors of syntax on par with the C++ horrors in the article. The difference between Haskell and C++ is that Haskell code always has a well defined meaning even if it is _insanely_ terse. There is no ambiguity like with C++.
- flukus 10y agoJavascript certainly has. Most people don't even seem to be writing javascript in javascript anymore.
- junke 10y agoNot all languages age the same way. That's the reason I enjoy writing Lisp code even if I am not paid for it. There are some warts, but it aged well.
- nommm-nommm 10y agoJava is over two decades old and one of the most widely used languages in the world. It has absolutely stood the test of time. While it does has its pain points its nowhere near as terrible as C++ and (in my opinion) is improving with new versions, and honestly, I think its a joy to program in though that might not be a "cool" thing to say. Whereas C++ is a chore to program in. That's my opinion, maybe I'm just too used to high level programming to be "good" in C++ but my experience is C++ breaks the "principle of least astonishment" every single time I use it. For example, a simple operation like clearing a stringstream is... not straightforward. ...Or maybe I'm just not smart enough.
- blub 10y agoWell, there's not a lot of room for problems to crop up when all one can do is define classes :) Still, here's a few for you: the design of Cloneable is considered to be a mistake, as are exception specifications. These have real negative consequences. File IO was laughably bad and completely unintuitive needing several classes for the simplest of tasks (perhaps this was fixed more recently, but funny you should mention streams). Resource management was quite tricky to get right before try-with-resources and it still is if one wants performance. Memory leaks and resource leaks are still possible. Boxing and unboxing. The particularly weak type-erased generics. Java's saving grace is that it's a very programmer-friendly language. No matter how much one screws up, the worst that's probably gonna happen is a null pointer exception with a nicely formatted stack trace attached. The tooling is top class. All of this means that anybody with a pulse can program in Java and get a mostly working program. It won't be a joy to use, unless one is particularly impressed by classes, methods, interfaces in abundance, class hierarchies and factories. C++ is not like that. If one doesn't use the safer modern idioms and makes a mistake it will crash (if lucky),or act in weird ways or corrupt something. Sometimes there is no way to avoid dangerous code. There is no nice stack trace, you have to work for it. Probably have to stare at assembly and work with a fully featured but thoroughly painful to use command line debugger that's twice as old as Java. But it's powerful and really fast. It lets one design creatively, because it supports more abstraction possibilities. And it's not owned by any corporation, it's an international standard that runs on most platforms. I understand why people use Java. I use C++ because it's not just a tool that gets the job done, but also a way to challenge myself to make something that requires attention and skill. If I want to, it's me and the machine without framewerks, factories, fancy IDEs, dependency injection, package managers and virtual machines.
- chc 10y agoEh, from what I've seen, a lot of what people now consider to be the "warts" of C++ were there when I learned it in the '90s. Not all, obviously — but a lot of them, like the STL and all the relics of C, are quite old. It seems similar to JavaScript. There were some initial good ideas and a bunch of early bad ideas and we're stuck layering improvements over that very uneven base.