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

3 of 616 comments (clear)

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

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