Catch up on stories from the past week (and beyond) at the Slashdot story archive


Forgot your password?

C++ 2011 and the Return of Native Code 616

snydeq writes with an editorial in InfoWorld about the resurgence of native code. From the article: "Modern programmers have increasingly turned away from native compilation in favor of managed-code environments such as Java and .Net, which shield them from some of the drudgery of memory management and input validation. Others are willing to sacrifice some performance for the syntactic comforts of dynamic languages such as Python, Ruby, and JavaScript. But C++11 arrives at an interesting time. There's a growing sentiment that the pendulum may have swung too far away from native code, and it might be time for it to swing back in the other direction. Thus, C++ may have found itself some unlikely allies."
This discussion has been archived. No new comments can be posted.

C++ 2011 and the Return of Native Code

Comments Filter:
  • Never went away (Score:5, Insightful)

    by i ate my neighbour ( 1756816 ) on Thursday August 18, 2011 @02:37PM (#37132738)

    Native was never away. It always has its place. It is just that performance/efficiency is not always top priority.

  • Re:For learning (Score:5, Insightful)

    by Moryath ( 553296 ) on Thursday August 18, 2011 @02:44PM (#37132822)

    The larger picture is fucking use the right tool for the job already.

    Java has its purposes. Write-once, Run-Almost-Anywhere is a good concept. Likewise, some of the other tools in other managed frameworks make certain things really simple.

    And when you need power and speed at the expense of having to do things a lot more exact yourself, then go to a language that'll work that way.

    The problem is not that one or the other is "bad." The problem is that too many programmers are golden-hammer morons who think their favorite tool is the only correct way to do everything on the goddamn planet, which is why you get Java applications running a chip on little mini kids games to do something that could have been done with a 5-cent microchip [].

  • Re:Yikes (Score:5, Insightful)

    by AuMatar ( 183847 ) on Thursday August 18, 2011 @02:48PM (#37132856)

    Yes, because managed code has no memory leaks. Please. I work on a mixed C++/Java Android codebase. I haven't found a memory leak on the C++ side in months. The Android framework decides to hold onto random references every new version.

    Quite frankly, memory management is not hard. If you don't understand the simple idea of allocate, use, release, then you are a complete incompetent and should not be programming professionally. I'll go so far as to say it's better for a language NOT to automatically manage your memory- in general the first sign of a bad or failing architecture is that object life cycles and memory allocation start to be non-trivial. Managing your own memory catches those architecture bugs and leads to cleaner, easier to understand code. And the cost is absolutely minimal, I doubt I've spent 10 minutes in the past 2 or 3 years actually debugging memory problems in C++.

  • by giuseppemag ( 1100721 ) <giuseppemag@ g m a i l . com> on Thursday August 18, 2011 @02:48PM (#37132864)

    ...choose the tool that's best for the job, don't choose the job that's best for the tools you know already.

    Game developers, for instance, are among the guys who write the most performance sensitive code out there, and they use a mix of C, C++, C#, Lua/Python for the various parts of the game. Usually the inner, tight loop is written in C/C++, higher level modules are written in C# and designer/modder scripts are written in a very high level language such as Lua. There is no best language in general, and whoever says otherwise is often an idiot.

  • Re:False dichotomy (Score:4, Insightful)

    by fusiongyro ( 55524 ) <faxfreemosquito@ya[ ].com ['hoo' in gap]> on Thursday August 18, 2011 @02:55PM (#37132934) Homepage

    Um, because it runs on the CLR in a fashion almost identical to Java on the JVM?

  • Re:Carmack (Score:5, Insightful)

    by Jthon ( 595383 ) on Thursday August 18, 2011 @03:01PM (#37133016)

    I think there was a hope that computing power would catch up and make VMs a competitive alternative to native code.

    While you're right there's a computing power issue here, the issue is battery life not lack of CPU cycles. VMs add overhead, as you add overhead you'll run longer and burn more power on the CPU. If you want to squeeze all you can out of a limited battery you need to optimize your code and in the end that's going to mean native code with very explicit memory management. VMs just don't play well in embedded environments.

  • by Animats ( 122034 ) on Thursday August 18, 2011 @03:08PM (#37133140) Homepage

    The article perpetuates the myth that native code has to be "unsafe". That's an artifact of C and C++. It's not true of Pascal, Ada, Modula, Delphi, Eiffel, Erlang, or Go.

    Nor does subscript and pointer checking have to be expensive. Usually, it can be hoisted out of loops and checked once. Or, for many FOR loops, zero times, if the upper bound is derived from the array size.

    One of the sad facts of programming is that there should have been a replacement for C/C++ by now. But nothing ever overcame the legacy code base of the UNIX/Linux world. Every day, millions of programs crash and millions of compromised machines have security breaches because of this.

  • Re:For learning (Score:4, Insightful)

    by lgw ( 121541 ) on Thursday August 18, 2011 @03:22PM (#37133350) Journal

    I disagree about C being easier to get into. The stuff you do in toy programs, playing with strings and arrays and such, is difficult and alien in C if you've never seen pointers, or manual memory management. In C++ you can start with string and vector, and get toy programs working with just STL stuff, worry about pointers and memory leaks later on.

  • by Bengie ( 1121981 ) on Thursday August 18, 2011 @04:36PM (#37134560)

    It's not only about being easier, but also proven. I would rather use a lockless thread-safe multi-reader/writer queue than implement it myself only to have a possible race-condition. It would be fun to learn it some day when I have free time, but enterprise code? No Way. I'll let engineers with PHDs and tons of testing figure out the hard stuff.

  • by Joce640k ( 829181 ) on Thursday August 18, 2011 @04:53PM (#37134824) Homepage

    But if you don't want to care about it then you don't have to - you can leave it to the garbage collector and it'll take care of it.

    ...this is the level of programmer who thinks he's able to criticize another programming language?

  • C++.

    Yes, you get a little bruised when it comes to pointers, but that is very much worth it in the long run.

    Students that don't learn about pointers and such early on (e.g. got Java first) tend to have a harder time in the upper classes where lower level languages are required. So, you can either "man up" and get the hard stuff learned early when it won't interfere with the classwork, or have your upper level classes being diverted in order to teach the stuff they should have learned earlier on and then not get to learn as much of the upper level material as they should have.

1 Mole = 007 Secret Agents