Advertisements
Posted by: jsonmez | December 1, 2012

Why C++ Is Not “Back”

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.

announcer

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?

banghead

No!  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

gun

And 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 newrevitalized project 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.

Advertisements

Responses

  1. 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.

      • 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.

  2. 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.

      • 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).

        • Thanks you sir!

      • 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.

        • 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!

        • 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.)

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

  4. 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.

        • 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.

  5. 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 🙂

      C+++LUA
      😉

  6. Love that quote by Mr. Stroustrup :]

    • 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.

  7. 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.

      • Java and C# cannot reach C++ as ‘good’ OOP

        • “Good” OOP is not about the language, but the programmer.

  8. 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.

  9. 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++.

    • 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.

      • 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)

        • 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

      • 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.

      • 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.

    • 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++:

          http://msdn.microsoft.com/en-us/windows/hardware/gg487420.aspx

          • 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).

          • 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…?!

          • 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…

          • 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.

  10. 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++.

    • 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.

        • 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.

          • 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.

  11. 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++ !????

      • 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.

  12. 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.

  13. 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

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

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

  15. 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.

  16. 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.

  17. 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.

  18. 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).

    • 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……

    • 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?

    • 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.

  19. 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.

  20. 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.

  21. 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.

  22. 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.

  23. 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.

  24. “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”.

  25. 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.

  26. 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!

  27. 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.

  28. 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.

    • 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.

    • 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.

      • “… 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.

        • 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.

        • 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

        • ” 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.

          • 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

  29. 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!)

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

  31. Reblogged this on the geeks club.

  32. 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.

  33. 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.

      • 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?

          • 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.

          • 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.

      • 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.

      • FUD.

        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.

        • 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.

      • 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.

        http://www.gotw.ca/publications/concurrency-ddj.htm

  34. If you understand C++, you understand every programming language BUT functional languages 🙂 those are a different world.

    • 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.

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

        • Yes, thanks I always forget his name…

      • I think the name you are looking for is Bartosz Milewski 🙂

    • thats why you add LUA 🙂

    • 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?

  35. 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/

    • 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”.

  36. […] Why C++ Is Not “Back” (John Sonmez) […]

  37. 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.

  38. [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.

  39. […] Why C++ Is Not Back […]

  40. […] “Why C++ Is Not ‘Back’” […]

  41. […] Why C++ Is Not “Back” […]

  42. 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.

    • 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.

  43. 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.

    • Well said!

  44. Portabiity;

    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?

    • C#

  45. 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”.

    • 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++

  46. 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.

    • @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.

  47. 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).

    • 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.

  48. Great article!

  49. 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-

  50. Ok. Leave it to us pros…

  51. 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.

  52. 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.

  53. 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.

  54. 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 😀 – 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.

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

  55. 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++”

  56. 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 …

    • 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?

  57. 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.

  58. 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’.

  59. 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.

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

  60. 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!!

  61. 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.

  62. 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.

  63. 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.

  64. “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?

  65. 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.

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

  66. 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.

    • “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.

  67. 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.

          • 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?

  68. 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.

  69. 因为C++没离开过

  70. 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.

  71. 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.

  72. 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!

    • 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.

      • 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.

  73. 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.

  74. Nice article

  75. 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….

    • 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.

  76. 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.

  77. C++ is not back because it did’n go anywhere 😛

  78. 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).

  79. 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.

    • 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 =)

    • 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.

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

  81. 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 ..

  82. 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.

  83. 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.

    • 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.

      • @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.

          • 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. 🙂

        • (by the way, I’m not the same 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.

  84. […] beaten path with those choices and you focus on these 4 important skills, you will be ok.  (You could even learn C++ […]

  85. 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.

  86. 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.

  87. 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.

    http://www.boost.org/doc/libs/1_52_0/libs/spirit/doc/html/spirit/karma/performance_measurements/numeric_performance.html

    • 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.

  88. […] using C++ as my main programming language, I eventually concluded that for most of my applications, its complexity is more effort than it’s worth, particularly now that computers are sufficiently powerful that we no longer need to prioritise […]

  89. 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.

  90. 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,

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

  92. […] Sonmez argues in his post that besides all the great new features which make C++11 feel like a new language, there is one big […]

  93. […] 有这样一种说法,要深入学习一到两门编程语言,并从事某个通用的专业领域,这当然很重要,不过,只要你还没带着那些抉择在这条老路上走得太远,并把精力集中在提高这4种重要技能上,你自会万事大吉!(你甚至可以学习C++ ;D) […]

  94. […] 在“为什么C++并没有‘王者归来’(Why C++ Is Not ‘Back’)”一文中,John Sonmez认为只有如下三个原因才会使用C++: […]

  95. 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.

  96. […] 在“为什么C++并没有‘王者归来’(Why C++ Is Not ‘Back’)”一文中,John Sonmez认为只有如下三个原因才会使用C++: […]

  97. […] 在“为什么C++并没有‘王者归来’(Why C++ Is Not ‘Back’)”一文中,John Sonmez认为只有如下三个原因才会使用C++: […]

  98. […] http://simpleprogrammer.com/2012/12/01/why-c-is-not-back/ […]

  99. […] 在“为什么C++并没有‘王者归来’(Why C++ Is Not ‘Back’)”一文中,John Sonmez认为只有如下三个原因才会使用C++: […]

  100. […] 在“为什么C++并没有‘王者归来’(Why C++ Is Not ‘Back’)”一文中,John Sonmez认为只有如下三个原因才会使用C++: […]

  101. Reblogged this on sunliwei.

  102. […] 4 种重要技能上,你自会万事大吉!(你甚至可以学习C++ […]

  103. […]      在“为什么C++并没有‘王者归来’(Why C++ Is Not ‘Back’)”一文中,John […]

  104. 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.

  105. […] José Ignacio – UruguayOreo Cookie Balls! A New Holiday Treat! The Holidays are Coming!Making the Complex Simplevar switchTo5x=true;stLight.options({publisher:'wp.af3cd5df-fcb2-41b8-9cde-d47816342f55'});var […]

  106. 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.

  107. 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.

  108. 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.

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

  110. 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.

  111. 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.

  112. […] If you don’t know about the other Qt smart pointers (QScopedPointer, QSharedPointer) and their C++ equivalents (auto_ptr, and shared_ptr) you need to check them out too. And if you don’t know how to use those, then you probably don’t know C++ as well as you think you do. When I started cascades programming, I was comfortable with C++’s syntax — I knew C really well, and had done a small project many years ago in C++. But lots of very smart people have figured out a ton about how to really use C++ since then. You can still shoot yourself in the foot, but it is a lot safer, when you know how. I think that’s contributed to a big resurgence of C++ (seemingly backed  by even Google and Microsoft. See a bunch of articles on this, and a good counterpoint here.) […]

  113. […] John Sonmez has written an excellent article, Why C++ Is Not “Back”, that echoes my own feelings about C++ 11: it’s great for C++ hardcore hackers who relish even […]

  114. 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.

  115. 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’).

    • 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. 🙂

  116. 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,

  117. 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.

  118. correction: “declare functions in-line” instead of “declare functions line”

  119. 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.

  120. 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”.

  121. > Why do you want to learn C++?

    Because there is vacancy for c++ developer

  122. #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.

  123. 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.

    • Exactly! Well written.

    • 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.

  124. 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.

  125. 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.

  126. 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++.

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


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: