Тёмный

CppCon 2017: Herb Sutter “Meta: Thoughts on generative C++” 

CppCon
Подписаться 150 тыс.
Просмотров 103 тыс.
50% 1

CppCon.org
-
Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2017
-
Two years ago, I started to focus on exploring ways that we might evolve the C++ language itself to make C++ programming both more powerful and simpler. The only way to accomplish both of those goals at the same time is by adding abstractions that let programmers directly express their intent-to elevate comments and documentation to testable code, and elevate coding patterns and idioms into compiler-checkable declarations. The work came up with several potential candidate features where judiciously adding some power to the language could simplify code dramatically, while staying true to C++'s core values of efficient abstraction, closeness to hardware, and the zero-overhead principle.
The first two potential candidate features from that work to be further developed and proposed for ISO C++ are the <=> unified comparison operator (minor) and what I've provisionally called "metaclasses" as a way to generatively write C++ types (major). This talk is about the latter, and includes design motivation, current progress, and some live online compiler demos using the prototype Clang-based compiler built by Andrew Sutton and hosted at godbolt.org.
-
Herb Sutter - Software architect, Microsoft
Herb chairs the ISO C++ committee and is the primary author or co-author of a number of Standard C++ features, including nullptr, enum class, parallel algorithms, C++17 structured bindings, and the in-progress unified <=> comparison operator.
-
Videos Filmed & Edited by Bash Films: www.BashFilms.com
*-----*
Register Now For CppCon 2022: cppcon.org/registration/
*-----*

Опубликовано:

 

