CppCon 2015: Bjarne Stroustrup “Writing Good C++14”

Sdílet
Vložit
  • čas přidán 22. 09. 2015
  • www.cppcon.org
    --
    Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/isocpp/CppCoreGuid...
    --
    How do we use C++14 to make our code better, rather than just different? How do we do so on a grand scale, rather than just for exceptional programmers? We need guidelines to help us progress from older styles, such as “C with Classes”, C, “pure OO”, etc. We need articulated rules to save us from each having to discover them for ourselves. Ideally, they should be machine-checkable, yet adjustable to serve specific needs.
    In this talk, I describe a style of guidelines that can be deployed to help most C++ programmers. There could not be a single complete set of rules for everybody, but we are developing a set of rules for most C++ use. This core can be augmented with rules for specific application domains such as embedded systems and systems with stringent security requirements. The rules are prescriptive rather than merely sets of prohibitions, and about much more than code layout. I describe what the rules currently cover (e.g., interfaces, functions, resource management, and pointers). I describe tools and a few simple classes that can be used to support the guidelines.
    The core guidelines and a guideline support library reference implementation will be open source projects freely available on all major platforms (initially, GCC, Clang, and Microsoft).
    --
    Videos Filmed & Edited by Bash Films: www.BashFilms.com
    *-----*
    Register Now For CppCon 2022: cppcon.org/registration/
    *-----*

