Slashdot Mirror


Bjarne Stroustrup Announces the C++ Core Guidelines

alphabetsoup writes: At CppCon this year, Bjarne Stroustrup announced the C++ Core Guidelines. The guidelines are designed to help programmers write safe-by-default C++ with no run-time overhead. Compilers will statically check the code to ensure no violations. A library is available now, with a static checking tool to follow in October.

Here is the video of the talk, and here are the slides.The guidelines themselves are here.

7 of 262 comments (clear)

  1. News at eleven by Anonymous Coward · · Score: 3, Informative

    Imperative programmers reinvent functional programming concepts, but in a shitty way. More at eleven.

    1. Re:News at eleven by Anonymous Coward · · Score: 0, Informative

      Haskell is faster for HTTP. (I would go so far as to say that functional programming has solved the issue of extremely fast HTTP serving.)

      Haskell is 4x faster than extremely optimized C++ code for parsing subversion log files. (Although admittedly this is a rather specific application.)

      The claim that functional programming sacrifices performance and/or latency (which I don't think you are making, but many people are) is false. Yes, development is needed, but there are plenty of missed opportunities.

  2. Ada had this in 1995 by david.emery · · Score: 3, Informative

    Ada95 added OO features including clear mechanisms (enforced by the compiler) on how to get OO design benefits without runtime performance costs or risks for dispatching.

    Much of what I've seen in C++ is a response to problems in the original language design, particularly gaps or errors of omission.

    Computer Science in the 21st Century seems to be full of stuff we knew about in the '80s and '90s, but forgot.

    1. Re:Ada had this in 1995 by david.emery · · Score: 4, Informative

      That "piece of shit" is in most modern commercial aircraft these days, as well as the ground ATC systems. Guess maybe you shouldn't fly, then, if that's your opinion, Mr Coward.

      There are legitimate criticisms that can be levied against any programming language, as well as against the Ada program. But this comment addresses none of them.

  3. Re:What instead of an exception? by tepples · · Score: 3, Informative

    Every object that can be thrown/caught must implement the Throwable interface

    Then have all exceptions extend a subclass of std::exception . The guidelines mention use of a subclass as opposed to using the built-in exceptions directly.

    the C++ alternative is only allocating objects on the stack and implementing destructors that clean up their resources

    Also called Resource Acquisition Is Initialization (RAII), or "automatic resource destruction" if you don't want to remind readers of the record industry (RIAA).

    but then you have the restriction of not being able to allocate on the heap

    You can take advantage of automatic resource destruction if you wrap your object on the heap in a smart pointer type (std::unique_ptr or std::shared_ptr as appropriate) on the stack. If that isn't appropriate in a given situation, C++11 supports a scope guard idiom using std::shared_ptr and lambda expressions. The finally factory described in the Guidelines is ultimately an update of a method described in a 2000 article by Andrei Alexandrescu in Dr. Dobb's .

  4. Re:Instrumenting c++ to behave like Rust by Tailhook · · Score: 4, Informative

    I found Rust

    I've found it best not to talk about Rust around here. The language has already accumulated a legion of haters at Slashdot. Rational discussion about Rust sans the office punklets happens at Hacker News.

    It was anticipated that Rust would motivate some progress in C++ memory safety. Some have argued that if that is all that Rust accomplishes it is worthwhile. Too bad an entire language has to be invented to get some folks off the dime.

    The uptake of Rust is so large though I don't think it's going to go away just because C++ adopts some degree of compile time memory safety. The language is great on it's own merits, there is none of that half century of baggage to slog through and the entire stack and all native Rust third part modules provide the same memory safety guarantees, barring 'unsafe.'

    These things, combined with the never ending stream of opportunities the segfaults and overflows that C/C++ cannot avoid providing will ensure a chunk of mind-share, haters be damned.

    --
    Maw! Fire up the karma burner!
  5. Re:As always, guidelines are for beginners by Darinbob · · Score: 3, Informative

    I use goto. Sometimes. When you're in C then it's can be effective way to do a function clean up before exiting. Sure this can be over done but trying to avoid a goto like a religious taboo can also result in some pretty nasty code to replace it.