Пікірлер
@Roibarkan
@Roibarkan 4 күн бұрын
A documentary about Sherry’s great book: kzbin.info/www/bejne/nHuTiWuIhLKGi9k
@sufalt123
@sufalt123 5 күн бұрын
cool
@8Johnny8Catsvill8
@8Johnny8Catsvill8 6 күн бұрын
Good talk, I liked it
@beremour
@beremour 7 күн бұрын
30 minutes still bla-bla...
@guiorgy
@guiorgy 7 күн бұрын
Cool story, wish the camera didn't have seizures though
@trk03t123
@trk03t123 8 күн бұрын
There is a Bug in slide 37. If void operator(void* ptr) {d_(static_cast<T*>(p))} is done then with smartptr_te<void> widgetPtr = smartptr_re(new widget(), [](auto p){ delete p; }) above "widgetPtr" will be called for d_(static_cast<void*>(p)) which is not correct. Real type erasure is deleter function with whatever param as such will be templated and stored internally at COMPILE time. No lazy cast while invoking the deleter. IMO. GCC have a test static_assert(__is_invocable<_Deleter&, _Yp*&>::value, "deleter expression d(p) is well-formed"); _Yp is of type widget and not Void.
@LegalizeAdulthood
@LegalizeAdulthood 9 күн бұрын
Avoiding tax is a virtue, not a sin.
@xealit
@xealit 10 күн бұрын
yey for POD messaging! especially in embedded. There is a reason why embedded people love C. They know what they are doing.
@CrazyMig
@CrazyMig 11 күн бұрын
Seems nice, but where is the link?
@romanzelenyi982
@romanzelenyi982 11 күн бұрын
I cannot agree that the requirement for moved-from object to be in a valid state is a mistake. Otherwise the standard must define a new state of object. Also, moving operation can be conditional, so there must be a uniform way to detect that state. All this would bring more complexity to the core language, not just the standard library.
@jonkalb2746
@jonkalb2746 6 күн бұрын
@romanzeleny1982 Thanks for taking the time to watch the video. I don’t agree for all the reasons that I put in the video. Note that although it would be helpful for the standard to spell out what I advocate for in the video, it isn’t truly necessary. As long as the standard doesn’t get in the way, which seems to be its direction. It is true that moving may be conditional, but there is no situation where that is true that proper (non-logic error) code doesn’t just assume that the object is, in fact, moved from. This doesn’t add any complexity. The complexity is already there. The only question is do we write code that neither compromises performance nor contains logic errors.
@TheHackysack
@TheHackysack 12 күн бұрын
This was very entertaining! Kudos!
@GraziaMacahilas
@GraziaMacahilas 13 күн бұрын
Investments are the roots of financial security; the deeper they grow, the stronger your future will be."
@Cirwlos
@Cirwlos 13 күн бұрын
From a didactical viewpoint, this is a disaster.
@MaddieM4
@MaddieM4 14 күн бұрын
I've been doing this informally in my head for years! It's really useful to see it formally laid out though, especially because it makes it easier to collaborate with other devs on problems.
@RicardoCapurro
@RicardoCapurro 15 күн бұрын
Congratulations!! Very interesting exposition about the burden introduced with move semantics on RAII and lifetime of objects, years ago when studying this I realized the same problems, and I concur it is a pity this had been implemented this way. Let's see if for cpp2 Herb fixes this problem, since function constructors are a great oportunity to consider moving to destruct the object and fix once and for always this problem.
@jonkalb2746
@jonkalb2746 6 күн бұрын
Thanks for your kind words. We’ll have to see where cpp2 ends up.
@peterprokop
@peterprokop 15 күн бұрын
I did a 500.000 LoC C++ project 20 years ago, very complex, real time 3D stuff with a DOM and Javascript interpreter, and it also required a lot of raw memory access to feed the graphics API, and I don't recall having these kind of problems. Used the standard library extensively, made a lot of own containers and iterators in std-library style, and don't remember having any issues with out of bound operations. Used smart pointers for everything long before it was in the standard. The downside was that I went totally overboard with c++ language features, including generating bindings for javascript, having multiple inheritance with heavy templating, data dependency management on the DOM with lazy evaluation, ultra-fast serializing and de-serializing, distributed operations, and processing audio, video inside a 3D-scene graph. When I read the code today, I am still amazed what I managed to put together, with a team of a dozen people, but it is just over-the-top in use of design patterns and language features. I think nobody but me fully understood it, and this is not a good thing. I worked, was deployed over a decade long in public-facing projects worth tens of millions, and ran reliably for months without resource leakage or crashes. But it was just too complex, I think. I even rewrote the garbage collector of the javascript interpreter. Implemented my own XML parser and DOM, type checked by XML-Schema, with all data having text and binary representation, kept lazily in sync. There was also lazy evaluation of bounding box calculation, and you could operate on the DOM and change everything, and dependencies were automatically installed or torn down with it. Pure horror in terms of memory and lifetime-management, and pure horror in complexity. I think code should not be that complex. Often simpler is better, but template metaprogramming combined with multiple inheritance is just too powerful to not make use of it, and then there are no limits in what you do. You can just cram in so much functionality that it makes your eyes bleed. Regarding writing safe and secure software, you can do that in C++ for decades already, but you have to know how and have the time and money and will to do it, and often it lacks one or more of these ingredients. Lowering the threshold and providing reasonable defaults to make C++ safer and more secure is a good thing to do, but the whole thing seems to be more a mental or political problem, and nudging people towards isn't bad, but may not be enough. However, requiring Rust for everything or turning C++ into Rust also does not seem to be a solution. Turns out, while Rust comes with impressive guarantees, it seems not well suited for game programming, and exploratory programming in general. The main problem is that you need to plan and think ahead more in Rust, and you can't easily try out "forbidden" things just to see if they work, and often you need to make a lot of changes to try small things. While it seems something that might be overcome with experience, at least one group of developers gave up after years of trying. I have not done anything in Rust yet, but I programmed in dozens of languages, and find C++ still the most versatile, and using Python to glue C++ stuff together is just great. Another aspect seems to missing: How will AI fare with C++? The good thing is that C++ provides robust capabilities to check code at compile time, and AIs seem to fare good with C++, but I did not try to use it for advanced C++ stuff. Changing the language too much might cause problem with AI software generation, but C++ is also pretty good at providing a safety net for AI coding - just something to think about. We will need the choice, but having the choice is also dangerous. This is a Catch 22. There is no good solution, but your direction seem so far ok to me. It won't solve the problem though, but it is usually preferable to have working, buggy software than no software at all, and we are fighting against this strong incentive, and I don't think we can win, we can only make an effort. Software development, even as an engineering discipline, is about mental models that are shared with a machine, and it is an art form, too, and art has no bounds. :-)
@cdriper
@cdriper 15 күн бұрын
great talk! I was skeptical before I see possibility to have a separate transition table
@Peregringlk
@Peregringlk 16 күн бұрын
Reference semantics for that kind of context like sort is expressive enough. Like, if my T-shirt is dirty, I want to clean my t-shirt, not copy my t-shirt, clean the copied dirty t-shirt, and when it's clean then replace it by my original dirty one. I want to clean THIS T-SHIRT, and every single little piece of code must be as closer as possible as the way we human think. Besides, if I go to a coworker, where 99% of workers focus on practical things and consider all of this kind of very technical stuff to be in the realm of nerdy obsessions, how would you convince them to change a very expressive way of writing things to a less expressive way of writing things without any actual, practical gain? It's much cheaper keeping things as simple as possible and debug the errors when they happen, than letting complexity get out of control and adding more and more features trying to patch the consequences of complexity going out of control. Making a modification inside a comparison function is complexity going out of control and THERE is where people have to attack: by teaching people that they should not do that. In my opinion some uses of references are fine, specially functions where its only mutable reference is the first argument, because we are very used to it thanks to assignments a = b.
@AbrahamsDave
@AbrahamsDave 5 күн бұрын
The ability to say “clean THIS T-SHIRT” is not hurt one bit by banning reference semantics. The argument is that by giving up the expression of shared mutable state you get practical gain in correctness, local reasoning, and efficiency. Also that pervasive use of references very quickly lets complexity gets out of control. The modification inside the comparison function is a particularly perverse example, but the point isn't to show that references are dangerous. The point is to show how they affect our ability to accurately and simply describe a function's contract. The more complex the accurate contract is, the harder the function is to use The kinds of things that happen with signals/slots or the observer pattern are much more typical paths to this kind of loss of control with references. I often see code that's 5-10x more complicated than it needs to be, and very difficult to debug or refactor because people are using shared_ptrs liberally. It's fine if you're not convinced, of course.
@peterprokop
@peterprokop 16 күн бұрын
Maybe at some point a language like "SimpleC++" might be needed, that contains only a subset of libraries and properly handles "old" code.
@peterprokop
@peterprokop 16 күн бұрын
Wrote machine learning code using GPU+CPU on an iPhone. Optimized it so much that it started to slow down after 15 sec and a minute before the phone got overheated. That was a bit frustrating because I needed the power.
@lbgstzockt8493
@lbgstzockt8493 16 күн бұрын
I relate to 57:00 a lot. When I use C++ it looks like someone writing python with different syntax. When I see people who complain about C++ being complicated write C++, it looks like completely unreadable code that I could not understand in a million years because it is 90% abstractions and unintuitive ways of doing things.
@dearfl1924
@dearfl1924 17 күн бұрын
Why not use something like std::vector<std::variant<small_type, std::unique_ptr<big_type>, ...>>?
@amirrezaghorbani2715
@amirrezaghorbani2715 17 күн бұрын
This is the type of talks I very much like. Not just telling you what to do or show you end result/product. But actually explaining the iterative process and design evolution clearly. Wonderful talk. Thanks.
@alanwest6949
@alanwest6949 18 күн бұрын
mycolouredcircle = colour{other} << 180_degrees; In value oriented programming I see conversion operators used as getters for the intrinsic properties, along with assignment operators again for intrinsic properties. I’m assigning a position to a positionable circle: mycircle = position{0,21}; I’m expecting colour::colour(colour const& other) to call operator colour const&() on any passed in object, but currently have to use alternative constructor with concept requires obj.operator colour const&() In the past I explored writing intrinsic properties as super classes, struct vector: capacity, size, data {}; Like why write a size_t capacity(vector const&) function when I can have a capacity value, and copy construct from an intrinsic property directly. I’m thinking C++ isn’t for value oriented programming. When I get around to it I may just C++ (see more) into a new language.
@speedstyle.
@speedstyle. 18 күн бұрын
Just don't put big types in std::variant, it has the 500x padding all on its own. You can put those types behind unique_ptr (similar to the small object optimization suggestion) or separate the logic for them with overloads/templates/polymorphism. Interesting points on heterogeneous containers generally though. It's not too different from the double-indirection version, with `offset` storing pointers into `array` a bump allocator
@Avantarius
@Avantarius 18 күн бұрын
An interesting talk. But also a cautionary tale about how C++ programmers over-engineer everything. I would just have slapped the 5000 byte struct inside a unique_ptr and called it a day.
@tommaisey9069
@tommaisey9069 19 күн бұрын
Just wrap the largest variant T in unique_ptr?
@314Labs
@314Labs 19 күн бұрын
Great talk. Learned a lot. Though, so many “umm”s..
@ChlorieHCl
@ChlorieHCl 19 күн бұрын
For the type/offset storage, I think it could be combined together, since you're already using bitfields for your type indices, i.e. store the type information in the LSB of an unsigned integer and store the offset in the MSB.
@ChlorieHCl
@ChlorieHCl 19 күн бұрын
I have another idea: Store an tuple of std::vectors in the vv type alongside a similar type/offset storage that index into the tuple of vectors. This will bloat the stack size of the actual vv type significantly but it solves all the problems w.r.t. alignment or insertions, since you can just manipulate the underlying normal std::vector of the corresponding type. The heap memory usage of this approach will be the same as that of your proposed implementation.
@adamrushford
@adamrushford 19 күн бұрын
stop teaching me more C++ I'm already fully insane
@lbgstzockt8493
@lbgstzockt8493 18 күн бұрын
lol
@tlacmen
@tlacmen 19 күн бұрын
the operator [] could return const variant, thus making assigning a compiler error. however, this could lead to unintended copies where people spell out the actual type instead of auto.
@Cfretz244
@Cfretz244 16 күн бұрын
I just learned something new! I considered this, but I mistakenly thought that const qualifiers were discarded by the language on return by value. However, testing it myself, your suggestion does actually appear to work! Yeah, that would be my next concern, auto always deducing const, even when you don't want it, and it also wouldn't behave as expected with binding to rvalue references, but this is very interesting, thank you! If I ever give this talk again I will present the pros/cons of this idea.
@theevilcottonball
@theevilcottonball 19 күн бұрын
C++ people trying deparately to avoid writing C.
@TsvetanDimitrov1976
@TsvetanDimitrov1976 19 күн бұрын
Personally my first choice would be a struct of vectors instead of vector of variants. No problems with alignment, minimal storage, and minimal complexity(unless there are additional constraints like keeping the "variants" ordered, but that can be solved with just an additional indirection)
@retropaganda8442
@retropaganda8442 19 күн бұрын
Well, the "target" model presented has been around for fifteen years in many C++ build systems. You can assume people already know about this and just take time to discuss a standardized format.
@edhemavdagic6664
@edhemavdagic6664 19 күн бұрын
great talk! quick question though: how exactly does vv::vector::visit figure out the type of the thing it's looking at? You're storing the type metadata in an array on the heap, so you can't use those runtime values to index into a type list or call the std::in_place_index_t constructor of std::variant. How do you map the runtime index to an actual type?
@edhemavdagic6664
@edhemavdagic6664 19 күн бұрын
got a basic version working with some magic fold expressions ✌thanks again for the cool talk 😄
@ConceptInternals
@ConceptInternals 19 күн бұрын
To avoid alignment issues, I think that we can store different types inside different vectors. I am not sure which operation will be more complex in comparison to proposed approach, but maybe something to look into..
@PaulTopping1
@PaulTopping1 19 күн бұрын
Why not store each of the possible types in the variant in separate vectors of each type? So a vector<variant<int,double,string> ends up being a proxy object that contains three vectors: vector<int>, vector<double> and vector<string>. All the alignment issues disappear. You would still have the capacity and size issues. Iterating and indexing are a bit tricky. Still, I'm surprised that this was not one of the designs considered.
@Arwahanoth
@Arwahanoth 18 күн бұрын
You would have too much cache locality and performance issue I think.
@andersama2215
@andersama2215 18 күн бұрын
Chipping in, you only really need to form vectors* for different alignments, then because accesses need type information and offset/index/alignment information store those as a tuple or a trivial type of integers (or a single uint64_t where the top bits are used to distinguish the type and alignment).
@bailiscremey8302
@bailiscremey8302 16 күн бұрын
I believe the C++ standard guarantees elements of a vector be stored contiguously and sequentially in memory, so that, for example, any library function which expects a pointer to the start of an array can work with data from a vector
@romanzelenyi982
@romanzelenyi982 12 күн бұрын
Perhaps, to satisfy ContiguousContainer requirement, as std::vector does.
@ChristianBrugger
@ChristianBrugger 19 күн бұрын
Wonder if the idea was considered to have one vector for each type. The type array would then give which array to look at. And the index instead of bytes would store the index in that specific array. That would make the internal implementation quite a bit simpler, while adding a bit more stack space. Heap storage and performance characteristics should be similar.
@KonradGM
@KonradGM 20 күн бұрын
i prefer the syntax showed at operator= a lot more than what we have today lmao
@higaski
@higaski 20 күн бұрын
JFYI GitHub meanwhile offers unlimited private repos
@alanwest6949
@alanwest6949 20 күн бұрын
I see investors and company owners will ‘Law of Attraction’ attract big obvious reflections of their actions. If their products are full of exploits it tells me they’re exploiting people. It would therefore be a mistake to continue working for them as you’ll subconsciously express in code, reflections of their actions. Potentially being blamed, and going on a journey of invalidating yourself, a further mistake that can be optimised away. This potentially reaches deeper, customers may ‘Law of Attraction’ attract business owners who will exploit employees, subconsciously attracting and buying products with exploits and backdoors that one day help them see their unloving/untrue actions (sins), even if ignorant to them.
@sanjaygatne1424
@sanjaygatne1424 21 күн бұрын
For online viewers, Hey Chat GPT formulate question according to answer given by Marshall Clow.
@simonmaracine4721
@simonmaracine4721 21 күн бұрын
Great talk!
@paulfloyd9258
@paulfloyd9258 21 күн бұрын
The functionality of sanitizers has been around for much longer than the last decade. Purify has been around since 1991 (over 3 decades ago) and Valgrind since 2002 (over 2 decades ago).
@brockdaniel8845
@brockdaniel8845 21 күн бұрын
Oh man he didn't know about the "Safe C++" proposal
@codures
@codures 22 күн бұрын
1:31:16 That typo in the title could have been much much worse 😂.
@NickolayGerasimenko
@NickolayGerasimenko 22 күн бұрын
Why do we need to create problems, than with even greater enthusiasm try to solve this problems? Simplest possible way is NOT to use fancy macros and all IDE would be able normally navigate this code. And that code with fancy macros should not pass code review.
@Roibarkan
@Roibarkan 23 күн бұрын
1:28:52 Odins other talk: kzbin.info/www/bejne/jYO3m3-Gf7mWnaM
@SphereofTime
@SphereofTime 23 күн бұрын
9:16 swingdoor turnstile
@SphereofTime
@SphereofTime 23 күн бұрын
8:42 Finite state machine implementation