Why C++ Is Not “Back”

转: Why C++ Is Not “Back”

Are you here because you want to learn C++?

I love C++.

C++ taught me how to really write code.

Back in the day I would study the intricacies of the language, Standard Template Library, and all the nuances of memory management and pointer arithmetic.

Those were some seriously good times.

I remember reading Scott Meyers Effective C++ book series over and over again.  Each time I would learn something new or grasp more of how to use C++.

I’m saying all this just to let you know that I don’t hate C++.

I love C++.

There are plenty of excellent developers I know today that still use C++ and teach others how to use it and there is nothing at all wrong with that. So what is the problem then?

The new message is wrong

C++11 just came out recently and it seems like there is this big resurgence in interest in C++ development.


Now don’t get me wrong.  C++11 is fantastic!  I am in just about 100% agreement with all of the changes that have been made.

C++ has definitely become much easier to use and it has even become more powerful.

There is one thing it didn’t become though—and this is the most important—more simple.

It seems that many of the seasoned developers have forgotten why we stopped using C++ and moved on to Java, C# and other modern languages.

Many younger or newer developers don’t really know the history and are getting confused by the current C++ message and resurgence.

Everyone keeps asking me if they need to learn C++, but just like my answer was a few years ago, it is the same today—NO! Ok, so “NO” in caps is a bit harsh.  A better answer is “why?”

Why do you want to learn C++?

There are only about three sensible reasons to learn C++ today that I can think of.

  • You absolutely need to eke out every bit of performance possible out of your software and you would like to do that with a language that will support OO abstractions.
  • You are writing code which will directly interface with raw hardware.  (Example: you are writing a low level driver.)
  • Memory control and timing is of absolute importance, so you must have completely deterministic behavior in your system and the ability to manually manage memory.  (Think real time embedded operating system controlling a moving piece of machinery.)

Now it is possible I missed a valid case, but chances are any other case is going to roughly fall into one of these three categories.

Wait! Wait!  What about portability? bangheadNo!

Please don’t learn C++ thinking that you will build software to work anywhere.

There are plenty of other options today for doing that and C++ is not nearly as portable as many people believe or tout.  The lower level the abstraction is the more different each operating system and platform is.

Also please don’t tell me C++ gives you more power and control to do exactly what you need. Most software development is about managing complexity not about being able to twiddle bits at a lower level.  In almost all cases of modern large scale software development, higher abstractions, not lower abstractions, are what you want.

But, I want to learn C++ anyway

Ok look, I know you think Windows 8 is cool and all the cool kids are learning C++ to write their Windows 8 applications, but you should know what is in the Kool-aid before you drink it.

Writing C++ code is not a picnic. Even with all the changes in C++11, C++ is still a very difficult language to learn and an even more difficult one to master.

You’ve probably heard this common quote about C++:

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow away your whole leg! — Bjarne Stroustrup

gunAnd if you don’t know who Bjarne is, well,  he invented C++.

So if he says that about the language, I am sure you can draw your own conclusions.

I keep hearing that C++11 makes things so much easier now and that C++11 has fixed many of the problems of C++98.  I don’t doubt that it has. What it hasn’t fixed is the size and scope of the language—it has actually increased it.

Sure, you can use a subset of C++.  Sure, you can use smart pointers in the new C++ to prevent you from having to manually manage memory.

You can utilize lambda expressions to declare functions in-line instead of passing function pointers.  Automatic type deduction is a much needed breath of fresh air. The problem is you still have to know the old way of doing everything and you have to understand exactly what is really going on when you are debugging a C++ program which is easily capable of stomping memory (something you probably have never even heard of if you were born in a managed code world.)

You will encounter C++ code from 20 years ago and it will look like a different language entirely. Here is a list of actual interview questions that I used to ask C++ developers interviewing for a job I was hiring for.

  1. How many ways are there to initialize a primitive data type in C++ and what are they?
  2. Why should you declare a destructor as virtual?
  3. What does it mean that C++ supports overloading?
  4. What are examples of overloading in C++?
  5. What is name mangling in C++ and why is it used?
  6. What is an abstract base class?
  7. What is RTTI?
  8. How can you access a variable that is “hidden” by another variable of the same name?
  9. What is a namespace and how is it used.
  10. What are the differences between a class and a struct in C++, and how does this compare to C?
  11. What are templates? How are they used?
  12. What is a copy constructor and when is it used, especially in comparison to the equal operator.
  13. What is the difference between a “shallow” and a “deep” copy?
  14. What is the const operator and how is it used?
  15. What are the differences between passing by reference, passing by value, and passing by pointer in C++?
  16. When is it and when is it not a good idea to return a value by reference in C++?
  17. What is the difference between a variable created on the stack and one created on the heap?
  18. How do you free memory allocated dynamically for an array? What are the implications of just using delete?
  19. What is multiple inheritance? When should it be used?
  20. What is a pure virtual function?
  21. What does the keyword mutable do?
  22. What does the keyword volatile do?
  23. What is the STL?
  24. What is a Vector?
  25. What is contained in the <algorithms> header?
  26. What is the difference between #include <iostream.h> and #include <iostream>?
  27. What’s the difference between “++i” and “i++”?
  28. What is short circuit evaluation? How can it be used? Why can is be dangerous?
  29. What is the ‘,’ operator?
  30. What is the only ternary operator? How is it used?
  31. What is the use of a const member function and how can it be used?
  32. How is try/catch used in C++?
  33. Why should you never throw an exception in a destructor?
  34. What is the explicit keyword?
  35. What is the proper way to perform a cast in C++?
  36. What does inline do?

Some of these questions have the same answers for C# or Java, but you can see from this list that C++ is very, very deep.  There is just a very large amount to know about the language itself. C# and Java development are somewhat about learning the language, but much more about learning the libraries. C++ development is more about learning every nook and cranny of the language.

C++ is the wrong direction for the future

The big problem is that programming languages really need to get simpler and increase the level of abstraction not reduce it.

There will always be a need for low level code, but a majority of the code that we write today is at a much higher level.

I first jumped off the C++ ship many years ago when I finally could no longer make the argument that I could develop apps faster in C++ than C#. I held out for a long time trying to believe that all the investment I had made in C++ was not lost, but it turned out that C# simplified things to such a great degree that the extra power C++ gave me was not worth the extra responsibility.

Just as I was taking a break from writing this blog post, I happened to stumble across a new revitalizedproject from Microsoft Research called touchdevelop.  This is the direction we need to go.

We need programming languages to be even simpler to use, not more complex. Now don’t get me wrong, you are pretty severely constrained in touchdevelop, but I believe something similar to this is the future. It seems that Microsoft is making a decent push for bringing C++ back to mainstream with C++ support in Window 8 and attempting to kill XNA, but I think there is a warped perception of the development community that seems to be entrenched in the minds of Windows OS developers about programmers wanting to use C++.

I just don’t ever see myself moving back to a more difficult language when I can write C# on just about every platform now.  C# is not the perfect language, but it is very elegant and simple.

Some parting words about C++

With all I said above, I still believe that there is some value in learning C++.

No, I’m not trying to contradict myself here.

Allow me to explain.

If you can program in C++, you can program in any programming language.  If you understand how stack and heap memory work, pointers and references and all the low level details that make C++ so tricky, it will help you when you are working at higher abstractions and in understanding how computers work in general.

My point of this post is not to bash C++ or bash people using C++ or teaching C++, but rather to blunt the message that seems to be being preached by an over eager C++ community.

Everyone is not going to become a C++ developer and they shouldn’t need to be.  While C++ may have the ability to make your program more efficient (in certain scenarios,) it is extremely unlikely to make you more efficient at creating your program (except in some extreme cases.)

So, I am glad C++ got a much needed overhaul, but I don’t think it is going to make a comeback any time soon, and that is a good thing.

If you’re planning to learn a new language, do take a look at my course: 10 Steps to Learn Anything Quickly.

John Sonmez