Komentáře • 140

  • @JCStelu
    @JCStelu Před 8 lety +154

    "- Doctor, doctor, it hurts when I hit myself in the head with the hammer!
    - So don't do it!"
    Thank you, Bjarne! :-))

  • @thesanctuary225
    @thesanctuary225 Před 5 lety +41

    Thank you sir Dennis Ritchie.
    Thank you sir Bjarne Stroustrup.
    You totally changed history of mankind.

  • @TheLappin
    @TheLappin Před 5 lety +11

    I feel like Rust and C++ are trying to do the same thing, starting from opposite directions. Rust started out safe, C++ started out expressive and both languages tries to move towards being both expressive and safe. They both have their use cases. C++ integrates well with legacy code, is already well established and has much library support. Rust is still getting there, but it has come very far since this talk took place and I think it's now ready to be adopted for new projects.
    Great talk, by the way!

    • @BB-lf5zm
      @BB-lf5zm Před 5 lety +1

      Rust has a lot of static analysis to make sure the code is safe, but a little too much to be enjoyable

    • @TheLappin
      @TheLappin Před 5 lety +5

      @@BB-lf5zm It's possible to get used to it. Initially when learning Rust, you'd have to fight the borrow checker a lot and it might not be all that enjoyable (for me this period lasted for months), but after some practice it's not that bad at all. And the advantages of the static analysis is not to be understated, particularly as your project grows larger it can be incredibly helpful. There are so many memory related problems that I can immediately rule out when searching for the cause of a bug in my program. Never getting segmentation faults is pretty neat too.

  • @enhex
    @enhex Před 8 lety +69

    "competing with C++ over the years has not been a winning strategy."

  • @VoidloniXaarii
    @VoidloniXaarii Před 8 měsíci

    Here in 2023 didn't think this 2014 c++ talk was worth my time... but then gave it a random shot... either this guy has charisma +7 or this is amazing.. or both? His book being delivered tomorrow... excited...

  • @maxx666mayhem
    @maxx666mayhem Před 8 lety +25

    Awesome video by Bjarne as always.. Thanks for sharing...

    • @josephlagrange9531
      @josephlagrange9531 Před rokem

      Dijkstra and Wirth spoke negatively about C++. Stroustrup lobbied C++ at that time. At fact I agree with some dudes claiming Stroustroup is far from good designer.

  • @NikolasDanielEngels
    @NikolasDanielEngels Před 8 lety +12

    Although all the restrions of C++, Bjarne and others always came with new ideas that respect the principles from the day one.
    Wonderful talk! C++ keeps going to be a better language for those who take programming as professionals...

  • @LydellAaron
    @LydellAaron Před 4 lety +7

    I like his mention at 11:20 for not allocating memory "malloc()" "new()" in reference to C/C++' use in flight critical systems. You want to do your non-deterministic memory allocations upfront or outside of deterministic real-time time-critical code sections.

    • @forgetfulfunctor1
      @forgetfulfunctor1 Před 2 lety +2

      I'm just asking cause I mightnt know the terms like how you're using them, but did you get deterministic and non- flipped?

  • @MikeDiack
    @MikeDiack Před 8 lety +3

    Again absolutely right SS. The avoidance of using new keywords and overloading the others etc. also makes it more difficult for compiler writers / static analysis tool developers - to develop and extend those tools as well.

  • @cgazzz
    @cgazzz Před 4 lety +5

    1:14:00, I did this exact thing as it was a huge problem where half the codebase was const correct and half wasn't. After explaining to my boss why propagate_const is needed to deal with it he said const correctness didn't really matter as you can get around it with mutable. About the same time that I quit.

  • @lodathi
    @lodathi Před 8 lety +6

    Amazing truths! I wish more young graduates thought this way.

  • @aeluned
    @aeluned Před 8 lety +6

    You just don't need most of that old style code for most tasks. And it's prone to human error. Give the compiler the intent you have and let it protect you from human error as much as possible. The old dark corners of C++ are so rarely needed. This is a such a powerful language and also a very stigmatized one because of that sort of thinking. Of course the old stuff will never go away, but let's be honest about how useful it is. Easy to learn, hard to master. That is a versatile language.

    • @BB-lf5zm
      @BB-lf5zm Před 5 lety

      For a normal desktop/enterprise applications, probably not, but if you get into gaming industry or applications requiring high performance, you will be surprised to find many dark side commonly. A simple pointer direct might damage the performance

  • @MrTargetSan
    @MrTargetSan Před 8 lety +6

    mr. Stroustrup said many right things.
    There's only one problem I see with them.
    C++ is a language of "unsound defaults". So making your code "sound" will require tons of work.
    In C++, the price to make an error is almost zero, but to fix it isn't.

  • @aliancemd
    @aliancemd Před 8 lety +6

    Very good talk. I am really torn between Rust and Modern C++...
    C++ has evolved very nicely but sadly, where I work people are afraid of using a newer compiler and newer features(actually, not afraid, lazy to learn new stuff is more accurate). We are still using GCC 4.4... Can't even use sanitizers, what to say of C++11, 14 and 17...

    • @Exachad
      @Exachad Před 6 lety +4

      I'm gonna puke! GCC 4.4?

    • @BB-lf5zm
      @BB-lf5zm Před 5 lety +2

      Get out of there now

  • @clodgozon3968
    @clodgozon3968 Před 5 lety

    I clearly understand the topic. Good job, C++ Creator!

  • @fritzschnitzmueller3768
    @fritzschnitzmueller3768 Před 3 lety +2

    I love bjarnes random book covers(e.g. Mountains or birds for c++ books-its funny) and love that he choose a wind power plant as beginning slide for this presentation :

    • @desertshadow72
      @desertshadow72 Před rokem +1

      I imagine his mind sees more beauty and complexity in the commonplace simple things so they are impressive to him.

  • @QuentinUK
    @QuentinUK Před 8 lety +30

    GSL Guidelines Standard Library.

  • @dudanov
    @dudanov Před 5 lety +1

    Thank you, Bjarne!

  • @MikeDiack
    @MikeDiack Před 8 lety +4

    Again, absolutely right. C++ must stop extending as a language. Many of us are not en fully au fait with all of C++11, never mind 14, 17 etc...

  • @ekimr90
    @ekimr90 Před 8 lety +9

    Of course there's dislikes! It's because C++14 isn't Assembly.

  • @annaoaulinovna
    @annaoaulinovna Před 3 lety +1

    c++ is awesome this guy must take nobel prize of computer science

  • @baltazarus3307
    @baltazarus3307 Před 4 lety +1

    Excellent presentation Mr. Stroustrup, I enjoyed.

  • @razterizer
    @razterizer Před 8 lety +27

    Bjarne rules.

  • @TheHappyDoomsayer
    @TheHappyDoomsayer Před 8 lety +5

    One has to understand that it is not required to know the full language to use it. See the slide at around 3:00, don't get lost in details and if you don't like X, don't use it.
    Across the millions of C++ users, every small addition is probably going to help thousands of people. If it doesn't help you, ignore it

  • @philophile147
    @philophile147 Před 8 lety

    This is actually a pretty clever place to do recruiting. Then again, hardcore cpp lovers have opportunities galore. I'd be interested in hearing about the magnitude of response you get!

  • @prafulsrivastava8942
    @prafulsrivastava8942 Před 2 lety

    I wonder what I would have done without CppCon. Keep up the good work!

  • @DaveYostCom
    @DaveYostCom Před 8 lety +3

    54:59 With these guidelines you can get perfect resource safety and resource safety. The talk perhaps should have started here.

  • @atoshdustosh2762
    @atoshdustosh2762 Před 6 měsíci

    Very useful concepts.

  • @GeorgeTsiros
    @GeorgeTsiros Před 5 lety

    GARRETT turbo, i'm sold 🤘

  • @Littlefighter1911
    @Littlefighter1911 Před 7 lety +6

    34:32 I accidentally did this and it has NOT been caught be the compiler, neither MSVC nor GCC.

  • @adrienhamelin484
    @adrienhamelin484 Před 8 lety +2

    That is exactly what he wants, to only teach the new stuff. Look at 1:27:40.
    The things like "owner" are only meant as low-level stuff for people that write containers and such, otherwise smart pointers remain the way to go (if you need ownership).

  • @michal.gawron
    @michal.gawron Před 8 lety

    I think that it's good to have a good teacher of C++, so people won't be scared. Bjarne is a good teacher, IMHO. ;-)

  • @AbcDino843
    @AbcDino843 Před 4 lety +7

    26:15, umm, should that not be q->use()?

  • @vimleshkumarkanaujiya
    @vimleshkumarkanaujiya Před 3 lety

    Legend behind Real Programming Language...

  • @X152535
    @X152535 Před 7 lety +4

    Has anybody reviewed the GCC compiler's source code recently to make sure the NSA didn't slip any other trojans in there?

    • @melvyniandrag
      @melvyniandrag Před 7 lety

      not yet lets do it

    • @gordongoodman8342
      @gordongoodman8342 Před 6 lety +1

      Any other trojans? Are you implying it was done before?

    • @ProphetPX
      @ProphetPX Před 6 lety +1

      hahaha what do you think "Security Enhanced" Linux distros are??? LOLLL :)

  • @KananDethin
    @KananDethin Před 7 lety +1

    Thank you.
    Watched the whole video.

  • @antonpetrenko9176
    @antonpetrenko9176 Před 2 lety

    one of the best hydra fighter!=)

  • @MrTargetSan
    @MrTargetSan Před 8 lety +2

    It's not propaganda. Maybe a bit of trolling from my side, yes.
    I really enjoy that committee started some real improvements. I just feel they're a bit slow and late. Development model with core team on a reference compiler and a large contributing community already shows better results.

  • @Trollkemada
    @Trollkemada Před 8 lety

    You should probably add the github link to the video description.

  • @SunggukLim
    @SunggukLim Před 7 lety +1

    he is good speaker

  • @andik70
    @andik70 Před 8 lety +5

    anybody has some links to good c++(14) code? (not the guideline, just leading by example)

  • @maximmarchal9991
    @maximmarchal9991 Před 3 lety +1

    11:40 wait why wouldn't they use new and delete after take-off?

  • @deusbuda
    @deusbuda Před 8 lety

    muito bom...

  • @mousedresden604
    @mousedresden604 Před 8 lety

    What is the URL for the materials he mentions in the talk?

    • @rock00dom
      @rock00dom Před 8 lety +7

      github.com/Microsoft/GSL
      github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md

  • @kousoulides
    @kousoulides Před 4 lety +6

    writing good C++ 98 code
    writing good C++ 11 code
    writing good C++ 14 code
    writing good C++ 17 code
    writing good C++ 20 code
    writing good C++ Java code
    dude stop, you had me at
    C++98

  • @JaihindhReddy
    @JaihindhReddy Před 7 lety

    Bjarne said there is a simpler, smaller, safer language in c++ struggling to get out. Is Google's Go an attempt to build that smaller, simpler and safer language from the ground up? Just how good is Go? Can someone point me in the right direction here? There just seem to be too many ways to do anything in c++?

  • @robfielding8566
    @robfielding8566 Před 8 lety +1

    Indeed it's fast at runtime. But C++ is not efficient for verifying correctness, and is slow to compile. I love the idea of compilers subsetting C++ as part of the fix. not_null should be the default, undefined behavior should always be a compiler warning that needs an explicit annotation at that point in order to proceed.

  • @VamoAComeLaPapa
    @VamoAComeLaPapa Před 8 lety

    This is not a language war, my friends!

  • @MrTargetSan
    @MrTargetSan Před 8 lety +3

    Dear mr. Stroustrup, if you want someone to use GSL, please at least move all what's not interface into separate INL file. Because parsing 2078 SLOC file to determine what's public and what's not isn't very pleasant.

  • @childhood1888
    @childhood1888 Před 2 lety

    One should not quote himself but it is a good quote.🙂

  • @raj8041
    @raj8041 Před 2 lety

    Hello sir, thank you so much for this lovely c++.
    Is it possible to write a singleton class using smart pointers, and that should be thread safe as well?

  • @SatansSpatula
    @SatansSpatula Před 8 lety +20

    Bjarne says we need a language or guideline where you don't have to be a language lawyer to use C++. Then he proceeds to show slide after slide of poorly explained language lawyer nonsense.
    You've spent too many years obsessing on ownership semantics, clever use of iterators, and refusal to introduce new keywords, preferring to overload existing ones. I've spent more time re-learning C++ every few years than I would have spent simply transitioning into new languages.

  • @michaelmoser4537
    @michaelmoser4537 Před 8 lety +1

    the GSL library is here
    github.com/Microsoft/GSL
    but so far i don't see the static analysis tool.
    Great that Mr. Stroustrup is working for a company where mortal programmers have real problems with pointer ;-) I wonder if C++ would have been a better language now if he did that ten years ago.

  • @thesanctuary225
    @thesanctuary225 Před 5 lety +1

    C is Wonderful Language.
    C++ is Wonderful too.
    It was really good idea that, when he create C++, didn't change C itself.
    (He presented good respect to his predecessor, Dennis.)
    Thus, we can enjoy C as well as C++ with same file format, cpp.

  • @aliveho2720
    @aliveho2720 Před 6 lety

    I love c++;

  • @TheBuzzSaw
    @TheBuzzSaw Před 8 lety +2

    I strongly disagree. C++11 and C++14 introduce infrastructure meant to replace much of how things were done in C++98. The old stuff will never go away, but it is BETTER and EASIER if a newbie starts out learning std::unique_ptr, range-based for-loops, etc.

  • @brotherhood_of_harkonnen

    24:52: resource management

  • @desertshadow72
    @desertshadow72 Před rokem

    Talk really gets started around 7:00 ish

  • @enhex
    @enhex Před 8 lety +1

    I have a different view on it. If there's something you don't like you probably don't understand what it's used for.

  • @MrTargetSan
    @MrTargetSan Před 8 lety +1

    Unless you try to debug code buried deep in something like Boost's MPL templates. You need to know language just to understand what others wrote.

  • @user-mi8es4ur5w
    @user-mi8es4ur5w Před 8 lety +1

    Свершилось! Лед тронулся еще в 11, но 14 это уже будующее в настоящем.

  • @freshsheets_
    @freshsheets_ Před 6 lety +1

    So basically just don't use 'new' or 'delete'

  • @chaosmeist3r
    @chaosmeist3r Před 8 lety

    already fixed in the repository

  • @moseswachira1165
    @moseswachira1165 Před 8 lety

    congrant

  • @Illasera
    @Illasera Před 7 lety +23

    Writing good C++ code, you don't, And never forget, "Avoing using linked list because, bad" - Bjarne Stroustrup

  • @josephlagrange9531
    @josephlagrange9531 Před rokem +1

    Dijkstra and Wirth spoke negatively about C++. Stroustrup lobbied C++ at that time. At fact I agree with some dudes claiming Stroustroup is far from good designer.

  • @thesanctuary225
    @thesanctuary225 Před 5 lety +3

    C++ is not hard to learn if you aleady mastered C.
    So learn C first and master it.
    Than learn C++.
    Now it's much easier.

  • @stupid_sleazoid2
    @stupid_sleazoid2 Před 6 lety

    0:13 guy in a hat - Larry Wall? (for comparison: czcams.com/video/HAXGD3JE7pU/video.html)

  • @chaosmeist3r
    @chaosmeist3r Před 8 lety +1

    26:00 "q" is a pointer, but instead of using the "->" operator for pointers, he uses the "." operator :/

  • @todorsamardzhiev144
    @todorsamardzhiev144 Před 8 měsíci

    3:10 oof, based

  • @SatansSpatula
    @SatansSpatula Před 8 lety +1

    Furthermore, I've got, what, four or more pointer wrappers, but I still don't have a decent string utility class that supports practical Unicode processing and useful member functions. No string::ToUpper, I still have to cobble something together with std::algorithm and bizarre char_traits members. C++ just isn't worth the effort. Put that energy into improving your architecture and algorithm selection in a better language.

    • @ledues3336
      @ledues3336 Před 7 lety

      What about
      std::string s = "This has lowercase characters";
      {
      int i = 0;
      while (s) {
      s[i] = toupper(s[i]);
      i++;
      }
      }
      // ps: there exists a tolower function too.

    • @ledues3336
      @ledues3336 Před 7 lety

      oops I meant ++i

    • @vladimirsadovnikov3797
      @vladimirsadovnikov3797 Před 6 lety

      And you'll get overhead of double-checking index parameter when calling both operator [] statements on each iteration. Nice performance!

    • @SrIgort
      @SrIgort Před 4 lety +1

      std::transform(beg, end, std::toupper)

  • @enhex
    @enhex Před 8 lety +1

    57:27 Is that Gabe Newell?

  • @MikeDiack
    @MikeDiack Před 8 lety +3

    Absolutely right SS. C++ has just turned into a mess.

  • @Jiskov
    @Jiskov Před 8 lety

    Why not both? Rust is an amazing leap forward in language tech, but there's no need to throw away what you know. The concepts in both Rust and modern C++ compliment each other, and both languages can easily coexist. Plus, Rust is getting big enough that it doesn't even need to poach mindshare from C++ anymore.

  • @f8881f
    @f8881f Před 5 lety

    43:56

  • @amirishere
    @amirishere Před 8 lety +1

    Every time you say "it's painful", I want to say "I feel your pain".

  • @DimitriSabadie
    @DimitriSabadie Před 8 lety +2

    As a Haskeller, I just laughed my ass off watching that.

  • @childhood1888
    @childhood1888 Před 2 lety

    31:33

  • @unk1nd7
    @unk1nd7 Před 8 lety

    LOL xDD

  • @voxelamateur
    @voxelamateur Před rokem +2

    A _smaller_ and _simpler_ C++? the man has lost its mind...

  • @philophile147
    @philophile147 Před 8 lety

    I know a UX designer who may be interested, messaging him now.

  • @moderncpp
    @moderncpp Před rokem

    4:25 Carbon folks don't want to listen!

  • @user-tr3qt3qs9t
    @user-tr3qt3qs9t Před 6 lety +7

    The good C++ already exists and it is called D. Instead of adding more keywords and new layers of abstract concepts they would better just throw away all the heaps of random junk they have already added during the last 20 years and see how C-like OOP, templates and proper memory management for medium to big projects should really look like.

    • @ytsas45488
      @ytsas45488 Před 5 lety

      Use Rust. It doesn't fall for the same backwards-compatible spaghetti that dooms C++, and doesn't use a tracing GC like D does unnecessarily. And D has questionable decisions, such as carryovers like function overloading and arbitrary additions like @properties.

  • @13Septem13
    @13Septem13 Před 8 lety

    No lol

  • @aigarius
    @aigarius Před 7 lety

    Yay, C++ community has invented pylint.

  • @biplabdas2408
    @biplabdas2408 Před 6 lety

    shit is better/.........

  • @VamoAComeLaPapa
    @VamoAComeLaPapa Před 8 lety +1

    Rust propaganda machine detected (I mean, Rust trolls). Nice language, enjoy it, but without trolling.

  • @kushagraverma7855
    @kushagraverma7855 Před 2 lety

    rust

  • @marianwitek403
    @marianwitek403 Před 8 lety +1

    fuck!!! I love C++ but this? many things are adding like pushing wall ;/ remeber spaghetti code at 80's 90's, object oriented programming was one of solve this problem including c++, now, if this modern c++ isn't spaghetti code what the fuck is!? I understand language must to evolution, example c++11 but knowing every difficulty to coding and solving problems that should be enjoyable but this is bull shit!! More pleasure writing assembly

  • @MrTargetSan
    @MrTargetSan Před 8 lety

    Let's say "--enforce rust-use" flag :)

  • @Littlefighter1911
    @Littlefighter1911 Před 7 lety

    He sounds a little like Trump and Dr.Evil (from Austin Powers) ._.
    Not the content, but the way of speaking.

  • @dawidbujak
    @dawidbujak Před 6 lety

    Bjarne, change haircut please

  • @martinda7446
    @martinda7446 Před 7 lety +1

    C++ is just a bit better than mediocre.

  • @paxdei1988
    @paxdei1988 Před 7 lety +2

    Go is crippled rubbish.

    • @TheMrKeksLp
      @TheMrKeksLp Před 2 lety

      Go and C++ aren't in the same class of tools so it's a bit unfair to say Go is a bad version of C++

  • @zahash1045
    @zahash1045 Před rokem +1

    A better title would be "how to write rust but in c++" lol

  • @chronius9496
    @chronius9496 Před 8 lety +2

    Actually it is bullshit, if you need to write new code, but also maintain another you need to understand all of it. C++ is bloated and fat feature monster. Is it bad or good only time will show.

  • @SleazyNice
    @SleazyNice Před 6 lety +2

    Writing Good C++ code is not possible because C++ is shit. All OOP is shit and should not be used.