7 ms·
Why C++ is back
- PommeDeTerre 14y agoHuh, C++ is "back"? It never left! It has still been powering some of the most complex, important and widely-used software systems the whole time, even if it doesn't get the hype of languages like Java or Ruby.
- aninteger 14y agoStill, it doesn't have much of a presence in the Ask HN: "Who's Hiring" threads. Nor Dice.com or Monster...
- loopoeo 14y agoThe big money jobs, like Google, Facebook, Microsoft, aren't listed on shitty job websites, nor hipster forums.
- tikhonj 14y agoTo be fair, the "big money" jobs aren't so much at Google, Facebook or Microsoft as they are at little hedge funds and prop trading shops. I haven't spent much time looking at the hiring thread this month, but I did see Two Sigma there, so there are some "big money" jobs on this "hipster forum" :).
- CCs 14y agoI got a $350k/year salary offer from a High Frequency Trading company based in Chicago. They use C, C++ and FPGA. As far I know in 2-3 years you can go over 500k. Not many developers get that much in the Valley...
- pkolaczk 14y agoHFT is gambling. There are probably more profitable positions in gambling e.g. in Russia :)
- PommeDeTerre 14y agoI don't think that those are good measures of a language's actual usage patterns. There are very different staffing dynamics when it comes to C++ projects versus projects written in Java, Python, Ruby, PHP, JavaScript and languages like those. In my experience, employee turnover is far greater when dealing with higher-level programming languages, and especially when it comes to web development. The overall skill level of these developers is generally far lower than what we see from even an entry-level C++ programmer, and it's much easier to replace them. Those who have overcome C++'s more significant barrier to entry can often command greater salaries and more stable employment situations. They are often working on absolutely massive projects where it can take some time to get up to speed. We aren't talking about simple CRUD web apps, for instance, where an average developer can get a pretty good comprehension of the entire system within a few days. So we see C++ being very heavily used, but with development and maintenance being performed by stable teams that will often work together for many years, if not decades in some cases. The lack of near-constant turnover really cuts down on the need to advertise for open job positions. Furthermore, we often see many C++ hires coming via referrals from other C++ programmers or other contacts, rather than through advertisements or job boards. It's actually a relatively tight-knit community in many areas and industries. C++ may not be as immediately visible as Java, Ruby, JavaScript and other languages, but it's still extremely, extremely important, and still very widely used.
- VexXtreme 14y ago> So we see C++ being very heavily used, but with development and maintenance being performed by stable teams that will often work together for many years, if not decades in some cases. The lack of near-constant turnover really cuts down on the need to advertise for open job positions. Sir, you nailed it. I've noticed the same thing in my company. There are a handful development teams currently present and almost all of them do various Java based consulting gigs for external clients. Most of that is CRUD based web form twiddling. And as it happens, the turnover rate on those teams is often through the roof. However, there is also one C++ team which does in-house development on a very critical piece of software and I've noticed a couple of things about those guys: they not only appear to be far more technically competent than their Java counterparts, but the turnover is nearly nonexistent. While other teams have seen massive turnover to the point of being unrecognizable after a period of time, the C++ team hasn't changed at all... and the funniest thing is, a lot of people are internally applying to work on that team but these guys are extremely selective about who they let in. There's definitely something to be said about C++ development and the effect it has on stability/turnover in dev teams.
- devbug 14y agoAbsolutely. However, the extent of C++ usage (and more generally "system languages") has indisputably shrunk over a wide range of domains. Startups are a great example.
- shmerl 14y agoLook at Jolla startup. They use C/C++ primarily.
- nohurr 14y agoOh look, you found ONE. Good fucking job. If you look hard enough, you could find one ANYTHING. It appears you really missed the point devbug was trying to make.
- shmerl 14y agoMy point was, that start-ups differ. As well as technologies they focus on. Not all start-ups are about the Web and frontend tech. Many are about backend, others are about core technologies like mobile operating systems and so on. Numbers are not the point. But significance and impact are.
- czbond 14y agoI know C++ very well, but I also know Ruby well. Some startups *ARE* using them, just not web/app startups. C is still heavily used in algorithmic, infrastructure, and networking startups - But they're a different crowd. More neckbeard and device drivers than TechCrucnh and Rails. But I do agree that it's use cases have been marginalized more.
- camus 14y agoI agree 100% , C++ was always here and never needed hype. C++ will still be here 50 years from now ( and C too ). Why ? because it does the job and the codebase is huge ! Can we say the same for other languages ? Maybe , maybe not.
- Aardwolf 14y agoIn 50 years, it'll still be there, together with Lisp and COBOL :)
- eru 14y agoAnd FORTRAN.
- jejones3141 14y agoI'm having a hard time reconciling "[C++] never needed hype" with the quotes from Ken Thompson in http://gigamonkeys.wordpress.com/2009/10/16/coders-c-plus-plus/ http://gigamonkeys.wordpress.com/2009/10/16/coders-c-plus-pl....
- halayli 14y agoYou came back. C++ is hard to appreciate without a good amount of programming experience. A general pattern I am seeing is that programmers learn C++ as their first language, move to Java, Python, etc.. gain some experience and then they come back to C++ and say you know what, C++ is not that bad after all. But they don't come to this conclusion because C++ changed, but because they learnt to appreciate its usefulness. After all, use the right tool for the job.
- platform 14y agoThere is a silver bullet that would make C++ very competitive for most of the web/db centric apps: It is Reflection/introspection capability built into the language. Without it -- it is impossible to do DB structures to C++ structure mappings, or UI fields to C++ structures mapping. There are of course work arounds (QT's macros, pre-compilers, etc). Every time I approached this topic with some in C++ community, the answer always was ' C++ philosophy is -- if you do not use a feature of a language you will not pay a performance penality for it'. Reflection, obvsiosly adds performance penalty. When I suggest that it should be a compiler switch (like RTTI) -- the reply I get -- is that reflection cannot be turned on/off on per compilation unit., and instead must be on per project level. But C++ standard does not define 'project level' compilation option -- therefore, not acceptable. That's pretty much where this discussion gets stuck
- CCs 14y agoIndeed reflection is limited. There's a library called Reflex: http://root.cern.ch/drupal/content/reflex http://root.cern.ch/drupal/content/reflex SOCI uses generic template accessors to read/write full objects: http://soci.sourceforge.net/doc/exchange.html#object_relational http://soci.sourceforge.net/doc/exchange.html#object_relatio...
- wonderzombie 14y agoI learned some C++ as one of my first languages ever, about a decade ago. Since, I've used Python, Java, and JavaScript professionally. In my spare time: Go, Ruby, Haskell, and Clojure. After changing teams about a year ago, I came back to C++. IMHO, C++ is the worst. By far. Without question. It's so bad I don't know what to rank as second-worst. Every new feature or quirk is tinged with horror. The latest example for me was: http://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers http://isocpp.org/blog/2012/11/universal-references-in-c11-s.... So was that HN piece about C++ pitfalls. No, for me, it is the diametric opposite. The more I learn about anything other than C++, the more C++ seems like a big, creaking pile of leaky abstractions. It's like if you took the worst aspects of C and Java. And I struggle — earnestly — to imagine how people could actually be OK with it, let alone enjoy it. But I have to use it at work. It's an industry-standard language. Some people like it. That's life.
- mcot2 14y agoOnce I learned Python, Java and C++ took a backseat for me on anything that doesn't need to be fairly low level. Even for stuff that is low level I have learned enough of the python-c api to connect things up when I need to interface with c/c++ code. That's just me though... I write a lot of quick data processing code that would be a lot of string manipulation mess in those languages. For writing operating systems, browsers, and other serious apps c/c++ is pretty much universal.
- dvirsky 14y agoSame here. I wrote shitloads of C++ in the past 10 years, but looking back, a lot of this stuff could have been written in Python or similar languages. Not being a hipster here, but I've experimented with Go lately, and while it is not ready to become a main stream language - it is certainly a very powerful one and a good replacement for a lot of the stuff I've been doing with C++ and could not have been done with Python & friends. I'm glad it's in my toolbox now.
- rom16384 14y ago/me too My default language used to be C or C++, but nowadays given the chance I code everything in Python [1], from throwaway scripts to medium size fetch/process programs. The performance is usually acceptable, and normally IO bound. [1] http://xkcd.com/353/ http://xkcd.com/353/
- marris 14y agoI think not. The language is too big [it's always odd to see some people say things like "the language is still too big", as if some recent effort has succeeded in making the language somewhat smaller, but not small enough... every recent effort has actually made the language bigger] There are too many ways to write bad code and too few ways to navigate bad code. It's hard enough to pick up a big C# program and figure out what it does ... C++ is not easier. I'm not sure why there's all this excitement over bit twiddling... every language lets you twiddle bits. I can only assume the cool feature here is mislabeled, and the authors are really excited about memory twiddling. Fair enough. It's fun to write code that touches data structures at a byte level. But it's not fun to read/fix someone's buggy byte manipulation code. If you're not writing a device driver, or your own compression library, then you should not do this. Now, I am a big fan of people learning low-level system details, provided they do it with some small C program, or by doing a project for their OS or compilers class, or by maybe working on some open source project. But anyone who chooses C++ when he doesn't need it reminds me of the kid who, rather than painting on paper, decides to paint on the carpet. You could do it. It's also probably a lot of fun. There's even the remote possibility that you'll improve the carpet. But you probably won't. You'll probably just make a mess. And it won't be fun to clean it up.
- furyofantares 14y ago> If you're not writing a device driver, or your own compression library, then you should not do this Or a cutting edge game, or a high frequency trading system, or a high performance server, or an operating system, or implementing a language, or a database, or a numerical library, or a crypto library, or a VM...
- xyzzy123 14y agoOr a web browser....
- marris 14y agoGame... maybe HFT... maybe High performance server... sure OS... most are not (C++ != C, C++ != assembly) Implementing a language... maybe Database... sure Numerical library... most are not Crypto library... most are not VM... maybe Browser... maybe the rendering engine Again, you need to wrap your mind around: (1) Some things will be written in C++ (2) C++ is not a synonym for "low-level." Many of your examples are really referring to C and assembly. Why would you prefer a C++ implementation of a crypto library to a C one? (3) The vast majority of computer code written today is not for any of these systems. Lots of code uses these systems, but most people are happy with language bindings for a crypto API. Or to a numerical processing library. Or running on a VM running on an OS. Does anyone have empirical data that the C++ fraction of software written today is increasing? If so, then you have a case. I'm going to guess that that fraction has been falling for quite some time, and will continue to fall.
- Jabbles 14y agoBjarne says that C++11 is a "new language", and I asked him back in May whether there were any tutorials for learning the new idioms and styles. He said "not yet". Does anyone know if this situation has changed? I can see his new book on Amazon is due out in March.
- Glowbox 14y agoSome books have been updated. Check http://isocpp.org/get-started http://isocpp.org/get-started and in general check out http://isocpp.org http://isocpp.org for more tutorials.
- ekm2 14y agoC++ Primer has been updated for the new C++11,at least according to its author.
- zxcdw 14y agoThis, and the Fifth edition is magnificent!
- ashcairo 14y agoCheck the get started section of the new official language website: http://isocpp.org/ http://isocpp.org/
- jmat 14y agoI'm reading and like 'The C++ Standard Library: A Tutorial and Reference (2nd Edition)' and 'C++ Concurrency in Action: Practical Multithreading'. Both cover C++11. So far the concurrency book's examples compile in VS2012.
- DanBlake 14y agoThere is much hype now with going 'back to basics'. You get more cred saying you are building things in C or C++ then you do if you are building them in C# or similar 'new' languages. However, one big fact that is being left alone here is that there is no inherent speed bonus in using C, C++ or ASM over C# for most cases. C++ apps can be faster than C# by a good margin, but you need to be able to program better in C++ then the C# compiler does in translating your good C# code. Simply writing in C++ != faster code. You have to beat the machine.
- Aardwolf 14y agoI think it's not only about being faster, but about having more control. If you actually want to write something for a machine, not a virtual one, you use C or C++.
- blablabla123 14y agoAre we talking about native C++ or C++ with all the .Net stuff? ;) Two years ago I have heard about many benchmarks, people saying that higher level languages can be nearly as fast. (Or even faster!) In fact I even believed this because it was said so often and Ruby for instance went fast. However reality proofed me wrong. When the CPU is going to 100%, C/C++ are always faster. (In case of Ruby it can be orders of magnitude...) However when doing mostly I/O-intense web apps, it pays to have a language that makes performant design easy.
- bcoates 14y agoRuby seems like a bad basis of comparison, as it appears to be designed without concern for runtime speed at all and the main implementation uses a slow, simple design. High-level languages in general can be very fast, but it doesn't mean any particular one is. C# and Java can produce very efficient programs, and for a lot of CPU-bound problems the obvious solution in either of those will be faster, particularly stuff that needs to perform lots of little allocations or where the obvious C++ program does too much accidental copying.
- 14y ago
- Aardwolf 14y agoIt was never actually gone ...
- joe_the_user 14y agoI'm sad the article doesn't have give really good and substantial reasons for c++'s continued popularity (whether c++ "is back" or "never left" is a judgment call). I would say that the basic reason is we still need systems that both customize their low-level (literal and metaphorical) bits and use large scale, powerful abstractions. Indeed, it worth remember that very high-level abstract systems (such as databases) often wind-up simultaneously crunching lots of data in unique ways and thus needs *particular" sorts of low-level operations along with a variety of high-level constructs. C++ has succeeded as a tool allowing you to do nearly any kind of abstraction up from the low-level operations implicit in c. And given that this is a broad mandate, the language comes out "too big" seeming, "too wordy" seeming and so forth. Not a nice language but efforts targeted to a similar area have wound-up making similar compromises and thus having equivalent problems (see the D Language - not that its failure but that it seems to have failed to be lots better than c++). C++ can be "the best language" (for its purpose) without being "a good language" (without being a pleasant or sane-seeming language). As jandrewrogers said, (at least the best) c++ projects use less than the entire language and use it according to their needs. Merely having good parts is not enough to make a language good but until we have a good alternative to c++ or until we have garbage collectors and virtual machines that are guaranteed to work best for any significant system whatsoever (good luck with that), c++ will have a place.
- kruipen 14y agoAll your comments about practical values of C++ are good. But I would like to point to something else: C++ is a smart, deep language. I mean this in a sense that genuinely brilliant people get real intellectual satisfaction from inventing and discovering C++ idioms and techniques. To me C++ templates rival aspects of Haskell in the sheer expressiveness of a beautifully simple concept.
- WalterBright 14y agoAs you can write Fortran in C (I've done it), it misses the point of D to view it through the lense of being a marginally improved C++. D is a substantially different language with a very different focus, and different paradigms.
- tezka 14y agonone of the posts I read here mentioned the true advantage of C++ over other languages: It's the only language that offers enough flexibility to write 1) generic, 2) correct and 3) efficient code. With C you get only 3. With Haskell you get 1 and 2. With ML you get some of 1 (yes I contend that C++, in the hands of a competent programmer, can be as good as ML or even better for writing generic code) some of 2 and some of 3. C++ allows you to have cheap abstractions (using them does not require paying significant penalty, unlike Scheme or Smalltalk). Java and similar managed languages excel in neither of these criteria in particular.
- tezka 14y agoFelt like expanding a bit more: Note that this is a result of evolution in the language: What's referred to as modern style of C++ that has emerged from the works of people involved in the STL/boost tradition and for the large part informed the new standard. It's a noticeably different style from what you would see in a codebase written in mid-90s. It's arguably less object-oriented than most Java systems, and adopted certain concepts from functional programming, while exploring several innovations hitherto unseen in other languages. What also enables this is advances in modern architecture. 64bit processors allow for large address spaces and large stack frame sizes, which obviate the need to allocate every single bit on the heap. You can often see sizable C++ programs measuring around 100KLOC or larger which use new/delete in a handful of places. Automatic storage is, well, automatically managed. For when free store semantics is needed, smart-pointers abstract the complexity of several common cases where automatic-management is not adequate. Using value semantics, streams, lambdas, regular expressions, and a good library for command line flags processing (e.g., boost) C++ can even be a perfectly apt choice of language for scripting. The development effort need not be much longer than python but with no optimization the result can be easily 10 times as fast.
- zxcdw 14y agoIt's nice to learn C, then learn C++98, then learn C++11, stick with it for 5 years and still find that the language has 8379483 quirks you've never heard of. Bjarne vouches for abstractions. Everyone does. What does Bjarne + standards commitee do? Make old stuff useless, yet make sure the user has to deal with it. Make new stuff so the language becomes more complex. Why do we want abstractions again? Because we want to get rid of useless stuff and make things simple instead of make them complex! What does C++11 do? It goes to the wrong direction. Very, very nice. When will we have something simple instead?
- deleted 14y ago[deleted]
- cageface 14y agoWhen I started coding professionally in 1996 C++ was the go-to language for all kinds of applications, many of which didn't require the speed or low-level control of C++ at all. Predictably, this resulted in a lot of over-budget and buggy apps written by people that didn't understand what they were doing. Since then a lot of higher level languages and frameworks have whittled down C++'s domain to what it is actually good for, and that's a good thing. But I write high-performance realtime audio software and C++ is really the only language that makes that possible while maintaining a sane level of abstraction.
- dotborg 14y agoMost of C++ production code I know, looks very similar to Java. memory managers, garbage collectors etc. are being used, most of language features are not used, so the code is simple, like Java, Powerful language full of features yet programmers are scared to use most of them.
- halostatue 14y agoI first learned C++ with Turbo C++ back in 1989, 23 years ago. I have used it professionally since 1996, 17 years ago. I've spent most of my career using C++, and the startup I'm at now uses both C++ and Ruby. The only type of compiler upgrade that I missed in my career was cfront to native (thankfully, but waiting for compliance from compilers is painful). Now that C++11 is out, everyone is claiming that C++ is back—when in reality, it never went away for a lot of people. Which is too bad. There's almost nothing about the language that makes it a good language. Even the so-called beauty of C++11[1] isn't usable by most practical C++ developers at this point because they are stuck with compilers that still struggle with rational C++98 and C++03 compliance (I'm looking at you, HP-UX aCC). Or maybe they've got something that's older and mostly compliant with C++98/C++03 because you have a hardware partner who only provides something that is compiled with VS2005 and won't sell you the source because you're not a large enough partner for them to give a damn. And gods help you if you have an error related to templates unless you're lucky enough to be using clang or can use an error filter to make the thirty thousand lines of errors readable, even if they aren't directly applicable to the missing semi-colon at the end of your class declaration. It will be 2015 before most C++ developers can even think of using anything from C++11 in a production environment, if their (almost certainly mandatory) coding standard allows for it. C++ requires coding standards because you really can blow off your leg.[2] Not only that, features that would be vitally useful in many applications like real introspection continue to be missing for no good reason at all. Multiple inheritance is an absolute blight on the language, and the fact that the `explicit` keyword even exists is problematic (or that constructors are, by default, not virtual). All of that said, there's a lot of C++ code out there and it's a good enough language for a lot of functionality, even though it's neither a humane language nor a particularly secure language. There's a lot of libraries out there, and they work reasonably well. For a lot of solutions, the problem isn't finding if there's a library to help you do something, but picking a library from a couple dozen implementations and making sure that some other library you depend on doesn't implement the same thing differently…and then making sure that what you pick actually works with the compilers you've chosen or had forced on you. If you're truly lucky, you work in an environment that lets you do the bits that you must do in C++ without too much issue, and then you can use Python, Ruby, JavaScript, Lua, or something else to drive the higher-performance code with languages that better express business algorithms. I'd still rather use Ruby for my whole program (when I had time for OSS projects, I even explicitly went with pure Ruby solutions because of compiler issues), but there are places where C++ isn't just the right tool, it's damned near the only viable tool. A full stack developer needs to know it. I'd argue that most devs should learn C++ just so they know how badly a language can be designed and still be useful for developing modern software.[3] [1] I'm sorry; the C++11 lambda syntax is unbearably ugly. [2] http://www.stroustrup.com/bs_faq.html#really-say-that http://www.stroustrup.com/bs_faq.html#really-say-that He tries to backpedal from this truth. Other languages that are more expressive and IMO more powerful because of the greater expressiveness do not offer the same capability to break things as badly. [3] Yes, I know. Most of the issues I have with C++ are probably fixed in C++11. It's impressive. It's still a crappy language with even worse compiler support. Far too much of the language is focussed on making me adapt to the compiler, when with modern type inference and a little convention-over-configuration or even hinting, you could probably cut the size of any given C++ program in half (in terms of number of characters) while not losing a thing in terms of optimization.
- pjmlp 14y agoWhen will these kids learn that Language != Implementation. Back in the old days we used to say "I have a compiler/interpreter for language X", not state that "Language X is compiled/interpreted". Slowly I am starting to think it should be compulsory to understand compiler design, before writing any blog entry about programming languages.