Plenary: The Beauty and Power of 'Primitive' C++ - Bjarne Stroustrup - CppCon 2020

preview_player
Показать описание
---
Often, we focus on novel, clever, and advanced features of C++. To contrast, here I look at addressing relatively simple problems in relatively simple ways under severe constraints of performance, ease of use, and reliability. My main example is to read and write typed objects from and to a byte buffer. This is of course something we do a lot and in a bewildering variety of ways. Any object that needs to be stored or transmitted to another computer must go through such a process. However, the constrains on such reading and writing varies immensely based on the kind of data to be moved around, the performance and reliability requirements, the hardware available, and history. Many trade-offs are possible, and many different interfaces. That makes this an interesting design exercise.

This is an exploration of a design space close to the hardware and of the use of C++ in that space, rather than a standards proposal or the presentation of a mature tool chain. And, no, by “primitive”, I don’t mean “old-fashioned, C-like” code; some of the general techniques are old, but some of the code requires C++17 and much could be done better given features we are unlikely to get even in C++23.

---
Bjarne Stroustrup
Technical fellow, morgan stanley
C++: history, design, use, standardization, future; performance, reliability; software developer education; distributed systems

---

*-----*
*-----*
Рекомендации по теме
Комментарии
Автор

This man is a mad genius. Still super sharp and ready to solve any problem thrown his way. Nice!

madezra
Автор

Really interesting approach. Good to see how the C++ creator uses C++ to solve a challenge. Also, I love when I can replace a large ultra-generic library with a small specialized "in-house" code.

ecosta
Автор

Really interesting to see Bjarne solve something so common, so diligently and so insightfully.

dream_emulator
Автор

Thanks Bjarne!! Great video! can't wait to take a look at the code

yoniyash
Автор

It's weird to see Bjarne give a talk that isn't a "big picture" overview of some part of the language. It's easy to forget that he's a working joe that just wants to write code like the rest of us.

superscatboy
Автор

Great content. Thanks for making it.

And also. Why there aren't any comments.

justcause
Автор

Maybe I am missing something, but isn't this serialization approach used by the google flatbuffers project?

bjkaria
Автор

I was curious to see what technique was used to view an existing raw memory buffer as a "flat" type (like Pair) when it is already populated with the byte representation (from a read operation), but does not yet have a C++ object of the flat type in existence there, with zero copy and without undefined behaviour. It's too bad that there wasn't time to cover that important detail, including how any sizes and offsets in it are bounds checked before use.

ChetMcSheply
Автор

Where can this flats library be found?

ecarew
Автор

I did a serialized object data inspired by BSON. It's called HiBON the purpose is to be hash invariant so the target is different but it would interesting to make a convert

carstenrasmussen
Автор

Awesome talk. What happens when you initialize a blank string field by size only (Extent), but set it later with shorter data? Do old byte values leak into the remaining space?

LucasHartmann
Автор

32:46 Shouldn't the "array with constant but runtime-known size" be called dynarray, not vector?

NoNameAtAll
Автор

why does Tail_ref Allocator::place(Allocator *a, const char *str) take a pointer to Allocator? it uses a->max and a->next to access Allocator::max and Allocator::next, but then it assigns to Allocator::next with next += sz. What?

alexparker
Автор

44:10 Looks like the assignment operator may read past the end of p. Can it lead to serious errors?

X_Baron
Автор

Does this have any benefits over the "plain old C" approach?

praphael
Автор

First step: rename all .c files to .cpp and compile with C++ compiler, and then fix all errors and warnings.

CookiePepper
Автор

Primitive Means build in classes like int etc... ???

roadtoprogramming
Автор

Beauty my ass. It's more fast and practical. What's wrong with that

Kenbomp
Автор

It's only me or all of these look ugly in both API and implementation parts? Thank god that won't be pushed into std. Performance is awesome (looks at a glance at least), but I won't be bothering even with 500 lines of such code.

mapron