62

To all the C++ programmers who haven't read "Modern C++ Design" by Andrei Alexandrescu yet, READ IT! Its great. To me, it opened up an entirely new approach to designing classes with a whole new dimension of possibilities. And it reads really well! Sometimes I got shivers because the code was so sexy 😅😂😂

Comments
  • 8
    @Lahsen2016
    yes 😫😖💕

    no seriously, yes.
  • 2
    I'll add it to my TO READ list
  • 2
    Agreed. I honestly thought C++ templates were just a convenient meh before reading this thing. Insane.

    For beginners, a quick introduction to compile time computation (just one of the things C++ templates allow) would be this: https://monoinfinito.wordpress.com/...
  • 1
    Thanks man, will look into it.
  • 2
    To everyone including those that never touched c++.. This is the stuff, the homedinger of 🍯 dripping gold paved streets.. Anyone who think of themselves as a programmer should read this just for fun. Overselling it slightly?
  • 2
    @SHA-16384
    I dont have much experience in any other languages exept C++ yet, so I can't help you with that :/

    The concept that this book builds on is that of generic programming. It is basically a way of programming your compiler to generate code for you. In C++ you can define "templates" for classes or functions which take types as arguments. You write these templates just like you would write an actual class, only that a template can have fields of an undefined/variable type.
    Only once you want to use a templated class in your code you define what types it should use and the compiler will generate the actual class/function by inserting the type you provided.
    This means that you can write the "same" class for all the types you will ever need. And while this might sound only barely useful, it is really suprising how easily you can write extremely flexible, expandable and yet efficient code.
  • 1
    @SHA-16384
    But what this book is actually getting at is the idea of policy based design, where you basically construct completely different classes on the fly by providing policies to a host class template. The policies are just classes which define functions and structures and by passing these to the host class template, you construct a completely new class just like that. It is maybe a bit like inheritance, only a lot less limited and also, it is all evaluated at compile time, which means most errors will be caught there.

    I hope I did not just write a bunch of rubbish, I have just started with the book, but the first 10 pages already got me excited about all the new possibilities. It really blew my mind.
  • 1
    @stimulate Studied C++ and templates last sem. Didn't know about the book. Thanks for the review. And the mention.
  • 0
    Wow the book cover has half of the whermacht cross logo
  • 1
    @Mayhem93
    Accident?
    I think not.
  • 1
    @stimulate
  • 1
    Proud of my romanians :)
  • 2
    If you like this book, see the last Herb Sutter talk in cppcon 2017. It was the most amazing thing I see since constexpr
  • 0
    People who didn't read this mandatory book still exist? Oo
Add Comment