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

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ก.ย. 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/
    *-----*

ความคิดเห็น • 140

  • @JCStelu
    @JCStelu 8 ปีที่แล้ว +156

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

    • @kamilziemian995
      @kamilziemian995 ปีที่แล้ว +1

      What to do when my hammer is C++?

  • @thesanctuary225
    @thesanctuary225 5 ปีที่แล้ว +41

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

  • @VoidloniXaarii
    @VoidloniXaarii 9 หลายเดือนก่อน +1

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

  • @TheLappin
    @TheLappin 5 ปีที่แล้ว +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 5 ปีที่แล้ว +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 5 ปีที่แล้ว +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 8 ปีที่แล้ว +70

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

  • @maxx666mayhem
    @maxx666mayhem 8 ปีที่แล้ว +25

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

    • @josephlagrange9531
      @josephlagrange9531 ปีที่แล้ว

      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 8 ปีที่แล้ว +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...

  • @lodathi
    @lodathi 8 ปีที่แล้ว +6

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

  • @clodgozon3968
    @clodgozon3968 5 ปีที่แล้ว

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

  • @MikeDiack
    @MikeDiack 8 ปีที่แล้ว +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.

  • @LydellAaron
    @LydellAaron 4 ปีที่แล้ว +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 2 ปีที่แล้ว +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?

  • @prafulsrivastava8942
    @prafulsrivastava8942 2 ปีที่แล้ว

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

    • @CppCon
      @CppCon  2 ปีที่แล้ว

      Thanks!

  • @dudanov
    @dudanov 5 ปีที่แล้ว +1

    Thank you, Bjarne!

  • @fritzschnitzmueller3768
    @fritzschnitzmueller3768 3 ปีที่แล้ว +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 ปีที่แล้ว +1

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

  • @MrTargetSan
    @MrTargetSan 8 ปีที่แล้ว +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.

  • @aeluned
    @aeluned 8 ปีที่แล้ว +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 5 ปีที่แล้ว

      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

  • @MikeDiack
    @MikeDiack 8 ปีที่แล้ว +3

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

  • @cgazzz
    @cgazzz 4 ปีที่แล้ว +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.

  • @philophile147
    @philophile147 8 ปีที่แล้ว

    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!

  • @Littlefighter1911
    @Littlefighter1911 7 ปีที่แล้ว +6

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

  • @baltazarus3307
    @baltazarus3307 4 ปีที่แล้ว +1

    Excellent presentation Mr. Stroustrup, I enjoyed.

  • @annaoaulinovna
    @annaoaulinovna 3 ปีที่แล้ว +1

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

  • @QuentinUK
    @QuentinUK 8 ปีที่แล้ว +30

    GSL Guidelines Standard Library.

  • @KananDethin
    @KananDethin 7 ปีที่แล้ว +1

    Thank you.
    Watched the whole video.

  • @GeorgeTsiros
    @GeorgeTsiros 5 ปีที่แล้ว

    GARRETT turbo, i'm sold 🤘

  • @X152535
    @X152535 7 ปีที่แล้ว +5

    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 7 ปีที่แล้ว

      not yet lets do it

    • @gordongoodman8342
      @gordongoodman8342 6 ปีที่แล้ว +1

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

    • @ProphetPX
      @ProphetPX 6 ปีที่แล้ว +1

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

  • @ekimr90
    @ekimr90 8 ปีที่แล้ว +9

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

  • @DaveYostCom
    @DaveYostCom 8 ปีที่แล้ว +3

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

  • @atoshdustosh2762
    @atoshdustosh2762 8 หลายเดือนก่อน

    Very useful concepts.

  • @michal.gawron
    @michal.gawron 8 ปีที่แล้ว

    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. ;-)

  • @vimleshkumarkanaujiya
    @vimleshkumarkanaujiya 3 ปีที่แล้ว

    Legend behind Real Programming Language...

  • @aliancemd
    @aliancemd 8 ปีที่แล้ว +5

    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 6 ปีที่แล้ว +4

      I'm gonna puke! GCC 4.4?

    • @BB-lf5zm
      @BB-lf5zm 5 ปีที่แล้ว +2

      Get out of there now

  • @maximmarchal9991
    @maximmarchal9991 3 ปีที่แล้ว +1

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

  • @antonpetrenko9176
    @antonpetrenko9176 2 ปีที่แล้ว

    one of the best hydra fighter!=)

  • @AbcDino843
    @AbcDino843 4 ปีที่แล้ว +7

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

    • @KangJangkrik
      @KangJangkrik 3 ปีที่แล้ว +1

      That's the point of the topic

  • @kaboissonneault
    @kaboissonneault 8 ปีที่แล้ว +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

  • @andik70
    @andik70 8 ปีที่แล้ว +5

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

  • @razterizer
    @razterizer 8 ปีที่แล้ว +27

    Bjarne rules.

  • @JaihindhReddy
    @JaihindhReddy 7 ปีที่แล้ว

    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++?

  • @adrienhamelin484
    @adrienhamelin484 8 ปีที่แล้ว +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).

  • @deusbuda
    @deusbuda 8 ปีที่แล้ว

    muito bom...

  • @SunggukLim
    @SunggukLim 7 ปีที่แล้ว +1

    he is good speaker

  • @MrTargetSan
    @MrTargetSan 8 ปีที่แล้ว +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.

  • @mousedresden604
    @mousedresden604 8 ปีที่แล้ว

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

    • @rock00dom
      @rock00dom 8 ปีที่แล้ว +7

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

  • @Trollkemada
    @Trollkemada 8 ปีที่แล้ว

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

  • @VamoAComeLaPapa
    @VamoAComeLaPapa 8 ปีที่แล้ว

    This is not a language war, my friends!

  • @childhood1888
    @childhood1888 2 ปีที่แล้ว

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

  • @brotherhood_of_harkonnen
    @brotherhood_of_harkonnen 2 ปีที่แล้ว

    24:52: resource management

  • @raj8041
    @raj8041 2 ปีที่แล้ว

    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?

  • @aliveho2720
    @aliveho2720 6 ปีที่แล้ว

    I love c++;

  • @kousoulides
    @kousoulides 5 ปีที่แล้ว +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

  • @robfielding8566
    @robfielding8566 8 ปีที่แล้ว +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.

  • @desertshadow72
    @desertshadow72 ปีที่แล้ว

    Talk really gets started around 7:00 ish

  • @MrTargetSan
    @MrTargetSan 8 ปีที่แล้ว +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.

  • @michaelmoser4537
    @michaelmoser4537 8 ปีที่แล้ว +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.

  • @user-mi8es4ur5w
    @user-mi8es4ur5w 8 ปีที่แล้ว +1

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

  • @chaosmeist3r
    @chaosmeist3r 8 ปีที่แล้ว

    already fixed in the repository

  • @thesanctuary225
    @thesanctuary225 5 ปีที่แล้ว +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.

  • @enhex
    @enhex 8 ปีที่แล้ว +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.

  • @freshsheets_
    @freshsheets_ 6 ปีที่แล้ว +1

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

  • @moseswachira1165
    @moseswachira1165 8 ปีที่แล้ว

    congrant

  • @MrTargetSan
    @MrTargetSan 8 ปีที่แล้ว +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.

  • @Illasera
    @Illasera 8 ปีที่แล้ว +22

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

  • @stupid_sleazoid2
    @stupid_sleazoid2 7 ปีที่แล้ว

    0:13 guy in a hat - Larry Wall? (for comparison: th-cam.com/video/HAXGD3JE7pU/w-d-xo.html)

  • @thesanctuary225
    @thesanctuary225 5 ปีที่แล้ว +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.

  • @TheBuzzSaw
    @TheBuzzSaw 8 ปีที่แล้ว +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.

  • @f8881f
    @f8881f 5 ปีที่แล้ว

    43:56

  • @childhood1888
    @childhood1888 2 ปีที่แล้ว

    31:33

  • @SatansSpatula
    @SatansSpatula 8 ปีที่แล้ว +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.

  • @todorsamardzhiev144
    @todorsamardzhiev144 9 หลายเดือนก่อน

    3:10 oof, based

  • @chaosmeist3r
    @chaosmeist3r 8 ปีที่แล้ว +1

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

    • @viacheslav1392
      @viacheslav1392 ปีที่แล้ว

      of course there is a macro man
      #define . ->

  • @enhex
    @enhex 8 ปีที่แล้ว +1

    57:27 Is that Gabe Newell?

  • @Jiskov
    @Jiskov 8 ปีที่แล้ว

    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.

  • @SatansSpatula
    @SatansSpatula 8 ปีที่แล้ว +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 7 ปีที่แล้ว

      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 7 ปีที่แล้ว

      oops I meant ++i

    • @vladimirsadovnikov3797
      @vladimirsadovnikov3797 6 ปีที่แล้ว

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

    • @SrIgort
      @SrIgort 4 ปีที่แล้ว +1

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

  • @josephlagrange9531
    @josephlagrange9531 ปีที่แล้ว

    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.

  • @MikeDiack
    @MikeDiack 8 ปีที่แล้ว +2

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

  • @amirishere
    @amirishere 8 ปีที่แล้ว +1

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

  • @DimitriSabadie
    @DimitriSabadie 8 ปีที่แล้ว +2

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

  • @moderncpp
    @moderncpp ปีที่แล้ว

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

  • @user-tr3qt3qs9t
    @user-tr3qt3qs9t 7 ปีที่แล้ว +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 5 ปีที่แล้ว

      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.

  • @philophile147
    @philophile147 8 ปีที่แล้ว

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

  • @unk1nd7
    @unk1nd7 8 ปีที่แล้ว

    LOL xDD

  • @voxelamateur
    @voxelamateur ปีที่แล้ว +1

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

  • @13Septem13
    @13Septem13 8 ปีที่แล้ว

    No lol

  • @aigarius
    @aigarius 7 ปีที่แล้ว

    Yay, C++ community has invented pylint.

  • @biplabdas2408
    @biplabdas2408 6 ปีที่แล้ว

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

  • @kushagraverma7855
    @kushagraverma7855 2 ปีที่แล้ว

    rust

  • @VamoAComeLaPapa
    @VamoAComeLaPapa 8 ปีที่แล้ว +1

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

  • @marianwitek403
    @marianwitek403 8 ปีที่แล้ว +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 8 ปีที่แล้ว

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

  • @Littlefighter1911
    @Littlefighter1911 7 ปีที่แล้ว

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

  • @zahash1045
    @zahash1045 ปีที่แล้ว +1

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

  • @dawidbujak
    @dawidbujak 6 ปีที่แล้ว

    Bjarne, change haircut please

  • @martinda7446
    @martinda7446 7 ปีที่แล้ว +1

    C++ is just a bit better than mediocre.

  • @paxdei1988
    @paxdei1988 8 ปีที่แล้ว +2

    Go is crippled rubbish.

    • @TheMrKeksLp
      @TheMrKeksLp 3 ปีที่แล้ว

      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++

  • @chronius9496
    @chronius9496 8 ปีที่แล้ว +1

    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 7 ปีที่แล้ว +1

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

    • @tomburris8380
      @tomburris8380 6 ปีที่แล้ว +3

      Really? What would you suggest as an alternative? :)

    • @SleazyNice
      @SleazyNice 6 ปีที่แล้ว +1

      Just use C.