27 сен 2017

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 144   
@edwrodrig1
@edwrodrig1 6 лет назад
Wow! C++41 will be huge!!
@chrisminnoy3637
@chrisminnoy3637 Год назад
True words, C++23 will be released within a few months, nothing of this is present in the standard.
@Eldorante
@Eldorante 6 лет назад
Herb is such a great speaker, the way he presents, talk make you wanna listen to him. Hopefully he won't stop so soon :)
@Runoratsu
@Runoratsu 6 лет назад
Totally agreed! Hi talks are not only informative, they're actually FUN to listen to.
@kamilziemian995
@kamilziemian995 Год назад
I only wish that he will speak slower. To understand some of his lines I need to rewind them four time.
@kosheryosher486
@kosheryosher486 6 лет назад
Arguably one of the most useful language proposals. Very elegant and it squashes so many not-so-nice bits of C++ in one go without changing the language itself. Superb job, Herb!
@sephirostoy
@sephirostoy 6 лет назад
I definitively love this proposal. It gives an elegant and versatile solution to most of C++ lacks (defaulted stuff, properties, enum flags, moc, ...). I'd like to see this feature asap. It's hard to imagine that it won't be part of C++20. :(
@kwinzman
@kwinzman 5 лет назад
I keep thinking: maybe we get modules for C++20 and coroutines and concepts. Metaclasses are at least C++24?. And even then my biggest gripe is I don't see a healthy package manager ecosystem. So realistically it's the good old C++11/14/17 for the next 5+ years. If you are starting a new programming project you have to make a choice if you would rather make it in another language.
@yash1152
@yash1152 Год назад
> _"modules coroutines and concepts"_ this is mentioned at around 1:28:47
@bobweiram6321
@bobweiram6321 2 года назад
Just mastering C++ is a profession in of itself.
@thesomething8467
@thesomething8467 6 лет назад
Because of constexpr, soon C++ programs will compile to a single write syscall that will print the result.
@sivabudh
@sivabudh 6 лет назад
theSomething Lol
@zetaconvex1987
@zetaconvex1987 6 лет назад
Herb said in talk that he wanted things like vectors to be constexpr. It struck me that there is a big idea to come out of this: a "constexpr" is just a non-constexpr thing for which halting can be decided. So, with the concept sufficiently developed, 'constexpr' might be viewed as a kind of hint to the compiler in the same way that 'inline' might. Just my intuition. I'm trying to find the names of the esoteric progamming languages, but I can't find them. One is called something like froogle, and the other something like snoogle. One of them is Turing incomplete, but can perform many computations. The other one adds a simple loop that makes it Turing complete. This distinction is what seems to be the distinction with what can be a 'constexpr' and what can't.
@origamibulldoser1618
@origamibulldoser1618 6 лет назад
Right. Until you depend on input. Which most applications do.
@stephenborntrager6542
@stephenborntrager6542 6 лет назад
If it's even possible logic-wise, this will already happen when the optimizer hits it. Write a loop that does a bunch of complex math from a constant seed with no inputs, and it will just turn into the result. I personally don't have any use for constexpr just yet, other than some pre-generation of tables maybe. Really just a compact way of loading a dataset we would otherwise be pre-generating with a seperate tool. This suggestion is an enormously different thing than just constxpr... more about logistical possibilities of being able to fix all the things in the language that bug you by tweaking it's rules.
@robbie_
@robbie_ 6 лет назад
Yes, with 10 terabytes of memory in order to do the compilation.
@biosdilt1399
@biosdilt1399 6 лет назад
Please make it happen in C++20, this is such a major feature, it will help the C++ world so much :)
@robbie_
@robbie_ 6 лет назад
Unfortunately my shop probably won't buy it until C++30 :(.
@jacobschmidt
@jacobschmidt 4 года назад
It didn't!
@AdityaKashi
@AdityaKashi 3 года назад
Herb: This new feature will make your life easier. You're already doing it, just with more difficulty. Me: No, no, no, no. I like my C++ as it is, this is going to mess it up. Herb: (Gives some examples) Me: Hmm.. that actually makes sense. I totally want this. Wait what? ... it's coming in C++ 30?
@OmarChida
@OmarChida 3 года назад
Excellent talk! This is soo powerful writting extensions to the compiler to enforce rules reflection injection all of that is just so amazing. This is the future.
@CppCon
@CppCon 3 года назад
Glad you enjoyed it!
@JackAdrianZappa
@JackAdrianZappa 5 лет назад
Wonderful talk! Very excited in the direction that C++ is going.
@benoitrousseau4137
@benoitrousseau4137 6 лет назад
That was very, very interesting. I like how this allowed you to bring concepts from other programming languages and giving you the opportunity to bring them to C++, except in a much more flexible way. Serialization is also going to be much easier if this feature gets in. This has potential to be misused, but so can operator overloading and templates, and it still brought more good than bad in the big picture. Thank you for the presentation, and good luck in your work with meta classes.
@kuhluhOG
@kuhluhOG 4 года назад
well, everything can be misused the more powerful something is, the harder it can be misused too
@tokyospliff
@tokyospliff 2 года назад
@@kuhluhOG yeh but u just learn it and use it properly
@UrSoMeanBoss
@UrSoMeanBoss 2 года назад
My excitement for these language features can't be understated. I just hope I live long enough to see it.
@GeneralBolas
@GeneralBolas 6 лет назад
I can answer that last question better than Herb did. The single biggest annoyance with the CRTP (for me and my uses) is the fact that the derived class *does not exist* during the instantiation of the CRTP class. While the bodies of member functions of the CRTP class can access members of the derived class, anything else cannot. Think about some of the boilerplate that C++ containers require in terms of typedefs. You have `value_type`, `reference`, `pointer`, etc. But really, the only one that the implementer needs to define is `value_type`; unless they're doing something special, `using reference = value_type&;` and `using pointer = value_type*;` work. So that's an obvious thing to put into a CRTP base class. But that doesn't work. Or at least, not directly. You cannot write `using pointer = Derived::value_type*;`, because `Derived` is an incomplete type at that point in C++'s template instantiation model. So what you have to do is have some traits class which you specialize for your container type, and that class has `value_type`. So the CRTP does `using pointer = typename trait::value_type*;`. When means that when I go to write the container that uses this CRTP base class, I have to go through a lot of pain. I have to close my namespace, open up the namespace where the traits class specialization needs to go, specialize it, close that namespace and reopen my namespace, and then *finally* declare my class. And that's for a very simple case. So while CRTP + reflection + injection can probably get some of the low-hanging metaclasses fruit, it will never be as good as full-frontal metaclasses.
@InfoDav
@InfoDav 6 лет назад
As always, very eloquent and interesting
@PoetaKodu
@PoetaKodu 6 лет назад
I WANT IT IN C++20. I REALLY DO.
@dariusduesentrieb
@dariusduesentrieb 6 лет назад
I WANT IT IN C++17. Guess it's a bit late for that.
@ytsas45488
@ytsas45488 5 лет назад
Probably not even going to be finished until C++26 or something. The syntax is still a 'strawman' syntax.
@n0ame1u1
@n0ame1u1 6 месяцев назад
Honestly even C++26 is not looking promising
@OperationDarkside
@OperationDarkside 6 лет назад
This is awesome! Please hurry with that one. And add some constexpr lists/vectors, so my "Serializable" class is not a pain in the butt to use anymore.
@KarlHansson
@KarlHansson 6 лет назад
Great video. Very interesting stuff.
@evilcanofsoda
@evilcanofsoda 5 лет назад
Yes, I love it!
@luiswirth
@luiswirth 5 лет назад
My mind is blown 🤯
@carldaniel6510
@carldaniel6510 6 лет назад
Great talk, Herb. I remember having a conversation with Brandon Bray about this topic back in 2003 - we were on a bus, traveling from downtown Seattle to the Microsoft campus during the MVP summit - probably the same year where you presented C++/CLI to the MVPs for the first time. I love the idea of meta programming that doesn't hurt.
@yash1152
@yash1152 Год назад
27:29 lots of abstraction layers and where cpp shines 27:43 abstraction needs tooling - e.g. simple variables and debug watch variable windows 1:18:12 some diagram regarding qt (cute) which i may find helpful later 1:21:53 how t'd help with particle physics data models too 1:25:46 "is it turning it into lisp" - this reminds me of the computerphile video on the topic: "lisp metaprogramming for quantum computing" 1:27:03 struct and class being the metaclasses already (with enum union etc being more - 1:07:51 , 1:10:55)
@chrisminnoy3637
@chrisminnoy3637 Год назад
It would be great to have this, I love it. It would be good to think also about doing Aspect Oriented Programming using this technique on compile time, which requires that you can search classes, functions and operations (joinpoints) where you can use Herbs system to inject new code.
@sirnawaz
@sirnawaz 6 лет назад
Liked the "Under Construction" image from Hyderabad (which is where I'm located :D); also liked its interpretation in the end, at around 1:29:58.
@yash1152
@yash1152 Год назад
> _" "Under Construction" image from "_ yeah, i was able to recognize that the image is from india right in the beginning at around 10:18 itself. the auto-rikshaw and stuff was very recognisable to me
@yash1152
@yash1152 Год назад
11:49 wow, CERN and bloomberg too 21:14 new word learnt: strawman 1:37:50 ABI break - jason turning mentioned this too in regards to suggestion of changing order of things in his already published book - i ignored it back then, but guess i'd have to learn it now
@errorlooo8124
@errorlooo8124 3 года назад
So template classes are rust attribute proc macros, cool to see c++ looking at getting something similar.
@2b2t95
@2b2t95 6 лет назад
Pretty sick mister Sutter.
@AxelStrem
@AxelStrem 6 лет назад
the diagnostics for meta-classes works great... but what about the diagnostics of that missed semicolon at 56:00? :)
@yash1152
@yash1152 Год назад
hehe
@TranscendentBen
@TranscendentBen 3 года назад
30:25 if constexpr ... this also makes me think about test coverage for compile-time code. I went to school for EE just a few short decades ago, I'm trying to catch up ... taking heart in what I saw in another conference video, "you don't have to know EVERYTHING about C++."
@bobweiram6321
@bobweiram6321 2 года назад
The rationale for this freaky generative code is "We're already doing it anyways." Trying to solve a problem with more problems is not a solution.
@reubenfrench6288
@reubenfrench6288 6 лет назад
Just as a thought experiment, what would a meta-meta-class be?
@botetescribavicentej.2326
@botetescribavicentej.2326 6 лет назад
One of the problems with the class approach for enums (basic_enum, enum_class) is that they are not enums. We have this problem in boost::scoped_enum. And as a class it cannot be used as a non type template parameter. Nor it can be used in a switch without explicitly casting to the underlying type. Hoping the language will evolve and we could use literal types an non type template parameters in the future and that the switch statement will do an explicit conversion to the underlying type behind the scenes as we have an explicit conversion to boo in the condition of an if statement.
@Cromius771
@Cromius771 6 лет назад
Soon you will be able to write your own meta-control statement switch which will auto cast to the same type in the condition and also do safe type checking
@Astfresser
@Astfresser 2 года назад
again, the lack of interfaces in C++ drives herb mad... better it be the proper way now and we finally arrive at an elegant solution.
@botetescribavicentej.2326
@botetescribavicentej.2326 6 лет назад
In c++17 we cannot specialize std::hash inside a class (See N1691). I was wondering if metaclasses could help to define a hashable metaclass that will generate the hash_combine function and specialize std::hash for the hashable metaclass.
@jaredmulconry
@jaredmulconry 6 лет назад
Botet Escriba Vicente J. It certainly could, by way of iterating over all NSDMs. That said, the current approach to hashing is not well suited to accumulating state into the final hash. There was a proposed alternate design that would work around that and that would integrate perfectly with this to make every one of your types hashable that can be.
@YourCRTube
@YourCRTube 6 лет назад
As much as this looks exciting, I am worried, it will be the next concepts - a stumbling block that takas decades to develop. Granted, if this thing flies, it will be the biggest feature since templates, radically changing how we write code and develop the language, just like with templates.
@stephenborntrager6542
@stephenborntrager6542 6 лет назад
Personally, I am 10x as interested in this than I am in concepts. I can immediately see how this can be useful, but I have never been able to understand what "concepts" are supposed to be... here's hoping he's being pessimistic about the timeframe specifically based on how concepts (didn't) go.
@troctschcpp5263
@troctschcpp5263 6 лет назад
I am wondering if $metaclasses could not simply replace concepts. As it provides tools to enforce and generate and concepts only provides tools to enforce...just thinking...what do you think?
@Zastai
@Zastai 6 лет назад
immediate concern: if things like compiler.require() trigger diagnostic messages, how do you handle i18n? It's just code, so the compiler can't use its own localisation support for it. So how/where do you provide translated messages?
@Zastai
@Zastai 6 лет назад
Also, the diagnostics in the prototype are clearly inferior to the ones in c# because they all point to the metaclass constexpr block, not any part of Shape. And it seems tricky to set up, especially when compiler.require tests multiple things - how would the compiler know what code location to issue the diagnostic for?
@meneldal
@meneldal 6 лет назад
You can iterate over every function and I assume that you could get the line the function was written with something like f.getLine() For localization support, have it print a string that you can fill with different languages and it would just take the string matching the current locale. Though obviously in practice most people wouldn't bother writing the error messages in something else than English.
@thought2007
@thought2007 6 лет назад
The same way you support internationalization for static assert messages? Programmers just agree on a convention.
@zuzana0111
@zuzana0111 6 лет назад
Matus is a star ;)
@ilnurKh
@ilnurKh 6 лет назад
About example with crtp: are there any way to make metaclasses decomposition? For example will it be possible use both equals comparable and literal ?
@botetescribavicentej.2326
@botetescribavicentej.2326 6 лет назад
You need to define a metaclass that composes from both. I agree that having the possibility to compose a class for several metaclasses will be desirable (as if they were mixins), but I suspect that there are advantages and liabilities to each approach.
@misium
@misium 2 года назад
I like this but i please make the syntax cleaner. How about putting all those metaclass definitions in a compiler{} scope....
@connorhorman
@connorhorman 5 лет назад
I just need 3 and to CRTP to a nice base class.
@yash1152
@yash1152 Год назад
18:21 what's constexpr? 19:09 is that what it is?
@jonasschulze8097
@jonasschulze8097 11 месяцев назад
I hope I’m not too late to the party. I don’t like that meta classes allow the user to replace the “class” keyword. Wouldn’t it be reasonable to merely add an optional “which kind of” class prefix, such that the existing “enum class” could be implemented by meta classes? Maybe there is just a “union class” to be found, that is a safer alternative to “union”; similar to “enum class” being a safer alternative to “enum”. I don’t know what to make of “struct”, though. One could argue that “enum struct” would have been a better choice than “enum class”. Maybe a “public class” could be synonymous with “struct”, and people could be discouraged from writing “struct”. Would this simplify things?
@arisweedler4703
@arisweedler4703 2 года назад
The power of metaclasses seems pretty awesome. You get a whole new dimension with which to express the semantic meaning of a piece of code. “Class” really is too general. Sometimes you need specific words to be able to write the right abstraction! Part that stuck out to me the most begins at around 50:00
@jonasschulze8097
@jonasschulze8097 11 месяцев назад
On slide 79, I think “prototype” should be named “EqualityComparable” instead.
@raghureddy3237
@raghureddy3237 6 лет назад
10:17 it is from the place where i live :)
@JDahl-sj5lk
@JDahl-sj5lk 2 года назад
I want meta classes now. But anyway, std::format was a very nice addition in c++20
@yash1152
@yash1152 Год назад
i dont know about that, can u explain a bit?
@X_Baron
@X_Baron 5 лет назад
I wonder, why couldn't you just fold meta classes or meta class functionality into regular (base) classes that you'd inherit from.
@lonsobaba2605
@lonsobaba2605 6 лет назад
This is really interesting. But are we trying to make c++ look more like C#. Do we really need properties?
@ThePraveable
@ThePraveable 6 лет назад
Yeah, we do. Every bigger library/framework/game engine implemented properties on their own, so it seems that properties are quite useful. :)
@theicebeardk
@theicebeardk 6 лет назад
And in essence what this would do is make it possible for your application, library, whatever to opt-in on this without the C++ language getting extended. So if you don't need Properties, well this proposal does not add Properties, so you don't have to use the metaclass system to add properties to your situation. You can go along happy as you like without properties. Meanwhile others can opt-in, opt-out, make their own exactly without having to go to committee or internet forums to complain about a lacking feature dealing with this. It could simplify any future versions of std::pair, std::tuple and hundreds of other things. It would allow system architects to create a set of metaclasses for their applications across a platform which would integrate with the language without having to extend it and release their own toolset for it. IE for example CORBA, COM and the like would use the metaclass system to integrate between their needs and other C++ code. I don't see a whole lot of C# ism over this other than Herb Sutter using it as a fun slide example / demo.
@stephenborntrager6542
@stephenborntrager6542 6 лет назад
No, you absolutely don't need properties, and that's not what this is about. This mechanism simply allows you to create properties. You could make something totally different. You could create a type category that is required to have only private data members, public virtual functions, no default constructor, and call them 'winsaucables'. The could throw an error message that says "you lack the win" if you try to include a public data member... (Of course, this is obvious abuse, for purpose of example.) It's damn flexible.
@thought2007
@thought2007 6 лет назад
What is this idea called, exactly? If metaprogramming refers to programming at compile time using traditional templates, what is the $-style metaprogramming?
@thought2007
@thought2007 6 лет назад
Metaclass. Listen to the whole talk.
@matsju2193
@matsju2193 6 лет назад
I snickered a little at "a name is a word of power if it's compile-able." I'll have to remember it and wait for a good opportunity to quote you on that.
@stephenborntrager6542
@stephenborntrager6542 6 лет назад
I wonder if "fus-roh-dah" is compile-able...
@joaotavora9434
@joaotavora9434 2 года назад
This is good, but I find myself laughing in Common Lisp very often.
@yash1152
@yash1152 Год назад
yeah, there are very few comments about lisp here, glad to find one
@kullatnunu6894
@kullatnunu6894 6 лет назад
"Code don't lie, code compiles, code unit tests" ... nice :) 1:14:16
@yash1152
@yash1152 Год назад
bi-dir arrow would be a much better name. i am afraid the "spaceship" name will stick if not changed immediately 1:04:04 ain't spaceship such a weird name for an operator??
@edwardmorley8359
@edwardmorley8359 6 лет назад
I'm not certain I agree with all of this. I like some of the ideas presented, but I see a tendency to over-simplify in such a way that it loses context and meaning. Some of these ideas may better fit into modules which are specific to certain usage; others I think could be developed on an open source library like what Google is doing with Abseil, if for no other reason than to create a library for the people that need it and use it, without continuously adding to C++ and over-simplifying access to it in such a way that you no longer need to understand what you are doing to do it. Which unfortunately some of these ideas seem to accomplish. That might not seem like a bad thing short term, but long term it is very likely the number of programmers who actually understood the language would diminish, and eventually it may even result in the language being smarter than the user, with no one knowing how to maintain it because all they understand how to do is use the front end to accomplish goals. Or basically, it seems like many of these ideas target simplification of C++ to the extent that most users interface with it as a scripting language, while the real work is hidden from them and not truly understood anyway. Eventually the language will stagnate, with no users that truly understand it, or how to make it better, or improve on or add to it. This seems very much contrary to the goals set for C++, and it is certainly contrary to advancement. All it really accomplishes is a short term, individual goal of making work easier. Efficiency is great, but I think it is better to know what you are doing, and develop efficient methods, than have efficient methods and not know.
@edwardmorley8359
@edwardmorley8359 6 лет назад
Basically it started off well, then had a lot of things touched on or added to which could be handled by other means, then touched on one thing that was truly interesting, and seems to have gone back to adding things which could probably better be handled by other means. Just my opinion of course. I am a relative newcomer as well, having been interested in programming for a number of years, but never spent any time on it besides watching tutorials, and understanding it from a software development perspective, (that's possible, perhaps surprisingly, for someone who doesn't actually use it). Point being, I don't write code, but I am learning about it. Almost strictly C++ as it is the only one that really interests me, and it seems that most other languages become more readable and easier to understand as I learn about this one. C#, lua, etc... Consider that a disclaimer.
@YourCRTube
@YourCRTube 6 лет назад
I know it is early to talk syntax, but I believe "class" and "meta" are already too heavily used in C++ and introducing "yet another class" and "yet another meta[programming]" will be hard to teach ("when to put $ in front of my class" questions) and for tools like search engines to pick up. I think, much like concepts this needs to have both keyword and a distinctive name. What about *blueprints* because it is exactly what these are - a blueprint for the compiler to create new type.
@yash1152
@yash1152 Год назад
> _"for tools like search engines to pick up"_ yeah, that's a very valid concern. like i was trying to search "ConTeXt typesetting language" and it was utterly fruitless 'cz hey, apparently "ConTeXt" is not so popular and it is overpowered by the "context" which is a very common english word.
@softwareEngineer77
@softwareEngineer77 6 лет назад
I'm a C++ guy since the beginning and I love it! I just want to highlight that the "Interface" concept in C++ was really missing!! Something we should have add since the day 1 in my opinion. Look forward to having it ...
@ytsas45488
@ytsas45488 6 лет назад
Cool stuff. But the C++ update cycle is so slow and the standards committee will not get rid of their past mistakes from the language. Ultimately, some other language will take over C++'s place as programmers get impatient of waiting 3 years for less than what they wanted, which gets delayed by another 1-3 years because compilers refuse to implement new additions to the standard library. Or, the standards committee can break backwards compatibility and get updates out faster. Clearly the latter is the better choice.
@howardhinnant
@howardhinnant 6 лет назад
$class good_job { constexpr { compiler.require("STANDING OVATION!"); } }; good_job Thanks_Herb {};
@AstralS7orm
@AstralS7orm 6 лет назад
Write a logic solver in this. Metaovation verified to have happened!
@robbie_
@robbie_ 6 лет назад
I wonder what Herb's IQ is...
@qm3ster
@qm3ster 2 года назад
What's the point of debugging? 🤔 Just make correct programs by composing correct functions.
@endight
@endight 5 лет назад
Who are watching it in 2019??? )))
@ReaperUnreal
@ReaperUnreal 6 лет назад
I'm excited for constexpr blocks and injection. D has had this forever, but I don't get to use D at work, I get to use C++.
@yash1152
@yash1152 Год назад
wow, someone uses D too?
@maximetournier8716
@maximetournier8716 6 лет назад
It's still kind of turning into lisp. A quite creepy one :-/
@chris8443
@chris8443 6 лет назад
Ever heard of Greenspun's tenth rule? :-)
@GeorgeTsiros
@GeorgeTsiros 5 лет назад
@@Ormaaj and then smalltalk. and then forth.
@yash1152
@yash1152 Год назад
​@@GeorgeTsiros wow, never thought to see a mention of smalltalk and forth here but what was the context? the comment u replied to is not visible anymore
@botetescribavicentej.2326
@botetescribavicentej.2326 6 лет назад
I don't see how basic_enum is able to introduce the enumerators outside of the class scope. IMO, all that metaclasses can do is to emulate scoped enums.
@seidenada526
@seidenada526 6 лет назад
"all that metaclasses can do is to emulate scoped enums" That is a really narrow vision, man. You should watch the talk again and try to openly listen what Sutter had to say. He listed many more examples, like enforcing company design rules, being a native alternative to external tooling (moc, etc.), generating several classes and external functions from a single definition and some others. In your comments I just see you looking for "how Sutter examples are different than my definition of enums and such" - and that's the beauty of his proposal: if you don't like it, write your own.
@botetescribavicentej.2326
@botetescribavicentej.2326 6 лет назад
Oh, I'm not saying that metaclasses can be used only to emulate scoped enums. It can be used for a lot of useful things. My concern was only about enums. I don't see how basic_enum can be used to emulate non-scoped enums. I would need to check to which slide the comment is related to.
@seidenada526
@seidenada526 6 лет назад
Oh, I got it. I don't see either how a metaclass could emulate non scoped enums, but that's not the idea for basic_enum (slide 58 btw). This metaclass is just an example of a base metaclass to allow the construction of enum_class and flag_enum without rewriting the common metalogic. He never stated that basic_enum is equivalent to the old, classic enum. Hope it helps.
@botetescribavicentej.2326
@botetescribavicentej.2326 6 лет назад
You are right, he disn't dais that. However in slide 59 1:11 Herb wonders if we had had several years ago metaclasses if we would introduce *enum class* in the language. Well, with *enum class* we introduces also the possibility to set the underlying type with non-scoped enums, and the basic_enum metaclass cannot be used to emulate this feature. In addition *enum class* can be used in switches and as template parameters. classes based on metaclass basic_enum couldn't not. I'm all for this powerful tool. Maybe too powerful. My point is that sometimes we need to change the language. Metaclass is not the solution to everything. Sometimes, it needs other changes, as maybe having any literal class as template parameter and why not have a switch that access as well any literal class.
@MarcoAntoniotti
@MarcoAntoniotti 6 лет назад
defmacro
@TaiDesHen
@TaiDesHen 6 лет назад
I am 50 minutes in and this looks a bit weird to me, why not use some attributes, to allow code injection? the 'interface Shape' instead of [interface] class Shape looks a bit weird to me, where is composition here?
@konstantingeist3587
@konstantingeist3587 6 лет назад
i thought about the fact that "random_word Shape { };" is probably grammatically ambiguous? they should make it "interface class Shape { };" instead, which fits nicely with "enum class" (and so enum could be even probably pushed to the standard library as a metaclass)
@alexc.p.2597
@alexc.p.2597 6 лет назад
This. Exactly what I was thinking while watching it and also how inelegant having both enum class and enum_class was
@TaiDesHen
@TaiDesHen 5 лет назад
Well, my main point in there was, that it does not look like that version of the proposal allowed for composition at all. which is usually needed in things like these.
@ska4dragons
@ska4dragons 3 года назад
@@hamu_sando 13:37
@chrisminnoy3637
@chrisminnoy3637 Год назад
C+23 around the corner, nothing of this unfortunately in the standard....Herb, push your weight
@TanzinulIslam
@TanzinulIslam 6 лет назад
All this reminds me of Perl (more 6 than 5) and JavaScript. And no, I'm not talking about the '$' syntax similarity with Perl, but the idea/practice of designing "everyday" language features with deeper meta-features.
@catbertsis
@catbertsis 6 лет назад
Tanzinul Islam i
@Ratstail91
@Ratstail91 Год назад
Oh shoot - free iPads.
@DanielJamesCollier
@DanielJamesCollier 6 лет назад
RIP compile times
@DanielJamesCollier
@DanielJamesCollier 6 лет назад
Although I do love the idea of meta classes
@stephenborntrager6542
@stephenborntrager6542 6 лет назад
His makeshift example for interfaces literally finished in half a second. I think this could actually improve compile times overall, at least compared to current template techniques.
@cc.jsullivan
@cc.jsullivan 6 лет назад
This will probably improve compiler performance where these techniques are used already, as every metaclass will have one concrete ruleset that is defined for every implementation, rather than having to depend on individual template instantiation per usage.
@kwinzman
@kwinzman 5 лет назад
If this replaces preprocessor and proprietary precompilers - think the QT compiler tool chain - then not necessarily.
@bobweiram6321
@bobweiram6321 2 года назад
Too bad their iPads doesn't support C++ as a first class language.
@botetescribavicentej.2326
@botetescribavicentej.2326 6 лет назад
I know a lot of people has defined his own flag_enum as you do in the presentation. I believe this is a design error. As Kevlin Henney described in his Flag Waving (www.two-sdg.demon.co.uk/curbralan/papers/FlagWaiving.pdf) we need to have some kind of enum_set type that is a different type of the enum itself. This can be generalized even to Ordinal types (types isomorphic to 0..N) and have an ordinal_set that works for all enums (that have all its enumerator different) and any other Ordinal type.
@platin2148
@platin2148 6 лет назад
Would really like something like: MySimpleClass mySimpleClassObject = ();
@aliancemd
@aliancemd 6 лет назад
All I see is macro_rules! :)
@vittorioromeo1
@vittorioromeo1 6 лет назад
Except for proper namespacing, proper reflection (even for types outside of your control), and nice imperative syntax :)
@johndubchak
@johndubchak 6 лет назад
Yeah! What Vittoria said! :-D
@EgnachHelton
@EgnachHelton 6 лет назад
But toolable
@ruadeil_zabelin
@ruadeil_zabelin 6 лет назад
4:12 Why not use the new syntax? Any reason for this? auto operator(const CIString& b) const -> std::weak_ordering or even just auto operator(const CIString& b) const Was it to not overwhelm?
@Sopel997
@Sopel997 6 лет назад
the first one does not buy you anything, the second one cannot be deduced
@ruadeil_zabelin
@ruadeil_zabelin 6 лет назад
The first one buys you consistent syntax throughout the whole code if you "Almost Always Auto" which is another one of his talks
@ongamex
@ongamex 6 лет назад
this is an example, you need the types to be explicit this is a new code on a presentation, you cannot deduce them by yourself.
@Sopel997
@Sopel997 6 лет назад
if you AAA you're doing it wrong
@ruadeil_zabelin
@ruadeil_zabelin 6 лет назад
And why is that? I find it rather nice, consistent and readable.
@ongamex
@ongamex 6 лет назад
if interface is used for concepts and not just abstract base classes it would be much better, we do not need interface..
@ongamex
@ongamex 6 лет назад
ah i didn't get it the fist time, he is describing a different feature
@alexo989
@alexo989 2 года назад
I keep wondering - who really needs all these bs ? who asked for it ? what happened to the main rule of programming "if ain't broken don't fix it"? we already had multiple( and completely useless in retrospect) fiasco with pre-processor generated code 2 decades ago , so we decided to create something even more convoluted to do that ? "you can do it in Java" , "you can do it in c#" - then freaking do it there , why do you use c++ in the first place ?
@JuvStudios
@JuvStudios Год назад
There's some value with this. Unlike other languages with heavy reflection mechanism, with this you would be able to ask the compiler just the things you need and store only that. It also enable simplifying certain common patterns. While other languages maybe have such features already, they are non-extensible.
Далее
CppCon 2019: Jason Turner “The Best Parts of C++"
58:36
50 YouTubers Fight For $1,000,000
41:27
Просмотров 132 млн
CppCon 2018: Jason Turner “Applied Best Practices”
1:03:19
Should you learn C++?? | Prime Reacts
20:29
Просмотров 331 тыс.
50 YouTubers Fight For $1,000,000
41:27
Просмотров 132 млн