18 ms·
The C++ bashing season is back (2009)
- beefhash 12y agoI wasn't aware the C++ bashing season had ever stopped. Did I miss something?
- wyager 12y ago> µTorrent is written in C++, and you could never, ever, make it so fast and small using any other language. That is not a reasonable claim. The article mentions C, but there are a number of languages that could ostensibly produce a binary of a similar size and efficiency. Rust comes to mind.
- pdpi 12y agoRust was announced in 2010, post is from 2009.
- quonn 12y agoTrue, but at the time of writing, Rust was not available, yet. Can you think of another language? Much of the excitement for Rust comes because it really is the first language that tries to beat C++ (and C) at it's own game.
- pjmlp 12y agoDelphi, Modula-2, Oberon, Component Pascal? All strong in the 90's, sadly the market went somewhere else. Only Ada seems to survive, but in its own area, high integrity computing.
- geoelectric 12y agoTo be fair, Delphi was pretty hard to get down to that kind of compactness because of dragging in the VCL as a baseline. You could technically program without it in standard event loop, but then the code would have been unfamiliar enough to other Delphi developers to perpetuate some of the same issues.
- pjmlp 12y agoWhy unfamiliar? It is how we coded in Turbo Pascal for Windows. Not everyone was using OWL all the time.
- geoelectric 12y agoDelphi picked up more people from VB and Powerbuilder than it did from TPW, I think. I got my professional start using Delphi, but never got the impression that many of my colleagues knew TPW well. Of the ones that didn't come from a database or 4GL background, most of us had used BCW for Windows coding and then switched back to Pascal when it became commercially viable to get a job in it. Borland Pascal didn't exactly have a ton of play in 1995. So it's true that they would've understood basic Petzold-style loops, but it would've been a bit surprising in Delphi. Later, most of the people I knew using Delphi didn't know bare Windows programming at all, since MFC had fully taken hold for people from that background. I was also under the impression that OWL was quite dominant, but I admit that I only passed through it briefly between Turbo Vision and VCL. Still, good point!
- amyjess 12y agoD, too, and while it survived, it seems to have been ignored. And I think you mean Modula-3, not Modula-2. It's kind of a shame. I'm a huge fan of languages like D, Modula-3, and Delphi, and I'm really disappointed they never took off.
- pjmlp 12y agoNo, really Modula-2. Modula-3 was hardly used outside DEC, while Modula-2 had big use in Europe.
- deeviant 12y agoYes, without C++, µTorrent could never have packed so many annoying "meet random super models and have sex!" ads into the ap. It just would have been impossible with something like java.
- flamedoge 12y agoThis calls for science!
- panzagl 12y agoArticle is from 2009. I was wondering if this was a reaction from the vaguely positive press C++11 and C++14 were getting lately, but it's not.
- somerandomone 12y ago>But for some kinds of applications it seems that the only viable options are still C and C++ ... and you could never, ever, make it so fast and small using any other language. C++ and C are the only options you have here. Is Go a viable alternative now?
- rjammala 12y agoI think once the garbage collector improves with the 1.5 release, it will be a serious competitor.
- deleted 12y ago[deleted]
- rjammala 12y agoTrue. Agree about the size. There is work in progress that will allow a Go executable to be used with shared libraries.
- voidlogic 12y agoMost Go apps can get better than advanced Java GC level allocation-memory performance simply by applying "sync.Pool" (http://golang.org/pkg/sync/#Pool http://golang.org/pkg/sync/#Pool) on applicable pain points. Its also worth mentioning using a custom allocator + mmap is possible in Go if you really needed it. Go is also better than Java about using stack allocation for objects.
- batbomb 12y agoI'd like to see some research to backup your first claim if you can point me to some.
- voidlogic 12y agoYou want evidence that a object pool with thread-local caching is faster than a garbage collector? Barring major implementation mistakes this should be self-evident, but you could easily write some benchmarks to verify. Its worth noting that if the Java GC was good enough people would not bother to write object pools in Java- but they do. And Go has a very advanced GC/mutliprocessor aware object pool implementation built in its stdlib. In an typical object pool only allocation up to the peak concurrent demand for the given object type will ever be allocated and the kicker is that allocation will only happen once. Adding thread-local caching means that that will scale well on multiprocessor systems. TL;DR: A system that does not generate garbage is going to be faster than a system that does. My argument is that effective use of a good object pool implementation in Go is faster than even a more advanced garbage collector would be.
- ossreality 12y agoctrl+f "rust" No? Too bad. Okay, I'm in with the rest. I'm spoiled, used to seeing the year in the titles of HN posts when it's old. My bad.
- api 12y agoI'll keep saying it: give me a modern language that is cross platform, results in reasonably sized code footprints, is fast, and that can be used to ship code on all the major OSes, and I'll switch. Until then C/C++ is the only way to achieve that. It's analogous to the situation with JavaScript on the web. JavaScript is the language of the web because JavaScript is the language of the web. C/C++ is the language of systems because C/C++ is the language of systems.
- evincarofautumn 12y agoRust is getting there. In addition, I and I’m sure many others are working on languages with these goals.
- Scramblejams 12y agoBesides the aforementioned Rust, I think Nim's got a lot of potential here. And although I'm not a fan, does Go not fit the bill for you? Of the three languages I mentioned, it's the only one that everyone agrees is production ready.
- plq 12y agoNim's got a long way to go with its thread-local non-shareable heap if it's aiming to replace C++. (I don't think it actually does.)
- Scramblejams 12y agoTrue, true, but he hadn't explicitly put that in his wishlist, so... :-)
- jayvanguard 12y agoDon't mix the two together. C is great for systems and some application programming, C++ is rubbish. There was one brief stretch in history around 1994-1998 where C++ was the best choice for application level programming. And even then only a very narrow type of app programming. Before that brief timeframe and since then it has been a poor choice for every single type of programming. There are better choices in all cases. It has no niche anymore where it is the best fit, not anywhere.
- eliben 12y agoMercy, folks, this post will turn 6 years old soon. Let me know if you have any questions (or just leave a comment).
- smhenderson 12y agoStill a great read though and, with the recent release of new standards for C++, still relevant today. Thanks for sharing...
- mbrubeck 12y agoIsn't it already over five years old?
- eliben 12y agoOops, thanks. Math is hard :) Fixed
- xjia 12y agoIf server-side (web)apps were written in C++ instead of Ruby/Python/..., I believe they can sustain much more users before they need to consider horizontal scalability seriously, since we can fully utilize the machine in C++. AFAICT it is nearly impossible to optimize to the level of cache efficiency (and etc.) in Ruby/Python/..., and a distributed system is much harder to cope with, and when you need to work on that, the choice of programming language becomes less important. However, building a not-so-bad prototype in Ruby/Python/... is much easier. So probably something needs to be done (e.g. "frameworks", libraries, tutorials) for C++. [EDIT] C++ (templates) can provide abstractions with zero run-time cost. C doesn't have such abstractions. Ruby/Python/... don't have such low cost.
- jayvanguard 12y agoBut most (or at least a huge percentage of) server-side web apps are written in Java. While I don't love Java it is better in every way shape and form for server-side web apps than C++.
- xjia 12y agoThat's probably due to the lack of resources (as I mentioned, libraries, tutorials, etc.) for programming server-side webapps in C++. However, this could be a chicken and egg problem. People use Java more often so they produce more resources.
- pjmlp 12y agoTrue, but early C++ libraries were tainted with a C mindset so althouth C++ could provide a Java like confort, you were stuck with C with classes libraries instead. Just look at MFC vs OWL vs VCL, or Visual C++ vs C++ Builder.
- CountSessine 12y agoThis really seems like the sweet-spot for Go - nearly the same runtime performance as C/C++, and no single-threaded memory leaks or stomps. Low memory overhead, fast startup time, and the time amortization inherent in garbage collection doesn't matter a whit.
- Animats 12y agoNow 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.
- jkot 12y agoI am former Java maintenance programmer and I hate C++ with passion for over decade. But I recently started KDevelop IDE and was very surprised how nice is C++ with QT lib. I am even considering to join an C++ opensource project.
- nicolasp 12y agoYou should give QtCreator [1] a try. It's made by the Qt people for Qt development, but even for non-Qt stuff it's a pretty good IDE. [1] http://qt-project.org/wiki/Category:Tools::QtCreator http://qt-project.org/wiki/Category:Tools::QtCreator
- cowardlydragon 12y agoThe FQA specifically mentions how nice QT is, about the only positive comment on C++ in the entire thing.
- ericfrederich 12y agoI'd like a fresh perspective on this taking at least C++11 into account, perhaps C++14.
- Doji 12y agoC++11 and C++14 make the language bigger, which doesn't address the problem of the language being too big.
- nether 12y agoWill we ever see a AAA video game title written in anything else?
- pjmlp 12y agoC++ wasn't always there.
- kibwen 12y agoIt depends on how you define "AAA". Any big-name game written before the mid-to-late-90s (Mario, Tetris, etc.) wouldn't have been written in C++. Mobile games (Angry Birds, Candy Crush, etc.) cannot be written in C++ by dint of their platforms. Minecraft, a contender for the best-selling game of all time, is written in Java.
- FigBug 12y agoAngry Birds most likely was written (at least partially) in C++ as Rovio has confirmed that they used Box2D, a C++ physics engine, as the engine for Angry Birds. All the major mobile platforms support C++. Android through the use of the NDK. Windows phone has support C++ since version 8. iOS has supported C++ as long as there has been the app store, either through Objective-C++ or C++ libraries with a C interface.
- pjmlp 12y agoSadly Android supports C++ just for libraries, any attempt to write a serious app in the NDK instead of a game, lands you in JNI wrapping land.
- FigBug 12y agoI'm doing it now for my first Android app and the JNI isn't as bad as I expected. I'm using juce and it has a bunch of macros that reduce the JNI calls down to 1 line, and there are a classes to convert the types. The UI is all in a webview anyway. It took me under two weeks to learn the Android tools and get a pretty significant app ported. But I was horrified at how bad the tools and emulator are. I spent more time trying to get things to work rather than porting code.
- a8da6b0c91d 12y agoI think people miss the context and subtleties of the Linus Torvalds rants. He was addressing rather idiotic junk on the mailing list about using C++ in the Linux kernel. He was trying to shut down some spergs who wouldn't grasp a more subtle request to not barge in on a decade plus old team of C hackers with tooling discussions. In other forums he has praised Qt and uses it.
- ksk 12y agoC++ is a language designed for specific use cases. If you want a systems level language with extremely low cost abstractions and write high performance, or low service-latency applications or applications that run on devices where you care about power consumption, memory utilized, etc, then C++ is one of the languages that you could consider. Its pretty bizarre to compare it to python or ruby or perl. Yes, you should use other languages if you can. C++ is used when you cant.