Slashdot Mirror


C++ 2011 and the Return of Native Code

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

65 of 616 comments (clear)

  1. Never went away by i+ate+my+neighbour · · Score: 5, Insightful

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

  2. Then learn the language better, stupid by Desler · · Score: 2

    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.

    So if you wanted to be shielded from the drudgery of memory management in C++ why weren't you using the features of the language that provide you automatic memory management to make this less of a pain? It's not as if you don't still have to do memory management in say .NET especially since the IDisposable pattern is needed all over the place in user-written code to clean up non-memory resources like file handles, GDI handles, etc held within your objects.

    1. Re:Then learn the language better, stupid by m50d · · Score: 2

      So if you wanted to be shielded from the drudgery of memory management in C++ why weren't you using the features of the language that provide you automatic memory management to make this less of a pain?

      Because it doesn't provide full automatic memory management (smart pointers don't handle cycles), and because you have to write reams and reams of angle brackets to use them.

      It's not as if you don't still have to do memory management in say .NET especially since the IDisposable pattern is needed all over the place in user-written code to clean up non-memory resources like file handles, GDI handles, etc held within your objects.

      I can't speak for .net, but in Java you have very little need for it. It's better to close your files and connections, but they'll be garbage-collected for you if you don't.

      --
      I am trolling
    2. Re:Then learn the language better, stupid by Duhavid · · Score: 4, Informative

      I can speak for vb.net ( may be true in c#.net, not sure ), but you can leak memory as well as other resources.
      I bought into the "garbage collection handles it" mindset, until it was rudely pushed into my face that some UI elements have to have dispose called, or they stay in memory ( IIRC, forms will not collect, so incompetent programmers that put properties on their forms can come later and get those properties from the form after it is closed, other things like that ).

      --
      emt 377 emt 4
    3. Re:Then learn the language better, stupid by Joce640k · · Score: 2

      Because it doesn't provide full automatic memory management (smart pointers don't handle cycles), and because you have to write reams and reams of angle brackets to use them.

      If you're creating cycles then you didn't understand RAII. The objects in your cycle don't 'own' each other.

      If you're typing lots of angle brackets then maybe you need to learn about typedef.

      It's better to close your files and connections, but they'll be garbage-collected for you if you don't.

      You seem to be saying that after I save a file I have to wait for the garbage collector to run before I can open the file in another application or move it somewhere else on the disk. How will I know when the garbage collector has run (assuming it runs at all...)? Am I supposed to quit your application to force it to close the file before I can safely email it to somebody?

      --
      No sig today...
    4. Re:Then learn the language better, stupid by m50d · · Score: 2

      You seem to be saying that after I save a file I have to wait for the garbage collector to run before I can open the file in another application or move it somewhere else on the disk. How will I know when the garbage collector has run (assuming it runs at all...)? Am I supposed to quit your application to force it to close the file before I can safely email it to somebody?

      If you care about when the file gets closed then you explicitly close it yourself. 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.

      --
      I am trolling
    5. Re:Then learn the language better, stupid by Desler · · Score: 2

      You seem to be saying that after I save a file I have to wait for the garbage collector to run before I can open the file in another application or move it somewhere else on the disk. How will I know when the garbage collector has run (assuming it runs at all...)? Am I supposed to quit your application to force it to close the file before I can safely email it to somebody?

      Exactly. A program that isn't closing files or disposing of native handles is just plain lazy and thus is probably the reason this person has C++ code that leaks so much memory or resources. Even IF the GC would take care of it for you you shouldn't be relying on it to do so (which in .NET the GC won't).

    6. Re:Then learn the language better, stupid by Desler · · Score: 2

      If you care about when the file gets closed then you explicitly close it yourself.

      What do you mean "if you care"? You should ALWAYS care. Leaving files opened for no good reason is the sign of being lazy.

      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.

      Translation: If you want to be a lazy and shitty programmer you can just leave it to the GC to close the file whenever it feels like it. It's not as if the user might want to open that file in another application or maybe reload it again, right? No, that never happens. One can only hope that you aren't responsible for writing critical software with such shitty standards for writing software.

    7. Re:Then learn the language better, stupid by m50d · · Score: 2

      What do you mean "if you care"? You should ALWAYS care. Leaving files opened for no good reason is the sign of being lazy.

      The whole craft of programming is applied laziness. Sometimes it matters when a file gets closed. Most of the time it doesn't - just like sometimes it matters what's in that list you're sorting, but most of the time it doesn't. Knowing when is what makes you a good programmer.

      --
      I am trolling
    8. Re:Then learn the language better, stupid by JonySuede · · Score: 2

      and in java 7 with the try-with-resources it is handled for you.

      --
      Jehovah be praised, Oracle was not selected
    9. Re:Then learn the language better, stupid by alexo · · Score: 2

      I can't speak for .net, but in Java you have very little need for it. It's better to close your files and connections, but they'll be garbage-collected for you if you don't.

      Not according to the Java documentation:

      Some applications interact with garbage collection by using finalization and weak/soft/phantom references. These features can create performance artifacts at the Java programming language level. An example of this is relying on finalization to close file descriptors, which makes an external resource (descriptors) dependent on garbage collection promptness. Relying on garbage collection to manage resources other than memory is almost always a bad idea.

      Also, for the fun of it, look at:
      http://stackoverflow.com/questions/6470651/creating-a-memory-leak-with-java

    10. Re:Then learn the language better, stupid by Joce640k · · Score: 3, Insightful

      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?

      --
      No sig today...
    11. Re:Then learn the language better, stupid by dmmiller2k · · Score: 2, Interesting

      ... to clean up non-memory resources like file handles, GDI handles, etc held within your objects.

      IMHO, it's easier to get this right using RAII with C++ than with any of the toy languages (e.g., Java, .NET), all of which require explicitly freeing, destroying, releasing (or whatever) resources from each and every code path that may exit a given scope.

      --

      "No matter how cynical you get, it is impossible to keep up." -- Lily Tomlin

  3. Why is C++ unmanaged? by Billly+Gates · · Score: 2

    Last I checked you could use .NET in C++. So use .NET for the gui and networking frameworks and use C++ to do hardcore number crunching. Also there are native data structures in .NET and Java you can use in your program if you need performance. Most amature programmers never look in the math or collections libraries.

    1. Re:Why is C++ unmanaged? by maxwell+demon · · Score: 2

      Last I checked you could use .NET in C++.

      No. You can use .NET only in MSVC++.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    2. Re:Why is C++ unmanaged? by Anonymous Coward · · Score: 4, Funny

      Managed C++ combines the streamlined elegance of native C++ with the high performance, execution stack transparency and platform/vendor flexibility of .NET.

    3. Re:Why is C++ unmanaged? by whiteboy86 · · Score: 4, Interesting

      Managed code has been the single biggest disaster at least where I work, stalls, huge memory consumption, unpredictable.. the dreaded 'garbage collection', I am glad we are out of it.. and if you fear crashes then you could use C++ exceptions, then you can divide by zero or do other bad stuff and never experience a hard crash... or even better, use the complete threaded sandbox (see Chromium sandbox). that means C++ is totally safe and the fastest at the same time - best of both worlds; that is why C++ is used internally by Google, Ebay, Oracle.. etc.

    4. Re:Why is C++ unmanaged? by Desler · · Score: 3, Informative

      You should look at the coding guidelines Google uses for C++.

      I don't recommend that. Anyone reading the Google coding guidelines will get a very wrong picture of how C++ is supposed to be done. Hell, their guidelines specifically disallow the use of RAII which is one of the dumbest things ever.

    5. Re:Why is C++ unmanaged? by GooberToo · · Score: 2

      I don't recommend that.

      That was my point. I completely agree with you.

      I just had a falling out with another developer because he told me I was doing things dumbly because it didn't comply with Google's coding guidelines or Linus' irrational hatred of C++; amongst many other insanely stupid and completely irrational justifications. Of course, the falling out was caused by me politely explaining to him that coding standards have significantly progressed in the last several decades, followed by inviting him to join me. in at least this decade, accompanied with references to modern methodologies and development guidelines. He thought very poorly of me and the corrections. This isn't an exaguration.

    6. Re:Why is C++ unmanaged? by Desler · · Score: 2

      That's what is always funny. The most outspoken critics of C++ are usually those most ignorant of the language. Hence why we have all sorts of people in this discussion whining about having to do manual memory management in C++ whilst being pig ignorant of the built-in features and design patterns that basically eliminate most of this burden.

    7. Re:Why is C++ unmanaged? by TemporalBeing · · Score: 2

      Last I checked you could use .NET in C++. So use .NET for the gui and networking frameworks and use C++ to do hardcore number crunching. Also there are native data structures in .NET and Java you can use in your program if you need performance. Most amature programmers never look in the math or collections libraries.

      Managed C++ in MSVC is simply C#.
      Unmanaged C++ in MSVC is actual C++.

      As to the native data structures in .NET and Java - you incur performance penalties when you want to use them directly as you have to thunk back and forth between the managed and unmanaged portions of the system. I think Java is better about it than .NET, but its a pain nonetheless. It's easier, and more performance, to just stay in either unmanaged or managed code all the time.

      --
      Truth is like the sun. You can shut it out for a time, but it ain't goin' away. - Elvis Presley (source: imdb.com)
    8. Re:Why is C++ unmanaged? by tibman · · Score: 2

      I still printf in c++... Come at me bro

      --
      http://soylentnews.org/~tibman
  4. Carmack by bonch · · Score: 2, Informative

    Carmack remarked about this on his Twitter account today: "iOS did a lot to 'save' native code on mobile platforms. Prior, there was a sense that only Neanderthals didn’t want a VM."

    Apple is even backing down on Cocoa garbage collection with their new Automatic Reference Counting feature, in which the compiler determines object lifetimes and inserts the needed memory management calls. ARC will be the default for new Xcode projects. I think there was a hope that computing power would catch up and make VMs a competitive alternative to native code.

    1. Re:Carmack by Jthon · · Score: 4, Insightful

      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.

    2. Re:Carmack by Joce640k · · Score: 2

      Garbage collectors have some problems which can't be fixed:

      a) Garbage collection only works for RAM, it doesn't release resources like files, network connections, etc. in a timely fashion.

      b) When RAM is low and you start swapping to disk a garbage collector which scans/compacts the entire heap every few seconds will cause massive disk thrashing.

      Given that freeing resources is mostly a non-issue in C++, why would anybody want a garbage collector?

      --
      No sig today...
    3. Re:Carmack by harl · · Score: 2

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

      I've never understood this position. It always reads as, "Since we have more power we can be inefficient with it."

      --
      I find being offended by me offensive.
  5. False dichotomy by MrEricSir · · Score: 3, Interesting

    Look at Objective C or Vala -- just as easy as C# or Java, but none of the headaches of a virtual machine runtime.

    --
    There's no -1 for "I don't get it."
    1. Re:False dichotomy by fusiongyro · · Score: 3, Insightful

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

    2. Re:False dichotomy by HarrySquatter · · Score: 2

      The CLR is a VM. You can't ask the machine to load CIL. It has to be interpreted by the CLR first.

      CIL is never interpreted. It is always JIT compiled.

    3. Re:False dichotomy by sco08y · · Score: 2

      Look at Objective C or Vala -- just as easy as C# or Java, but none of the headaches of a virtual machine runtime.

      Objective C doesn't have a runtime? I wonder why Apple decided to write a manual for it.

  6. Re:Yikes by CadentOrange · · Score: 5, Informative

    This keeps getting brought up, but I've written commercial C++ code for years and I've not had memory management issues. There have been problems with legacy 3rd party libraries, but if you religiously apply the RAII ( https://secure.wikimedia.org/wikipedia/en/wiki/RAII ) idiom you will usually be fine. I can't remember the last time I worked with a raw pointer and had to new/delete my own memory.

  7. Re:For learning by Moryath · · Score: 4, Insightful

    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.

  8. Re:Yikes by gbjbaanb · · Score: 2

    The corollary of this is that you *need* super hardware to run the latest applications because they are so inefficient.

    Instead of dumbing-down programming (which is a false economy anyway as poor devs write poor apps regardless of the ease-of-use of their programming environment), we should be increasing the skills of the developers. That means stopping from making things so easy that my manager can do it, still making a hash of it, only now thinking that any outsourced cheap developer can do my job!

  9. Re:Yikes by AuMatar · · Score: 5, Insightful

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

    --
    I still have more fans than freaks. WTF is wrong with you people?
  10. Smart people know already... by giuseppemag · · Score: 5, Insightful

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

    --
    My book: Friendly F#, fun with game development and XNA; my game: Galaxy Wars by VSTeam; my gamedev language: Casanova.
    1. Re:Smart people know already... by feandil · · Score: 2

      Game developers use C# to write their pipeline tools (level editors, particle editors, AI editors, etc.), not the game itself. except for XBLA indies, all major console games are pretty much 100% C++.
      some also include scripting languages like lua or python for higher level, non time critical processes (like level scripting), but if you want your game to run fast (and you do, as faster=more stuff on the screen at the same time) you use a visual tool that internally generates C++ code.
      as long as C++ is the fastest, closest to the machine language it's never going to go away.
      and don't talk to me about managed code, when you have 64MB of ram to run a game on the wii I can tell you you better know exactly how you use your memory at any given point in time. you ban dynamic allocations and make sure all objects are placed in a nice contiguous way (to avoid cache misses) in your memory pools.

  11. Re:Yikes by Desler · · Score: 2

    Yes, because managed code has no memory leaks.

    Yes, and managed code never has need for manual memory management. Oh wait...

  12. Doesn't have to be unsafe if native by Animats · · Score: 3, Insightful

    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.

    1. Re:Doesn't have to be unsafe if native by Twinbee · · Score: 2

      How dare you want that functionality. May you work with Javascript forever as a suitable punishment.

      --
      Why OpalCalc is the best Windows calc
    2. Re:Doesn't have to be unsafe if native by m50d · · Score: 2

      The point is that you can take a safe language (i.e. one without pointers to arbitrary memory, among other things), and compile it to native code. Of course there can be bugs in the compiler, but guess what, there can be bugs in the JVM too.

      --
      I am trolling
    3. Re:Doesn't have to be unsafe if native by petermgreen · · Score: 2

      Well it's certainly not for lack of options

      Ok name a language that

      1: allows both RAII and close to bare metal coding to coexist as appropriate for each peice of the code in question without having to resort to the mess of mixing languages
      2: Has a high quality FOSS implementation
      3: Is widely ported

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    4. Re:Doesn't have to be unsafe if native by master_p · · Score: 2

      The crashes are solely due to using C++ as C, i.e. manual memory management, C casts, pointer arithmetic and C arrays. If none of the C features are used, then C++ is as safe as the languages you mention.

  13. Re:This isn't auto mechanics! by Moryath · · Score: 2

    Gimme an algorithm or any other job and I'll implement it in 'C' - I don't need no pussy language that makes parsing text easier (Perl) or web back ends easier (Python) or worry about the mythical write once run everywhere languages like Java.

    And back in the day of the old PS2, every goddamn game development house started out their dev cycle by reimplementing mip-maps because it wasn't supported directly by the hardware. Fucking insanity. If there's a tool that has been developed for text parsing, and 99% of your program's functionality is text parsing, then use something that was DESIGNED FOR TEXT PARSING instead of having to reinvent the goddamn wheel.

    Tools are made because they make life, or at least a specific task, easier. They should be used for that purpose. They should not be used for things they are not designed for. C++ was designed for low-level access to the hardware, which is fine if your program needs low-level access to the hardware, but it shouldn't be used for every task just as Java, or Perl, or Python, or any other tool shouldn't be used for things they weren't designed for.

  14. Re:For learning by GooberToo · · Score: 3, Interesting

    Java has its purposes. Write-once, Run-Almost-Anywhere is a good concept.

    It is a good concept. Unfortunately, several studies (at least one was covered here on slashdot) indicate the vast majority of Java development runs on the same platform on which it was written. Furthermore, the vast majority of this Java software can not run anywhere without additional code changes because of programmer short sightedness or just simple mistakes.

    So while its a nice "have", pragmatically speaking, it doesn't apply to most Java software.

    Which means, at the end of the day, your development cycle of something like Java vs C++ isn't all too entirely different for code which actually is, "Write-one, Run-Almost-Anywhere."

  15. Re:Yikes by Joce640k · · Score: 2

    Yep, I don't recall having memory management issues with C++ in the last ten years or so. Smart pointers take care of freeing RAM and the std::vector I use has bounds checking and extensive iterator checking turned on by default (even on operator[]).

    Done properly C++ is as safe as Java, i.e. the only memory error is null pointer.

    Java, OTOH has no stack unwinding for timely release of resources. Garbage collection is useless for anything other than RAM. Want a file or a network connection closed? You have to wrap it in a try...finally block and close it manually. Every single time, no way to automate it.

    Then there's Java's brain-dead inheritance model. Get ready to do multiple inheritance manually by copying/pasting code from all the base classes. Cross your fingers that the interface never changes and you have to go and hunt down every last copy of it.

    Want some "drudge"? Use Java.

    --
    No sig today...
  16. Re:This isn't auto mechanics! by smelch · · Score: 2

    Meanwhile, other people will actually ship on time and within their budget by not being a moron who thinks the only thing important in development is computational efficiency.

    --
    If I can just reach out with my words and touch a butthole, just one, it will all be worth it.
  17. Re:For learning by lgw · · Score: 3, Insightful

    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.

    --
    Socialism: a lie told by totalitarians and believed by fools.
  18. Re:Yikes by Joce640k · · Score: 2

    I doubt I've spent 10 minutes in the past 2 or 3 years actually debugging memory problems in C++.

    For a laugh I just searched for the word 'delete' in my current C++ project. There was a grand total of nine of them in 250,000 lines of code (and they were to define some new container classes).

    There's no manual memory management anywhere in the rest of the code. Memory management in C++ is a myth perpetuated by C hackers who can't be bothered to educate themselves.

    --
    No sig today...
  19. Re:For learning by GooberToo · · Score: 2

    Yes, and then forget all about OOP, and learn Java.

    You're both right.

    I tried to teach Java to my son. It quickly got stuck because of OO concepts. We went to Python. Life was good. And as you rightly point out, the OO taught by Java is crappy at best. If you really want OOP, Java isn't a good choice for that either.

  20. Case in point: the Nintendo Wii by DeadCatX2 · · Score: 2

    Nintendo dropped the ball big time when they used a string comparison function for evaluating the digital signature hash. String functions terminate early (with success!) for strings where the first byte is null. All an attacker had to do to fakesign a Wii application is brute force change some random unused byte until it caused the first byte of the hash to be 00.

    --
    :(){ :|:& };:
  21. Re:Yikes by Desler · · Score: 2, Informative

    This just in: If I create a program specifically to leak memory it will... LEAK MEMORY!!! Seriously, who is actually writing code like that? And why the fuck would you be creating the string with "new" anyway? Your code makes absolutely no fucking sense and appears to have been written intentionally to be crappy.

  22. Re:Oo isn't all there is by Un+pobre+guey · · Score: 2

    I'd see C extended with supple string handling and regexes, for example. On top of a class model, obviously.

    You mean like C++ with Boost?

  23. Re:Yikes by Desler · · Score: 4, Informative

    Now the program when written the correct way as:

    void testMemory() {
                    std::string s();
                    s.append("sample");
    }

    void testLoop() {
                    for (int x = 0; x 100000; x++) {
                                    testMemory();
                    }
    }

    int main(int argc, char *argv[])
    {
                    testLoop();
                    getchar();
    }

    Will not leak memory. Imagine that. If I don't write the program in a stupid way it won't actually behave stupidly! AMAZING!

  24. Re:For learning by Lord_Naikon · · Score: 2

    You're simplifying things. Most importantly Java has actually all the tools necessary to communicate with the operating system while C/C++ have almost none of them (for instance networking, graphics are missing). Plain C/C++ is not usable as a cross development platform _unless_ you restrict yourself to only use portable (3rd party) libraries. On the other hand, 99% of the Java libraries out there are already completely portable, so every Java program in Java can be made portable with a minimum of changes even if it wasn't designed for that initially, or in simple cases will just work out of the box.

    So I wouldn't say it is as easy in C/C++ as in Java. This has obviously more to do with the standard libraries than the language itself.

  25. Confusing lots of issues by SoftwareArtist · · Score: 4, Interesting

    People tend to lump lots of things as if they were all the same thing, but they're really completely independent:

    Does the language run in a virtual machine, or is compiled down to native assembly in advance?
    Is memory management done explicitly, or is there a garbage collector?
    Does it allow direct access to memory (necessary for some parts of system programming)?
    Does it check for common errors, such as going past the ends of arrays?

    There are garbage collectors for C++. C# runs in a virtual machine, but still permits direct access to memory. STL collections in C++ check for out of bounds indices. So here is how I would categorize different languages, roughly ordered from "most native" to "most managed":

    C++: Incredibly complex, lots of bug opportunities, very verbose, very fast, suitable for system programming
    D: Some complex, some bug opportunities, some verbose, very fast, suitable for system programming
    Objective C: Some complex, some bug opportunities, some verbose, fast, suitable for system programming
    C#: Some complex, some bug opportunities, some verbose, fast, suitable for system programming
    Java: Some complex, some bug opportunities, some verbose, fast, not suitable for system programming
    Scala: Very complex, few bug opportunities, not at all verbose, fast, not suitable for system programming
    Python: Fairly simple, some bug opportunities, not at all verbose, slow, not suitable for system programming

    --
    "I'm too busy to research this and form an educated opinion, but I do have time to tell everyone my uninformed opinion."
  26. Re:Yikes by Xtifr · · Score: 3, Informative

    One could argue that the less deletes you have, more are the chances you have that there is a memory leak...

    <grammar_nazi> fewer </grammar_nazi>

    One could argue that, it's true, but it would most likely be evidence that the person arguing was utterly ignorant of anything that's happened in C++ since the early nineties. Between the container classes of the STL and Boost, and the RAII model, having very few deletes is generally a very good sign, since it shows you're not resorting to too much error prone manual memory management. If the few deletes you have are all in destructors, that only makes it more clear. (And even there, using autoptr or sharedptr is generally vastly superior to trying to figure out when you can issue a manual delete.)

    In modern C++, you can manage vast amounts of memory properly without ever once using delete. In fact, you're more likely to be managing your memory properly if you don't.

  27. Re:For learning by inasity_rules · · Score: 2

    Electronic engineering students. While C++ is taking over the world, I know of at least one course where understanding microprocessor design (let alone assembly language) is a requirement. Unless the course has changes in the short 2 years since I took it...

    --
    I have determined that my sig is indeterminate.
  28. Re:This isn't auto mechanics! by Bengie · · Score: 3, Insightful

    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.

  29. Re:But for learning programming, what's recommende by TemporalBeing · · Score: 3, Insightful

    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.

    --
    Truth is like the sun. You can shut it out for a time, but it ain't goin' away. - Elvis Presley (source: imdb.com)
  30. Re:For learning by Lord_Naikon · · Score: 2

    Why is it so hard to understand that Java, a language DESIGNED for portabilty, is more suitable for cross platform development than C++? You can throw any number of well designed cross platform C++ libraries at C++, it is still NOT part of the language, not part of the standard development platform and therefore it is harder to do cross platform C++ development than in Java. I can not comprehend why you think otherwise. Yes, the disparity in cross platform developement ease between the two may slowly fade in time, especially in the light of the new C++ release which makes a lot of features that you need from an API standard (threads for instance), but to say they are on par is simply an outrageous claim and definitely not a "simple fact".

    Allow me to demonstrate some practical problems with C/C++ cross development between Windows & Unix)
    - Non standard build system (make / vc++), different systems used for different libraries.
    - Different linking process (.so vs .dll/.lib)
    - Wildly differing implementations of the standard C library (stdio in VC++ is severely broken).
    - No network API, so we will have to deal with either manual compatibily shims (more work) or 3rd party library (more work)
    - No GUI API, same as above

    The uniformity in Java is what makes cross platform development such an easy task:
    - Everything is .JAR, build tools the same for all platforms (granted, you still need a Make equivalent, say ant, but the result of the build process is portable)
    - Linking is just throwing a bunch of JARs together
    - There is only one implementation of the standard library that everyone uses.
    - Network API is standard
    - GUI API is standard.

    Now please enlighten me how exactly C++ crossplatform development is just as easy as in Java.

  31. They're both called iOS by tepples · · Score: 2

    Why not just make a new user account that has access only to those resources that a given program may access, and then run the program as that user? That's what iOS for iPhone and IOS for Wii do, I've read.

  32. Re:Yikes by Terrasque · · Score: 2

    I use Python for most things, c/c++ when I feel the need for speed/power.

    And today PyPy released version 1.6 of their python interpreter :) More python speed!

    --
    It's The Golden Rule: "He who has the gold makes the rules."
  33. Re:Yikes by gangien · · Score: 2

    Yes, because managed code has no memory leaks.

    Of course this is true.

    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.

    Then the android platform is a piece a crap. Or your developers suck. Neither of which is very relevant when discussing whether managed code is or isn't a good thing, as there are plenty of good platforms.

    Quite frankly, memory management is not hard.

    Not much in programming is hard. But anything you have to think about is bug prone. Including manual memory management.

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

    I think you are just being stubborn or displaying false bravado.

  34. Re:For learning by Lord_Naikon · · Score: 2

    Yes, I agree with you, and I too use Qt and boost to ease porting. It's still not as easy as Java though :P

    What's wrong with VC++ stdio?

    _snprintf() and _vsnprintf() do not conform to the C99 standard: they do not guarantee NUL termination of the buffer while they should and return the wrong value if the buffer was too small. The former was a mistake of epic proportions if you ask me.
    Microsoft tried to fix that with the non-standard _snprintf_s() and _vsnprintf_s() but these still return the wrong value in case of a buffer overrun.
    I guess they prefix everything with _ because they are unable to implement conforming procedures.