Day 1 Keynote - Bjarne Stroustrup: C++11 Style

chr1skol1 · 83K views · 2012 · 1:29:48

Open on YouTube

C, C++, Rust, Go & systems languagesProgramming language designSoftware architecture & designtalk

Why Stack Overflow recommends it

Stack Overflow users link it when explaining compiler-enforced semantic and unit types in C++, and as a pointer to staying high level and preferring vector over list.

Recommended by 4 people across 4 different months, 2013 to 2018.

What it is

Bjarne Stroustrup's opening keynote from the 2012 GoingNative conference, presenting a modern, high-level style of writing C++11. He covers type-rich programming, zero-cost abstractions and choosing sensible default containers.

What people said

Recommends Félix Cantournet · 2014-09 · Stack Overflow · on “Simple types with higher meaning (C++11)”

I suggest you watch this keynote by Bjarne Stroustrup, specifically starting @ 21 minutes. He explains how to enforce meaningfull types and units using built-ins and C++11. [1]: [this video]

Recommends Centril · 2015-02 · Stack Overflow · on “Why shouldn't I use "Hungarian Notation"?”

@Krumia I would use a language that lets you do zero cost abstractions and declare unit types that can't be mixed, such as C++ (watch: [this video] ca 20 minutes in) or rust: [LINK] In rust, a struct Density(f32) cant be mixed with a struct Volume(f32). With some meta programming and operator overloading, you can add all math operations you need. You could easily make a mistake and mix up lxTank + dTank. With compile time checked types you can not make a mistake, the compiler wont let you.

Recommends U007D · 2016-09 · Stack Overflow · on “Compiler-enforced semantic types”

This issue of getting compiler-enforced semantic types can crop up in all sorts of situations, from your situation to co-ordinate systems with different origins (where the values are all the same type (eg. int), but semantically, the types must not be mixed, because they represent offsets from different origins (x,y,z=0,0,0)--this occurs frequently in mathematics, where, when graphing the quadrant with positive x and y, the origin is in the lower left, and computer science where it is very common to place the origin upper left) to spaceship navigation (more on this last below). In 2012, Bjarne Stroustrup gave an interesting talk on what he called type-rich programming introducing compiler-en

Recommends Piotr Falkowski · 2016-12 · Stack Overflow · on “Multithread wrapper”

I'm not going to answer your question with a template, altough it's certainly a valid approach. I'm going to reccoment insted to use thread pool, and wrapping your all actions into a common interface. see eg.: 1 [LINK] , 2 [LINK] , with boost: 3 [LINK] ' stay high level [this video] '

Cites Sam · 2013-01 · Stack Overflow · on “Relative performance of std::vector vs. std::list vs. std::slist?”

Default data structure to think of in C++ is the Vector . Consider the following points... 1] Traversal: List nodes are scattered everywhere in memory and hence list traversal leads to cache misses . But traversal of vectors is smooth. 2] Insertion and Deletion: Average 50% of elements must be shifted when you do that to a Vector but caches are very good at that! But, with lists, you need to traverse to the point of insertion/deletion... so again... cache misses! And surprisingly vectors win this case as well! 3] Storage: When you use lists, there are 2 pointers per elements(forward & backward) so a List is much bigger than a Vector! Vectors need just a little more memory than the actual ele

Cites user2036087 · 2013-11 · Stack Overflow · on “Finding exactly N consecutives in a sorted list”

I recently stumbled upon a little problem. Part of an algorithm I was working on needed to find n consecutive numbers in a sorted list of numbers. So, for example, the list would look something like this: 1 2 2 3 4 5 5 5 6 7 8 9 9 9 9 Given that list and N, the amount of consecutive duplicates, the algorithm needed to find the first number in the smallest group of exactly N consecutive numbers. So for example with N = 2 and the given list, the algorithm should find "2". With N = 3 it should pass the group of 2's, find the group of 5's instead since it's the smallest group of 3 consecutive duplicates in that list. It shouldn't return 9 since there are actually 4 consecutive 9's and with N = 3

Cites Cris Luengo · 2018-01 · Stack Overflow · on “Is there anything like Haskell Data.Sequence in C++?”

It seems to me that the way to implement* such a data structure you'd need a tree that stores the number of elements in each node. It allows insertion and retrieval in O(log(N)), and indices are maintained simply by counting how many elements there are to the "left" of a given node in the tree. * I'm answering maybe a slightly different question here, the actual question asks for a recommendation for a library, which is explicitly off-topic at SO. A node of this tree would look like this: template<typename T> struct Node { Node* left; Node* right; size_t elements; T value T& access(size_t index) { if (left->elements == index) { return value; } else if (left->elements > index) { return left->