John Sonmez is the founder of Simple Programmer and a life coach for software developers. He is the best selling author of the book "Soft Skills: The Software Developer's Life Manual."

  • You hit the nail on the head for me in your closing. I grow up in a managed code world. The more I learn, the more I realize how much I don;t know about what goes on “under the hood” to make the magic happen. Yes, I said “magic.” Anymore, I feel like I am simply learning how to glue various frameworks and libraries together, without really understanding what goes on underneath.

    Ok, I am overstating that a little. I am gaining some understanding of what is going on under the covers, but it still feels like I am using tools that have been so abstracted I being to feel like when I use a .net List that this construct actually works the way a visualize it.

    Some folks who really know what they are doing create the underlying basis for all of these fantastic tools at our disposal today. More than likley, at some level far below, it comes back to C++ (or even C).

    I plan to learn to use C++. Not because I expect to code in it, or even get very good at it. But I feel like it becomes my responsibility to at least UNDERSTAND it.

    Nice article, and great points!

    • Thanks, that is a good attitude to have IMO. It is always best to first learn how to use and abstraction, then understand how the abstraction works. Going the other way is much more difficult.

      • ragnvaldr

        Would you then say that learning C++ is a good way to go if you DO want to understand how it’s working as you go?

        I have a really hard time being told “Do this. No, just trust me, you’ll understand it eventually, but for now just know that it works.”
        Sometimes? Yes, that’s fine. But overall, I like to know why I’m doing something the way I’m doing it, and I find it hard to learn without that.

      • depends where your passion is I think. I remember I started out coding in 1981 on a ZX-81, coding in Z80 machine code as it was all there was. It was so fun to add two registers together and see the result of the code. I actually made it do that! If the passion is to get down and dirty then do it. If the passion is more product related, then choose a high level lang suited to the product you have passion about. Go where the heart is.

  • Fred Herbert

    Some industries (like large scale videogame development) are so intertwined with C++ that using something else doesn’t even cross their minds.

    • True to some degree. Many video games today are designed with much higher level abstractions. Consider the Unity software.

      • mjklaim

        As a game developer I need to complete your answer for other’s information:
        1. C# and Python have been used A LOT in game dev industry for around 8 years to build what players don’t see but makes or breaks a game dev team: the tools
        2. lua and other lightweight scripting languages (including Javascript and Python) are used a lot. A game is rarely made of only one language.
        3. Not all games need raw power or to be cross-platform: a lot of games are now developped using C#, on different platforms (not all unfortunately) or begin first as Python games or other languages easier to code fast then get a rewrite in C++ because it needs to run faster on some plateforms for example. Game industry, or more precisely game developpement is far more subtile and complex than it may seem to someone coming from most other domains of software. That being said…
        4. Independant game developers (which are free of publisher and have free speech attitude) embrace any technology that fit the game needs. Most Indie devs don’t build games for game consoles, so they use C#, Python, Lua, Objective-C or anything that works. They use C++ only when it’s really needed, like when the author of Super Hexagon for example had to rewrite his successful game in C++ to make it both more efficient and cross-platform (yes, it is important when you want your game to be available on a lot of other platforms that you might not know now).

      • Yet Unity itself is coded in C++ and the same goes to the Mono runtime that lets you use C# and other languages with Unity.

        • harsimran

          Of course! All the low level interactions require C++. But once you have those, it is easy to use a managed language to write the game logic. This is what Unreal Engine does, and Unity, and probably most game engines.

          With the low level already taken care of, the managed language saves you so much time!

        • John

          Nope. Mono is written in C. The internals won’t even compile on a C++ compiler (the public API headers compile on C++, but the code itself won’t.)

  • Oh God I *remember* the answers to all those interview questions and it seems like this unimaginable Cthulhoid horror now.

  • OK, that’s a sentiment I’ve heard a lot recently. The other side is the speed and efficiency of C code. I’ve devoted the past few years to Java after taking one beginner C++ class at college. I’m now wanting to get back to C++ because I want to be able to understand the language in order to implement it in Java and/or Android. To be more specific, the C++ code I’m interested in is for real time sound synthesis. I’m very conflicted about this decision: will I be wasting my time learning C++ if i could figure out how to implement real time sound synthesis in Java??

    • You could learn C programming, and then learn JNI for Java/C integration. But I guess there are libraries in Java (with JNI wrappers on fast C library) that do what you want already.

      • This would be my suggestion. Unless you are planning on pioneering totally new ground in real time sound synthesis, I could keep the core logic in a higher level abstraction like Java and JNI into C where needed. There should be libraries already at that level.

        • Nicolas Janin

          Unfortunately, I believe no garbage collected language is well suited to real time sound synthesis, because there would be stop the world pauses of a few ms, and that would be quite unacceptable for this application. I imagine you could buffer one second or two of PWM data in the sound card memory, but that would no longer be real time. A reference counted language could fit in, I guess.

  • Kushal

    Interesting read. I must share something which relates to your post. Recently, a few interviewers frowned when I told them that I would like to write my code in C++. One of them even told me it will be better if I can use a dynamic language. Frankly, I was a bit surprised.

    • What I’m surprised is why choose 1, when we can have many. look at the comments from mjklaim . I’m utterly suprised then why people dont even consider C++ and dynamic languages. what is the runtime of a dynamic language, it is c++ :)

      I’ve already chosen for myself. A year ago I could agree with Jonh completely. But 1 year ago ;) and it has nothing to do with C++, i simply found LUA :)


  • k0nsl

    Love that quote by Mr. Stroustrup :]

    • mjklaim

      Actually I think that quote is (as often) misused here. If my understanding is correct, Bjarne wanted to express the particular way C++ have to make sure you can’t ignore an error YOU just made. Which C and many other languages would have let compiled and would have generated obscure generic errors on runtime. C++ checks a lot of things for you and provide more error handling mechanisms than a lot of other lanuguages. Most of the unsafe way to use it can be summed up by using C-idioms in a C++ program, which leads to a unmanageable catastrophe.

  • Lord Lingling

    The term complexity management is a very common argument used both for and against C++ but it is always poorly qualified. What does it really mean? The cost/benefit idea between efficiency and responsibility you put out is very interesting in this respect because it is much more tangible. Nice article.

    • IMO the complexity management argument is used for and against C++, because if you are using something like C, C++ will help you manage complexity much better by allowing OO concepts to be built, but if you are using a language like C# or Java, C++ add complexity because the more ways you can do the same thing in a language the more complex it is to understand code written in that language.

  • Reblogged this on Lambda reflection and commented:
    I liked this man’s views on C++ so much, that I wanted to share it with you guys.

  • Since arguable the most versatile low-level program, that is, the linux kernel, is written in C as a matter of policy, and not in C++, why not use thoroughly proven and much simpler plain old C when you need to capture every bit of performance, do raw hardware interfacing, or are facing real-time constraints? What value does C++ actually add to C in that respect?

    Furthermore, the sheer horror of interfacing C++ libraries — littered with overloaded functions and templated classes — to outside scripting engines seriously invalidates its use case. Unlike C, C++ is not even capable of communicating properly with the outside world. Seriously, the complicated semantics of C++ APIs make it unusable as infrastructure/system software.

    C++ is solution that has for decades been looking for a problem. C++ does not shine anywhere or at anything. There is always a simpler, better, and faster solution than C++.

    • Jan

      Absolutely right. For OO abstraction you have Java or C# – and for memory management and low level performance you have C

    • The Linux kernel is written in C because Linus says that C++ sucks. For some reason that makes good C++ programmers reluctant to work for him. It has nothing at all to do with performance or anything.

      • Cristian Amarie

        It might have to do with some C++ idioms not always applicable in kernel, mainly RAII and object ownership. (Ownership belonging to Linus, of course… :D)

        • simbin

          Kernel Mode Programming (e.g “Kernel” level Device Drivers) used to require ‘.c’ Files, would not work with ‘.cpp’. Microsoft Support for DDK would hung up on you if they found out you used .cpp files. You would even have problems getting ‘logo’ on your Driver from M$. Something to do with Stack Space constrains in Kernel Memory. Does NOT like Classes and Hierarchies, screws up stack-space. STRUCTS are ok

      • Sean McArdle

        One of the points Linus has made against C++ is that there are a lot more bad C++ developers out there than C developers, so using C doesn’t present as many disadvantages as they gain from keeping bad C++ devs out of their project.

        • More bad coders in C++ than C. I don’t think that is necessarily true. I’ve seen enough really bad code written in C in the 20 plus years of my career. For loop bodies that literally go on for pages and pages coz they didn’t want to break it up into to function calls. Of course I am pitting my anecdote against Linus’s.

      • Sean McArdle

        Sorry, hit post by accident. So the legitimate arguments that Linus makes against C++ have more to do with the people using it than the language itself. That said, when Linux kernel development started, C++ debuggers and tooling were terrible. It’s still hard to find a good debugger than can handle macros and templates correctly in all cases.

    • You overlook the fact that a c++ library can (and should) be exposed with a plain c interface. The reason for writing it in c++ is to gain the compile time, type safety and library advantages. The reason for wrapping it as plain c is for the reasons you gave, + compatibility with every other language in the world.

    • Roger

      C++ is faster than C. You can essentially compile any C as C++ (with changes irrelevant to runtime speed), so it is trivial to show that C++ is as fast as C. Then, C++ gives you extra expressive power with things like templates, enabling things like having the compiler compute things. Thus, you have the possibility for more performant code in C++, though in practice most people don’t take advantage of those features and C and C++ end up benchmarking at essentially the same speed.

      Linux is in C because Linus hates C++. Other operating systems, such as Windows, are in C++.

      • Except that they aren’t. Low-level code in Windows is written in C. Most of the platform components are COM-based or COM-ish in nature, which means using C++ only as C with classes. With COM, things like new throwing are unwelcome since your code messes up the COM infrastructure if you get OOM exception midway creating your COM module (which – I’m simplifying here – is represented by a global variable; exceptions are thrown into CRT startup and you’ve got mess on your hand, can’t clean up and leave the infrastructure in a half-baked state).

        Some portions of the UI (e.g. MMC snap-ins) are written in C# and there’s some other management stuff that’s C#/PowerShell. The “real” or “proper” C++ is nowhere to be found in Windows (well, maybe in Win8 in the new Metro interfaces but I wouldn’t really count on that) and C is generally preferred. So there’s at least one thing Linus and Windows devs would agree on.

        • > The “real” or “proper” C++ is nowhere to be found in Windows […]. So there’s at least one thing Linus and Windows devs would agree on.

          I don’t think so. Linus Torvalds hates C++ just “because” (and C++ is not the only thing he hates).

          Microsoft seems to have a more constructive viewpoint on C++:


          • This article doesn’t change a thing about what’s actually in the Windows source tree. Besides if you filter out the venom Linus spews, there are actual valid, grounded in facts arguments against C++ in kernel (and some of the core tools like gdb).

          • simbin

            The following comment is from above, just thought relevant here too.
            Kernel Mode Programming (e.g “Kernel” level Device Drivers) used to require ‘.c’ Files, would not work with ‘.cpp’. Microsoft Support for DDK would hung up on you if they found out you used .cpp files. You would even have problems getting ‘logo’ on your Driver from M$. Something to do with Stack Space constrains in Kernel Memory. Does NOT like Classes and Hierarchies, screws up stack-space. STRUCTS are ok

        • It’s also (although vaguely irrelevant) worth pointing out that JPL won’t use C++ on their space probes: the software for Curiosity, for example, is entirely written in C: JPL claim that anything higher level than that introduces the possibility of bugs. I can see why… I mean, did you watch that landing sequence…?!

          • John

            I would love to see a full evidence-based rationale for that claim. C lacks many features found in C++ that protect code from all kinds of bugs. So, to me, to say code written in C is less prone to bugs than code written in C++ is counter-intuitive.

          • I only know about JPL’s approach because I talked to the lead programmer for the Curiosity mission about it…

          • Nicolas Janin

            AFAIK, the reason is the existence of static analysis tools. Static analysis that help prove a program correct is tractable in C and night impossible in C++ (even though Clockwork does a good job, but not good enough for JPL, in particular regarding real time constraints and memory management issues).

          • Ah yes — very good point.

  • Epic article! In all honesty I agree with you saying that it’s much easier to develop software in higher level abstractions, but I too believe that learning more about how the computer works in general is a good reason in itself to learn C++.

    • johnbloom

      I agree with you. I learned C++ in college but after that it was all managed languages. I think it is people who have come from C++ and learned from using it that can say they don’t need to go back. What about us who have had our hands held by the GC and the Jit? I think I am part of the group who has a desire to write apps where I need to struggle with pointers and memory management so that I know what the GC is doing when it sits there automajically cleaning up my memory.

      You may be right but some of us will still try to learn the hard way because we are programmers and we need to answer the question, “Why?” and the only way to do that is with a language where the rubber meets the road.

      • Been thinking about this a bit more and I think I am changing my view even further. We rarely study assembly language in order to understand higher level languages, so I am wondering if tomorrows programmers will even ever need to be concerned with memory or other lower level details. Certainly today it is important, but I could see that basic knowledge becoming less and less valuable.

        • Jeff

          I myself came from C++ background have have moved to higer level languages.

          I believe all good programmers always feel the need to dig deeper and not understanding what goes under the hood is unsettling. Like in our days of C/C++, we wanted to learn assembly. In the modern day of C# we want to learn C/C++.

          After a certain level a developer achieve in honing his/her skills, the next natural step is to dig deeper in order to advance his/her to the next level.

          • Eduardo

            I think many people dig deeper because they want to have a competitive advantage about his products: speed, efficiency, size, etc.

        • I suppose it depends what you mean by “programmers”.

          Most software engineers basically write business logic and user interfaces, gluing frameworks and tiers together. That hasn’t really been my career, which has been in high-performance areas where a core of low-level C++ is the money maker on which higher abstractions are built.

          I’ve had to rearchitect whole subsystems to avoid a single conditional branch which the CPU couldn’t predict resulting in a bottleneck, and which a little information theory revealed was impossible to predict.

          Now it’s possible that this kind of skill will be less in demand. (It’s also possible that CPUs of the future will incur less of a penalty for mispredicting a branch!) But I doubt it will ever go away. There may be fewer programmers with those skills, but those who have them may be able to name their salary.

          • I’m with you on that; I pretty much can name my salary for exactly that reason: it seems to me that to be a Programmer, as opposed to a programmer, you really have to know how low-level stuff works – right down to the machine code… and it’s frightening how many programmers don’t.

  • Dan

    Good post, John.
    I think a majority of the push at Microsoft toward C++, as it always seems to be, is political. Now that the guy that hated .Net is gone, it will be interesting to see how aggressively it gets pushed going forward.

    I fully agree with you about the direction software development languages need to go. For a majority of the software out there (including games, which have been traditionally coded in C++), the needless complexity is a huge step backwards. We need tools (and a language is just a part of that tool set) that allows us to build apps efficiently and elegantly. As you stated, C++ has it’s uses for high performance apps that require detailed control over memory management. But it is certainly not Maslow’s hammer.

    • Do you really believe the complexity behind game-dev steams from C++ !????

      • Dan

        Pretty sure I didn’t say that.

        At it’s surface, if you get away from the creative investment involved, game development isn’t really complex at all as it generally follows a very common update/loop pattern.

        C++ has traditionally been the choice due to it’s perceived performance gain. But obviously, with the existence of XNA, jMonkey, Unity and a host of game-specific DSLs out there. There is proof that for many cases, C++ needlessly burdens the programmer for little gain. I think most game developers would rather concentrate on content creation than the nuances of memory management and performance if it’s good enough to get the results they want.

  • Your questions about c++ really remind of my first year on the college )) We’ve started programming lessons with c++ and I’ve loved it.

  • clojurian

    Very nice and interesting article. It’s really astonishing how popular C++ still seems to be among people who want to learn programming. Sure, it somehow has a cool name, but we need to move on to more modern languages.

    I’m currently very fond of Clojure. The language’s designer has put much effort to create a good balance between simplicity and power. From reading your article I guess that it could be something that may interest you.

    See also: http://www.infoq.com/presentations/Simple-Made-Easy

  • Matthew Fernandez

    Perfect summary of what C++ is good for and what it isn’t. If only more C/C++ gurus were as level headed.

    • decourse

      I’ve always found it odd that general-purpose programming languages seem to develop an implicit theory about what they are “good for”.

  • CJS

    Something that usually gets left by the wayside is there are a number of numerics situations where C++ is a great choice. If you’re doing numerics then you’re often wanting to get highest possible performance while using fairly high level mathematical abstractions. You also often want to interface with legacy-ish C or Fortran libraries. (If you haven’t worked in this area, then don’t laugh. There’s a lot of very old, reliable fortran libraries out there that replacing would require coding thousands of LOC by highly, highly trained specialists. Some of those programs can be based on entire lines of research spanning decades.) And you probably don’t want to spend the time for the jvm to start up and compile everything. In that situation C++ is a very competitive choice. But admittedly this is a niche use.

  • luitvd

    I’d actually argue that for the latter two of the “three sensible reasons to learn C++” plain old C would be a much better fit. Personally, if there’s something I need to build that’s too complex to do in C, I turn to Go.

    If you haven’t heard of Go, part of the reason to conceive the language was the trouble the creators had when working with C++. The fact that the language didn’t attract many C++ developers is also quite interesting. http://commandcenter.blogspot.com/2012/06/less-is-exponentially-more.html is a good read, even if you don’t know Go.

    • Thanks for the link, good point.

  • There was a time in the 1990s (maybe mid to late 90s) when C++ was seen as the future of programming – OO was generally accepted as “the” paradigm that everyone had to use and C++ was its biggest proponent. I’m just glad that these days there is an embarrassment of choice when it comes to selecting a language to use.

  • I don not know all the full details of C++ 11 but just the headline features tell me this is going wrong. Each language should occupy only 1 kilometre of the abstraction layer stratosphere. For a language to have such a high-level abstraction constructs as lambda expression equivalent and also able to move bytes on a stack/heap IS PLAIN WRONG.

    • I couldn’t agree with you more. This direction of C++11 has been a major mental thorn in my side.

    • Excellent point. Dropping down abstraction layers is bad. If you need to drop abstraction layers make it explicit by making your program polyglot and use a different language.

    • I couldn’t disagree with you more. One of the major strengths of Forth and the reason for its love from the embedded community is because it provides exactly what you just stated – the ability to write abstractions (full DSLs) as well as low-level handling. Moving between languages is a performance and coding barrier. It’s amazing how much complex “performance-oriented” C code spends its time reinventing paradigms that are built into C++ and optimised by the compiler (from a perspective of about 20 year working on C and C++ code).

    • Brian

      The sad thing about c++ 11 is that its made the language even less usable, hijacked again by those that put complexity/ and ‘look how clever I am’ ahead of ease of use.

      The only thing that was required was perhaps the ability to add a single keyword ‘mange’, so any allocation or resource is managed as in c#. Now there are even more ways to screw up and add ‘look how clever I am code’!

      Should add those two items are usually occur together with c++ although also seen in other languages……

    • Roger

      Why is it WRONG? Or even wrong? I need both features in the apps I develop. I talk to hardware constantly. And I want to work at a higher level abstraction where I can. Heck, if I want to use something like C++ AMP, I must use lambdas.

      Why do you want to take power and expressiveness away from me?

    • decourse

      Have you ever heard of embedded DSLs?

      It’s not wrong for programming languages to occupy multiple strata. Adding yet another language into the build environment for your application isn’t exactly cost-free.

  • hp

    Using C++ you can make everything possible without dependencies to runtimes and introducing any overhead. With managed languages only a small subset of possible programs is accessible. If you are happy with that – ok. I would never be. And I enjoy the freedom by relying only on open standards.

  • Alo

    I started out on C++ and spent the first four years of my career exclusively on C++. That experience has been extremely valuable for me down the line because – as you pointed out – once you learn C++ to an adequate level, you can pick up any other language really fast and you’ve developed a deeper understanding of how software works on a lower level – a knowledge that’s much harder to acquire when starting out at higher-level languages; I’ve always frowned upon the idea of starting programmers out on Java for that very reason.

    The points made in this article are valid regarding C++’s application in modern real-world programming – for simplicity, development speed and other reasons – but spending a few years at the beginning of your career – preferably in an environment where you are encouraged to dig deep and develop and understanding of how things really work – will serve you very well when you move to the business world.

  • Only real men can use C++. All the boys go and play with their managed/dynamic toys to create database queries and wrap the results in markup.

    • z0ltan

      Found those balls yet, son?

      • pip010

        still tr0lling around I see ….

  • CAS

    I am glad that you posted this article, and I agree with what you say. C++ was the first language that I learned (well except for the old BASIC and a bit of C and assembly) though I only really took it as far as console apps and the odd very basic windows app, since C# came out. I switched to C# and found it much better for Winforms. Later I learned Java and found that most of the mathematical apps I would have used C++ for I could do more easily in Java. As someone with a science and mathematics background, I really do believe in ‘simplify, simplify, simplify!’ There is no gain in over-complicating things. Of course C++ is valuable for drivers and time-critical apps, but that’s not something I have done. A lot of people who still use C++ for everything do so because they come from a science background and it’s the only language they know, which is fine, but I do wish more of these people would look at more modern options too. I still use C++ sometimes, when someone requests it, or for fun, or when I want to use OpenGL (which is available for Java, but I have never set it up for Java). For Winforms I usually use C#, which also has the obvious advantage of ASP.Net for Web programming, and sometimes Java. For most general purposes I use Java. I like a language which allows me to focus on the code purpose rather than memory management.

  • What nonsense. C++ never “left”. It is still responsible for the core functionality of myriad everyday systems. The difference is that nowadays people are not taught it, but instead taught wishy-washy high-level languages that have different applications …. and *falsely informed that this means C++ is no longer useful*.

    • You are correct, C++ never left, but it definitely faded.
      It is still in use for many systems as almost all applications need some access to lower level hardware and very performant code in the OS and other subsystems.
      But, a majority of code we write today is written on top of the back of that C++ code. Just like someone needs to write assembly and actual logical gates that ends up on silicon in order for our CPUs to work.
      My points is that most developers today don’t need that kind of power, because the price that comes with that kind of power is high.

  • Griwes

    “What is the STL?” – and old and long unused library, that had its parts incorporated into new, bigger C++ Standard Library.

    STL is NOT synonymous to “standard library”, in case anyone wanted to answer this question with “standard library”.

  • Öö Tiib

    The reason why C++ never left is that when algorithms are implemented
    by competent specialists then C++ implementation runs 5 times faster and takes twice less memory than others written in those “modern” languages. Where performance is not important there script languages are fine enough. Again … C++ is lot simpler to integrate with most script languages than those “modern” languages.

    • Agree. I am just saying when you need to write those performant algorithms do so in C++ or C and write the rest of your program in an easier to maintain language.

  • CAS

    It should also be noted that real-time Java is being developed and I believe that it has already found military applications. I wish people would stop the ‘language wars’ as each programming language has its pros and cons and to claim that any one is superior is childish. It is also childish to claim that the language a person uses determines how good they are as a programmer. It’s more what a person does with their knowledge that matters in a pragmatic discipline like computing. (I am glad the author avoided such childishness). I believe that nobody can truly master a programming language – there is always more that can be achieved with any language than any individual has managed, so people really ought to be more modest!

  • I find this kind of sentiment common from people who have never mastered C++.

    For those of us who have actually written template libraries, I can speak from experience that it is MUCH easier to create reusable code at a higher abstraction in C++ than it is in C#.

    I’m a former C++ master who became a C# developer a few years ago due to marketplace pressures. I am CERTAINLY more productive in C#, but it’s simply not possible to reach the same level of code reuse as you can with C++ templates.

    The classic example is the triumvirate of containers, iterators, and algorithms. In C++, you can create one algorithm that will work with any container and adjust itself at compile time to take advantage of random access if necessary. Try doing that in C#. And I’m not talking about the “new C++” here, either; C++ permitted greater code reuse in 1998 than C# does today.

    A big difference between the two languages is that C++ was not strictly OOP; it was a multiparadign language. C# was originally just restricted to OOP, slowly adding support over recent years for more powerful paradigns, but they still have a long way to go.

    C++ has always permitted more code reuse than C#, but C# has been the more productive language. The recent changes in C++ are all about making it more productive. What edge does C# have now?

    • I was beginning to wonder if I was the only person thinking what you wrote.

    • and that is only one nail in the Java/C# coffin. const correctness anyone? java and C# kiddies have no idea what I’m talking about ;)

      Really C# is going no-where. it want’s to be C++ and python at the same, having LINQ is like having a language inside another language etc. etc.

    • Thanks for seeing this. I can’t touch C# or Java for this very reason.

  • wai

    This reasoning is why every application, no matter how trivial its functionality, is 150MB and bogs down any machine more than 2 years old. A generation of developers that not only don’t know how software actually works, they don’t know why they should care. “Developers” who no longer craft code, but lash together bloated chunks of the latest framework. Sure, the development time is short, but every user pays the price for as long as that “code” lives.

    • Spike

      I couldn’t agree more with you. And writing efficient code with one of these modern languages often costs a lot more than doing it in C++, in terms of time and complexity of the code. And sometimes is not even possible.

    • Jeff

      Hardware are getting more powerful and cheaper by the day whereas labour is getting more expensive.

      From a business view-point, it makes sense and I don’t buy the argument that “users pay the price”. They may pay miniscule for that extra 150MB but the software becomes much affordable.

      Likewise for performance, unlike the days of “386” or Pentium computers, processor becomes so powerful that any bloatware (as ugly as it is) performs reasonably.

      Like John said in this article, Choose C/C++ on a need to basis rather than just because “It’s more powerful”.

      Its like driving an F1 car to buy groceries so it is faster.

      • Rob K

        “… labour is getting more expensive.”

        No, no, it’s really not. Look at all the off shoring, and H1-B visa tricks that are going on in the industry.

        • Jeff

          But even offshoring is getting more expensive. Eventually all labour cost must increase.

      • Hardware in the *mobile* space is getting more powerful, as they can still increase clock speeds, but how much faster is the clock on the fastest i7 available today vs the fastest CPU 5 years ago? The scaling is horizontal, not vertical, and the mobile’s are (eventually) going to run into the same kind of wall.
        No matter the computing envelope, you are going to run into the state that you can’t go faster in hardware without changes in the software to take advantage of parallel processing. It’s just a matter of when, not if.

        • opwernby

          Bizarrely, this is happening. Microsoft just released details of research being done into writing a compiler which can figure out which bits of your code can run in parallel, and then compile them as separate threads designed to operate in a load-balanced manner across the several cores of a multi-core CPU. They claim to have already tested millions of lines of code through their new compiler, and that it works… http://research.microsoft.com/pubs/170528/msr-tr-2012-79.pdf

        • Jeff

          ” The scaling is horizontal, not vertical, and the mobile’s are (eventually) going to run into the same kind of wall.”

          I disagree. Heard of quantum computing? My personal opinion is that, eventually performance tweaks wouldn’t mean much. (Butthat does not meqn to say good coding practices no longer apply)

          • Seen any real-world quantum computing SDKs for consumer/business devices recently? It may be relevant in my lifetime, but I’m not holding my breath for it, it’s a long way from being relevant to ordinary mortals.

          • Jeff

            Yes, I am pointing out the technology to remind you that hardware has a long way to go before it hits a wall, and by then any performance gains using lower level languages will not be significant.

            In fact, the difference in performance between a well written c#/java and c++ codes no longer justify the cost of maintaining and developing one in most of today’s business applications

  • Good post! One additional reason to use C++, though, lower power consumption. In many cases a C++ application can use dramatically less power than a corresponding higher level language. This is useful in the subset of applications that have incredible scale as it reduces power costs, reduces carbon output, and requires fewer machines. In some unique cases (Twitter, Facebook, Instagram, etc) we’re reaching the case where developer productivity gains from a high level language are dwarfed by the cost of actually running the application. (Welcome back to the 1950s and 1960s!)

  • TVD

    For me it’s simple, “C++ Never Left.”

  • Reblogged this on the geeks club.

  • You’re wrong. Smart pointers aren’t new C++. If you intricately managed memory in C++03, you were almost certainly doing it wrong. The only difference is that when you learn C++11, almost nobody who still thinks that is right is still with the language, so whilst smart pointers aren’t new, what is new is that a large chunk of the C++ community is no longer wrong enough to think they are. That’s what makes them new to so many C++ developers.

    The problem with C++ was never the language. It was the attitude of the people using it.

    • You are correct. I didn’t mean to imply smart pointers were new. Scott Meyers talks about them extensively in his Effective C++ series.

  • Disregarding the language war flame bait for a moment I have to disagree on another important point: When has performance ever not been important? “Performance doesn’t matter” is simply wrong. It matters on the client because you’ll save battery power on all those mobile devices. It matters because users actually do notice and care about smooth user interfaces. It matters because everyone is using a gazillion tabs and applications concurrently. Your program needs to be a good citizen and not hog the machine. And it matters on the server because running them is expensive and it matters whether you can handle 10 times the number of concurrent connections with half the memory.

    Efficient code wins. Every time. It’s much easier to write efficient code if you are using a language that doesn’t impose a heavy tax from the get go (garbage collection, interpreters, virtual machines).

    And yes, choosing the correct algorithms has even more of an impact than the implementation language – I’m assuming you get that right no matter the language. That’s another good reason pro C++ – you’ll be hard pressed to name another language with the same quality and breadth of libraries.

    • Performance only matters when it does and then the next generation of hardware makes it not matter again.

      Speed of development and ease of maintenance almost always matter. My only point is don’t trade performance for those two unless you really need to.

      BTW, try and write an iOS application in C++ for example. :)

      You can do it, but it won’t be fun.

      • mjklaim

        I made my first IPhone application (a full commercial game) in 2 weeks using C++, not knowing either MacOSX or XCode or the Cocos2dx library I had to use (which is far from being idiomatic c++ by the way). I didn’t have any particular problem with using C++. I don’t see what you mean. Can you please elaborate?

        • I’m talking about not being able to use the Coco libraries for developing your game, but I admit I have a knowledge gap there. I guess there is no reason why you couldn’t reference Objective-C libraries from C++, but I would assume it would be somewhat tricky. How did you get your entry point into your iOS app? What about things like packaging it correctly? Manifest, etc?

          • Seth

            It’s actually no more tricky than accessing C from C++. Obj-C is largely just syntax sugar over some abstractions built in C and that same sugar is available directly in C++ (creating Objective-C++); Accessing Cocoa from C++ is more straightforward than JNI or P/Invoke.

            On another topic; several times it is implied that ‘high level’ abstractions are not available in C++ For example you say “higher abstractions, not lower abstractions, are what you want.” However, much of the power (and complexity) of C++ is it’s unparalleled toolset for producing abstractions. So IMO the abstraction argument only works if you rule out abstractions that aren’t built-in.

          • mjklaim

            Whatever the language you use for the game itself, you still have to work with the platform API which is C and Objective C. This is not an exception. All I did is use Cocos2D-X (the X is important, check the website for info) which provide scripts to setup a full ready project with C++ in all the supported platforms.
            So basically, it’s a problem of tools. It would have been the same with Android and other platforms assuming that I the game to run on widely different platforms (like consoles).
            Note that this imply that the game code is cocos2d-x specific, whith some part totally agnostic. If I didn’t use cocos2d-x, I would anyway have used some kindof similar platform abstraction framework.

      • decourse

        Performance always matters. The catch is that “performance” means different things in different applications.

        Sometimes, “throughput” is the most important thing. (“Throughput” is here defined as the amount of data that the system can handle just prior to overloading.) Sometimes graceful degradation is more important than raw throughput. On mobile platforms, battery life is the most precious commodity.

        And as P.J. Plauger famously pointed out, all useful programs have real-time constraints. A program which takes three months to compute the monthly payrolls is, after all, useless.

      • Oather


        Objective C and C++ work well together, both compile to object files that can be linked in the same binary.
        You even can compile a file as Objective C++, and seamlessly call both Objective C and C++. Hell, you could use a C++ smart pointer to manage Objective C ref counts.

        • Cristian Amarie

          I wonder why hardware is getting cheaper and better, yet simple programs that worked lightning speed on NT4 now bonks the memory as hell, or does not even start because I don’t have .NET the very latest version, please. I have the measurement against SQL Server; if it takes more memory, then sucks. And almost everyone sucks. Hell, I even tested .NET things against Starcraft 2. Starcraft 2 loaded first. QED.

      • opwernby

        Performance always matters: claiming that faster hardware solves the problem is not valid: what if you’re running 100 pieces of code like that in parallel? However, as long as you’re not hogging CPU time, response times might not matter quite as much: for example, in an internet-based application like something consuming a web service, or in something which spends most of its time reading and writing to/from disk, processing times are far less critical: the application is spending most of its time waiting for I/O to happen, so the in-application processes are negligible in terms of overhead.

        However, as a programmer, you should always try to create the most efficient algorithm for the problem at hand: not to do so is an IKEA approach: don’t varnish the underneath of a table because nobody ever looks there. IKEA’s fine if you know you’re buying crap, but if you think you’re going there to buy quality furniture, then boy, are you going to be disappointed when you get home.

      • In these “productivity years”, performance was a second-class citizen for programmers thinking that “newer hardware will fix their performance problems”; but, as Herb Sutter says in its “The free lunch is over” essay, performance is coming back to the map.


  • If you understand C++, you understand every programming language BUT functional languages :) those are a different world.

    • mjklaim

      Actually, understanding template metaprogramming is understanding a functional language (which was discovered, not desined). Someone I don’t remember the name makes a lot of conference and articles online about the strong similarities between Haskell and C++ template metaprogramming, and how they could learn from each other.

      • Bartek

        The guy writing about C++ and Haskell is – I guess – Bartosz Milewski (http://bartoszmilewski.com/). Very good reading indeed.

        • mjklaim

          Yes, thanks I always forget his name…

      • antoined

        I think the name you are looking for is Bartosz Milewski :)

    • thats why you add LUA :)

    • decourse

      This seems like the right time to mention Prolog.

      • Before college (a long time ago) i was a “QuickBasic” kid. I took a 1 cemester course on Prolog during college …. and after i survived that, somehow C felt like a walk in the park :p

        GOD, you had to bring that up, didn’t ya?

  • Christian

    I think a good alternative to C++ is in many cases Google Go. It is as compact as C but much more comfortable (a bit like Python). You can do low-level and high-level stuff in Go, the compiler is fast and static duck typing is awesome. Go is worth taking a look: http://golang.org/

    • mjklaim

      Just to be complete: The other two potential alternatives to C++ are D (the closest) and Rust (which is more alien but have interesting concepts). Anyway, none of the cited languages, including Go, are yet used heavily where C++ can be used for these reasons:
      – performance don’t compete yet with C++ (important in some kinds of games – in theory this is the weaker argument as it could soon be wrong)
      – portability (which is important to a lot of developers working on platforms other languages just can’t reach – so it IS important to a lot of people – like game devs)
      – stability (because they are still in work-in-progress stages)

      That said, D seem to soon reach the state where two of these problems are “solved”.

  • Radu

    Great article, as a harcore C++ developer (that also has used about half-a-dozen other programming languages). It reflects most of the thoughts I have about the language and its role as a development and educational tool. I define C++ these days as a general-purpose programming language NOT to be used by the general-purpose programmer.

  • stevej

    [1] In question 14 you call “const” an operator. It isn’t.
    [2] I haven’t used C++ in a long time but still like it. The new features in C++11 and the (promised) speedier standardization process are a good thing. Sure it’s big(ger) and not for everyone or everything. But neither are Java or C# or anything else.
    [3] I don’t agree that knowing C++ makes learning “every other language” easier. FP? Logic programming? C++ is multi-paradigm, but not every-paradigm.
    [4] Whenever I return to a language after using others a lot, I find I code in the “older” one in “newer” ways. Time to put on the C++ hat again I think — and to be careful and point the gun away from my feet and legs!

    • I can’t disagree with any of your points. And you are right const is a keyword.

  • My vision about C++ is power.

    Raw, unlimited power.

    C-people fear/mistrust C++ because of templates and function overloading, preferring to keep to the familiar pointers arithmetic and procedural programming.

    C#/Java people fear/mistrust because of pointers and multiparadigms, preferring their generics, lambdas and function overloading.

    The thing is: When you are a C++ coder, you end mastering all the ends of the spectrum. And on top of that you get unparalleled customization and unparalleled help/support from your own compiler (think: compile time error). And indeed, after going over the (possibly steep) learning curve, you understand how coding in C++ makes your code more robust than it will ever be in C#, Java or C (Resource handling and exception safety comes to mind… For those doubting me, please compare again the IDispose/Autocloseable pattern with RAII)

    C++ goes very low and very high. In this, C++ is a greedy language. If a feature is interesting and/or powerful, and can be implemented at zero or almost zero runtime cost, and I want it. Too bad if that frightens the C folks (Lambdas!!!!) or outrages the Java folks (Lambdas!!!!). If a feature is good, then it is good, and C++ certainly won’t segregate because of color, origin, or paradigm.

    This is indeed not a language for the faint of heart. You need patience, and you need determination. You won’t learn the language by copy/pasting examples for tutorials. You will need to read books and articles. RAII and exception safety are not buzzwords. They are instead a new mindset you need to acquire. But in exchange, you get a broader vision, and a deeper understanding of programming. Because I code in C++, and can discuss with any Java or C# professional engineer on the same grounds, despite having a lot less experience than they have in their respective chosen language…

    Of course, other paradigms still escape me (functional, for one), but then, nothing is perfect… Perhaps I’ll get it in C++17?…

    Anyway, I agree with you. Coding in C# or even Java is more productive than coding in C++. But when you try to make your code stronger (think, *industrial* strength), when “shit happens” is not a viable excuse, when you are trying to reach excellence or perfection, this is the moment the “easy languages” let you down (that is, when they are not actively fighting against you). And this is the moment when C++ really shines.

    Indeed, C++ is not “back”. C++ is “better”.

    Now, should you learn it? Well… Read again the “not a language for the faint of heart” part.

    • Magnum

      I’m really looking forward to all the cool functional programming tricks that will come out over the next few years with C++11’s constexpr feature.

  • I absolutely 100% agree with every word you wrote.

    Yes, C++ can still be useful in some problem domains. Yes, C++11 is better than C++98. But we stopped using C++ for a reason, and that reason wasn’t “it doesn’t have lambda expressions”. The so-called resurgence of C++ is a well-intentioned but horribly misguided attempt to get people to concentrate on exactly the wrong problem.

    • Jeff

      Well said!

  • andydent


    What language can I use to write common business logic for iOS, Android, OS/X and WIndows which has tight integration with their respective UI frameworks?

    • Muki


  • tripcore

    Well, I guess it all depends on what kind of applications one aspires to write. If you’re writing a state-of-the-art game, a web browser, a word processor, a digital content creation tool, then C/C++ continues to be the best (if not the only) choice. Sure, not everybody has to write those types of applications but just because you don’t doesn’t mean C++ is “not back”.

    • Jeff

      True. For those who doesn’t use .Net, there is a middle ground to be found. Using unmanaged code with managed code is possible. Unsafe code is also another alternative to is C/C++

  • Well I do agree on some point, in plain i think all should always use the tools they need and that can easily get the work done, but also look for the long term future too.
    In general I believe,
    1. C++ gives people(experts) opportunity to better optimize. So if you do not want the optimizations, please do not use C++.
    2. I have always seen many people blame the language for bugs. It is not, with power there always comes better responsibility. So if people think they cannot take those responsibility, or control the raw power, then use other languages. Please do not use C++.
    3. It may or may not be a general preference language. If you want to learn using a language in short term and start writing nice GUIs then please do not learn C++ or use it. They application written by impatient C++ programers is always used to abuse C++ in public forums.
    4. Also in most projects I have worked (by the way i work on C a lot in beginning of career, C++ mostly, JAVA frequently, python occasionally) I have always seen few developers getting lazy and working without thinking of long term bottle necks. This always happens due to various reasons. So if you do not want to think the difference between List and Vectors, or you do not care about it, please use some other language, not C++. Still if you choose to learn C++ do not complain about the learning curve.
    6. This may be my personal view, but i have always noticed that out of 10 people working in a very high level language, at least 3-4 gradually think only of short term results. They do not worry about the performance hogs. For example we have been using C++ in server side for last 8-10 years, but in the same time changed the front end language twice. Major reason is performance hogs. Its not the language that brings this hogs, its just the lazy thinking that “I will code as per will, let the language take care of everything”. This is the mentality that brings these hogs. C++ shows early failure symptoms when you code like this, other languages just forgive you till the customer becomes unforgiving.
    5. You cannot write nice GUIs with C++ in a week, do not try to learn it to write GUIs.
    6. C does not solve all the problems, nor is template meta programming or overloading complex. It just takes a little bit time, patience and effort to learn it and appreciate it. It does not come over night. In C you can write fast code, but in C++ you can write fast code that can be maintained better, and extended easily. If you do not want to think in OO or Functional terms do not use C++, use C.
    7. If you learn C++ as a big brother of C, there is always chance you will suffer. Please learn C++ as C++, this will set the proper learning context in your mind.

    • Cristian Amarie

      @spmisra C++ is not only an optimization wagon. It is, after all, the only language (mixing also C here) in which the other things are made in. Templates with function pointers doing function composition is a thing you won’t see in a script language very soon, I think. And really smart things can be done in even fewer lines of code. Without looking back.

  • A very interesting article, but I was a little baffled by the idea that C# is the obvious choice if you need the speed of C++ and a more modern language.

    C# is only good if you’re only ever targeting Windows machines. But who is doing that these days?

    I’m working on various projects right now, but they fall into two categories – server-side programs, which run on Linux, and cross-platform desktop apps, which run on Mac and PC.

    C# just isn’t ever even a possibility for me because of this. If I picked up something else, it’d be something mobile, for which C# is possible but never the “native development language” (unless I’m targeting users of Windows phones, which aren’t very many).

    • andydent

      Well, C# under Mono is surprisingly good and I was actually quite impressed with MonoTouch when I tried it earlier this year. It was the lack of some other infrastructure around it which put me off. They have settled for the same role as C++ with different native code being required for the UI. With a major focus on iOS, it was the fact that the C++ is inherently part of the vendor toolchain but MonoTouch was an extra compilation step which put me off – I didn’t think the productivity gains of C# over modern C++ would be enough to justify the aggravation.

      If I had to write a lot more complex business logic I would be seriously contemplating C# and Mono.

  • Great article!

  • MSFT is working on a common compiler for C++ and C# … hthttp://channel9.msdn.com/Forums/Coffeehouse/MS-working-on-a-same-compiler-for-C-AND-C–Not-in-incubation-but-for-production-

  • Stan Thomas

    Ok. Leave it to us pros…

  • For application developers you made a great point “The big problem is that programming languages really need to get simpler and increase the level of abstraction not reduce it.” I agree and point to XAML as the next level of abstraction. Right now it’s primarily UI focused but eventually the amount of C#, VB, Java, C++ code should become minimal. The other nice thing about a higher level of abstraction is that the “common” code can be in your language of choice. (Including JavaScript) Cheers to all.

  • alleey

    In this article and elsewhere people favoring C# over C++ because of rapid development they owe it to BCL and not C# in the strict sense. I find this to be an unbalanced comparison as such.

    Probably the single most critical failure of C++ language and community has been the lack of a standardized, comprehensive and ubiquitous library that compares well against BCL for example.

    Writing C++ applications can be as fast as writing them in C# or java given you have a good collection of reusable components – and some developers do have that capability.

    Even though C++/CLI isnt strictly the language C++ that is under discussion but try writing C# or java code that has to inter-operate with native and the same with C++/CLI and the later is a winner by any yardstick used to bash about it.

    I seriously hope for the deadly combination known as C++/CLI to become mainstream C++ and stump all competition.

  • Great post that makes concise points about using C++. I started programming with a semester of Java and then started a program that is based in C++. I think I was able to pick up the C++ syntax a lot easier than students who were going through the program without any programming experience because I could glaze over the arcane syntax and better understand what was going on by making the translation to Java, but I still get boged down in the sand traps of the language. I was trying to parse a csv file and learned the hard way that there are multiple getline() implementations in different libraries and each works a little differently, particularly with how it handles carriage returns. There’s no way to know that until you’ve done banging your head through three dozen webpages and two manuals before finally giving up and trying something else.

    I think C++ is unhelpful for use in first semester introduction to programming classes and in teaching data structures, you have to spend so much time on the implementation, the students often lose sight of the structure they’re trying to replicate. I’m glad I’ve gained the proficiency in C++, but I don’t think it’s worth the cost and definitely not a one-size fits all instructional language.

  • Cristian Amarie

    It’s always about who is using it. I am more comfortable, for example, in C++ than in C# simply because I have templates and I can control the objects lifetime. I think the vast majority of the C++ naysayers are mainly because the developers are not comfortable. Interfacing with OS C APIs is also a large problem for non-C/C++ languages as well; even if not talking with drivers or hardware, things like COM, sprintf, legacy etc. are natural in C++, yet painful in C# or Java.

    The underwater thing for the other languages are the runtimes, setups, installs, jars, cabs, assemblies … a myriad of things that C++ simply can link statically and resolve everything at runtime. One build, one binary. (See Skype.exe for example). Something that I always hate in C#, for example – there’s EVERY time something not working, simply because I have Outlook 2010 and the customer have Outlook 2007 (talking about Outlook add-ins in C#).

    After all – it’s “right tool for the job”. Nobody will do a website in C – except Bjarke Viksoe, I suppose :D – or a device enumerator class in Java. Language per language, thought, C++ is more powerful because of, ehm … templates (most powerful, even if other languages have their equivalents) and lifetime control (GCs may do a fine job, but not on external/volatile objects).

    • If you are using Skype in C++’s favor then you faulter, simply because skype was written in Delphi.

      • Cristian Amarie

        @NlightNFotis Skype UI is written in Delphi, the rest is C++. And I bet it will get rewritten completely in C++.

  • Jono

    you realise that the reasons you gave to write c++ still apply to 90% of critical infrastructure code running on the planet (and always will).

    – you need performance. check.
    – you are writing code which will interface with raw hardware (it’s called a microprocessor). check.
    – you must have deterministic behavior check.

    you could have called your article “Don’t write web pages and phone apps in C++”

  • I can follow on you way of reasoning about c++. However, I can only agree with your points about not using c++ only if we speaking APPLICATION development. All the rest is quite C++ dominated and it never really faded away.

    After using C# since beta and being a seasoned c++ and Java developer , I wonder now why people use such nonsense in OOP as C# and Java, where C++ is sooooooo much better at proper OOP. (e.g. const correctness) on the other hand ELEGANT? is not a word I would describe neither C# nor Java. this word is exclusively dedicated now to lady LUA alone.

    About productivity and maintainability:
    1) almost any dynamic language is more productive than C# and Java
    2) C# by now means nurturing a maintainability, again it nurture prototyping which is exactly on the opposite end!

    You can’t believe the piece of crap code I’ve seen in C# and the utter non-sense I’ve encounter. A C++ programmer simply had to shoot himself many many times to reach such a code base, for good. The managed word BREEDS sloppy programmers and frankly silly attitude towards serious software.

    anyway, really nice Article, but a bit short-sighted …

    • Dan

      To understand you correctly…

      Are you suggesting that language syntax choice is at fault for a developer’s lack of organization, non-use of design patterns and misunderstanding of object oriented concepts?

  • I totally agree that one should be aware of the lower level! That’s why I chose to implement my own managed programming language.

    It’s called Kava: http://www.yannbane.com/2012/12/kava.html.

    The (K)VM is implemented in C++. I’m just starting, but I can already see how’s it going to be very useful, both educationally and pragmatically.

  • Learning, is a natural part of a ‘programmers’ evolution which is driven by desire. “Learn C++ in case i need it” ~thinks the ‘Programmer’.

    Learning, is a serious investment of time and effort which is driven by need. “Learn C++ because i need it” ~thinks the ‘Developer’.

    Since working as a freelancer or contractor means we must operate as both ‘Programmers’ and ‘Developers’, we inevitably develop a blended view of things. Some more ‘Programish’ some more ‘Developish’.

  • greybeard

    OK, I’m feeling like a dinosaur. When I started, there was a similar article, this time about assembly language. If you absolutely had to squeeze the last cycle out of your hardware, it was the way to go, but it was like working without a net. Now, C++ is the risky language. I think I’ll go sit out on the porch in my rocking chair and quietly start muttering to myself.

    • opwernby

      Can I join you?! (see my post, below…)

  • Duke S.

    C++ is not “back” because it never left :)

    Really; there are many people who use C++ productively as “much better C”.

    I abhor many of the new additions;
    some people are trying to turn C++ into Visual Basic 6 – i.e. something very safe that somebody with no knowledge of algorithms can use after studying for 21 days.

    That is very wrong; Porsche is not a tricycle.
    People spend more time “fighting” with new features than writing new code.
    That may be warranted for a complete newbie, but that is a terrible drag on a professional.

    (BTW, opposite trait has been plaguing Visual Basic after VB6)

    People! [product managers], stick to your [or some!] principles!
    You don’t have to turn every product into “everything for everybody” !!
    You will actually loose money doing that!!

  • Well, your right that c++ is not “back”. The fact is that it never left. That is because there is such a huge installed base.

  • You makes some interesting points but I think the interview question list is a little weak. I think you probably come up a similar length list for C# or Java or whatever with the same degree of subtle gotcha. Unless you’re trying to hire dilettantes.

    On the other hand I do most of my coding in Matlab (which is written in C++ BTW ;^) now.

  • Jason Spencer

    Since a quick scan doesn’t show a mention, folks might consider the D programming language. It’s machine-compiled but has all the features of C++11 (and more, I’d argue) in a way that makes sense as a whole, and adopts many of the newer language productivity features (slicing, pure functional, etc.). Compiler source is available and mature. The drawback is there’s no standard for it, and tool/library support is basically open source.

  • Jerome

    “Now it is possible I missed a valid case, but chances are any other case is going to roughly fall into one of these three categories.”

    The reason I use C++ is that the guys who pay me insist upon it. That seems like a really good reason to me, but I don’t see it on your list. Do you have a trust fund or something?

  • Y’know… it’s a funny thing, but I don’t like C++ one little bit. I’m an old assembly language programmer – been programming over 30 years now – and I’ve also written tons of things in C in my time… but C++ never did it for me as a language: it always seemed to me to be a way of adding bugs at the compiler level (or precompiler level, as the case may be).

    However, I love C#: it gets it right — it might be a bit slower, but it’s a truly beautiful language. I love C, too — it’s one step above an assembler, and as such, it’s a powerful and elegant tool for a lot of system-level stuff…

    …but not C++… although I’ve written compilers in it (and the odd device driver), whenever I’m programming in it, its feels to me like Chinese whispers – you know: that old game where you sit around in a circle and whisper a message to the person on your right, who then whispers it to the person to his right, and so on, until it gets back to the start – at which point you all laugh at how different it’s become from what you originally said. I know it’s something that has pedigree at this stage, and that the “precompile to C” thing is long gone… but I still don’t trust it, and I never have: to me, it’s a way to remove yourself from the low-level nature of the thing you’re trying to do… and if you’re not trying to write low-level stuff with it, then use something suited to a high-level purpose. C#, for example – or before that, Borland’s style of object Pascal (also very beautiful).

    Computers aren’t naturally object-oriented: to try to force object orientation onto system-level processes just doesn’t make sense – all it does is put a level of fakeness over everything you’re doing… so by trying to “help” the programmer by providing structure, the language destroys the very thing it should be good at.

    • opwernby

      Bet you didn’t think you’d get a post complaining that C++ is too high-level for itself!

  • The big difference to me is: C++ is a development language and C# is a development environment (Language, LINQ, Entity Framework, Reflection, Metadata etc). When C# 2005 came out we jumped on it and left C++ because productivity doubled, quality improved and maintenance became much easier. Also from 1998 to 2011 C++ was on hold. There were more enhancements to Object COBOL then C++ during that time frame. I’d call that being placed on the back burner. Now C++ is getting some attention so gamers can push the limits on smart phones. For business and data entry based apps C# runs very well on everything else. Cheers.

    • andydent

      “Also from 1998 to 2011 C++ was on hold.” comment from someone who appears to have paid zero attention to the work and announcements from the standards committee.

  • Do you guys think that C++ performs better than a well-written code in assembler? Do you guys think that C# performs better than a well-written code in C++? This is a rerun of an old movie.

    The answers to both questions is no, however, hardware, language specs and compilers evolved in a way that, marginally, on a cost-benefit equation it ended up proving better for the Industry to jump ships.

    As I said on my blog many times, if C++ were replaced by D as a standard, this whole discussion may be over since it has the best of both worlds: it is elegant and friendly as C# with the performance of C++.

    • C++ *does* perform better than “well-written” assembler, for all but the most arcane use cases, when you factor in the effectiveness of modern optimizing compilers. It used to be true that hand-optimized assembler could beat compiled code in some hot paths, but it’s very rarely true any more, and it only occurs when the C++ code subverts the optimizing compiler.

      • Ummm… no it doesn’t. A good machine code programmer can always optimize better than a compiler. And by definition, any C++ instruction will compile to more machine code instructions than properly written assembler. Also note that in machine code, you’re not limited to the strictures of the language. If you find C++ performing better than assembler, then that’s because the programmer doesn’t understand machine code.

        • Do you have a demonstration that isn’t so ridiculously contrived as to be meaningless?
          I’ve seen several self-identified “good machine code programmers” write hand-rolled assembly that was soundly beaten by the compiler/linker. The reason is that the compiler/linker can do global optimizations that the hand-rolled assembly simply can’t, due to the lack of information available.
          As I mentioned, I don’t believe it’s impossible, but I haven’t actually seen anyone do that since about the year 2000.
          Your assertion that “by definition, any C++ instruction will compile to more machine code instructions than properly written assembler” is fallacious. You can’t possibly demonstrate that, because you’ve defined an infinite problem set, among other issues with that statement.

          • Cristian Amarie

            I think he wasn’t referring exactly to that – obviously in 99.999% of the cases the compiler would do it better, and then some. But taking just one example – Quake “magical” inverse square root – proves, I think, it’s not 100%. Great programs comes sometimes with great code, and that’s not what a compiler does; programmers do.

          • Well, I just tried a simple case: Euclid’s algorithm. The compiler came out instruction for instruction identical to what I hand-wrote in assembly language – using registers instead of memory, and everything. That was pretty impressive, I have to say – back when I actually bothered with C++, the optimization was nowhere near as good, so things have certainly changed.

            But Euclid’s algorithm is simple; as Cristian points out, assuming that the programmer can really program, there are going to be cases where he’ll see optimizations that the compiler can’t.

            And what does, “due to the lack of information available” mean? Why doesn’t the assembly language programmer have information?

    • greyfade

      It doesn’t matter if C++ performs anywhere near well-written assembler. The power of C++ is its tools of abstraction, not its performance.

  • I feel like this is a pretty common thread in Software Engineering: “But I need X”, for any X in “web scale”, “high performance”, etc. The simple fact is that most people don’t really need the bare metal performance that C/C++ provides them, and some better architecture along with a managed language will probably work much better.

    That being said, when you finally need everything C/C++ can give you in terms of low level twiddling and performance, you’ll know.

  • 因为C++没离开过

  • TS

    C++ is great – you can go down to bare metal like in C, but you can also use it to build as much abstraction layers as you need in the way you need them – unlike C# or Java, which take away a lot of the expressiveness of C++ and push you into using their predefined abstractions which might sometimes handy, but also often turn out to be just an annoying problem which results in ugly helper code bloat.

    On the other hand, languages like Lua or JavaScript are really great by really letting me write what I want to write without needing to do the much ground work at all.

    Funny observation: It is possible to write C# so that memory consumption and execution speed comes close to C(++). However, it requires at least the same amount of thinking than writing it in C++, and results in code which is way less obvious in telling you why it is written that way since it is no longer written directly but rather going on implicitly in the internals of the runtime.
    Similar tricks apply even for JavaScript, but given the fact that each runtime is different and under intense development as well, low-level optimizing is pretty insane there.

    In general it is a dangerous widespread belief that environments providing easy-to-use abstractions require less skills: It is true that they allow less skilled to pile up large constructions as well, but once the pile collapses you´ll need expert skills anyway – which are hardly learned if you have never used the complicated way of doing stuff where flaws tend to bite you quickly.

  • Nicolino

    Regarding C++ decay and the growth of other languages like C# or Java, in the last 10 to 15 years, is not related to the languages themselves or how easy or hard to learn they are. But the software development kits behind them.

    Behind Java you had Sun, and behind C# you had Microsoft, so they basically owned the languages. They provided tons of out of the box libraries to work with common problems developers have, UI, images, XML, zip files, etc.

    C++ is a headless beast with no real owner, so you don’t have a standard SDK like with these other two, so you end up having 10 different ways (libraries) for parsing an xml or you have to write several lines of code to use an open source library to open a jpeg file for example. These things made easier to switch to other languages or worst, teach them instead of C++.

    The lack of ownership and the absence of a real SDK comparable to the others made C++ lose terrain.

    I don’t know why Microsoft is pushing hard to revive C++ and why they are putting all the effort now on C++ in the same way they did it for C#. Now it looks like they regret of having empowered C# while the same thing could have been done for C++ in the early 2000’s.

    Really don’t know.

    • CrankyMiddleAgedGuy

      Absolutely right. The development of C++ libraries occurs at a snails pace. I’m afraid that we would be better off producing a comprehensive standard library rather than one that is reviewed to death before it is agreed and published.

  • Nothing on my desktop is C# or Java. Nothing. Not ONE desktop application isn’t written in C/C++ on every platform I know. No games I play are written in C# or Java. No browser I rely on everyday is not written in C/C++. Not an operating system I use isn’t written in C/C++. None of the useful features of modern hardware (GPUs) is useable from outstide C/C++. No phone would be able to provide a useable browser without webkit (C/C++). No other technology will be still top notch in 10 or 15 years.

    YOU guys are rewriting your apps. You guys lost XNA. You guys have no longer Visual Basic.

    WE will have software transactional memory next year and this will be a big thing with hardware support in Intel hardware and GCC supports this TODAY

    So write your PONG game in whatever language you want.
    C++ Developers don’t write the PONG game, but everything else on that machine is C/C++!!

    Stay Visual Basic!

    • tripcore

      Well said. Seriously, reading these comments makes me a little depressed because they show how little appreciation most programmers have for the most essential applications. OTOH it makes me feel good about my job security.

      Really, it’s all about putting things in perspective. I love Python but I’m sure it’s much less essential for the future of computing than C/C++. I bet C/C++ will outlive most dynamic languages, not because dynamic languages are bad but because there’s an alternative to any one of them (e.g. Ruby vs Python, C# vs Java), whereas there’s no alternative to C/C++ in the foreseeable future (no, Go and D will not replace C++ for decades).

      Yes, C++ is complex but it’s not a good enough excuse to slap a dynamic language where it doesn’t belong. C with Python instead of C++? What could possibly go wrong? No problems whatsoever with the interfaces, no overhead for the Python interpreter, no dangers of pure C dumb pointers? I agree there can be lots of good reasons to use Python but not wanting to learn C++ shouldn’t be one of them.

      • Dan

        XNA wasn’t a language. It was a framework. Just like any number of C++ game frameworks that have been abandoned. (And XNA actually lives on as MonoGame)

        The whole point of computing is to make tasks easier.

        We don’t force end users to learn vi to appreciate the complexity of Office Word/Google Docs/etc.

        Programmers are end users too. And just like your normal desktop user, there will be those who don’t want to be burdened with the complexities of C++, and there will be the power users that benefit from the understanding.

        At the end of the day, as a developer, what matters most is the usage of the program you write. The point of writing a program is for it to be consumed by some user. Most users won’t care how you wrote it. They will care if it works. This make a scenario where an application written in Python can be more popular than a similar app written in C++ very plausible.

        Especially in our service oriented “online” world, how many of those C++ applications on the desktop are relying on scripted or managed code services on the web somewhere. That desktop browser written in C/C++ is not worth anything without the HTML/javascript scripting providing it content. Everything is integrated these days. And for many of the good reasons John stated in the article.

  • Anonymous Coward

    I think your description of the situations when C++ is a good choice are not OK:

    You absolutely need to ink out every bit of performance possible out of your software and you would like to do that with a language that will support OO abstractions. – why not code every performance-critical part in C++ and script the rest in Python, Lua or whatever? Although, if you really-really need to squeeze the last bit of performance out of the hardware, and can’t even afford the glue code in a scripting language (when would that be, on a modern desktop or server system? – even the mars rover has some Java code on it), that’s IMO the only reasonable use case for C++.

    You are writing code which will directly interface with raw hardware. (Example: you are writing a low level driver.) – that’s clearly plain C land, IMO.

    Memory control and timing is of absolute importance, so you must have completely deterministic behavior in your system and the ability to manually manage memory. (Think real time embedded operating system controlling a moving piece of machinery.) – again, plain C all the way, IMO. Plus, the simpler language gives you the same control with less effort – C++’s OO scaffolding only gets in the way in such cases, IMO.

    OTOH, I think that even if C++ is in no way a language I’d use in production for most code, it’s definitely a language worth learning. I repeatedly find that people with C++ knowledge have a better understanding of both the dangers of complexity and of how to write code in languages with managed memory in a more efficient and flexible way. IMO C++ gives you knowledge and habits which are useful when you switch to a higher level language in production, and which are very hard to acquire otherwise.

  • Manideep Bora

    Nice article

  • Alien superStar

    Well, in my opinion, the reason why there is not the chance for C++ to replace the Java at the top is because it dont have good enviroment for developing applications for internet, mobile and some simmple apps.
    Yes there is QT, and dot net C++ but I would like to develop forms in HTML 5 and to be able to writte just one program and to us it on all enviroments.
    Why you cant use Linux and Macintos in same program, that is the one of the reasons why….
    And when U get to GDI++ you figureaut is GDI—-, and that You need Direct X or OpenGL, and Delphy 7 was really good, but some people think it is Microsoft fault for deth of component market and it looks to me that they wanna kill C++…

    And also C++ didn’t react in righ way, expecialy with those mobile applications…, it is tugh to develop some other things like data base applications, where Delphy was supperior, and C++ have very best sintaks but it has not use all power from it….

    • Cristian Amarie

      Well, I think you talk about a library, not about language. And there are HTML (either WebKit or IWebBrowser2) embeddings/bindings for C++, but – and I am talking from experience here – HTML is done by guys looking for beauty. Countless times the HTML guy removed the IDs from elements (just to name a thing) and where is the crash? In C++ code, of course.

      Microsoft pushed years ago .NET as panacea – and it was not, obviously – and now they are backpedaling somewhat from it, although not stated so. I think why component software – yes, you would like databases and recordsets and common controls for web – and what did you get? Silverlight, bloated DB assemblies (as if ODBC or even ADO was not good) which added NOTHING as value, reinventing the wheel just for the sake of having .NET as suffix.

      As for mobile, I don’t know what was wrong with, for example, Windows CE C/C++ code. Yet another reinvention, again adding (almost) nothing, invalidating good existing code just for some accordion js control. And we wonder why developers feel lost – veterans included – after having the main or NSApplication skeletons generated by some flashy wizard supplied with a 2 GB IDE.

      I remember Hendrix saying sometimes “if you play someone else’ song, play it better, or let the original version be”. IMHO, same happened with .NET. They saved the masses by pointers (because that was the real pain in the ass) – something already achieved by VB6 – only to “discover” suddenly the need for translation of IEnumVARIANT or std::vector into foreach-ready collections.

  • This whole discussion would be unnecesary if C# had a native compiler created not only to improve startup times (like NGEN) but to improve the perf of the whole code (to match C++).

    Then, imho, it would be a perfect scenario for hybrid solutions: C++ for the parts when you really need to directly manage memory (as well as raw HW interfacing), and C# for the remaining parts of the app/game.

  • hinst

    C++ is not back because it did’n go anywhere :P

  • Cristian Amarie

    I’d been reading a number of comments stating “if you need bare metal/performance [etc.] then go C++”.
    I don’t think C++ is just a some form of new assembly – usually enriched with superior comments to non-C++ world.

    Its power stems also from freedom (can start a class hierarchy any time without having a some base class you don’t want), generic programming (templates are unrivaled, let’s not discuss this anymore, I suppose it should be clear for anyone). Great programs are (almost) all written in C++ (with bare bones in C here and there), and that’s on every world, even if you point to Office, KDE, WebKit etc.

    It’s basically a language that can do anything; programming in C++ is truly a form of art, not a job. It’s about the difference between a Fender guitar and a programmable drum machine. It’s hard to learn and even harder to master – but the result is music.

    No surprise that C++ programmers are proud than can do it – I know I am – while on the other worlds this sentiment appears missing, despite the very latest performance test that demonstrates (yet again) that Java is sometimes even faster (with the mandatory ! signs).

    • Well put

    • Patrick Keenan

      Agreed, it’s not about slamming out the next “app”, infact if I never heard the word app again I would be happy.

    • theHypnotist

      “despite the latest performance test demonstrating that Java is sometimes even faster than C++”

      That’s funny considering that the Java VM was written in C++/C/ASM in the first place and probably the C++ was compiled with a really good compiler like Intel…Anyway, congrats to the author of this article for writing a nice controversial piece guaranteed to spark debate and language wars for years on end.

      I like the idea that there will always be “power users”/app programmers like COBOL of the past and C# of the present and on the other hand, other people like the ASM programmers of the past and the current C++ programmers for the system level stuff or high-performance programs including the VMs.

      One of the points of the author was that if a person wants to get a job he can learn Java/C# and not mess with C++ and do fine if he wants to and he doesn’t have to do the C++ if he wants a job.

      Being a C++/game programming enthusiast with a bit of a C gaming background way back, I can relate to the musical metaphor. Inevitably my personal experiences with Java have felt dry by comparison to the “juiciness” of C/C++.

  • bk1x168

    I like your points, but I would just add some more cases, where C++ is useful:
    * When using libraries that are C++, it might be easier to program in C++ than to support bridges
    * When doing complex calculations with non-primitive numeric types, a language without operator overloading (like Java) is a no-go. This kind of application is quite rare, though.
    * When doing operating specific stuff, C++ might be one option of getting the job done.

    Generally i think that there are quite a few interesting programming languages around, not just Java, C++ and C#. I would recommend to choose the tool for the job, not to use one tool for everything.

    • TS

      Calculations on non primitive numerics are far from being rare – complex numbers are widespread in engineering and science, and vectors and matrices are almost ubiquitous. Handling sets or concatenation can also be expressed more cleanly in operator style.

      Luckily, C# and Lua designers noticed that as well =)

    • Cristian Amarie

      Well, you don’t need just calculation over non-primitive types. It’s enough, taking just one example, to talk about functors and operator () (either returning a copy of an object calling functor, or modifying the existing one). I am using massively calls such as f1(f2(… fn(x) … )) for implementing application logic, to separate method calls from the logic. Other than collecting function pointers on a stack, C-style, operator () is the only natural way IMHO.
      I suppose the vast majority of C++ usage is nothing more than pointer/object encapsulation, providing just containment, aggregation and a RAII form of lifetime. But when it comes to algebraic structures, C++ is really unrivalled.

  • Mike T

    The phrase you’re looking for is “eke out”, not “ink out”.

  • I hate C++ , loves C instead , C++ is neither high level nor low level which makes it neither good for system software development nor app development . I used to be system software engineer for a large company and maitaining well written C code was far easier than maintaining C++ code ..

    • agrre with the exception:
      C++ is PERFECT for APP-dev if you know what to use and what to leave behind.
      especially now with c++11!!!

  • Phylos

    My evolution as a programmer: assembly languages -> C -> C++ -> C# -> F#.

    It’s good to see that C++ is getting a “modern” facelift, but after 8 years of C++, the advantages of using C# or F# still far outweigh any recent improvements. Now I use F# whenever I can because of default immutability, type safe discriminated unions, pattern matching and so on. F# offers a more advanced and flexible type system than C++ or C# and while being a functional first language still allows you to do imperative or OO programming when it’s appropriate. While I still need to do a lot of C#, when there’s a complex algorithm involved I often use F# to get a correct version up and running quickly and then convert to C#. I often do this for finite state machines even though ironically the F# implementation is actually stateless, using recursion, discriminated unions and pattern matching.

    When I was doing embedded systems programming, C was used for 90% of the code and assembly when needed for such things as interrupt service routines and fast block copies, but it would have been insane to code everything in assembly language. The same goes for C++. It’s just pure insanity to code everything in such a low level language as C++ when alternatives like C# or F# can do the same job in less time, less code and far less pain.

  • TVD

    Every blog post, every tweet, opining the irrelevance of C++ is done from a Web Browser written in C++. Oh the irony!

    • So true, without C++ you can’t have your pc, laptop or mobile working even.

      • aszkid

        Well, we’d get to C by talking about OS and kernels.

    • Dan

      And (with the exception of ancient CGI apps), that content is being served up to you with the involvement of some sort of non C++ language-oriented process. Locally with html/javascript. And it’s probably being brought to you from a server via some sort of web language/framework like PHP, ASP, Tomcat, etc. The browser written in C++ is not worth anything without it.

      It all co-exists in 2012 and beyond. Could we have written everything in C/C++? Sure. But I’d argue we wouldn’t benefit from half the advances we have today if that were the case. The development world isn’t run by a handful of people proficient in C++.

      C/C++ is neither doomed to extinction nor destined to have a significant come back. It does, however get the pleasure of being the parent of a lot of languages that make development life easier.

      • TVD

        @Dan: All those dynamic languages and markup languages you mentioned…What language is their interpreter written in?

        Dan, each interpreter is written in C++.

        C++ is not the “parent” of any of these languages – Not even by a long shot. C++ is, however, the engine interpreting each of these languages.

        When our time has come, it is the next generation who will maintain these interpreters. That is why I believe it is a mistake to tell that generation C++ is irrelevant.

        To tell them otherwise is to sell them a home without electricity. Dreams without foundation.

        • I agree with that. I think it comes down to the following: programmers will always exist as one of two states: systems programmers and application programmers. Application programmers don’t care how their languages work; systems programmers must care. An application programmer will never be involved in writing something like a compiler or a server; they’ll just be involved in using them and writing scripts for them. To a systems programmer, an application programmer is just a power user.

          • Dan

            I’m the other Dan. :)

            Yeah.. Every discipline specializes at some point. You don’t want a pharmacist doing surgery. You don’t want a family law lawyer defending your intellectual property case.

            System programmers are important. Application developers consume their work to make apps for everyone else..

            This is all starting to sound like that bad joke where all of the body’s anatomy begins to argue about who’s function is the most important. :-)

          • I’m an app developer.
            trust me what goes for APP these days is very broad, much broader than it used to be.
            so from a app-dev perspect:
            there are good reasons why not all apps are written in Javascript/Python etc.

            and it is quite a MYTH c++ is not good for app dev .

        • (by the way, I’m not the same Dan!!)

        • Dan

          This can go in a circle forever. And that first version of the C++ compiler was written in Assembler.. etc etc.. :)

          What prompted the need for those languages to be rendered into existence at all? Surely the authors of the C++ written interpreters/compilers had a good reason to do so (and some of them are JITed into native now, so is C++ really involved at that point, or is the binary doing the compiling without the need for C++?). Ironically, I’m sure those developers agreed the necessity was to address the needless complexity of C++ for serving up web content. As such, my parent analogy was more of an evolutionary one than a literal one.

          C++ will be irrelevant because it’s not always cost effective to re-write everything. Just as Cobol programmers make a pretty good living these days because it’s deeply ingrained in banking mainframes. Those Cobol programs could have been written in assembler, I suppose.

          But all of these assertions about how deeply relevant C++ will be really doesn’t seem to take into consideration that there might be something in the future that eclipses it. Either something that currently exists and development momentum makes it a 100-110% perfect alternative, or something that hasn’t been born yet. There was life before C/C++ in the form of assembler. And I remember when C was introduced, a lot of the assembler experts said the same types of things about C.

          • “C++ will be irrelevant because it’s not always cost effective to re-write everything.”
            it depends on the context !
            whats the best dev methodoly (since I see you are interested in the topic) it is:
            1) context driven development
            2)thinking driven development
            before TDD :)

          • Jeff Howe

            @Dan: “And that first version of the C++ compiler was written in Assembler.. etc etc.. :)”

            I understand the point, however, as a point of history, the first C++ compiler was not written in assembly language. See

      • I would follow on the current (not to mention past) state of WWW technologies as “Advancement”
        if for one think people are starting to be aware that HTML5 is simply HYPE

  • Thomas

    You mentioned in a comment that “..C++ definitely faded.” Can you prove this, or is it just gut feeling?
    There is a huge installed code base in C++, and many of the most interesting projects out there use C++. If you want to linger around in boring enterprisy Java/C# projects, go on. And please, keep on writing articles like this one, as it rather drives people away from C++ which increases my market value as a C++ developer because, I definitely see an increase in C++ usage.

    As far as productivity is concerned, this has nothing to do with the programming language being used. I have been working in a couple of projects where my C++-colleague and I were as productive as our Perl-Java-colleagues. It’s all about proper design, creating the right abstractions and so on. As Fred Brooks once mentioned, addressing the essential complexity of the software process is what brings you productivity increases, and this goes way beyond the tool (ie. the programming language in this case) selection.

  • bk1x168

    C++ and C are both cool languages and as has been mentioned, a lot of our infrastructure (OS, windowing systems, browsers, databases, programming languages etc) have been written in one of these languages (or possibly other static languages with native compilers) No doubt about that. While such infrastructure development is tremendously interesting, more developers seem to be involved in application development, where C or C++ are not mandatory, but can be replaced by Java, C# or even languages with higher abstraction like Perl, Ruby, Python, Scala, Groovy, Lisp, etc. The initial article can be applied to these cases and I agree that it is not likely that C++ will gain back a lot of terrain again in application development. Some application development is done with C++ but I would not expect a large movement from Java to C++. Moving away from Java and C# would be more plausible when switching to Ruby, Scala or Perl6.

    • completely disagree. look at the post just above and the people experience with Qt. truly cross-platform with native look.
      please tell me one alternative for this package!?

  • terry

    This is a good post to read, C++ is not perfect but it fit my requirements the best now.C++ give me speed and abstraction power.Besides, it is much more easier to work with openCV2(my specialty is image processing ) if I use C++, I don’t need any additional binding.

    I tried other language(C, C#, java) before but I end up choosing C++ as the main tool to develop the core algorithms and the gui(Qt behave better than I imagine).C could give me raw speed but I have to sacrifice abstraction, it is harder to develop type safe(int, float, uchar) codes and switching different policy without severe performance penalty sometimes(cases like quicksort vs sort) since it don’t support overload and template;The speed of C# and java are not as good as C/C++, and I found that I don’t gain any huge productivity when I use them to develop reuseable algorithm(template play a very important role for the algorithms and data structure I need).

    C++ is complicated, a lot of traps and defects, it is never a perfect language, but it fit my requirements.The other reason I chose Qt to develop gui is because Qt promise they will be able to cross desktops(windows, macs and linux) and mobiles(android, ios).I never develop any mobile app, but if Qt support ios officially, I would like to give it a try.

    Besides, dear opwernby, I don’t know the old day, today the performance of C++ is very good, sometimes the codes generated by the compiler even outperform those good programmers who familiar with assembly.Technology keep evolving, the power of optimization is amazing.


    • opwernby

      Yeah – I’ve been playing with it a bit as a result of reading this, and looking at the machine code it generates: it’s very smart. In fact, if you write a procedure which is only called from one place, the compiler is even smart enough to inline it in the compiled code: I found that very impressive. It also sometimes codes two checks into a while loop instead of just one at the beginning to avoid having to use a jump unless your really have to… a person couldn’t really do any better than that. At this point, it really comes down to whether you trust it to get it right all the time… I don’t – yet – but I have to say I’m impressed by what I saw it do.

  • matiu

    I personally find c++ easier than Java. I started programming in Basic, then moved to assembler, then Delphi. I did only 3 months as a Java programmer about the time EJB came out and there was one IDE that was so slow, it was easier to write in simple editor. That might have put me off a bit.

    I re-looked at java earlier this year, and wrote a few small programs, but I honestly find c++ easier to handle and understand. Elegant, modern c++11 is the most delicious language for me.

    I also quite like C# and would probably use that more than C++ if it had better support on Linux.

    There were many years using the scripting languages (python+php+perl) for websites. One of the main reasons I came back to C++ were when some of the big sites started needing dedicated machines with 8 GB of ram and horrible things like nightly restarts, then scaling and scaling on the cloud.

    One python web app, grew to take an 8 GB machine, then grew some more. Initially we started splitting it out onto three machines, then we re-wrote it in C++ with Wt http://www.webtoolkit.eu/widgets and found it running comfortably on a 512 MB vps with DB and everything.

    The re-write was indeed a *lot* of work, but I think it is justified in avoiding the scaling work in the future. Also the C++ version handles threading really well, where as the python version needed 4 procs to take advantage of the multicore cpu.

    Finally, I really like Go. I think it shows the future of programming and is very cleverly designed. The main reason I don’t use it right now is the lack of generics (templating), which C++ spoilt me with.

  • Cross

    I’ve been working as java developer and .net developer for too long, during the last year I’d to start using C++ and C more and more, just because it’s faster and you’d a better control of the memory management. But it’s not just me, a lot of people are getting back to C++, just because the modern phones are pushing that very hard, if you want to develop an application that will run on iPhone, Android and any other, you will need some level of abstraction and create the common logic in the only language that runs on almost every single hardware… C or C++, I think that’s why C++ is getting again and again in the first place of the languages on use: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html, I dont think C or C++ are better than any other language, just as someone else said you need the right language for the right job, if you need your code to run fast then you will need to be as close to the machine as possible, even if that means to write some code in assembler (Chrome had to do that for some components).
    At this moment, I’ve the same productivity with C++ than I’ve with C# or java, just because I built my own set of tools that make my life easier. Sometimes I’m faster coding in C++ than C# or Java.
    I understand your points, but saying that C or C++ is not going back it just goes against the surveys, if you dont want to learn it… or you want to forget them, it’s ok,

  • Mike Bracuti

    How to initialize a primitive in C++? Well, I imagine buying the primitive a good primer would be a good start.

  • JK

    It is not correct to say c++ won’t be back because it has never gone out. It is still used in areas it was orginally intended for. Eg: Complex and high performance apps / games, middleware libraries, OS (Symbian), Complex apps which also need low level access. One more thing, programmers doesn’t just mean application programmers. They also include System programmers. Many of the high level libraries have their significant portions written in c++. So whether it will be useful for you to learn depends on what area you are going to work.

  • Reblogged this on sunliwei.

  • sjo

    As someone who only wrote his first line of C++ about a year and a half ago and knows the answer to each of the above questions, I have to disagree with the view that C++ is impractically complex. It’s certainly much more complex than languages like C (semantically) and Scheme (syntactically), but not in any sense unmanageably so.

    Now, I may just not have enough experience with C++ to see just why any of these poses a significant obstacle to using the language, but I personally feel that for just about any feature of C++ you could name (beyond some of the more esoteric “features” inherited from C), the power and flexibility you gain far outweighs the initial cost of learning the uses and caveats of that feature.

    In other words: yes, Java is simpler; but if you want protability, you’re limited (as far as I know; I’m not a Java programmer) to bytecode and heap allocation. Scheme and other Lisps are simpler, but you cannot include or link against anything but C with any kind of ease, and even then not natively. I don’t think anyone has ever accused Perl of being simple, and just about the only advantage C holds over C++ is compatability, and that advantage is waning every day.

    The thing of it is, every program, every method, subroutine, or transformation involves a certain degree of necessary complexity. That complexity must be managed in order to produce a correct and functioning program, and that’s one of C++’s strengths: instead of relegating the management of program complexity to the user, C++ tries to encompass and, most importantly, provide a standard set of tools for managing, as much of that complexity as possible. But where C++ really stands head above shoulders is in that, while it allows you the kind of abstract programming that a few decades ago was feasable only on a Lisp machine, it also allows you every last bit of control K&R gave us when they invented C.

    So while I would not recommend that anybody use C++ exclusively, I personally think that anyone who does not use it to some extent is really missing out, and that to respond to the question “Should I learn C++?” with a “No,”—of any degree of capitalization :-)—is to do the asker something of a gross disservice.

    • there is no such think as Java interoperability, there is such thing as write once debug everywhere. ask any ANdroid developer :)

  • Great article. I’ve been professionally developing in C++ for a little more than a year [after having enjoyed of the managed world for nearly 3 years], and certainly is been (at quite some moments) a real pain in the *ss. I’m looking forward to the days where I can program back in a higher level of abstraction and productivity.

    • let me paraphrase you:
      cause Im lazy managing my own memory.
      I prefer creating GARBAGE and someone else cleaning it for me! (like your Mom) :))

      • Nguyen Nguyen Khac Trung

        You seem to be obsessed with C++ and dislike higher level languages. That’s fine as long as you don’t insult others, that’s annoying.
        I agree with being lazy to manage my own memory, but that’s not a bad thing.
        The difference in productivity when working with C++ versus working with higher languages are much greater than cleaning my own garbage versus letting my mom cleaning it for many projects.
        Working with higher level languages is just faster, more productive, especially when coupled with powerful IDEs with features like API references, code completions, realtime syntax checking, etc. The philosophy I’d like to use is use the right tool for the right job, if the performance and functionality of the final product is sufficient and the cost of development is lower, why not?

        • pip010

          Please point to exactly where I have attacked/insulted anyone on this thread personally!
          Before you jump on me personally !
          I will simply comment your post with: C++ is a higher level language
          then the rest need no comment :P

          • Nguyen Nguyen Khac Trung

            “I prefer creating GARBAGE and someone else cleaning it for me! (like your Mom) :))”
            the levels of programming languages are something like
            assembly< C < C++ < Managed C++, Java, C#…< JavaScript, PHP, etc
            But it doesn't matter, C#, Java, managed languages are still easier and nicer to work with.

  • Buddy

    I’m shocked that no one has mentioned the security, or should I say insecurity of .NET / Java. Even if you obfuscate your C#/.NET code, you can use an application that comes with visual studio to disassemble the code. MSIL may be foreign to some, however, it’s nowhere near as complex as assembly language. There are free decompilers all over the internet. A round trip reverse engineer of a .NET application takes little effort, especially when compared to a C++ reverse engineer to assembly language. Your source is “open” whether you license it that way or not. Microsoft had a dream to freeze Win32 and to create a completely managed OS. That dream was called Longhorn.. and that dream failed.. The result was Windows Vista which added some C and COM APIs that did not have .NET counterparts. Now we have WinRT… and is WinRT based on .NET? no. It’s based on COM. COM uses native C++’s v-tables. A C++ compiler can read WinMD (metadata) of a C++ program’s components.. It knows where their v-tables are and what functions they contain so at runtime, C++ programs don’t need to use metadata at all: everything they need to know about the v-ptrs and v-tables is built in to the program. The process is more complicated for .NET. And who said C/C++ isn’t used by Microsoft? One of the main reasons that you see Windows in offices.. that’s right.. Microsoft Office is written in native code.. not managed. I like C#. I love XAML. However, you take a big performance hit when you rely on the CLR to execute your applications. One more point. To all of the developers that rely on faster hardware to make up for performance lost by using higher level languages, you should google Wirth’s law. Wirth’s law states that software is getting slower more rapidly than hardware becomes faster. This is because efficiency is a second class citizen to “productivity”. I say if you are passionate about programming, learn C++. I’ll go one further, learn assembly. Will you write a LOB application in assembly? No. However, if you master assembly, you will gain intimate knowledge of how your choice of data types and logical decisions effect your applications down to the instruction. If you master assembly, you will have a leg up on a developer that has never stepped outside of managed code.

    • You have excellent points. Thanks for adding this to the discussion.

    • let me add something, which might speak louder to managers/biz-people

      A : write a cloud server app in Java
      B : write a cloud server app in C++

      production cost of A is less than B

      but you safe on electricity alone (assuming 24/7/356 availability)
      huge $$$$

      and indeed it is all about wested instruction cycles all over the place. logic, GC etc…

    • “However, you take a big performance hit when you rely on the CLR to
      execute your applications. ”

      That kind of depends on how well the Microsoft .NET JIT optimizes the IL the C# compiler provides, does it not? Sure, I don’t expect a large C# program to run as fast as it’s lean and mean C++ equivalent, but for some of the simpler apps there may not be a noticable difference.

      “One more point. To all of the developers
      that rely on faster hardware to make up for performance lost by using higher level languages, you should google Wirth’s law. Wirth’s law states that software is getting slower more rapidly than hardware becomes faster”

      Thats why we have multiple core CPUs, and why Microsoft has added the async and await keywords to C#, parallel LINQ and the System.Threading.Tasks to .NET framework 4.

      And before you say you can do the same with C++ too, I think there’s a PThreads library IIRC, I bet it’s far harder and takes much more effort to debug, optimize and keep memory-leak free.

      BTW I used to program in C++ but I wouldn’t advocate its use “just because” it makes me l3373r than my online peers :)

  • As far as I am concerned, learn C/C++, and even assembly if you like programming, not just for finding a good job for programming.
    Complexity is sometimes beautiful than simplification in some cases.

  • Reblogged this on Get Back At Me and commented:
    C#, Java, hmm

  • Excellent post. I look forward to digging into this more.

    I am a C/C++ developer, and I develop real-time embedded code, so I am not leaving C or C++ for a long time. So please bear with me when I ask, would you be willing to share your answers to the interview questions in the post? I know the answers to several, but there are more for which I don’t. I know I can search the web, but I don’t trust most of the answers I get out there. I would really like to know what you believe are the correct answers. Please post them or give advice on where you believe the best answers may be found. Thank you very much.

    • I don’t want to just post the answers to the questions here, because this very list may be still be in use, but if you have a specific question you are looking for the answer to, (or rather my answer to,) please email me and I’d be happy to give you my opinion for what it is worth.

      One important thing to note about these questions is that they just give me a gauge of where someone is at. Some of the questions are not even questions with 100% certain correct answers. I am often interested in what kind of conversations these questions bring up when I am using them in an interview.

  • In October, I had to create a WinRT app in about 3 weeks that could do basic drawing of a picture with text and image save functionality for the Win8 release. When I started I thought it would be a piece of cake to do in C# and XAML because I’d done something similar in Silverlight. I then found that WinRT could not render XAML to a WritableBitmap like Silverlight and WPF and the only way to do it was using DirectX and C++! Panic set in as I started learning how to use observable collections in C++ with about 50 lines of code per property versus 1 in C#, I though I would never meet the deadline.

    Luckily I found SharpDX which is a direct C# interface onto DirectX and WIC which saved my life and I spent 2 weeks working out how to do the drawing and save in Direct2D and managed to bash together the UI in C# and XAML in a week. If I did it in C++ it would have taken months.

    I use C++ when I really need to, but I’m not fluent enough to be productive using it so I would always use C# if I can.

    Great article.

    • same can be said now for switching from c# to javascript
      after all
      for winRT you are free to go: c++/c#/JS

  • Sillydog

    You think C# is easier than C++? I beg to differ. C# has become so bloated with layers of intracacy. Read this and tell me you still believe that C# has a big edge in ease of use over C++: http://msdn.microsoft.com/en-us/library/dd799517.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1

    I’d say they’re about equal now.

    • @Sillydog : “You think C# is easier than C++? I beg to differ. C# has become so bloated with layers of intracacy. […] I’d say they’re about equal now.”

      Beauty’s in the eye of the beholder… You don’t see the difference because your skills are not high enough, but trust me, C# is still a lot easier than C++.

      The important part in my answer is “your skills are not high enough”. And this is Ok.

      Perhaps C# jumped the shark (the sharp?… :-) …) for its intended population… Or perhaps not, and you are not part of its intended population.

      Again, this is Ok.

      Nothing is the right match for everyone.

      If I die without having to debug some optimized assembler again, I’ll die happy. And I don’t like what they are doing today with JavaScript… But, at least, I admit I’m not part of the intended population. Assembler has a lot of performance constraints, and JavaScript must go beyond its current limitations.

      So I humbly admit I’m not part of the best practitioners of those languages, try to get ouf of the way of their strange features, and let the users and designers discuss the fine points.

      Note that I never studied computer science, or software engineering (I went for physics). But even I know more or less what is covariance and contravariance. And even I know how useful they can be. And even I can following the link you provided, and understand the explanation on MSDN.

      If you can’t, then perhaps you should reevaluate your perceptions of your skills and knowledge, instead of shifting the blame on the designers with the easy “bloated/layers/intricacy” buzzwords.

      Learn, dissect, discuss.

      You’re a software engineer.

      Not a lemming.

      Conclusion: Perhaps covariance/contravariance in generics was not needed in C#. Or perhaps it was. If you want to discuss that point, then come up with use cases proving you’re right and they’re wrong.

      The “bloated” excuse is overused since OOP appeared and shocked the “Procedural” crowd 30 years ago. And using it again is plain wrong and insulting.

    • nailed it! exactly what i was pointing to.
      and i can give more examples….

  • SteveO

    Why C++?
    The only way to access DIrectX on Win8 (with VS2012) is through C++.
    (At least for now. Who knows if XNA is really ‘dead’. Heck, even some are suggesting .NET is now ‘legacy’).

    • Dan

      You should check out SharpDX.

      I believe this is how the MonoGame framework is enabling Windows 8/RT support.

      Speaking of MonoGame.. It’s living proof that the death of XNA (or at least the spirit of it) is greatly exaggerated. :)

      • show me all the mono-games :)

  • Naveen Francis

    Is there a real need to code programs which work on multiple OS?With more standardization , Increasingly the focus is shifting from various technologies to develop UI to a standarized way to do UI such as HTML 5/Javascript gives you this feature. Programming Focus is shifting back to the core logic which is usually hidden as a service over the network and work as native code.
    Source code level portability is a more sought after feature with standard C++ library implementing a common API to work with OS related features such as threading,

    • HTML do not bring native-look-feel
      one expect from desktop-apps
      and why is the reason now native-apps are more popular for mobiles?

  • I would be more encouraging on learning C++. I am not a C++ master (only a few years serious experience, and I always learn something when I go through my C++ books). I don’t use it in many projects, just when I need to do game or intensive server operations. I’m much better versed in more abstract languages and work with new developers frequently…and the lessons one learns in the C++ way of thinking are, I believe, extremely valuable when planning projects in more abstract languages.

  • correction: “declare functions in-line” instead of “declare functions line”

  • poojabba

    This is simply elitism. You should be encouraging more people to learn C++ because after mastering C++ the programmer has a better understanding of the computer.

    • but Microsoft don’t want you to know about the computer, it only cares you know about .NET ;)

      • Not quite true, Microsoft have implemented P/invoke in .NET so you can access Win32 methods and COM components; if they didn’t want you to hit the underlying APIs of Windows they wouldn’t have given you this functionality.

        • true, but I don’t think that is the reason. the main reason is interoperability.
          a much better way to look under the hood is to tell your VS to download the source code of any CLR object you step-in. very good one~ MS good job!

          however, next thing you will realise, CLR (in particular winforms System.WIndows.Forms) is a behemoth on top of Win32 calls.

          • Well, yes of course, the whole point of .NET is to be like Java IMHO – machine agnostic, abstract away the implementation and concentrate on getting the job done. With Mono, that goal has been achieved.

          • Carlos Ferreira

            Just use cross-compilers for that machine agnostic thingy… and you are done.

            PS: Java doesn’t actually run everywhere like they like advertise… different systems, different resources constraints.
            Also, for embedded devices, there’s nothing like a good native app to spare your battery.

          • pip010

            Write once debug everywhere and cut on performance (battery life) with GC sweeps now and then.
            I wrote this slopy switch statement. Which, the Java compiler accepted just fine. Then deployed on different Android devices just to find out it behaves differently, like on some it did falldown to next ‘case’.
            For a language almost my age one will think they atleast had figured out a simple switch statement, NO!

            Why I love long compile time and C++ :)))))) it actually does something :)

          • Thomas Wood

            No hard feelings and I don’t mean to be rude, but mono is really not that great. When I think of mono, I don’t think “goal achieved,” I think “I will never get this to compile.” caveat –> I only use Linux.

        • wtphuckdisisstupid

          That’s not quite true. Microsoft, and others, have been selling the lie that C# is just as good as C++. When people find out that there are simply things that they cannot do in C# with the machine, the whine about it, and Microsoft gives them a way “out” of the sandbox. The same thing exists in Java, and in particular, that Android nightmare that Google created. In fact, Google has been lying to everyone claiming that they support “native C++ development”. Right. It’s Java, with little teenie tiny window that, if you squeeze your butt-cheeks together tight enough, you might be able to get access to some native coding, but other than that, it’s back to Java-land.

          I would finally like to say that, not only do I know the answer to every single question that the author of this article posed above, but I also understand how a computer works. You know, a bit of statistical mechanics, bi-polar junction transistors, MOSFETS, logic gates, combinatorial logic, registers, finite-state machines, pipelines, DRAM, SRAM, caches, interrupts, translation look-a-side buffers, asynchronous clocks,…atomic operations, ring-0, ring-3, system traps, virtual memory, sections, threads, mutexes, events, semaphores, waitable timers, memory allocation, memory management, containers, virtual functions, exceptions, run-time type information, constructors, destructors, assignment operators, access control, etc.

          …get what I am trying to say here?

          The problem is not C++. The problem is the person in the chair. Another big lie that is often put forward by the non=C++ types is, “a language is a language is a language.”

          This is simply not true.

          Everyone knows that a person who really understands most of C++, I mean really understands it, cannot be called “just a programmer.”

          That person will know a lot of things that gives him context in the world of computation that is unmatched by any other context that would be provided by any other language, except assembly, of course.

          So this is the real problem – denial. The neo-Hegelian horde wants to be accepted as true, bona-fide engineers, while their depth of knowledge in the world of computation is relatively shallow.

      • Carlos Ferreira

        Windows sucks, period.

        No need to discuss operative systems that fail and leave the developer hanged.

  • qq

    I can’t say I really understand the “born in a managed code world” part. Is this a group of people that are employed by companies today? I work as a software developer at a relatively large company in Europe and being 19 years old this concept is completely foreign to me. I’ve never seen the reason to limit myself only to managed languages neither has this been suggested to me at any point in my life other than by random articles on the internet promoting language X. Same deal for the friends I have that started coding at a later date and thus went to university instead of job hunting after high school, they certianly learn a lot more programming than just the syntax and concepts of C#/Java at school. I use a variety of languages at work depending on the task an would absolutely hate it if I was forced only to used managed languages even for all the things where it’s not suitable (the company I work at develop computer security products, so that’ a lot of things), whether that be by company policy or by having had managed languages pushed down my throat for all my life in a “managed world”.

  • exn

    > Why do you want to learn C++?

    Because there is vacancy for c++ developer

  • Warren

    #26 in your interview questions (iostream versus iostream.h) really takes me back to the early days of C++. I used Turbo C++ 1.0 way back in the day.

  • Tom

    C++ never left or became in any way unpopular, the programming community simply grew and developed a need for mindless drones to slam out incoherent crap as quickly as possible.

    It’s not only dangerous but irresponsible for us (as a professional community) to teach people (idiots) to swing a hammer and not tell them what to do with it or teach them what a nail is. Every argument I’ve heard against C++ basically boils down to “it’s too hard”. Tough. Programming is a fluid method of problem solving and problem solving complexity will range from mindless to overwhelming. Wrapping it in a pretty bow only adds a layer of abstraction hiding very real and manageable problems that should and would otherwise be solved.

    I’ll retain my archaic stance that hiding from problems doesn’t solve them, and that a programming language isn’t something that can or should be learned in an hour. C/C++ is not hard, it just requires you to have a fundamental understanding of how computers and programming in general works. If you lack that knowledge, you have no business touching code anyway. It’s no more syntactically complex than C#, Java(X), etc (probably less actually), and it’s foolhardy to ignore the plethora of libraries available that perform the same tasks faster and usually with less effort.

    If your only goal is to be a script kiddie, then go ahead and addict yourself to the drag-and-drop behavior of so called “modern languages”. It’s a mild step up from flipping burgers at McDonald’s.

    • Thomas

      Exactly! Well written.

    • Dan

      I’d say the differences in salaries would strongly disagree with you (at least according to Glassdoor).

      In fact, aside from some very high level C++ engineer positions in that regard, C# is comparable, and sometimes a step up from C++. Salaries of that magnitude are not paid for knowledge of a language that can be learned in an hour. :)

      While I do agree that there are a lot of developers out there that copy and paste recipes without fully understanding how something works, and that’s not necessarily a habit we should all endorse, there are a lot of C++ developers that do that exact same thing. I have seen it and cringed over it myself.

      But bad developer habits are language agnostic. You can’t really blame one language over another because it’s perceived as easier or harder, and correlate that to “enabling” the behavior.

      A key goal of problem solving IS abstraction. If a problem has already been solved, then what exactly is the point of re-inventing the solution every time? There are plenty of frameworks in C++ that subscribe to this theory.

      The side effect is that it creates an environment that’s a little more accessible to a beginner (even in C++). Why is that so horrible?

      Given your well defined grasp of problem solving in your opening paragraph, surely you can see some of the contradiction your convictions present here.

      The goal of computing is to make things easier and promote productivity. Why should programmers be exempt from these benefits? Languages and compilers, after all, are just as much computing tools as word processors and spread sheets.

      Clearly the high level C++ engineers that created C#, Java, or any other “skript kiddie” languages understood this concept well.

      • “But bad developer habits are language agnostic.”

        let me not agree upon this flying conclusion. languages DOES matter!

        let me just generalize by saying, alot of crap I find in C# code base is impossible to find in C++ simply because you cannot get away with it most of time. you need to fight the compiler ;) in C# compiler is thin-shallow as a napkin

        to finish with one nice example of how ERRORS are very much language design oriented:

        in C# i recenlty stumbeled upon:

        void SomeInternalFunction(string arg)


        no need to comment what a #$@@ and how much time it took me to debug and find this bug.

        while one will simply write in C++:

        void SomeInternalFunction(const std::string* arg)

        arg->toLowerLatter()//COMPILER ERROR


        end of story….

        you want to go even further : go ADA

        • Darren Grant

          Just as counterpoint, there are numerous easily-searched examples of poorly written C++ code that compiles. [1] The difference is that there is a major potential for undefined behaviour that would be incorrect instead of fatal in other languages.

          The type system in C++ can do a lot of useful things if you navigate around pitfalls with a solid methodology, but if you really want the rigor of a solid static type system *and* productivity, this is not the language. There are some superior options that are rapidly becoming popular.

          [1] http://stackoverflow.com/questions/4295681/evil-samples-of-subtly-broken-c-code

          • pip010

            I don’t argue that using c++ you cannot shoot yourself in both left and right food, especially when you are used to shooting with airguns alone.

            what I’m arguing is at least with C++, one can achieve an optimal solution, where in Java&C# you are often in a funnel !
            if it fits fine, if not, you are left in a dry desert!

          • Justin Fuller Drobey

            You just reminded me of something my C++ teacher said in College when my colleagues were complaining about how dumb C++ was:

            “C++ is one of the smartest codes. The computer only executes EXACTLY what you told it to. If you don’t know what you’re doing, how do you expect the computer to guess?”

          • pip010

            “Just as counterpoint, there are numerous easily-searched examples of
            poorly written C++ code that compiles. [1] The difference is that there
            is a major potential for undefined behaviour that would be incorrect
            instead of fatal in other languages.”
            yes it is true. some of the pitfalls pointed in your links are not c++ specific.

            “The type system in C++ can do a lot of useful things if you navigate
            around pitfalls with a solid methodology, but if you really want the
            rigor of a solid static type system *and* productivity, this is not the
            language. There are some superior options that are rapidly becoming

            void* arg// BANG! no type safety

            so… yes, again c++ is designed with flexibility not safety first!

      • Jim Burnett

        There are some fairly high paying jobs for C developer which can be picked up fairly quickly if you know C++. Take embedded C for example. There are plenty of good jobs for niche C/C++ programming and these niche industries pay well.

      • pip010

        “A key goal of problem solving IS abstraction. If a problem has already been solved, then what exactly is the point of re-inventing the solution every time? ”

        ahh how sick I am of this being cited by every second developer in the wild.

        let me ask YOU ONE THING ONLY!?

        the wheel was invented centuries ago!

        why do we keep coming with new models for tires then!???

        how come we do not have the ‘magick’ tire we can place on trains, buses, and F1 race car !?!?!

        YES! because it makes NO sense discussing a wheel if we have no idea where you plan to put this wheel on!

        CONTEXT people, CONTEXT!

      • CrankyMiddleAgedGuy

        One of the greatest advantages that I see that C# and Java have over C++ is library support. boost is fantastic but poorly documented (in my opinion) and tiny compared to libraries available to C# and Java programmers.
        It is the power of those libraries that allow “skript kiddies” to glue stuff together and produce satisfactory results in most cases.

        • z0ltan

          Wake up and smell the coffee, gramps. There never was a golden age of programming, and there never will be. Stop acting like programmers were real programmers back then, and all we have are “script kiddies” (as you put it) today. Every generation has its own challenges, and its own set of genius programmers. Deal with it.

          • pip010

            ahhh I can speak of challenges too, but now that I see The ‘challenged’ :)))))))))

          • z0ltan

            Are you mentally deranged? (serious question)

          • jwn0001

            OUCH, guess that must have hit a nerve?

        • KD

          C++ has lots of libraries which is the only reason I use it but they don’t come with the language. Qt is probably the most complete general purpose C++ library. I use C++ for domain specific libraries like VTK & OpenCL for visualization, ITK for image processing, Seqan for genetics, …

    • I would disagree with you Tom, I think C++ is much more difficult than C#, and I’ve used both in anger. Tbh I got to a point where I thought assembly language was easier to read than C++, that’s how bad things were getting – I had some really crap legacy code to work with though.

      const * const parameters, mutable fields, const_cast, dynamic_cast, reinterpret_cast, add in macros which can have undesirable side effects, include files that need #if !defined(THIS_FILE_INCLUDED) etc…. not to mention don’t return pointers from functions as they may cause memory leaks….

      I made a real balls up of my job in 1998 in C++ and that was my fault for thinking I knew it, when I didn’t. I got the sack and learned an important lesson – it takes years to understand C++ and its nuances. C# by comparison is a doddle.

      • and it is a doddle what you are left with!

        one of the biggest pitfall is programmers not thinking about memory!

        • I agree with you, programmers these days have it easy as regards to memory management.

          True, you can still use pointers in C# if you want to, by explicitly using the /unsafe switch in the build config and using an unsafe method, but even so, it’s hardly on a par with remembering to use delete with new, delete[] with new[] and free with malloc is it??

          • ” use delete with new, delete[] with new[] and free with malloc is it??”
            smart pointers?
            how about the fact now you can ENABLE GC in c++?

            how about the non deterministic destruction?
            how about if my resource is not memory?
            how about if I switch from memory implementation to let say file based one?
            ( a common issue people start pointing to, that as far as memory is concerned you are fine (or sami fine, since you can still mem-leak and usually is way harder to tackle than typical c++ leak), but as far you resource is not memory you are screwed)

            so back to my mem-2-hdd solution:
            you need to add IDisposable + finalizer and use it correctly :), which changes the semantic of use everywhere in your app, fundamentally breaking basic OOP principles!

          • The smart pointers I give you, yes I forgot about those.

            Enable GC in C++ – you’re not referring to Managed C++ are you, or do you mean an off-the-shelf GC you have to purchase?

            If you use the using keyword in C# with an object that supports IDisposable you are guaranteed to dispose the resources you have acquired (mem/file/db connection etc), you do not need a try.. catch… finally block to ensure this. So how you are screwed, I do not know.

            Of course, if you are maintaining an IDisposable ref as outside the scope of a method, that is to say via a static field or as a reference held in memory for a long time some other way, I’d say that’s bad design and should be refactored :)

          • About GC and C++ : http://herbsutter.com/2011/10/25/garbage-collection-synopsis-and-c/

            “You mean switch from a standard .NET FileStream object to a MemorySteam object? ”

            no, the other way around, but regardless.

            Look at: http://minorfs.wordpress.com/2011/04/29/why-garbage-collection-is-anti-productive/

            also my last comment!

            ” I’d use an adapter design pattern and make a consistent interface for both”

            yes you can do alot, but the fact that you need to do something is already telling me there is something broken in your OO design. fundamentally what is missing is a unified resource management.

          • It may very well be that you can have a Stream parameter in a method and substitute a FileStream or a MemoryStream and have them work as expected (as per the Liskov substitution principle) – I haven’t checked or tried. Did you?

            A unified resource management? You mean a facade pattern that can work with many different types of stream (memory/disk)? But how can one size fit all?

            Show me where this is in C++, you can’t knock .NET without showing me the equivalent in C++!

          • pip010

            where C++ is having a deterministic destructors, things are simple. resources get acquired in constructors and released in destructors. you are in full control of scope. you use RAII, which as simple as using std::unique_ptr, so you know no resource leakage. this is an unified resource management!

            i care not if it is a file, memory, texture, mutex lock etc.

          • Gareth Morris

            I can feel you channelling Stroustrup. GC will never be a replacement for the thought required for resource acquisition and release. A programmer who doesn’t follow RAII but does understand GC will still leak. Resource management (and memory happens to be one of many resource types) is language agnostic and C++ provides the programmer a very simple way of handling their resources. :)

          • pip010

            ” less extensive standard library” I will give you that.
            it is too algorithmic and not app oriented, but hey exactly what boost is trying to fill in, but still short of what python,c#,Java etc. have

          • Liam

            You my hero.

        • David Lannan

          Oh. please. Thats like old ASM coders trying to defend their turf against using C – “Programmers should think about registers”.. geez, get over loving languages and use the appropriate tool for the appropriate task – c++ is simply not effective anymore. (dev time, quality – way too bug heavy, tools, libraries.. etc). And the most stupid thing is C++ is trying to introduce all the HLL features without a GC.. (although even that is on the table now).. so.. yeah.. make a OO lang that has all the features of C# or Java.. oh.. whoops.. now we have C# or Java… silly silly language fanboys.

          Reminds me of the engineers that complained when ladder logic was replaced by coros and c… haha it happens over and over again peeps.

          • pip010

            C# and Java are broken. the two languages we most definitely don’t need.

            For Prototyping : any pure dynamic language is better to Java/C# where edit&continue is a bad joke! ahh how powerful is to change and see effect without compile :)))

            For Production: strong static typed languages C++/Ada/Delphi/D/Fortran/etc.

            For Loosing your time for prototyping and catching runtime errors in production: Java and C# are perfect ;)

          • Carlos Ferreira

            For prototype, I prefer Python. I have a L2 network protocol implemented solly in Python.

          • J.M. Becker

            @pip010:disqus: I think you may be on to something here, D and Delphi are great for doing fast work…. but both avoid the bloated garbage from java or .net.

          • jgmitzen

            Delphi’s compiler is unoptimized and expensive (at least $1000) and lacks a great deal of modern features. It lacks the useful features of Java and .Net as well as the bloat.

          • jgmitzen

            As a very recently former Delphi developer, please, please, please don’t recommend Delphi to people. :-( It’s filled with repetition, broken or missing features (has had 64 bit compiler for only(!) two years now yet an Int64 still can’t be used in a for loop and a while loop must be used instead!), archaic limitations that date back to turbo pascal (a set can only have 255 elements and can’t have a value higher than 255, string literals can only be up to 255 characters, etc.), and costs at least $1000. Almost any language you mentioned – including Java and C# – would be much better choices for real production work.

          • z0ltan

            I highly doubt you are proficient in either of the mentioned languages, or even proficient in any programming language at all.

          • pip010

            lol, try again tr0ll …

          • z0ltan

            You are one angry dinosaur, son. And you presume that you can speak amongst men. Sacrilege!

          • J.M. Becker

            NO NO NO!

            I’m sick of programmers defending their inefficiencies by comparing the C/C++ argument to the old ASM argument.
            There is one serious thing ASM lacks, and performance can never make up for it, and that’s portability. We see example after example where C’s portability saved the day. And you know what… C/C++ is still fast as hell, the other languages seem to have lots of programs which perform slower. It’s not the same argument, the ASM guys were definitely wrong, but not for the reason you listed.

          • David Ostler

            Oh, please!!! Every programmer who is worth his weight, knows that if you want to create a program that will amount to anything, you have to use binary. I’m SICK of all this language crap.
            You all can just 00101100

          • pip010

            just to pass your own argument back,
            “get over loving languages and use the appropriate tool for the appropriate task”
            ladder diagram,VLOG,.. and going lower than asm still makes sense till today, e.g. industrial automation.
            less Babylonian stacks less trouble! :)

            and on the side,
            c++ is more than capable of doing anything other OO languages do…
            ahh if only you knew your tools :)))))

          • z0ltan

            Do you even know C++? I suspect you have no idea about real C++ programming at all.

          • pip010

            lol, try again tr0ll …

          • z0ltan

            Still doesn’t answer the question, son.

          • pip010

            there is a rule, don’t feel clueless trolls…

        • jgmitzen

          This is the same thing said by Delphi Pascal programmers as sour grapes because their language doesn’t have automatic memory management. There’s also the shared view that when it’s shown that your language is much, much harder to use than another you simply declare that having to struggle through all the extra steps and housekeeping means you’re smarter than everyone else and you’re glad your language is so difficult to work with. It’s really sad.

          A language is an abstraction. If you’re thinking about what’s going on under the hood, you have a leaky abstraction.

        • z0ltan

          Bullshit. That might have mattered half a century ago, but it’s not as relevant today. Today what matters is programmer time, and the amount of complexity that can be solved by said programmer in that time. You are an ignoramus, a Luddite inflexible mopper, or a complete tool. Pick your choice.

          • WxsOnline

            “Today what matters is programmer time and the amount of complexity that can be solved by said programmer in that time.”nnAsk any triple-A game developer or database/simulation system developer where managed languages cannot even reach acceptable performance levels… they will definitely disagree with your generalization.

    • Darren Grant

      “It’s no more syntactically complex than C#, Java(X), etc (probably less actually)”

      This is just not true. C++ supports many more semantics and enjoys less self-similarity than other languages. Try comparing the size of the spec for any recent C++ incarnation [1] with that of C# [2]. It is a byzantine level of complication that impacts application level development all the way down to tooling compliance: incomplete tools, more bugs, turn around times of years, etc. To be fair, Clang has helped spread this burden out a lot recently.

      [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf
      [2] http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf

      • OrangeMonkey

        That statement is so silly I am surprised you responded to it. Want proof that C# is vastly less syntactically complex than C++? Simple, just go write a parser for each language. I will take a look at your C# parser next week when you get it finished, if it takes you that long. And in five years, when your C++ parser still isn’t quite right, I will try to be kind.

    • GREAT COMMENT! (had to say it)

    • rha

      Tom, excellent post. Excellent, excellent post.

    • OrangeMonkey

      I use C/C++ everyday and i have only ever used C# in one commercial product (and not much of it). So, I am clearly in the C++ camp. But, it has always always always irritated me how hard it is to write a simple program. I mean, just write me a simple program to play TIC-TAC-TOE with a friend using a nice GUI on a Windows platform using C/C++. It’s a PITA. Okay, now say I want that same program to run on my friends MAC. Oh, and on my other buddies Linux box. What about my phone?

      My point here is this. Somewhere along the way we got all caught up in how computers work, and we forgot that they are supposed to be a tool. I just really want the darn thing to do what I am thinking about in my head right now. I don’t want to have to spend a career learning APIs, and nuances about pointers, stacks, vectors, what have you. I want to use the darn thing to solve the problems I think are important. This is what C++ will never ever offer. This is why something else is needed.

      With the power of computers growing so rapidly, I see a diminished need for what I do (system level programming) year by year. I am definitely headed to be the Y2K Cobol programmer of tomorrow. And that is exactly how it should go. It doesn’t need to be, and shouldn’t be anywhere in the ballpark of this hard to make these machines do what we want. We have not engineered the problem appropriately!!

      So, I am all for C++ sticking around, but if everyone is using it, we have failed to see the potential in computing and to make it accessible. That would be a huge indicator that collectively we suck at engineering.

      • z0ltan

        “I just really want the darn thing to do what I am thinking about in my head right now. I don’t want to have to spend a career learning APIs, and nuances about pointers, stacks, vectors, what have you.”

        Spot on. Absolutely so.

        • pip010

          cry and run to your mommy … maybe one day we will find a z0ltan job.

      • Beardie

        Qt goes some way to solve your issue with cross platform and not worrying about re-writing the world.

      • Noba Dee

        The trouble is clearly that “the problems [you] think are important” are only the shallow what-does-it-look-like and how-does-it-feel-to-use-it stuff. You’re totally ignoring important stuff like how-long-will-it-run-without-destroying-the-system and what-do-I-do-about-it-when-it-does. It IS important to understand how things work, and the whole problem today is that the vast majority of “coders” (hate that term) fail to understand this. You people, collectively, will be the death of us all, mark my words.

        • OrangeMonkey

          I think you missed the point entirely.

          First, If you look at the paradigm of C/C++ (and keep in mind I am actually a big fan of these languages I use them every single day) they are probably the worst for solving the very issues you mention: “how-long-will-it-run-without-destroying-the-system and what-do-I-do-about-it-when-it-does”.

          I would be willing to bet that C/C++ programs are responsible for taking down Windows platforms exponentially more often than programs written in any other language (except for anything produced by Adobe like flash which is just an abomination).

          My point wasn’t that programmers should not know how things work at a very detailed level today. Clearly. it is the lack of this level of due diligence that is killing computers across the land as we speak. My point, that you, and I would be willing to bet most folks in this industry, fail to grasp is that we shouldn’t *have* to understand this level of detail of these systems. The very fact that we do have to dive in this deep means we failed and failed miserably to solve a fundamental problem. We have abstracted extremely poorly and thus we have failed to engineer well.

        • OrangeMonkey

          You are confusing the situation created by languages and hardware that we have currently engineered, and THAT is my point. We DO have to care about the details today, but my argument is that that is a failing. We shouldn’t have to care about those things. Software should not be able to be so fragile. It is, make no mistake, but that is simply because we have engineered poorly.

      • Bob

        From the very beginning computers were and always have been just a tool. Does program accomplish it’s goals? Did programmer meet deadlines? The language used is unimportant when the bigger picture is understood. Sometimes that picture includes performance, sometimes correctness of code is very important. So programming is very much an engineering process.

    • z0ltan

      You’re a tool. C++ is not a hard language because it’s good. It’s a hard language because it’s a terrible mess of random features and syntax tacked on like a horrible montage of horror. Oh, and go fuck yourself, cunt.

      • pip010

        I should have seen this one first! duno if you are script-kiddy, but you definitely act as a kid. growUP and then come back…

        • z0ltan

          Idiot makes predictable idiotic comment. What with your obsession with ‘script-kiddy’, I’d wager that you’re aspiring toward becoming a ‘script kiddy’. Grow up and aim higher, you fucking child.

    • swampwiz0

      The problem is that the makers of APIs & stacks have done such a good job that there is little reason to program in C++ anymore, except for serious hardware & efficiency domains. Employers would rather hire these script kiddies than grizzled C++ experts like yours truly.

  • drd

    Here’s a vision for a future C++ Compiler & IDE:

    1. User can create a C++ native project and add C# classes directly in the same project next to C++ classes. The C++ code can be compiled with 3rd party compiler like Intel compiler and magic happens which allows the C# classes to talk with the C++ classes (and invoke C functions) and the other way around as if they were the same language, no performance penalties at all.

    2. The C# classes code in the C++ project can be modified while the entire application is running in optimized release build. This happens by attaching to the running project, suspending it for a millisecond when it hits a pre-determined “safe to hotpatch section” and updating the C# code inside.

    3. Changes to C# portions do not cause the C++ code to re-compile or link.

    4. As alternative to embedding C# the embedding interface supports embedding other future languages which gain the same features as above.

    • here is one line solution:
      1) C++ and LUA :))))))) and you save on all the misery you suggest :) also keep in mind that C++ do support SAME GC as C# (if you want to) so you are free to write a code like: return new MyClass();

  • drd

    No one seems to mention anything about security, vulnerabilities, exploits. We’ve certainly seen some CLR related exploits patched recently not to mention the huge amount of Java exploits, but *atleast those are getting fixed*. To see the complete failure of C/C++ in this respect is simply to look at the millions of devices with statically linked old libraries and software that won’t ever be getting updates. Atleast with C# if you get some buggy software you can decompile it (or the popular library shipped as dll next to it) and fix the bug even if the developer went bust.

    Native compilation hasn’t stopped software from drm being bypassed – in the scenario where the original developer is no longer interested/available to work on their legacy code and the customer has no source code available, it’s much preferable that the customer has the software written in C# even if it’s shipped only as binaries. If you have some really secret algorithms, put them inside a hardware dongle or keep them on your cloud server. It could still prove quite tricky to ensure that your secret codes only communicate with code you’ve authorized and not some unwanted code, so the only good security is to setup a video camera and a robot to tap the keyboard commands and hope you don’t have a bug which allows the attacker to type in their attack code on the terminal.

  • Biob

    There are a ton of comments here. Interesting read no doubt. I completely agree that there is a need for a language with high abstraction and rapid development methods. Oh wait, Visual Basic anyone? I know most will laugh at that comment but mixed with VS ide and IntelliSense you have almost what you are talking about, plus the english-like syntax makes it easy to follow (like reading a novel). But seriously though…. .NET can get slow once your program starts to grow. This is why I love C++. I personally think C++ is here to stay b/c there is no other language out there that offers the level of flexibility that C++ does. Lacking abstractions you say? Well not -out-of-the-box , there are wonderful 3rd party libraries like Boost and Qt that when used together rivals the depth of the .NET library. So the moral of my story is that C++ may not be back (in a mainstream sense) but it’s here to stay, b/c all those nice languages you use today that automatically writes your code up for you (through telepathic programming) are built in you guessed it .. C++.

    • VisualBasic lol :)
      alot of verbosity little of an essence

      • Megatron88

        What is so “LOL” about ?!

        • pip010

          “english-like syntax makes it easy to follow (like reading a novel)” this is a broken promise. it never really picked up and really what Basic left as heritage is:
          “alot of verbosity little of an essence”
          I agree VS IDE + VB6 was progressive idea at the time and too bad no one followed on the pure “visual” aspect of programming :(

          • Megatron88

            True !

    • Megatron88

      Nop, Visual Basic 6.0 is the fastest, faster than C++

  • Greetings! Very helpful advice in this particular post!
    It is the little changes that will make the most important changes.
    Many thanks for sharing!

  • Josue Andrade Gomes

    I’m also a big fan of C++ and totally agree with you. Unfortunately there is no alternative for high-level native development. Maybe D or Go but they still didn’t capture any significant attention.

    • well now, C++ is not 1 language it is like N-languages
      yo choose your destiny :)
      unlike many other lang it does not dictates which roads you should take etc.

    • Carlos Ferreira

      GO didn’t capture attention because there is still the addiction to JAVA or C# (VM languages).
      But there is a thing happening that will kill these languages and boost C++ once again. That problem is called, Moore’s Law (or the failure of it).

      If you have noticed, CPU’s aren’t going to evolve much more with the current silicon-based chips.
      Manufacturers are throwing multicore CPU’s but they know that there is a limit, specially when the code is sequential and it is not possible to just parallelize.
      Every time there is lack of performance, one cannot just buy more computers. More computers mean more expenses (energy waste for powering and cooling). In a economical global crises environment, a company must optimize their resources and not waste them….
      This is where C++ shines -> $$$/ Watt (dollar per watt)

      • Collin

        I’ll disagree with “CPU’s aren’t going to evolve much more…”, more advancements come every CPU generation than just clock speed increases. Each generation of CPU comes with improved pipelines, more intelligent out-of-order execution, lower instruction latencies, and more. There’s more to CPU speed than just clock speed and core count.

  • Srivathsan Madhavan

    After reading your article, I now really understand the motivation behind the Go Programming Language! That, I believe, is the way to Go!

  • first_name last_name

    “Also please don’t tell me C++ gives you more power and control to do exactly what you need.” Well, I’ll tell you whether you like it or not, yes, it gives you more power and control. That’s why people use it for the low level stuff. C++11… People usually describe it as a revolution, especially the lambda part. I’m an old developer and I don’t see what’s the big deal here. Yes, lambda is cool, but I can write the same code with and without it. Before lambda I had no choice, today I have.. So, WTF…
    Regarding languages generally, you usually need more than one language to complete the project. If you are not playing with the web pages, than C++ could be one of them. I have seen guys like you telling me how the C# is the fastest possible language in the world. They presented the theory, but I didn’t swallow it. A year after that the same guy hired me to rewrite some C# routines in pure assembly. And guess what, about 20 times faster than C# and about 5-6 time faster than C++. But, the entire project contains C#, C++ and asm code.
    It seems like you miss the point regarding language choice. Whoever needs to write something related to audio, video, smart card, ETW, finance/trading, etc… He or she is going to need the C++. Yes, maybe it can be done in some higher language, but just like you can blow your leg of with the C or C++, you can do the same with the C# because of that attitude “hey, I can do it in C#”, believe it or not. The project grows and it will hit you like a train. Then you will end up separating code and refactoring because you want to clean up the mess. I have seen code running 24/7 written in C# and Java. It NEVER runs 24/7, so guys tried debugging it, but they failed. Actually they are not sure if their code is bad, or just the platform doesn’t handle it well. At the end they developed a watchdog code to restart the dying monster every once in a while. If that watchdog starts dying, I guess they will need a watchdog for the watchdog.

    And all that, because somebody made a wrong assumption “let’s do it in higher level language, it will be faster, the developers are cheaper and it will be cool”. Yeah, right…

    Language choice has nothing to do with your own language preferences. You pick the language when you know what you have to develop.

    • right tools for the right job is close to the truth, but not as universal as people tend to portrait it !

    • greyfade

      The reason lambda is cool is that it’s a powerful abstraction. Functional programming allows you to declare intent in the same place and context where the code is used.

      Lambda expressions are more than just an easier way to write function objects – they are a way to place your code exactly where it will be used, and do so in a way that is clear and concise, especially where giving the function a name is not strictly necessary.

      • ttman

        Isn’t the function name an important part of understanding the function?

        • greyfade

          It can be, but it’s not necessary when it’s a short, one-line function that performs a clear, easily-understood operation, and is only ever actually needed in one location, in context.

          Realize, though, that a lambda can also be stored in a variable which you can name to reuse the function in more ways.

          Lambdas are the most basic abstraction of code, and they form the underpinnings of an entire mathematical framework of computation, called the Lambda Calculus; and that is the basis for all functional programming languages. It’s a tool of incredible utility, even in languages like C++ and Java (and all of the other imperative and OOP languages that have added it.)

  • Frederick

    Dunno if I can share this but this provided me with some C++ incite!


    Not as indepth as yours though.

  • “It seems that many of the seasoned developers have forgotten why we stopped using C++ and moved on to Java, C# and other modern languages.”

    1)Java -> broken dream about interoperability. nightmare for security! [write 1 debug everywhere]

    2)C# -> Java with alot of perfumes. but regardless how much favor you add to a shit it is still a shit.

    Since I’m using C# from 2001 (early beta and had followed on the evolution of C# I must add the same conclusion C# is getting hugely bloated framework, where complexity grows (the bad type of complexity (nonsense)) at no apparent benefit to:

    performance, security and/or maintainability.

    on the other hand C++ gained on all three fronts.

  • Weaver2

    I like C++. It was the first language I’d argue I actually learned years and years ago. However, I do agree that for the most part C#, Java and the likes are far faster and simpler to develop with and very little performance increase, but with a shorter development time.

    I do however think it would be a good skillset for a lot of programmers to have. I interviewed for Amazon and one of their take home questions was “Implement malloc”. If you didn’t know C there is no way in hell you could have done this question.

    That being said, I feel it’s become a stronghold for intellectually arrogant programmers who simply want to work with something they’ve masters that is very difficult. I can understand the pride, but you should choose the best tool which solves your problem. This isn’t to say every coder in the world working in C++ fits this description, but I think we all know “that guy”.

    If you’re doing embedded or system level programming, you’re going to need C/C++. If you’re writing a simple gui app? Well, there are probably better alternatives.

    IMO the real difficulty in C++ comes from the template language and all the hideously confusing things you can do in it. And I’m sure I’m not the only one who has seen that bastard abused to high hell to make incredibly obfuscated production code.

    • jsonmez

      Excellent points! Great comment.

  • stator

    Lol brave article. How dare you rouse the Sintax Divas? We should code in 1’s and 0’s with a push button, because it gives more low level control…
    But seriously, I don’t hate C++, but really dislike the show-off gibberish some C++ “experts” put out there.
    I absolutely agree something with more abstraction is the way of the future (i’m working on that). Even though you need a minimum behavior-definition, you can’t low-level write a billion instructions.
    The compilers have to do the optimizations (i.e. like in everything technical, have a set of guys figure it out once, instead of everybody out there having the burden). More work is still needed on that area, so we don’t have to spend time looking at the assembly, but rather defining the tasks.

  • Carlos Ferreira

    “Ok look, I know you think Windows 8 is cool and all the cool kids are learning C++ to write their Windows 8 applications, but you should know what is in the Kool-aid before you drink it.”

    Programming for windows 8 isn’t actually a good reason to learn C++…

    I would hope there would be a reference for linux development Applications or network applications, but ok…

    I liked the 20 elements list though. If the questions would be asked for the Java or C# developers, they would die in the first 5.
    Developers that only learned Java and C# do not truly understand how computers work…

    I’m a Python developer, but before that, I learned Java and C#. Before those, I learned C++, Mercury, OCaml, Prolog. Before those, I learned C and Assembly for MIPS.
    There’s nothing like learning C and Assembly to understand what a program really is.

  • wtphuckdisisstupid


    One hundred years from now, after we’re all dead, a breakthrough technology will arise. Those with technically-oriented minds will latch onto it first, and make careers of it. Some of these will become billionaires (trillionaires?). External observers will take note for one or two decades.

    Then, gradually, people who, otherwise, would never have chosen a career in technology, will be unable to resist the urge to “me-too” themselves into the field. And when they enter the field, they will discover that the tools for creation require a type of disciplined imagination that they had been hoping to avoid since grade-school. They will look all around for alternative doorways to enter the field, trying to find a short cut, a lower barrier-to-entry, a silver bullet that will get them into the game.

    Some company will come along with an alternative tool that promises just that, and this alternative tool will be heartily-embraced by hordes of pseudo-engineers who finally feel that they are part of the game.

    But every now and then, one of the real engineers will use the original, “difficult” tool to create something that changes the world. And the pseudo-engineers will look across the field, with a mixture of awe, inspiration, resignation, and contempt; because deep down, everyone will know the truth – though the new tool does provide certain benefits, it cannot possibly compare with the old tool, when the old tool is wielded by a master of the art.

    Motivated by the worst traits of human nature, these pseudo-engineers will launch a campaign to destroy the old tool, denigrating it at every opportunity…disregarding the possibility that the fundamental issue might be their own capacity for technical thought.

    • jsonmez

      This is one of the most awesome comments I have ever read!

    • Richard Eng

      “…though the new tool does provide certain benefits, it cannot possibly
      compare with the old tool, when the old tool is wielded by a master of
      the art.”

      When a tool is wielded by a master of the art, great software can always be written. That tool need not be something that is complex and bloated. That tool need not present a large cognitive burden to the user. A great craftsman can also work with a simple, elegant tool with a well-considered feature set. Notable examples include Scheme, Smalltalk, Python, Ruby, and Go. A good programmer can master a simple tool more readily than a complex tool.

      • theHypnotist

        First we have to agree that a great craftsman can handle large cognitive burdens like C/C++, and then agree that all the best programmers have their favorite scripting language. The end result is that the great craftsman doesn’t hesitate to go “into the hole” with the hardcore languages when it’s called for, and in the end it’s always called for!

        • Richard Eng

          I disagree. Yes, a craftman *can* manage the cognitive burden associated with languages such as C++, but that does not mean he *wants* to take on the burden. A craftsman will hesitate to use a complex tool unless there is a solid justification for doing so. He is human, and all humans prefer to do things with less effort.

          I concede that there are certain problem domains for which C++ is ideally suited and therefore one should wade into the complexity. However, in general, most software development benefits from less arduous environments. It results in fewer mistakes, higher reliability and safety, and lower development costs.

          I put myself forward as an example. I’m a retired software engineer with over 20 years’ experience, mainly in C. I’ve written everything from device drivers and telecom applications to web and mobile apps (iOS and Android). I know my way around programming languages. BUT, I still appreciate the advantages of using Smalltalk, Python, and Go. It makes life easier. It makes programming more fun. Altogether, it makes me more productive. Much more productive.

          I’m not afraid to use C/C++, esp. where they are ideally suited. But I don’t need to use them everywhere. For general-purpose development, I prefer simpler tools.

    • itdoesntmatter

      This comment made the last mind-numbing 30 minutes so worth it… And I say this while being one of those “me-too” engineers. If only I had been born 10-20 years earlier when there was nothing but these low-level, powerful languages abounding. Instead, I have been born into a world of highly marketed, nicely packaged libraries, languages and frameworks all screaming for my attention. However, I am beginning to see that perhaps to truly master a craft, one must take the road less traveled. Well said…

  • This is a very interesting article. The insights herein are truly informative. Thank you for sharing.

  • Jared Thompson

    I completely agree with everything discussed here, and this article is beautifully written. I write in C if I have to do low-level stuff, staying away from C++ entirely if I can. C++ is awesome if you’re writing complex, fancy code to achieve some kind of deep purpose, or you’re squeezing every bleeding drop of performance out of hardware, but abstraction is king in the reality of modern coding. I simply don’t have the time to write 1000 lines of boilerplate every time I start a project, and spend my time contemplating the essence of object inheritance and constructor logic. Java is not infinitely better, but its an improvement. Look, if abstraction was not king, why would libraries like boost exist? If low-level purists want to help the community, they should be using languages like C/C++ to write better abstractions. Oh wait…what’s Python again?

    BTW – I am not a pro-programmer. I’m a graduate student in theoretical physics.

  • Craig

    Yuk. I hate these smug, behold-as-I-educate-thee kind of posts. Couldn’t you take a less presumptuous, less patronizing narrative? You know, in order to not seem like an utter dick?

  • J.M. Becker

    I prefer C to C++, it’s extremely powerful and the language is much smaller. I just don’t see the benefit of adding all this extra crap, unless the codebase is truly monumental and the programmers are very isolated from each other. Essentially for an enterprise, with it’s rotating programmers and hideous code practices…. maybe the extras can help.

    But generally C speaks to me as the perfect level of abstraction. As little as possible, but still enough to handle things portably, and then the libraries can add the extra levels themselves. O yea, I will admit though writing a script is much faster than writing a real program, in either C or C++. I’ll also admit if C++ helps your productivity, then by all means USE IT… just saying make sure to also give C a chance. The quality of C++ code is still second best in my opinion to all the alternatives in common usage, so please keep using C++ and not java or .net.

    • antred

      What exactly is “extremely powerful” about C? It offers fewer useful language constructs and less abstraction than just about any other language I can think of.
      If by “extremely powerful” you mean that there’s no problem you can’t tackle with C, then I’ll have you know that the same applies to C++ (or pretty much any other language, for that matter).

      • In no way did I mean that C was more powerful than C++, but was just considering C on it’s own merits. Although if I was to make a comparison, I would say they are both equal in terms of programming power. By power I mean the ability to get just as deep in a fine grained sense. For example, you can use either C or C++ to create efficient OS and Kernel level software, but at the same time you can flexibly connect your code to a platform. Using other languages for these system tasks is far from ideal, even though it may be possible in some situations. There are a few other languages that *could* fulfill that same role, but they aren’t near as universal. I also think you misunderstood my point, it wasnt “C is so much better than C++” . But was rather “I prefer C to C++…. so make sure you give C chance’… and it ended with C++ is still my second choice before all else, and if you really prefer it then use C++.

  • Gaurav mann

    I am 16 and i did not find it tough(it is damn easy) , i don’t even remember now how actually i got around with it , it just feels natural and once you learn it you can learn any other language with amazing ease .
    I agree that i find it easy because i am 16 (because i can not come up with that overused line “i am professional developer”)

  • Youme

    If you’re going to go over and live in China, you’re going to learn the language. If you’re going to be stubborn and cross your arms and say English is the world language, you’re going to have a rough time. You use what language fits the job. Everything out there, even assembler, has their uses today. Limiting yourself is probably the worst thing you can do.

  • Pedro Henrique

    The feeling I have about C++ is a lot like the feeling I have about web browser development, interpreters development, compilers development, OS development and so forth.

    Developing software like those is obviously relevant, extremely. However, there is also something off about their demand.

    Saying that OS development “came back” because of (idk about OS development, so this is potentially a bad example) android or iOS or newer major versions of some OS sounds really silly, but at the same time it’s true that it never left. That’s because the people on the Linux kernel constantly develop their software, MS engineers do too, also in IBM, and many other companies who work with OS development. For them, it was always relevant and present to perform OS development: it never left. For a game developer otoh, I don’t think it ever started.

    As something really important as an OS, a web browser, an IDE, a compiler, it could seem really odd that their development isn’t so present. It’s surely not common for people to go around developing their own OS or their own compiler, and although they develop IDE plugins somewhat frequently, there aren’t many people developing new IDEs.

    I believe this is the kind of thing which has a high degree of importance but its demand can be fulfilled with a few high quality solutions. For example, wanting or not, for most people, very few OSes suffice; the same goes for browsers, IDE, compilers for a particular language, and so forth. In this sense, I guess C++ is somewhat like that in the sense that it has importance, but it has this strange pattern of demand.

    I believe it’s safe to say that as OS development “never started” for a web application developer, C++ also “never started” for many developers out there. However, for those who do use C++, the new standard surely gave them a refresh, and it surely never left. For all these years, many companies remaining doing C++ development. But at the same time, with the arrival of many newer languages, C++ lost some position, surely. I can think of some companies which stopped doing C++ in favor of other languages (C#, Java and PHP particularly) because they were using C++ for commercial automation software, business automation software, web applications, etc.

    At the same time, C++ left, never left, never started and started (it depends on the particular situation). I do believe, that more people/companies left it than adopted it. I’d surely say it faded considerably.

  • Timo Ylhäinen

    Nice writing and all true. I also learned C++ the old days and still use it (and I love it too). But would I recommend some to learn it? NO!

  • 琴の火鉢

    1) Regardless of how/how badly one can shoot one’s self in the foot; it still happens. Ruby hasn’t replaced late night coding sessions and sprints. Code reviews still happen, QA teams still dissect code, and I don’t care what pressure the latest web site is under without some one to fix code ALL of them would never launch.

    2) Embedded devices completely NULLify your main point anyway. Once was called in as a consultant (when I still did that) to convert an application on an ARM device from ROR (not to rag on ruby but it comes to mind in as the solution in your argument) to native C/C++. A complete rails machine was wholly inappropriate for the embedded application I was asked to work on with less than 800M of ram…

  • Toni Nikkanen

    C++ is too high level for about half of the programming still done in this world – embedded software development. There, C is still the king, it never went away.
    But ever since the 90’s, it’s been the application developers who are the visible ones. Except back then people used to say, that almost all software in the real world is written in Visual Basic 6.0… Nowadays those same people use C#, Java, or make web applications. Only thing that hasn’t changed is they are still acting like the other half of software engineering doesn’t exist.

    • Megatron88

      Visual Basic 6.0 is incredible fast and I have seen many VB6 app’s much faster than those made in C++

      • OrangeMonkey

        Just because someone writes a slow C++ app, and you compare that to a VB app, doesn’t mean that any managed language can ever even hope to match C/C++ in performance. They simply cannot do so, in the general case. Now, in MANY cases, who cares? Use the managed language, it will be plenty fast enough. The CLI is amazingly optimized, so it IS really peppy. But, you couldn’t service interrupts on full duplex video capture DMA device with it :)

    • OrangeMonkey

      There is absolutely no situation where C++ cannot equal C in performance. Remember C++ is a superset of C. I have used C++ in many high performance situations, and have seen it used in many others, including real-time embedded applications. It’s simply a matter of tools being available and up to the job. The embedded space has been off the charts slow in embracing C++, but its made in roads in all of the big RTOS platforms now. That said, its nice to read that C++ is old hat now ROFL. It sure isn’t going anywhere at the system level space.

  • Walt Karas

    A key issue to consider is “genericity”.

    Smalltalk is the champion of simple non-intrusive genericity. Every Smalltalk class (whose methods take objects as parameters) has the flexibility of a template. As long as the objects with which the class instance interacts have the expected (implicit) interface, they can be properly used with the class instance.

    C++ provides two approaches to genericity: templates and virtual member functions. Templates allow non-intrusive genericity, but the programmer has to be awere that the generic source code is being translated into (potentially very bulky) non-generic object code. Virtual member functions provide intrusive genericity: a class must have a particular base class in order for generic code to operate upon its instances.

    My knowledge of Java is sketchy. As best I remember, Java’s support for templates and method overriding is less flexible/capable than in C++.

    If you’re looking to trade performance for simplicity (yet capability), I think you have to take a serious look at Smalltalk, before concluding that Java and/or C# is what you’re looking for. How many intermediate cases are there really, where Smalltalk cannot provide the necessary performance, yet Java or C# can?

    As a practical matter, a new language obtained by “remodeling” Smalltalk with more C-like syntax might be more practical. Perhaps a second, non-performance intensive language, with stricter typing, should also be available.

    • Richard Eng

      I’m with you here. I love Smalltalk. It is such a “perfect” little language. Very pure. Very elegant. Very powerful. And it’s highly readable, to boot! I used it with the Seaside web framework and it was such a joy to program.

      I wouldn’t want a C-like syntax to go with Smalltalk. It’s already so readable. Why ruin it?

  • Marios F

    The opening of this article reminded me a racist “friend” of mine who always points out that he has many non-white friends, before he spouts his hatred-filled guts all over.

  • Roger

    c++14 and c++17 coming!
    With c++11 if you don’t get caught up reading prior ways you can with

    #include “boost/multi_index_container.hpp”
    #include “boost/multi_index/member.hpp”

    you can build some truly powerful software. And rapidly.

    I say learn it.

    Then it is also native for node and V8. And a little pion network for RESTful c++ for some extra speed.

  • Simon Georgia

    Const is not an operator.

  • George Alexander Louis Windsor

    Great article…but please fix your end parentheses (which always go inside the punctuation, unlike the American style of end quote placement, which itself is gradually being supplanted by logical punctuation).

  • CrankyMiddleAgedGuy

    I too love C++ but it is dying in the finance where I work. I’m guessing it’s dying everywhere. The only people who really use it are quants (who haven’t got a clue) and some real-time dealing systems. More and more of them are using Java with custom VMs that don’t garbage collect.
    The GNU compilers are awful. The compiled executables are linked to the C/C++ shared libraries so when the platform ages and a new version of Linux is installed, the application can stop working. The Linux way is to distribute source code and recompile it with the OS upgrade, or distribute with a shim and rely on the “community” to support it. Neither is satisfactory. MS “DLL hell” almost looks like heaven in comparison. It’s almost as if the GNU developers hate C++. (Linus, is that you?) I doubt the C++ compilers are very efficient either (I’ve never needed to push it to the limits) as they share most of their innards with Ada, Java and other compilers. The C++ specific stuff is just a front end.
    Microsoft can’t be bother to keep its compiler compliant.
    And the place where I work wanted everyone to become JavaScript programmers (first it was all development in VB, then Java, now JavaScript…)
    I have actually started to look at BA work simply to avoid web development.
    Most of my colleagues don’t even like C++. They view it as too hard and like languages like Python that are fast but not even type safe.
    So, I’m afraid that for most applications, C++ is a non-starter.

  • OrangeMonkey

    Great article! I have been a professional programmer for > 15 years all of that time in asm/C/C++. I too love C++. However, if I was working on the latest finance software on wallstreet that was going to be pushed out to 50,000 nodes, I cannot think of a worse language to use. It definitely has it’s place, and isn’t going anywhere anytime soon. I think I have that point down a little better than the author here, but the author’s point is still very valid. For most, virtually all, programming tasks today, higher level languages are MUCH better suited to the task. Especially given the fact that most CS/Engineering students I see coming out of college have no idea what a stack is, or how a compiler works. To me, that is a crime, but then I am conflicted. There are millions of programmers in the world today, how many of them will ever really need to know how a compiler works? How many of them could even learn that? I don’t know honestly, but just on a pure numbers basis, I gotta think not many. Also, I think taking pointers away from application programming was genius. Talk about knowing where your pain points are! It only makes sense.

    And if I have to write a nice graphics application for Windows, would I rather write a C++/DirectX app, or a C#/WPF app? Not even a contest, unless performance is an issue (like some 3D real-time something or other). And even the performance argument in this case is losing its luster. No, the author hit this nail on the head.

  • zoli

    Regarding your points 1-36 C++ does have (lot of) libraries witch can /could abstract that C++ is huge and let you programming (for non-professional blindly ) and for a professional very effective. You don’t have to know the whole C++ ( if you are not a compiler writer), the basic for you to can start programming it can be learned in 1 month ( I think this is the time that a Drupal developer also need to invest for not programming blindly). I like threading in C++11, it may be easier then in Java. It may be true that C++ will not come back : we can not see the future but the past and present is there. C++ is mature, lot of libraries, frameworks and freedom. Everybody can choose what fits her best. I will stick with C++, really do not see any reason for picking Java or C# in place.Not saying that Java or C# are not ok. I like Python using for the purpose for witch are batch files are in ms-dos/ Unix are and JavaScript for browser side programming.The GPU has ist own language. What I am like to saying C++ has its place also today , year 2014, especially because CPU’s don’t get faster.Check Free launch is over by Herb Sutter and you may be also interested in cpp-go-java-scala-performance-benchmark from google.

  • Vlad

    infer the list of provided interview questions I suspect the author’ s c++ knowledge is far below median

  • Gene Poole

    What’s funny about C++ is that it’s a moving target.

    They put a superstructure of Templates on top of C++. And who really uses it? Probably not as many Programmers as was originally anticipated. They are similar to overloaded constructors. Nice concept in theory. It probably was someone’s applauded thesis paper… When it comes down to it, Templates are not really that useful in real-life situations.

    MS invented managed C++, then reinvented it naming it something else. Now it’s CLI. This is C++, I ask? IMO, not in the strict sense of the term. They are more-or-less bolt-ons to, can I say, ‘raw’ C++. Someone in these posts mentioned the term Framework. Although if you ask people, they will tell you that it is C++. Two or three years from now, there will be another Framework to C++. I guarantee it.

    And so it goes. And why does things go this way? C++ will eventually be a monster to keep learning and mastering if things continue the way that they are. ‘Raw’ C++ written for example, for Windows programming, is complex enough. Keep piling on stuff ‘to make things simpler’… will backfire with higher maintenance costs and longer development cycles, making C++ pretty much a second choice for development at best.

    • Tiago Martins

      I have to disagree with your opinion about templates. While it’s usually avoided by newcomers to the language, talk to any experienced C++ programmer and he will probably say that templates is single handed one of the greatest strengths of the language and one of the reasons for C++ being such a great language for library writers. The biggest problem with templates, and probably why most beginners run away from it, is the syntax and cryptic error messages but those are known language defects and are being worked on right now.

  • Alex

    C# instead of C++? You may be okay, as long as you don’t target any
    platform except Microsoft Windows. But who needs to target obscure platforms like
    iOS or Android, right?

  • Nicolas Baron

    The thing is that if you learn C++ you won’t have to code in C++ for your entire life. You need to learn C++ to work with any other language in the future. Period.

  • Khalid H.

    Well, I’m not expert yet, I’m senior in SW. I’ve checked and learned all the c++ subjects from three different text-books including Bjarne Stroustrup. Among all other languages that I’ve tried and learned, yes they have similarities, and I like Java, c# and others, but to be honest for some reason I always go back in programming c++ for the fact I feel that my programs much creative and faster. It helps me to work with memory allocation and make me understand the OS architecture much better.

  • Troy Thomas Seman

    I know Visual Basic 6 and VBA. I learned a little C but never really used it. I have a project in mind for the emotiv epic and the forthcoming insight egg headsets. I want to make a mobile application that will make heavy use of audio panning. I also want a free form 2 interface. I’ve been shopping around, looking at things like Unity 3D, phone gap and other ways (hell, I even looked into Labview) to write cross platform code that will do more than a simple audio playback.

    What I’ve found is that I’m not going to be able to escape learning C++.

    He’s why.

    1) All these high level frameworks abstract away some very simple and often times necessary functions. I’m not talking about writing drivers. I’m talking about simple panning of stereo audio.

    2) when you invest in a framework you strand your code in that framework and the platforms it runs on.

    *3) If you don’t know C++, then when you need it, you don’t know it so you don’t have that tool in your tool chest.

    If all you ever want to do is fiddle with business data in spreadsheets then great. You can live on that island and never know what you’re missing out on. If you ever want to do something really interesting and original, you’re still going to have to learn the basics.

    I ccan’t tell you how much I kick myself for still not knowing C++. All the opportunities I’ve missed. You really got to learn it and then forget it if nothing else. It’s like learning math but using a calculator.

  • Coding0100

    ……I don’t like Windows 8. Infact, I don’t like Windows at all… You would have to be made to like it.
    I’m not an experienced programmer, I know cout<< and thats about it. But, I'd much rather spend extra time learning c++ than to learn Microsoft's toy language.

    (I'm 11 by the way and started learning c++ yesterday)

  • Flavio Kodama

    the thing is what you want for your product? rapid prototyping? complexity management? portable code? access to drivers? low cost of hiring developers? fast execution? any specific library? every tool has the better purpose for every scene. and every scene is now dynamic. I used to like those dogma articles. But now I got a little more experience. You must be open minded, always. Nobody can control every aspect of a huge system, if is huge it can’t be handled by one, so its not need to be coded in one language. Just that. More languages, more costs. More costs must bring enough benefits. If was not enough benefit you know what to decide for.

  • John Blow

    Stop being such cry babies just study you assholes, you can make anything with C++, if you are good ofcourse, C# is fucking stupid is made by microsoft and is slow as the fucking JAVA, normally bad programmers don’t know C, C++, Assembly and that’s the diference between a good low lever programmer and a try harder low level high level programmer, go study you whinning bitches and stop saying it’s dificult -.-“

  • loveC++

    Agh! another topic again arguing over who is bad and who is good when none of them is perfect.Just go with what you love.

  • Jadeus

    Yeah, well just cuz C++ is not a good idea for the future, doesn’t mean it a bad thing now. Right now, it is a realy retarded thing to say that we should give up learning C++. Look at binary, if people didn’t learn binary, then we wouldn’t have things like java or C++ so dont give up on c++. In fact we should be Trying even harder!

  • rtretyertyrt

    The C++ is the crucial thing for programmers and many other people to.
    Some people think the only people that use C++ are those who write program as pros for some company where they develop some very important applications etc. There are other people that write C++ code as well like> in education, some scientists, those people that are …. (I will not say English or France word for them, as well as some other people…
    One problem that I see is that it has not taken communication in consideration from beginning, and

    multithreading was ignored for to long, I talk about standards, and why we could not have semaphore as most people do.
    Then there is a problem of true RAD that should become the standard.
    One more thing why do we have int, it should be gint16 or _int16 or something like that.

    C++ is still the best but it is losing pace with some other languages. Ok it is still the better for many important things but it could be even better.
    Some people would like to see it gone down the history lane but ISO 11 and 14 is still providing.

  • snewman8771

    you are an idiot! Jesus christ! People like you are the reason many coders make buggy code and shit that doesnt work. It’s a science, if you cannot learn how to program in C++ then dont learn how to code in higher languages, you will make programs that crash/buggy/dont work, because you dont understand the language it was written in. Your wrong. Complete disgrace to coders everywhere.

  • Karl Marx

    Anything significant in the business world will be written in SAP-ABAP. Good salaries there, but you need to understand business processes. Don’t try landing airplanes with SAP-ABAP. How much do you want to know? If you are programming robotics, you might want to use C, C++, asm or Forth. If you are making simple software for cube sitters to use – then Basic & .net is “ok.” If you are designing airplanes or dams or buildings, etc, then use Matlab & something like Solidworks or Autocad. If you are designing something intricate for a space vehicle then you might want to use a tool with some abstraction between you and the processes, like using Matlab so that you don’t mess up writing your own home grown equation solver. If you are getting a grad degree in some natural science you can use Python or Perl, if those are what you know. I like to use shell scripts to write & run long SQL code. It’s all good. You can know 75%-85% of C++ &/or Java and get some good out of the concepts you will encounter.

  • georgetech

    I don’t really get the C++ vs C# comparison. Outside of Microsoft shops, you can’t really use C#. Most of the server programming environments are not Microsoft. So you can’t use C# in most of the programming environments. Yes, I’ve seen Mono. I don’t think Mono is a reliable option in the environments where you would actually need to use C++.

  • Richard Eng

    “C# is not the perfect language, but it is very elegant and simple.”

    Excuse me? C# is elegant and simple?!

    Using number of keywords as a rough metric of language complexity, C# has 79 keywords. In addition, there are 25 “contextual” keywords, for a total of over 100 keywords! This compares with 73 keywords for C++, a monstrosity of complexity.

    Now, I know that C# is LESS complex than C++. I did say number of keywords is a rough metric. Nevertheless, it should be clear that C# is NOT a simple language. Not by any stretch of the imagination.

    Just look at this feature comparison with Java: http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java

    It should be no surprise that C# is MORE complex than even Java (which only has about 50 keywords). These days, it’s conventional wisdom that Java is getting too complicated.

    We know what “simple” programming languages look like. Think Python. Think Ruby. Think Go. Think C.

  • Andrew McCallum

    The problem with managed languages is that they just aren’t fast enough. When programming for mobile devices and games, you’re working in an environment which fraught with hardware limitations, and you cannot wait for that garbage collector to periodically scoop up all of the unreferenced data.

    But, yeah – for desktop applications and scripts…use C#, Java and Python(my favorite)…. why not?

  • Binh Thanh Nguyen

    Thanks, nice post

  • fadecomic

    I know this is old, but I just stumbled here, and I had an observation on the comments rather than the article itself. The comments can basically be summed up as either “I agree. I just want to write something that works”, and “I am an old hat at C++. Old hats can do anything in C++.” These camps are arguing, yet they’re not really at odds. Both are correct. But I’d argue that the second comment is kind of irrelevant. This statement is roughly true of anyone who is an expert in any technology. An expert composer can compose a symphony on vacuum cleaners. Where is the value in computer programming? Arguably it’s in the finished product. The fun may be in creatively solving the problem, but the money is in getting the specified result to the paying customer. An expert martial artist may have devoted decades to his craft and be deadly and beautiful and adaptive, but a gun gets to the same result a lot faster and easier (google Boxer Rebellion).

  • Piyo Hoge

    I think I know the reason why I shouldn’t throw an exception in the destructor. because it might call another destructor throwing an exception during exception handing process. it crushes a program…not sounds good. (am I right?). Therefore calling a function which throws an exception in the destructor is also not good, right? because exception propagates. maybe calling a function calling a function throws an exception is again not good. But it’s hard to make sure some function throws an exception or not. This is why people have to write ClassName::Destroy kind of method (so what is the meaning of destructor/constructor’s existence?). I also afraid to throw an exception in the constructor. because it might cause memory leak (I’m not so confident about this thou). Seriously I really hate these kind of things. I really do think it is a critical defect of C++ design. If someone using custom made memory manager throw an exception in FreeMemory() method or something like that it causes an disaster. but what is the proper way to deal with unexpected situation when freeing a memory block? logging is not good because potentially it raise an exception. maybe it uses std::ostream::write kind of thing. So I always end up with “exception considered harmful” type of conclusion. maybe I’m wrong (there is some proper way to deal with these problems). but all the thing I can do is always put try ~ catch block in the constructor/destructor for safety. I don’t hate C++. I use it for my personal project but I don’t think it designed good. C++ is a kind of a last resort for writing efficient and complex programs. Most of cases C is enough for efficiency and architecture dependency and there is a lot of better language for complex but not performance sensitive programs…I agree with object oriented integration with C language is a good idea but C++ is absolutely not a best solution. C++ is still alive because there is a lot of code base written in that language. I really want “better C” language designed from scratch…how do you think about this? I really want it :(

  • tom rose

    Java and C++ both can do a good job. Conversely, either can be used to write bug-ridden and/or incomprehensible code. Any programmer that already knows a 3GL and OO concepts can learn enough of Java or of C++ to start work in them in a few days and to become very proficient in a few months, or even weeks.nnThe problem is not with the languages available to us, but with the way clueless management forces us to program everything as an “object”, even when it adds unnecessary complexity, makes the code harder to understand, and the objects so created will never be re-used in a month of Saturday afternoons.nnOO is just one of several useful programming paradigms. It should be used when it is a good fit for the problem. When it is not, then some other paradigm should be used. It is ridiculous that the IT world at present is obsessed with a “one size fits all” approach.nnBut what can you expect of a profession that thinks that “Agile” (a very useful development methodology) is the one true way, and should be used for every project? Sometimes the waterfall method is a better choice – but in some companies to voice such an opinion would be to risk losing your job!

  • federico caprari

    Well I don’t agreed with you :) nI’m not a C++ developer, but an ObjC one. But I know it, and I work in Java as well. nTruth is that high level languages give to the world a generation of developer that don’t have any idea of what happen in a computer when they click on “run” button. And they don’t know how a Von Neumann machine can think in an object oriented way even if its brain wasn’t made for that. In my experience high level interpreted languages doesn’t make great programmers, doesn’t make who has the control of an applications and solves the problems in a brilliant way. They make just developer that use and couple programs writes by someone else. There are a lot of people like that, and market needs them, of course. nI think C# is a good choice for develop apps on windows phone and windows itself, but when you have to develop “the best app” on the market maybe some part of it needs more. Maybe this is not the Microsoft actual way, but I don’t work on Microsoft platforms sou2026 nBut I think you have forgot one thing: you can always make a language simpler and gain abstraction writing codes. Writing a personal framework. Even in assembly you can use libraries you write ones, reuse forever or almost forever. It is one of the firsts things you learn in computer programming: reuse the code you write. Instead, you can’t break the limit of your knowledge or of your instruments without facing the challenge. C++ is maybe the most complicated OO language of the history. ObjC is much simpler believe me. But its simplicity isn’t made just hiding low level details or limit your implementation of that pattern as well. You can’t survive in ObjC if you don’t know how a computer works. C++ can be more simpler, but programmers can’t.

  • Bob

    We’re u making all your base class destructors virtual? Even when they aren’t polymorphic? I would get sick of the language too if I had to redefine memory releases for base properties in my derived classes every time.nnnnnnn

  • Jalmari Iku00e4valko

    “The big problem is that programming languages really need to get simpler and increase the level of abstraction not reduce it.”nnI do not really see the increase of abstractions per-say as the right direction either. Abstractions do not bring simplicity and may do the exact opposite. Rather than hiding functionality and piling programming languages, frameworks, APIs and so on top of each other, the existing functionality should be improved upon or reworked and components of software laid out side by side, not on top of each other. Clever design, common protocols and commonly shared solutions are better than virtual environment on top of virtual environment on top of library A and top of library B on top of driver on top of kernel.nnnnI do agree that programming languages themselves need to be designed and evolve for higher simplicity and consistency. From that perspective, C++ has grown somewhat monolithic and steadily increased its own complexity. Yet at the same time, moving certain things from Boost to standard library and offering unifying ways for commonly used techniques could be considered a potential reduction in abstraction!

  • chacha chacha

    Check that project https://github.com/charb/jcpp
    It brings Java world to C++

  • What is this about C++ being back? Where did it go? I don’t know what the author is talking about.

    Major things written in C or C++…

    * Microsoft Windows 8.1
    * Linux kernel
    * FreeBSD
    * Battlefield 3
    * Unreal Engine 3
    * Team Fortress 2
    * Portal

  • reneb86

    I may be a little late to this discussion, but I wanted to share my thoughts on the matter nonetheless.

    Technology becomes better and better and we can see how java and C# code, on the test bench, sometimes outperform C or C++ code with all that it has going for it. On the test bench… Observe around you how seemingly simple applications seem to be taking forever and ever to complete simple tasks. That’s your badly written high level code being crunched to death by virtual machines, interpreters, platforms, frameworks, or whatever to get it running. Memory gets allocated without being freed. Simple ordering of lists suddenly require 5 list iterations (or even copies) because they are linq’d together. Every function throws at least a couple of exceptions during runtime. Bad code all around.

    Now we know that clean and efficient code CAN be written using languages such as Java or C#. The thing is… they just never are. These languages and their platforms empower bad developers. they don’t punish bad practices. Compare your handheld device with your Pentium of old. Compare the tasks you did on both, and scratch yourself behind your head wondering how on earth it is possible that your smartphone takes so absurdly long to get simple things done.

    Rewrite all the java and C# code out there to mediocrely written C++, and you can close down 20 nuclear reactors with the power you save. THERE’s your reason. C++ is the most practical link we have between raw hardware and understandable concepts, and we should encourage everyone to explore it. You can use any language you want, but learning C++ is a must. It just makes you a better developer.

  • swampwiz0

    Back in the pre-.NET day, I was a Visual C++ developer. Because there was only Visual Basic as the Windows stack competition, any *true* object-oriented development for Windows had to be done in C++ (Basic still did not have polymorphism.) Using the MFC made coding in C++ not very painful, but with a lot of hokey stuff like the macros to do the message map and date binding, and as well no clear code to realize the initial windows & controls stuff in the resource file (it was there, but without clear coding to get to it.)

    This all changed with .NET and C#. First off, C# was basically Micro$oft’s version of Java (it seems to me to be a better Java than Java itself), and Visual Basic.NET was simply C# code in Basic body, so Visual Basic .NET really had no reason to co-exist other than the fact that some folks didn’t like the C-style of C#. And C#’s Winforms API (which replaced Visual C++’s MFC API) got rid of all the hokey stuff in Visual C++ that I had described, and made it so that everything with building the controls made sense. I actually preferred it.

    Unfortunately for folks like me, since the new C# was so much easier to be proficient in, there was a lot more competition to get work developing C#. Whereas folks like me were hard to find because of how difficult C++ was, C# folks were easy to find. And also, all the accumulated knowledge of the Visual C++/MFC stack because virtually worthless. I decided to “retire” a few years earlier that I would have liked as it seemed to have become impossible to find work in C# development without having all the “purple squirrel” attributes.

  • PassingBy

    What is your own answer to “Vector” then ? I personally don’t see a point of using “vector” instead of more wide concept of array.
    Regarding throwing exception in destructor – what is your point ? It could make sense when using nested destructors.

  • Dmitry Kim

    If you want to participate in languages evolution and fully understand it, you must learn C and C++. If you want just earn some money developing some stuff, just choose easiest and the most money-effective one for your target.

  • Inu Yayo Baka-Bakpao

    If *modern* (bs if you ask me) languages can compete with *older* languages like C/C++ then I could agree with you. Java is lightyears away from being anywhere near usable. Take a look at smartphones & android. How much energy on this planet is wasted just because google decided to use Java? I don’t even want to know.

    C++ has a good learning curve. I started with PHP – moved to C++ and was amazed how EASY it is to write efficient code. If you mess up, you inform yourself and you can use the newfund intelligence source to enhance your abilities. You are not relying on somebody else to fix performance issues for you.

  • Michael Osei

    What you should remember. Is humans like pythons and rubys, computers like c and c++ its as simple as that.

  • alexandrebourget

    haha… reminds me of Rob Pike’s story in here: http://commandcenter.blogspot.ca/2012/06/less-is-exponentially-more.html .. that C++11 meeting after which he wanted Go lang to be.

  • boris

    C++ original philosophy was good, they wanted zero cost abstraction and c compatible. The sad part now is that C++ is growing so far away from C but still has a lot of old stuff in it that should be deprecate now. for examply why can you use C casts and C++ kind of casts, why are there still macros, NULL and 0 for pointer. all the kind of initialisations etc. if C++ drops (C++– maybe?) all the legacy stuff then it would be an ‘easy’ language.

    But i think a better way to go is Rust it also has the zero cost abstraction idea, has a superior type system, is really small and doesn’t include classes(no more inheritance etc.), But has traits + structs and Templates instead. It also includes a lot of safety. Sadly it doesn’t include compile time calculations yet.

  • 0
  • 1
    觉得还不错? 一键收藏
  • 0


  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助