News for hackers. Stuff that matters.
Re:C++ is a hack by evmar on Tuesday February 16, 2016 @12:07PM (#11111302)
"There are only two kinds of languages: the ones people complain about and the ones nobody uses."

- Bjarne Stroustrup

Re:C++ is a hack by stinos on Tuesday February 16, 2016 @12:14PM (#11111376)
Basically, this!

Most of the OP's points are valid, no denying that. But, looking at the myriads of properly working, fast, not 'exploding in your face at runtime', often even beautiful code produced in C++ despite these shortcomings: doesn't really seem like a poblem if one knows how to deal with it.

Re:C++ is a hack by jobu on Tuesday February 16, 2016 @12:50PM (#11111719)
Yeah, after fifteen years of C/C++ I can say most of those complaints are minor, have easy workarounds, or can be ignored when doing general-use programming.
Re:C++ is a hack by stcredzero on Tuesday February 16, 2016 @12:18PM (#11111422)
doesn't really seem like a poblem if one knows how to deal with it

And that is the downfall of all programming languages/paradigms!

Re:C++ is a hack by pcwalton on Tuesday February 16, 2016 @12:33PM (#11111546)
> But, looking at the myriads of properly working, fast, not 'exploding in your face at runtime'

Does remote code execution due to use after free fall in the category of "properly working" and "exploding in your face at runtime"? I would think it does, and C++ is vulnerable to that like few other languages are.

Re:C++ is a hack by dragontamer on Tuesday February 16, 2016 @12:37PM (#11111583)
Why are you using "free" in modern C++ code?

That was mostly put in there as a transition from C. Modern C++ users shouldn't be using new / free at all, since shared_ptr (and weak_ptr, its counterpart) and unique_ptr basically cover all the use cases.

Re:C++ is a hack by pcwalton on Tuesday February 16, 2016 @12:40PM (#11111611)
Whether you actually call "free" doesn't matter. You're falling victim to the "smart pointers/modern C++ is memory safe" fallacy. It is not, for reasons I've elaborated on at length numerous times before.
Re:C++ is a hack by dragontamer on Tuesday February 16, 2016 @01:20PM (#11111925)
So are you going to elaborate again or post a blogpost of your points? Its hard to hold a discussion if the other side doesn't... discuss... things.
Re:C++ is a hack by pcwalton on Tuesday February 16, 2016 @01:27PM (#11111987)

    std::vector<std::string> v;
    v.push_back("Hello");
    for (auto&& s: v) {
        v.clear();
        std::cout << s; // use after free in modern C++
    }
There is no reasonable way for a compiler to precisely check for use after free in C++ short of changing the language, and this can be easily proven.
Re:C++ is a hack by dragontamer on Tuesday February 16, 2016 @02:17PM (#11112376)
Technically, that's a iterator invalidation and those are indeed hard to keep track of. There are runtime libraries that keep track of pointer-invalidation for you however.

In any case, a std::vector<shared_ptr<std::string> > would actually avoid the issue in this particular case.

Use after free... is more about use of raw pointers IMO. I wouldn't describe that code to be a "use after free" at all. In most languages, you are simply not allowed to change the container at all. Iterator invalidation is a hard issue in any language.

Re:C++ is a hack by pcwalton on Tuesday February 16, 2016 @02:40PM (#11112557)
Iterator invalidation does not result in remote code execution in other languages. Regardless of what you call it (and you are in the minority by not considering that code UAF) the result is the same when combined with vtables and attacker-influenced heaps: arbitrary code execution.

shared_ptr is also not memory safe when combined with references, which you need to use to call methods on the shared_ptr'd object or to pass those objects to most functions.

Re:C++ is a hack by gpderetta on Tuesday February 16, 2016 @07:26PM (#11114204)
Tecnically that's reference invalidation and no pure library is going to help you. You need compiler/runtime help (i.e. static analysis or some sort of sanitizer).
Re:C++ is a hack by maccard on Tuesday February 16, 2016 @12:42PM (#11111628)
I don't think the parent meant free as in "free()" - more along the lines of.

  Foo f;
  DoSomething(std::move(f));
  // can still use f here.
Re:C++ is a hack by dragontamer on Tuesday February 16, 2016 @01:23PM (#11111945)
But if "Foo" was composed of unique_ptr (or shared_ptr), then those smart pointers would be nulled out after the std::move (due to the default move constructor)

So again, unless Foo f was composed of "raw pointers", even that kind of code is safe from "use after free" vulnerabilities.

Re:C++ is a hack by stinos on Wednesday February 17, 2016 @02:51PM (#11120704)
Does remote code execution due to use after free fall in the category of "properly working" and "exploding in your face at runtime"? I would think it does

Not exactly. Use after free, while indeed problematic, is not what I would consider proper code, and I think you're well aware of that :]

Re:C++ is a hack by jokoon on Tuesday February 16, 2016 @12:11PM (#11111347)
I wish D will be popular in the future.

Breaking compatibility with C isn't such a bad thing. Also I think C, C++ and D are easily made compatible with each other (I would not bet on that too much though).

Re:C++ is a hack by douche on Tuesday February 16, 2016 @12:20PM (#11111441)
I've been hearing about D for at least ten years. I don't think it's going to really break out at this point - it's been sort of lapped in the trendy, new language corner by Go and Rust and whatnot.
Re:C++ is a hack by kedean on Tuesday February 16, 2016 @01:04PM (#11111816)
Worse, it's been lapped into the 'who cares' corner. D had a burst of buzz for a while, about 10 years ago, but at the time nobody really wanted alternative systems languages. IT got a little support, but mostly people ignored it. Now, you have Go/Rust/Nim jumping into the space and getting lots of Buzz, but if D is mentioned then one of two things will happen:

A) "Oh yeah, that language from the mid 2000s. I didn't want to use it then, why would I use it now?" B) "D? Oh it's from the mid 2000's? I wonder why nobody used it? It probably sucks."

Even if those statements are false, it's hit the same problem that a 50-year old programmer in the job market is going to hit, age discrimination.

Re:C++ is a hack by stcredzero on Tuesday February 16, 2016 @12:17PM (#11111413)
Is the usefulness correlated with frequency and number of complaints? (On first consideration, it kind of seems like it.)
Re:C++ is a hack by angelbob on Tuesday February 16, 2016 @12:38PM (#11111594)
Correlated? Sure. Directly proportional? No. There are language like PHP that get complaints disproportionate to their usage level, for instance.
Re:C++ is a hack by wyager on Tuesday February 16, 2016 @12:45PM (#11111657)
Re:C++ is a hack by kazinator on Tuesday February 16, 2016 @01:15PM (#11111881)
Which covers the situation also of people complaining about languages that other people use. :)