7 ms·
Now is a good time to bash C++. The alternatives are better than they were in 2009. For web stuff, Go is a good alternative. Rust is starting to look like a g
by Animats 12y ago
Now is a good time to bash C++. The alternatives are better than they were in 2009. For web stuff, Go is a good alternative. Rust is starting to look like a good alternative for low-level code.
The C++ crowd keeps trying to paper over the Mess Inside with templates, but the mold keeps coming through the wallpaper. After dealing with C++ since the mid-1990s, it's time to move on.
There have been good alternatives over the years, but their backing companies failed for other reasons. Xerox had Mesa and Cedar. DEC had Modula 3. Borland had Delphi. None went mainstream outside their niches.
Today, a compiler almost has negative commercial value. It took $20 million to launch Java, and the compiler was given away. The Go and Rust compilers are free. There was a time when a C or C++ compiler cost several hundred dollars. Now, you have to give them away. It's hard to fund development in that environment.
- eliben 12y agoI have to admit I fail to see the point you're trying to make with the price of the compiler; how does this bear negatively on the C++ language?
- pjmlp 12y agoYou need to be able to provide a compiler for your language that can beat C++ compilers, while offering for free, because in 2015 almost no one pays for compilers. So without a strong revenue, it is almost impossible to provide alternatives, hence the status quo doesn't change.
- CountSessine 12y agoI still don't understand the point that Animats is making - what you've said argues in favor of C++ given that C++ already has multiple high-quality compilers available for it. If revenue is such a big issue, how has the Rust community come so far with their compiler?
- pjmlp 12y agoPart of the Rust developers are employed by Mozilla, and Rust is being developed since 2006. http://www.steveklabnik.com/fosdem2015/ http://www.steveklabnik.com/fosdem2015/ You would hardly hear about it if development wasn't sponsored.
- CountSessine 12y agoAgain, maybe I'm being a bit thick here, but I still don't understand the point he's making. First he declares that the alternatives to C++ are better than ever, which I guess is true. He makes a point about Golang being a great alternative to C++ for web apps. I can't imagine that anyone is actually using C++ for web apps (are they?!?), so I don't see Golang as a C++ alternative so much as I see it as a Java or Ruby alternative. But I guess you could say that Golang is still quite literally a better choice for a webapp than C++ is - for that matter Golang is superior to INTERCAL for webapps too. Then there's this whole coda to his post where I guess he's trying to make the point that you can't make money selling C++ compilers anymore? Is he just missing the point? C++ compilers are part of an ecosystem - of course you don't make money selling them. Why has Microsoft always nearly given away Visual Studio? Why is Xcode free? Or is Animats making a more subtle argument here that I'm not parsing?
- pjmlp 12y ago> I can't imagine that anyone is actually using C++ for web apps (are they?!?) Well, Apache and IIS modules, or web access to embedded devices. > C++ compilers are part of an ecosystem - of course you don't make money selling them. It wasn't always like that. Back in the 80's and 90's if you wanted a compiler for any language, including C++, buying was the only option. I did buy a few of them. Microsof only offers Visual Studio since the 2005 version, as open source started to make a dent into Windows. The .NET SDK was the first developer tooling that Microsoft offered for free. Given the price difference between Macs and PCs, XCode isn't quite free. And you need to pay 100 euros/dolars yearly if you want access to the developer program. And if you look into the games consoles, embedded market or high performance computing, compilers are still commercial. But in the desktop and server market, hardly anyone will be willing to pay for compilers in 2015.
- bryanlarsen 12y agoThe reason that compilers are free is because they are complements in economic terms. Having good compilers available for free makes CPUs more valuable, that's why Intel & Apple invest millions of dollars every year into compilers. Good compilers make software more valuable, that's why Google, Apple and Mozilla invest millions. But you're right: compilers almost have negative commercial value. So many deep pockets are spending so much and giving away the results, making it hard to compete.
- weland 12y agoIt's worth noting though that part of Go's toolchain is based on that in Plan 9, which was well-funded at one point.
- static_noise 12y agoYou can bash C++ all you want yet it is the one language that stands in the middle of high performance and systems development. Somehow all the "alternatives" fail in some part and all you're left with is C++. Rust may be getting there but it will take years until you will program your embedded realtime application in it.
- pjmlp 12y agoIt wasn't always like that though. C++ got into this position due to people like me, that were considered hipster back then, by going with that slow molass, full of portability issues trying to implement parts of C++ARM, instead of C. I did it, because sadly the vendors of the alternatives mentioned by Animats didn't managed to keep their languages up to what the OS vendors were putting on their SDKs. So stuck between C and C++, at least C++ was already a better alternative than writing plain unsafe C code.
- tdees40 12y agoI'd make the argument that Rust is making many of the same mistakes as C++. It's got a kitchen-sink approach that has already accumulated some barnacles, and that ownership system is a mess.
- Animats 12y agoThe ownership system, the big innovation in Rust, isn't bad. The type system, macro system, and error handling interact to form a big mess. Exceptions would have been simpler than the mechanisms used to avoid exceptions.
- Animats 12y agoA note on exceptions. Exceptions have a bad reputation in some quarters. They're not in Go, Rust, or C, and they're troublesome in Java and C++. They're successful in Python. Why is this? It took several go-rounds to make Python exceptions generally useful. Originally, exceptions were just strings. Exceptions became more useful when an standard hierarchy of exceptions was defined and libraries were modified to use it. The Python exception hierarchy has a root of Exception, and one of its subclasses is EnvironmentError. Errors that reflect problems external to the program, such as I/O, network, and external data format errors, are subclasses of EnvironmentError. So if you catch EnvironmentError and report it properly, that covers most common cases. Exceptions not under EnvironmentError generally indicate program bugs, so those are usually allowed to propagate upward to the point where crash-level errors are handled. The default is a program abort and a stack backtrace. The other problem is getting things closed out properly after an exception. C++ tried doing this by having destructors close things. This works until something goes wrong in a destructor. Exceptions raised within destructors tend to cause problems. This tends to result in ignoring errors at close time. Go's "defer" has the same problem. Calling destructors from a garbage collector is even worse. Microsoft tried to address this in Microsoft Managed C++, resulting in painfully complicated destructor semantics. (Look up "re-animation" for Managed C++, if you like.) The Python solution was a "with" clause. This is borrowed from Common LISP's "(with-open-file ..) construct. The Python syntax is "with opening expression as object handle :". The opened object is open for the scope of the with clause, and upon exit from the with clause, the "__exit__" method of the object will be called, no matter how the with clause is executed. To make this work, I/O, locks, and database connectors had to be retrofitted with "__exit__" methods. This was done around Python 2.5-2.6; it took a while. The result is that Python functions that open and close things tend to have this pattern: def dosomething(args) : try: with *thingtoopen* as *handle1* : with *otherthingtoopen* as *handle2* : *do work on open things* except EnvironmentError as message : *report errors which occurred opening things, working on them, or closing them* This is reasonably simple, and tends to result in programs that do something reasonable for error conditions. Importantly, even if an exception is raised, the close operations take place. Even the case of a close operation raising an exception is properly handled; the other close operations still take place, but they are aware there's an exception situation. A database connector would do a ROLLBACK instead of a COMMIT in such a situation. This is probably the direction Rust should have taken. Error handling in Rust requires excessive boilerplate code every place an error can occur. The new Rust error hierarchy scheme [1] is especially verbose. [1] http://lucumr.pocoo.org/2014/10/16/on-error-handling/ http://lucumr.pocoo.org/2014/10/16/on-error-handling/
- edwinnathaniel 12y agoFor web stuff I'd say Java is a better match :D
- joe_the_user 12y agoI'm putting together an app where the c++ code is more or less adding a structure over "raw bytes" in memory or on disk. I actually looked at Rust but I can't see how it would help when you want to have all you operations really be a big chunk of already allocated memory. c++ isn't going to be growing because it's less applicable to the new use cases but I don't think that makes it less applicable to standard use cases.