Live data from Hacker News

Bjarne Stroustrup – The Essence of C++ [video]

channel9.msdn.com

1–10 of 85 posts

Re: Bjarne Stroustrup – The Essence of C++ [video]

#2
I think I watched all the talks from Going Native 2012, and I highly recommend them [1]. I expect 2013's will be just as good, though I won't have time to watch any for a while. Here are the others: http://channel9.msdn.com/Events/GoingNative/2013?sort=sequen...

[1] http://channel9.msdn.com/Events/GoingNative/GoingNative-2012...

Re: Bjarne Stroustrup – The Essence of C++ [video]

#4
I posted some of the others while they were live : https://news.ycombinator.com/item?id=6336789 https://news.ycombinator.com/item?id=6336778

Hopefully we can have an interesting discussions on those topics now that at least 1 news about them has reached the main page.

Re: Bjarne Stroustrup – The Essence of C++ [video]

#5
really interesting to see classes as ressource manager above all, instead of concept incarnation. I was almost convinced to go back to C++ until the slide with auto range and all, combining new features of C++, at which point i remembered why i didn't want ro have a look at C++ code again.

but hey, i'm not a system programmer so i can afford it :)

Re: Bjarne Stroustrup – The Essence of C++ [video]

#7
post #5

really interesting to see classes as ressource manager above all, instead of concept incarnation. I was almost convinced to go back to C++ until the slide with auto range and all, combining new features of C++, at which point i remembered why i didn't want ro have a look at C++ code again. but hey, i'm not a system programmer so i can afford it :)

RAII ("classes as resource manager") is one of the nice concepts in C++. My favourite is certainly const correctness.

And then there's tons of things that creep me out a bit. Being a multi paradigm language sounds good on paper, but it seems to cause a lot of accidental complexity. The best way to stay sane is probably to pick a certain subset of C++ for your project and stick to that, that's what I tend to do.

Then again, that's not uncommon in simpler languages either. "JavaScript, The Good Parts", lint and all that. Code accessibility matters IMO.

Re: Bjarne Stroustrup – The Essence of C++ [video]

#8
post #6

I liked this snippet about pointer misuse: void f(int n, int x) { Gadget* p = new Gadget(n); // look I'm a java programmer! :) // ... if(x

I rather prefer Java:

    void f(int n, int x) {
        Gadget p = new Gadget(n);
        // ...
        if (x 
Yes, good night's sleep tonight after writing that...

Re: Bjarne Stroustrup – The Essence of C++ [video]

#9
post #6

I liked this snippet about pointer misuse: void f(int n, int x) { Gadget* p = new Gadget(n); // look I'm a java programmer! :) // ... if(x

I rather prefer Java: void f(int n, int x) { Gadget p = new Gadget(n); // ... if (x Yes, good night's sleep tonight after writing that...

The point of the example is that this is how NOT to do it in C++.

There are two better options:

  void f(int n, int x) {
      Gadget p(n); // Stack allocated
      // ...
      if (x 
Or, if it really has to be a pointer:

  void f(int n, int x) {
      std::unique_ptr p = new Gadget(n); // Smart pointer
      // ...
      if (x 
Both will be automatically freed as soon as the scope is exited.

Re: Bjarne Stroustrup – The Essence of C++ [video]

#10
post #6

I liked this snippet about pointer misuse: void f(int n, int x) { Gadget* p = new Gadget(n); // look I'm a java programmer! :) // ... if(x

I rather prefer Java: void f(int n, int x) { Gadget p = new Gadget(n); // ... if (x Yes, good night's sleep tonight after writing that...

The point is not about C++ vs Java, it is rather about writing C++ like you would write Java, which leads to leaks.
Post reply on HN