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

  Рет қаралды 341,555

CppCon

CppCon

8 жыл бұрын

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 жыл бұрын
"- Doctor, doctor, it hurts when I hit myself in the head with the hammer! - So don't do it!" Thank you, Bjarne! :-))
@kamilziemian995
@kamilziemian995 Жыл бұрын
What to do when my hammer is C++?
@thesanctuary225
@thesanctuary225 5 жыл бұрын
Thank you sir Dennis Ritchie. Thank you sir Bjarne Stroustrup. You totally changed history of mankind.
@enhex
@enhex 8 жыл бұрын
"competing with C++ over the years has not been a winning strategy."
@kuchenzwiebel7147
@kuchenzwiebel7147 4 жыл бұрын
For the long term....
@maxx666mayhem
@maxx666mayhem 8 жыл бұрын
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.
@TheLappin
@TheLappin 5 жыл бұрын
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 жыл бұрын
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 жыл бұрын
@@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.
@VoidloniXaarii
@VoidloniXaarii 9 ай бұрын
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...
@lodathi
@lodathi 8 жыл бұрын
Amazing truths! I wish more young graduates thought this way.
@NikolasDanielEngels
@NikolasDanielEngels 8 жыл бұрын
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...
@clodgozon3968
@clodgozon3968 5 жыл бұрын
I clearly understand the topic. Good job, C++ Creator!
@MikeDiack
@MikeDiack 8 жыл бұрын
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.
@dudanov
@dudanov 5 жыл бұрын
Thank you, Bjarne!
@QuentinUK
@QuentinUK 8 жыл бұрын
GSL Guidelines Standard Library.
@ekimr90
@ekimr90 8 жыл бұрын
Of course there's dislikes! It's because C++14 isn't Assembly.
@prafulsrivastava8942
@prafulsrivastava8942 2 жыл бұрын
I wonder what I would have done without CppCon. Keep up the good work!
@CppCon
@CppCon 2 жыл бұрын
Thanks!
@fritzschnitzmueller3768
@fritzschnitzmueller3768 3 жыл бұрын
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 Жыл бұрын
I imagine his mind sees more beauty and complexity in the commonplace simple things so they are impressive to him.
@LydellAaron
@LydellAaron 4 жыл бұрын
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 жыл бұрын
I'm just asking cause I mightnt know the terms like how you're using them, but did you get deterministic and non- flipped?
@aeluned
@aeluned 8 жыл бұрын
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
@annaoaulinovna
@annaoaulinovna 3 жыл бұрын
c++ is awesome this guy must take nobel prize of computer science
@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!
@MrTargetSan
@MrTargetSan 8 жыл бұрын
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.
@kaboissonneault
@kaboissonneault 8 жыл бұрын
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
@baltazarus3307
@baltazarus3307 4 жыл бұрын
Excellent presentation Mr. Stroustrup, I enjoyed.
@bjarnestronstrup9122
@bjarnestronstrup9122 4 жыл бұрын
Technically speaking it's Dr. Stroustrup.
@baltazarus3307
@baltazarus3307 4 жыл бұрын
@@bjarnestronstrup9122 xD true!
@razterizer
@razterizer 8 жыл бұрын
Bjarne rules.
@DaveYostCom
@DaveYostCom 8 жыл бұрын
54:59 With these guidelines you can get perfect resource safety and resource safety. The talk perhaps should have started here.
@cgazzz
@cgazzz 4 жыл бұрын
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.
@GeorgeTsiros
@GeorgeTsiros 5 жыл бұрын
GARRETT turbo, i'm sold 🤘
@MikeDiack
@MikeDiack 8 жыл бұрын
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...
@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...
@KananDethin
@KananDethin 7 жыл бұрын
Thank you. Watched the whole video.
@atoshdustosh2762
@atoshdustosh2762 7 ай бұрын
Very useful concepts.
@Littlefighter1911
@Littlefighter1911 7 жыл бұрын
34:32 I accidentally did this and it has NOT been caught be the compiler, neither MSVC nor GCC.
@aliancemd
@aliancemd 8 жыл бұрын
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 жыл бұрын
I'm gonna puke! GCC 4.4?
@BB-lf5zm
@BB-lf5zm 5 жыл бұрын
Get out of there now
@antonpetrenko9176
@antonpetrenko9176 2 жыл бұрын
one of the best hydra fighter!=)
@adrienhamelin484
@adrienhamelin484 8 жыл бұрын
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).
@SunggukLim
@SunggukLim 7 жыл бұрын
he is good speaker
@X152535
@X152535 7 жыл бұрын
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 жыл бұрын
Any other trojans? Are you implying it was done before?
@ProphetPX
@ProphetPX 6 жыл бұрын
hahaha what do you think "Security Enhanced" Linux distros are??? LOLLL :)
@MrTargetSan
@MrTargetSan 8 жыл бұрын
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.
@deusbuda
@deusbuda 8 жыл бұрын
muito bom...
@AbcDino843
@AbcDino843 4 жыл бұрын
26:15, umm, should that not be q->use()?
@KangJangkrik
@KangJangkrik 3 жыл бұрын
That's the point of the topic
@Trollkemada
@Trollkemada 8 жыл бұрын
You should probably add the github link to the video description.
@andik70
@andik70 8 жыл бұрын
anybody has some links to good c++(14) code? (not the guideline, just leading by example)
@siweiliao4557
@siweiliao4557 7 жыл бұрын
facebook/folly
@mousedresden604
@mousedresden604 8 жыл бұрын
What is the URL for the materials he mentions in the talk?
@rock00dom
@rock00dom 8 жыл бұрын
github.com/Microsoft/GSL github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md
@brotherhood_of_harkonnen
@brotherhood_of_harkonnen 2 жыл бұрын
24:52: resource management
@maximmarchal9991
@maximmarchal9991 3 жыл бұрын
11:40 wait why wouldn't they use new and delete after take-off?
@VamoAComeLaPapa
@VamoAComeLaPapa 8 жыл бұрын
This is not a language war, my friends!
@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++?
@childhood1888
@childhood1888 2 жыл бұрын
One should not quote himself but it is a good quote.🙂
@robfielding8566
@robfielding8566 8 жыл бұрын
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.
@aliveho2720
@aliveho2720 6 жыл бұрын
I love c++;
@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?
@kousoulides
@kousoulides 5 жыл бұрын
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
@desertshadow72
@desertshadow72 Жыл бұрын
Talk really gets started around 7:00 ish
@michaelmoser4537
@michaelmoser4537 8 жыл бұрын
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.
@MrTargetSan
@MrTargetSan 8 жыл бұрын
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.
@enhex
@enhex 8 жыл бұрын
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.
@chaosmeist3r
@chaosmeist3r 8 жыл бұрын
already fixed in the repository
@freshsheets_
@freshsheets_ 6 жыл бұрын
So basically just don't use 'new' or 'delete'
@user-mi8es4ur5w
@user-mi8es4ur5w 8 жыл бұрын
Свершилось! Лед тронулся еще в 11, но 14 это уже будующее в настоящем.
@TheBuzzSaw
@TheBuzzSaw 8 жыл бұрын
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.
@lexshardaduriz1036
@lexshardaduriz1036 5 жыл бұрын
Conservative.
@SatansSpatula
@SatansSpatula 8 жыл бұрын
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.
@MrTargetSan
@MrTargetSan 8 жыл бұрын
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.
@moseswachira1165
@moseswachira1165 8 жыл бұрын
congrant
@thesanctuary225
@thesanctuary225 5 жыл бұрын
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.
@thesanctuary225
@thesanctuary225 5 жыл бұрын
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.
@willowFFMPEG
@willowFFMPEG 4 жыл бұрын
Can confirm
@Illasera
@Illasera 7 жыл бұрын
Writing good C++ code, you don't, And never forget, "Avoing using linked list because, bad" - Bjarne Stroustrup
@enhex
@enhex 8 жыл бұрын
57:27 Is that Gabe Newell?
@stupid_sleazoid2
@stupid_sleazoid2 7 жыл бұрын
0:13 guy in a hat - Larry Wall? (for comparison: kzfaq.info/get/bejne/fqeIeqdkr6uboIk.html)
@f8881f
@f8881f 5 жыл бұрын
43:56
@chaosmeist3r
@chaosmeist3r 8 жыл бұрын
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 . ->
@todorsamardzhiev144
@todorsamardzhiev144 9 ай бұрын
3:10 oof, based
@SatansSpatula
@SatansSpatula 8 жыл бұрын
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 жыл бұрын
std::transform(beg, end, std::toupper)
@childhood1888
@childhood1888 2 жыл бұрын
31:33
@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.
@amirishere
@amirishere 8 жыл бұрын
Every time you say "it's painful", I want to say "I feel your pain".
@MikeDiack
@MikeDiack 8 жыл бұрын
Absolutely right SS. C++ has just turned into a mess.
@philophile147
@philophile147 8 жыл бұрын
I know a UX designer who may be interested, messaging him now.
@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.
@DimitriSabadie
@DimitriSabadie 8 жыл бұрын
As a Haskeller, I just laughed my ass off watching that.
@moderncpp
@moderncpp Жыл бұрын
4:25 Carbon folks don't want to listen!
@unk1nd7
@unk1nd7 8 жыл бұрын
LOL xDD
@13Septem13
@13Septem13 8 жыл бұрын
No lol
@user-tr3qt3qs9t
@user-tr3qt3qs9t 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.
@voxelamateur
@voxelamateur Жыл бұрын
A _smaller_ and _simpler_ C++? the man has lost its mind...
@aigarius
@aigarius 7 жыл бұрын
Yay, C++ community has invented pylint.
@biplabdas2408
@biplabdas2408 6 жыл бұрын
shit is better/.........
@kushagraverma7855
@kushagraverma7855 2 жыл бұрын
rust
@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.
@VamoAComeLaPapa
@VamoAComeLaPapa 8 жыл бұрын
Rust propaganda machine detected (I mean, Rust trolls). Nice language, enjoy it, but without trolling.
@marianwitek403
@marianwitek403 8 жыл бұрын
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
@martinda7446
@martinda7446 7 жыл бұрын
C++ is just a bit better than mediocre.
@zahash1045
@zahash1045 Жыл бұрын
A better title would be "how to write rust but in c++" lol
@paxdei1988
@paxdei1988 8 жыл бұрын
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++
@dawidbujak
@dawidbujak 6 жыл бұрын
Bjarne, change haircut please
@chronius9496
@chronius9496 8 жыл бұрын
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 6 жыл бұрын
Writing Good C++ code is not possible because C++ is shit. All OOP is shit and should not be used.
@tomburris8380
@tomburris8380 6 жыл бұрын
Really? What would you suggest as an alternative? :)
@SleazyNice
@SleazyNice 6 жыл бұрын
Just use C.
CppCon 2015: Andrei Alexandrescu “Declarative Control Flow"
1:07:35
Stupid Barry Find Mellstroy in Escape From Prison Challenge
00:29
Garri Creative
Рет қаралды 20 МЛН
Khóa ly biệt
01:00
Đào Nguyễn Ánh - Hữu Hưng
Рет қаралды 19 МЛН
СНЕЖКИ ЛЕТОМ?? #shorts
00:30
Паша Осадчий
Рет қаралды 8 МЛН
Final muy increíble 😱
00:46
Juan De Dios Pantoja 2
Рет қаралды 34 МЛН
Bjarne Stroustrup: C++ | Lex Fridman Podcast #48
1:47:13
Lex Fridman
Рет қаралды 1 МЛН
Bjarne Stroustrup - The Essence of C++
1:39:11
The University of Edinburgh
Рет қаралды 1,2 МЛН
Stop Writing Classes
27:29
Next Day Video
Рет қаралды 930 М.
Stupid Barry Find Mellstroy in Escape From Prison Challenge
00:29
Garri Creative
Рет қаралды 20 МЛН