CppCon 2018: Herb Sutter “Thoughts on a more powerful and simpler C++ (5 of N)”

  Рет қаралды 79,269

CppCon

CppCon

Күн бұрын

Пікірлер: 100
@benhur8666
@benhur8666 4 жыл бұрын
Impressive talk, in my opinion he is the one with a greater vision in the committee, looking forward for the metaclasses
@vertigo6982
@vertigo6982 6 жыл бұрын
I bet Herb has a huge walk-in closet to display his impressive Hawaiian shirt collection.
@bobweiram6321
@bobweiram6321 2 жыл бұрын
Yeah, C++ will do that to ya.
@acmdz
@acmdz 6 жыл бұрын
Very excited about metaclasses. I think it's the most powerful language feature introduced since templates.
@frydac
@frydac 6 жыл бұрын
yes, very impressive feature, can't wait to see what ppl come up with using them.
@mateferencnagy-egri4210
@mateferencnagy-egri4210 6 жыл бұрын
Because metaclasses are tightly coupled to reflection and codegen, I'll just just say it. If the restrict(amp) compatible (aka. "static C++") statements of a function could be traversed via reflection, one could implement not just MOC-like tools, but C++AMP/SYCL-like compilers as ISO C++ libraries. Herb having designed C++AMP as well, that would be one less language extension to do again, something that would enable GPGPU within C++ as a library feature. I was told that the current reflection TS does not allow traversing private members either. Adding these two would solve most of the headaches HPC is suffering from, portability of code, vendor lock-in, API support, etc.
@Eldorante
@Eldorante 6 жыл бұрын
Great talk Herb!, I've seen Herbs talk about Metaclasses from last year and I really want to see this in C++.
@sivabudh
@sivabudh 5 жыл бұрын
C++ metaclass is going to be a killer feature. I think we probably will have it in the language by 2022-2024. I doubt other (mainstream) languages have this capability.
@HermanWillems
@HermanWillems 5 жыл бұрын
smalltalk-80 has it. And that's an old language. Hahahahaha
@PixelPulse168
@PixelPulse168 6 жыл бұрын
I'm still waiting for a new episode from CppCon 2018. Please upload a new one.
@andreicirstea8517
@andreicirstea8517 3 жыл бұрын
Imagine not having reflection in 2021... a feature that should have been here for the last 10 years.
@SqueakyNeb
@SqueakyNeb 2 жыл бұрын
Maybe because it's not a zero overhead abstraction?
@Fetrovsky
@Fetrovsky 6 жыл бұрын
The presentations are great as always. I just wish they wouldn't include that weird noisy music at the beginning.
@RachelMant
@RachelMant 6 жыл бұрын
Spotted an error at the 1h mark - the lock_guard should be using {}'s rather than ()'s to capture a lock to data1, otherwise it's a function call def and not what was wanted.
@oisyn
@oisyn 6 жыл бұрын
You're wrong, 'data1' is not a type and therefore it wouldn't be a valid function declaration.
@meinklavier
@meinklavier 6 жыл бұрын
I really like how C++ has evolved to such powerful language, but metaclasses syntax looks kind of weird to me
@alfredomoreira6761
@alfredomoreira6761 6 жыл бұрын
So Herb came last year with a good syntax for metaclasses that could be improved and the C++ Commity walks in and made the syntax uglier, less readable and overly complex instead of making it better! Nice Job commity!
@Sopel997
@Sopel997 6 жыл бұрын
I think the new one is better. More explicit and easier to read. Also I find it more intuitive to be imperative (functions). Because of that it may also be easier to extend in the future, when a need may arise for something that couldn't be specified nicely in a declarative manner (class body) (I think it was already stretched).
@aaardvaaark
@aaardvaaark 6 жыл бұрын
Agreed. Especially frustrating to hear that they will *never* accept properties being built right into the language - and then they poison the metaclasses with yet more esoteric syntax.
@mapron1
@mapron1 6 жыл бұрын
The "definition" of metaclass as not ugly as hell, it someway more cleaner that it compiletime code transformation function. So, I can accept it someway. But "instantiation" - meh, no, I hope there will be smth cleaner.Just as Herb said - make me way to directly tell my intent. class(cmth) - not a great, class (some BS) for properties - total mess.
@iiVEVO
@iiVEVO 4 жыл бұрын
how is it ugly
@jaysistar2711
@jaysistar2711 5 жыл бұрын
Herb, I don't know why you seem to need to explain why adding features makes the code simpler. Functions are like words that you add to the language. Imagine if every time you wanted to reference a coffee cup, you had to say "a small bucket made with an insulated material to prevent burning of the holder by the contents, which is expected to be hot, and probably is coffee." It's much quicker to just say "coffee cup", which does imply that the listener has some knowledge about what material the bucket would be composed, and it's size, but it's far more convient for the speaker, and I'd say the listener gets the benefit of parcing and processing the sentence much more quickly.
@krumbergify
@krumbergify 3 жыл бұрын
Your analogy is good and I kinda agree, but the problem is that a lot of books and people use the verbose way of describing a coffee cup, so until they migrate to your new word the language will be larger. Hopefully people and education catches on and we can forget about the various verbose versions.
@edino1981
@edino1981 6 жыл бұрын
I like meta classes, image possibility to have meta class that can transform C++ class to object that is compatible with Python, PHP or Node engines.
@schulmastery
@schulmastery 6 жыл бұрын
He really did a disservice to his argument by showing the child's play C# class declaration, and then the C++ attempt to emulate part of it partially with refrefs and angle brackets abound.
@00nula00
@00nula00 6 жыл бұрын
I have to say, last year Herb's syntax was so much more beautiful and straightforward. Current committee's syntax proposal sux, sorry.
@timseguine2
@timseguine2 6 жыл бұрын
I googled "defun defun 3" like suggested actually and it came up with nothing. I am guessing the idea is that it replaces the defun macro with a function that returns the constant 3?
@timseguine2
@timseguine2 6 жыл бұрын
emacs.stackexchange.com/questions/375/symbols-value-as-a-variable-is-void-defun-when-reloading-emacs seems to suggest differently
@timseguine2
@timseguine2 6 жыл бұрын
You can shoot yourself in the foot in any language, but if the goal is to not add more ways to do it to a language, you shouldn't try to copy features that add them.
@PixelPulse168
@PixelPulse168 6 жыл бұрын
Compiler checks dangling pointers and null pointer. It must be a dream. Where is the paper of how this is implemented?
@matthiasgehre6323
@matthiasgehre6323 6 жыл бұрын
It's linked in here: herbsutter.com/2018/09/20/lifetime-profile-v1-0-posted/
@HermanWillems
@HermanWillems 5 жыл бұрын
That's why compile time is the future. Everything in compile time, nothing in run-time. This means the compiler can check everything.
@blacklion79
@blacklion79 2 жыл бұрын
3.5 years later, and what is result?
@TheLavaBlock
@TheLavaBlock 6 жыл бұрын
It will be hard first but it can be easier for us all...
@cmdlp4178
@cmdlp4178 6 жыл бұрын
Removing macros means making debugging harder, if no new language feature is added, that allows writing assert. I thought about a new type of parameter passing; pass by expression. The parameter is never evaluated until you use it in the function body. There should also be a way to get the source code of an expression-parameter to be used in a message. I am using $ as a symbol for expressions, you evaluate it with $, as you dereference a pointer with *: void assert(bool$ expr) { if constexpr(DEBUG) { if(!$expr) { assertion_failed(expr.source, expr.file, expr.line); } } } assert(42 == 20+20+2); An expression has a $ operator to be evaluated, the members source, file and line to contain debug information. As expressions are statically included in binary, the function needs to be inlined always, as you expect it with lambdas: template void assert_f(T expr_func) { if constexpr(DEBUG) { if(!expr_func()) { ... } } } assert_f([]{ return 42 == 20+20+2; });
@dominiccasts
@dominiccasts 6 жыл бұрын
Contracts ( www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0542r5.html ) is the thing that replaces assert().
@cmdlp4178
@cmdlp4178 6 жыл бұрын
@@dominiccasts The problem with the contracts is, that it might be compiler dependent, which information is outputted. When you are able to define a macro (or a function with the expression parameters as mentioned in my previous comment) you have full control about the behavior. Sometimes you want to enable or disable checks for a specific part of the code. In my optinion the contracts-proposal may even improve debugging, but I think there will be programmers, who want to write the assert-macro/-function by themselves in a more classical way. Expression values are more useful for just only an assert-macro and lazy evaluation. It can be a big step for metaprogramming. I hope there will be a feature like the expression values in the future. It could fully replace the need for macros in C++.
@OperationDarkside
@OperationDarkside 6 жыл бұрын
I strongly oppose the syntax of writing "__" before something. Doing the "$" in PHP for variables is bad enough. The original one, was so nice. But else, great talk as always. Didn't understand the Compress->Encrypt->Stuff though.
@7thfleetOne
@7thfleetOne 6 жыл бұрын
I believe that denotes placeholder syntax.
@OperationDarkside
@OperationDarkside 6 жыл бұрын
@@7thfleetOne I hope so. This is such a strong feature, it should be very well readable
@X_Baron
@X_Baron 6 жыл бұрын
Yes it looks like a hack for the Compiler Explorer so that it can define non-standard keywords. Sort of like putting some __PREFIX on predefined macros.
@vertigo6982
@vertigo6982 6 жыл бұрын
They usually indicate predefined compiler macros... so that __ gives them that distinction that they arent your typical keywords or variables.
@SniffyPoo
@SniffyPoo 6 жыл бұрын
C++ will never have named function parameters because there is too much conflict with lax legacy design. this seems to me to be representative of a general problem, too much baggage from the C days.
6 жыл бұрын
yeah, would love to see a brand new c++
@X_Baron
@X_Baron 6 жыл бұрын
It looks like metaclasses (or metafunctions?) would allow a nice way to implement the named parameter idiom without much boilerplate. Maybe this is beside your point, though.
@SniffyPoo
@SniffyPoo 6 жыл бұрын
if you have to add lots of weird extra syntax to accomplish a simple goal like a syntax of computearea(height:2, width:3), then the issue is the baggage in the core language.
@tomwimmenhove4652
@tomwimmenhove4652 6 жыл бұрын
What IDE is being used here (other van vStudio)?
@xarcaz
@xarcaz 6 жыл бұрын
cppx.godbolt.org ?
@Sydra.
@Sydra. 5 жыл бұрын
Why just metaclasses? Why not metaeverything? You could make some general code factory syntax with the same effort.
@DemHoNMomentz
@DemHoNMomentz 5 жыл бұрын
Isn't that how you end up with Lisp?
@HermanWillems
@HermanWillems 5 жыл бұрын
@@DemHoNMomentz C++ is a multi-paradigm. It would be great if both ideas from Smalltalk & Lisp are in C++ without a garbage collector. And also creating a choice between deterministic & performant algorithms. Because sometimes you want deterministic code, and sometimes performant. Depends on the use case. That would be the ultimate language for me.
@Gargantupimp
@Gargantupimp 5 жыл бұрын
WORD OF POWER! Is Herb a DnD nerd?
@debugx1
@debugx1 6 жыл бұрын
very cool
@redradist
@redradist 3 жыл бұрын
Active object is create, I've created library to make easier working with it github.com/redradist/Inter-Component-Communication and created even simpler abstraction based on common bus that is called in my implementation locales, take a look at example github.com/redradist/Inter-Component-Communication/blob/develop/examples/ForeCast/main.cpp
@heinsaar
@heinsaar 6 жыл бұрын
I really don't understand why some programmers just don't get it: look how complicated the universe is - the laws of physics, biology, math - their "Standard" has WAY more pages than all of the books on science combined. And yet we wake up, live our day and go to sleep - as simple as that. The more complicated a specification is, if it's done the right way, it can make life as beautiful as can be.
@AchwaqKhalid
@AchwaqKhalid 6 жыл бұрын
Nope. *simplicity is the ultimate sophistication*
@minRef
@minRef 6 жыл бұрын
Psst 1) Go to the CppCon main youtube page 2) Go to the “videos” tab 3) Change the sort field from “date added” to “most popular” 4) At the top should be a vid with a guy wearing a red shirt. Enjoy.
@shycha
@shycha 6 жыл бұрын
shevegen Yeah... You're right. Except there are two bits that machines understand -- zero and one. Still less than four DNA components, yet somehow something more sophisticated can be built on top of it. Exactly as in the DNA case. My point is that your reasoning is invalid since you've taken something of arbitrary complexity, i.e., DNA components, without justifying such a choice in the first place. Why not protons/electrons/neutrons? On the other hand, I somewhat agree with what you trying to say. Although, I cannot agree with the reasoning. Peace! ;)
@KrzysiekzBlaviken
@KrzysiekzBlaviken 6 жыл бұрын
@Ernest Rutherford Mike Acton haven't said, that he doesn't use templates because of code bloat. The only concrete fault of templates he mentioned was compile time.
@johnyxnn
@johnyxnn 6 жыл бұрын
The start part is really scary
@Inityx
@Inityx 6 жыл бұрын
Hmmm... Sounds like a more complicated Rust to me.
@Inityx
@Inityx 6 жыл бұрын
@Ernest Rutherford www.rust-lang.org/en-US/friends.html
@Elite7555
@Elite7555 6 жыл бұрын
Ernest Rutherford, immature in the sense that there aren't enough libraries for all needs (although that changes rather quickly). But the core language is stable and very mature. The excellent FFI makes it rather simple to build pure idiomatic Rust abstractions with zero (or at least close to zero) overhead. Nobody said they should stop using C++, but Rust is a viable alternative; especially when memory safety is of concern.
@Elite7555
@Elite7555 6 жыл бұрын
shevegen, if you are familiar with the concepts of ownership (which is not an invention of Rust), interfaces, lifetime and generics / templates, I don't think it is any more complicated than C++. And please look at how complicated and unwieldy C++ has become.
@alfredomoreira6761
@alfredomoreira6761 6 жыл бұрын
and we see no gafa in this list
@sheldonhawke8868
@sheldonhawke8868 6 жыл бұрын
...and also unsafe
@Voy2378
@Voy2378 6 жыл бұрын
Make interface keyword FFS
@norbertnemesh
@norbertnemesh 5 жыл бұрын
It's too narrow, blah blah blah. We like general features, blah, blah blah. This is the exact reason why in 2019 I still don't have a standard tool to parse a phuckin json in c++. Goddammit!
@HermanWillems
@HermanWillems 5 жыл бұрын
Parsing a json should not be a standard tool. It should be a library. Because it's a program on itself. And improvements can be made trough time.
@ОлегРыськов
@ОлегРыськов 6 жыл бұрын
IMHO, C++ is moving towards the Chinese language in terms of simplicity: hieroglyphs are also simple for the Chinese people, some hieroglyphs are rarely used and there is a historic logic behind every piece of it. But the raise of Rust, Go and LLVM-based languages shows that there is another approach for simple English-speaking people..
@xarcaz
@xarcaz 6 жыл бұрын
At least it could be worse; it could be Russian. ;-)
@noxmetus
@noxmetus 6 жыл бұрын
typedef reflects the way the typing system works in C++. People are lazy and usually don't learn it, and then they are puzzled by why a pointer to a function looks like this. It's simple: type description is a set of all these *, &, [], etc, you have to apply to get the value. With making typedef a secondary citizen, I am afraid even less people will learn how types are formed in C++.
@Hoowwwww
@Hoowwwww 6 жыл бұрын
c++ has ugly syntax, it is made by people who prefer to spend their time writting stuff, rather than writting solid and usable code
@user-ov5nd1fb7s
@user-ov5nd1fb7s 6 жыл бұрын
The more i look at c++, the more it looks like a hacky language. Random if else statements in a basic loop just not to crash, what the hell is that? Complete garbage.
@llothar68
@llothar68 6 жыл бұрын
Yes the syntax is terrible when you get into templates. And it will get worse with concepts. They are just to close minded to invent a good syntax at least for the parts that dont need backward compatibility. Concepts are not C++ no to mess this up too.
@thestickbot
@thestickbot 6 жыл бұрын
Which example are you talking about? Erasing an element when iterating or something else? You have to do checks in other languages too in the same situation to avoid problems, so I really don't see your point here...
@user-ov5nd1fb7s
@user-ov5nd1fb7s 6 жыл бұрын
41 minute, v.erase(); I mean, come on. Are you suppose to write garbage like this when you want to delete an element from a collection? if (*i * 2) { v.erase(i) } else { i++ } If this is how C++ development is done, i am glad i never did any.
@thestickbot
@thestickbot 6 жыл бұрын
@@user-ov5nd1fb7s I think you might misunderstand why that if check is there... the if check is not there to make sure that the program doesn't crash, it's just a simple condition to check if we want to erase the object or not. In this case, we apparently want to erase the integer only if its value is 2. You would need to do the same check in other languages as well.
@user-ov5nd1fb7s
@user-ov5nd1fb7s 6 жыл бұрын
I was talking about the else, needing to increment the index inside the loop body. You shouldn't need to do that. The first example should work properly, where the index is incremented inside the loop definition. It should be smart enough not go outside of the vector bounds, without you needing to have ugly checks all over the place. For basic operations, you shouldn't need to do any checks like that. It should be clean code without these hacks.
Маусымашар-2023 / Гала-концерт / АТУ қоштасу
1:27:35
Jaidarman OFFICIAL / JCI
Рет қаралды 390 М.
Как Ходили родители в ШКОЛУ!
0:49
Family Box
Рет қаралды 2,3 МЛН
Can C++ be 10x Simpler & Safer?  - Herb Sutter - CppCon 2022
1:54:00
CppCon 2018: Jason Turner “Applied Best Practices”
1:03:19
C++ and Beyond 2012: Herb Sutter - atomic Weapons 1 of 2
1:21:13
toalexsmail
Рет қаралды 53 М.
Bob Nystrom - Is There More to Game Architecture than ECS?
23:06
Roguelike Celebration
Рет қаралды 212 М.
CppCon 2018: Jason Turner “Surprises in Object Lifetime”
1:01:28