HN Theater @HNTheaterMonth

The best talks and videos of Hacker News.

Hacker News Comments on
CppCon 2018: Nicolai Josuttis “The Nightmare of Initialization in C++”

CppCon · Youtube · 19 HN points · 6 HN comments
HN Theater has aggregated all Hacker News stories and comments that mention CppCon's video "CppCon 2018: Nicolai Josuttis “The Nightmare of Initialization in C++”".
Youtube Summary
http://CppCon.org

Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/CppCon/CppCon2018

After introducing uniform initialization with C++11, there are at least 5 ways in C++ to initialize an object.
Each have them has different rules, different effects, and different usage depending on the context and goals.
The situation is so confusing that today nobody can tell anymore which type of initialization to teach to beginners.
That's nothing but a disaster.

This talk will discuss the different forms of initialization, compare them to know when to use which, discuss what changed with C++14 and C++17 and what still has to change, and finally what to teach now to beginners.
I promise a source of trouble and discussion.

Nicolai Josuttis
IT Communication

Nicolai Josuttis (http://www.josuttis.com) is an independent system architect, technical manager, author, and consultant. He designs mid-sized and large software systems for the telecommunications, traffic, finance, and manufacturing industries.

He is well known in the programming community because he not only speaks and writes with authority (being the (co-)author of the world-wide best sellers The C++ Standard Library (www.cppstdlib.com), C++ Templates, and SOA in Practice), but is also an innovative presenter, having talked at various conferences and events.

Videos Filmed & Edited by Bash Films: http://www.BashFilms.com

*-----*
Register Now For CppCon 2022: https://cppcon.org/registration/
*-----*
HN Theater Rankings

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this video.
Oct 29, 2022 · 3 points, 0 comments · submitted by Tomte
Mar 03, 2022 · 7 points, 0 comments · submitted by Tomte
What a tour de force! Thanks for the link. It beats my previous favorite C++ presentation:

"CppCon 2018: Nicolai Josuttis “The Nightmare of Initialization in C++” https://youtu.be/7DTlWPgX6zs

Next Halloween I will dress up as std::variant

Several CPPCON talks in recent years have reinforced that for me as well. https://www.youtube.com/watch?v=7DTlWPgX6zs, for example.

Edit: I originally linked to the wrong video (https://www.youtube.com/watch?v=TFMKjL38xAI), which was a different talk by the same person.

Jun 30, 2021 · 2 points, 1 comments · submitted by Tomte
belter
This has been posted five times in HN, strangely never had any comments. So I will add one here...

1) Its a great presentation by Nicolai Josuttis https://www.josuttis.com/

2) It should be essential view for the many that have to or want to work with C++ code bases.

3) In C++ here is an enormous amount of work that happens behind the scenes. In working groups, committees and conferences but still, I admire Nicolai Josuttis willingness to constantly stick his neck out and propose improvements to what is a nightmarish ecosystem. Another example is this presentation where he tries to fix std::thread:

  "std::jthread - I Told You Concurrency Is Tricky - Nico Josuttis [ ACCU 2021 ]"

   https://youtu.be/ln5ERAVXEMY
   
4) I normally watch this any time I dabble with the idea of doing any more C++... Then I come to my senses and go back to C and Rust :-)
Agreed.

Just gonna drop this here: Nicolai Josuttis “The Nightmare of Initialization in C++” [0]

[0] https://youtu.be/7DTlWPgX6zs

pietroglyph
The thing is that this is not a huge issue in practice. I stick to uniform initialization in 99% of cases and it works out pretty well. I have far fewer bugs from initialization screwups than from other things.
Aerroon
But what kind of an effect does this have on someone new learning the language? It seems to me like it would make it slightly harder to learn and get used to.
lenkite
Simple, read and religiously follow the Core Guidelines. Bad, converting initialisations are also flagged as warnings (or errors with -Werror).
May 07, 2020 · 2 points, 0 comments · submitted by Tomte
I think this depends to some extent on the type of job you're going for, which might seem trite but a graphics role is going to be different from a systems programming role.

I've been writing Java for a long time and tired after a while of the JVM "getting in the way", and the lack of bare-metal acceleration available. Eventually designing and working on zero-GC systems led me to wonder why we didn't just write it in a compile-to-native language in the first place. I skipped both C and C++ and started hacking on x86 and amd64 assembly. It turned out that approaching C after that was fairly straightforward, with the dark corners of the standard libraries forming the still fairly gentle but steepest parts of the learning curve. I've been writing a toy project in it for a while and it's been a lot of fun. Implementing what I understsand to be Modern C's Best Practices have left me with something fairly usable :-O

I've also looked at what you'll probably hear called Modern C++, but IMO it's and order of magnitude harder to get started on. I was watching Nicolai Josuttis' "The Nightmare Of Initialization in C++" the other day[1], which chimes with the first chapters of Scott Meyer's "Effective Modern C++". What a mess (C++ initialisation, not the book)!

Java's potentially a better bet in the wider market as the number of job listings could be higher, but others may disagree. That said, Java is now a vast ecosystem and you'll need to learn at least one of its various build tools. I'm not sure whether it's worth recommending a set of third-party libraries to learn, as each shop will have their own preferences. Being aware of the larger Apache projects and what they offer will probably help. Perhaps even start hacking on one of those or become a contributor?

If you feel you'd rather get into C or C++ then I'd recommend getting a deeper understanding of data-structures, as well as your target OS's IO APIs. You can be very productive in Java before you have to think too hard about them.

HTH.

[1] https://www.youtube.com/watch?v=7DTlWPgX6zs

Nov 06, 2019 · 1 points, 0 comments · submitted by Tomte
Sep 17, 2019 · kinjba11 on Why Go and Not Rust?
C++ has more historical baggage than any other mainstream language. Consider something as simple as initialization: https://www.youtube.com/watch?v=7DTlWPgX6zs
Apr 08, 2019 · 2 points, 0 comments · submitted by Tomte
C++ initialization is such a convoluted mess that CppCon was able to have an entire hour dedicated to "The Nightmare of Initialization in C++".

https://www.youtube.com/watch?v=7DTlWPgX6zs

C++ has a rigorous standard. There is no rule that wasn't added for a reason. Nor are there lines of code with which you can specify which rule it must follow.

The path to hell is paved with good intentions. Just because each step is logical and defensible doesn't mean the end result isn't fire and brimstone.

I believe that good things are more than the sum of their parts. You often hear this with respect to creative works like movies or games. I think it also applies to source code, language design, and much more. The flipside is that bad things are less than the sum of their parts. I've shipped games that fall into this category. C++ initialization has a LOT of parts. And I would strongly argue the end result is less than the sum of those parts.

Nov 17, 2018 · 2 points, 0 comments · submitted by Tomte
HN Theater is an independent project and is not operated by Y Combinator or any of the video hosting platforms linked to on this site.
~ yaj@
;laksdfhjdhksalkfj more things
yahnd.com ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.