CppCon 2017: Ben Deane & Jason Turner “constexpr ALL the Things!”

Поділитися
Вставка
  • Опубліковано 28 лип 2024
  • CppCon.org
    -
    Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2017
    -
    constexpr: in C++11, a curiosity; in C++14, viable for more uses; now with added power, in C++17 will it become an important tool in the programmer's toolkit?
    In this talk we will examine the possibilities and power of constexpr and explore what can (and what should) be done at compile-time with C++17. We'll present techniques for building constexpr data structures and algorithms, and look at what the standard provides and where it can improve. We'll also explore constexpr use of user defined literals for expressive compile-time abstractions.
    Compile-time computation offers perhaps the ultimate zero-cost abstraction, and this talk attempts to gauge the power available with C++17 constexpr.
    -
    Ben Deane: Principal Software Engineer, Blizzard Entertainment
    Ben has been writing games for almost 20 years, and in C++ for most of that. He is currently a Principal Engineer at Blizzard Entertainment where he works on the Battle.net team. He's always looking for useful new techniques in C++, and he likes functional programming.
    Jason Turner: Developer, Trainer, Speaker
    Host of C++Weekly / jasonturner-lefticus , Co-host of CppCast cppcast.com, Co-creator and maintainer of the embedded scripting language for C++, ChaiScript chaiscript.com, and author and curator of the forkable coding standards document cppbestpractices.com.
    I'm available for contracting and onsite training.
    -
    Videos Filmed & Edited by Bash Films: www.BashFilms.com
    *-----*
    Register Now For CppCon 2022: cppcon.org/registration/
    *-----*

КОМЕНТАРІ • 38

  • @henke37
    @henke37 6 років тому +107

    "There was a misunderstanding between me and the compiler".

    • @meow75714
      @meow75714 2 роки тому

      How polite of him to address Mr. Compiler like that.
      For rest of us compiler is a real bitch.

  • @jankodedic3130
    @jankodedic3130 6 років тому +90

    Great talk by Ben and JSON, as always!

  • @dipi71
    @dipi71 6 років тому +54

    Just when I thought I had a grip on C++ … well done, guys. ((slow-clap))

    • @OperationDarkside
      @OperationDarkside 6 років тому +12

      Kinda rethorical question: Do you ever?

    • @WorldWideWebWisdom
      @WorldWideWebWisdom 2 роки тому +5

      @@OperationDarkside 3 years later, I can confidently tell you that you never do.

  • @arthur.passos
    @arthur.passos 5 років тому +21

    "Jason" just talked about how we actually represent "Jason" values

  • @connorhorman
    @connorhorman 5 років тому +9

    I’ve done all of SHA2 in constexpr, and I’ve even written a program that Randomly decides when it wants to compile.

  • @hanneshauptmann
    @hanneshauptmann 6 років тому +1

    great talk by deane and jason, as always !

  • @odedkadshai
    @odedkadshai 4 роки тому +1

    a milestone lecture. well done!

  • @cc.jsullivan
    @cc.jsullivan 6 років тому +9

    wow, this really is constexpr all the things

  • @prezadent1
    @prezadent1 6 років тому +8

    Great talk by Bean and Freddie, as is the norm.
    I don't know whats going on either. I just try to fit in.

  • @JosefdeJoanelli
    @JosefdeJoanelli 3 роки тому +1

    "constexpra" tripped me up every time

    • @TheMR-777
      @TheMR-777 2 роки тому +1

      @Mercer “constant expression” can be any constant expression
      “constexpr” is a 'term', which also mean functions, and methods, which evaluate on compile time

  • @OperationDarkside
    @OperationDarkside 6 років тому +22

    "You can clearly see..." -> No I can not, lol
    Nonetheless, awesome

    • @AM-qx3bq
      @AM-qx3bq 4 роки тому +2

      That's functional syntax for parsing a string key to the value of your reaction. Nice.

  • @yomoma6692
    @yomoma6692 6 років тому +1

    So much usefull knawledge. :D

  • @alcesmir
    @alcesmir 6 років тому +1

    33:45 Isn't that essentially zipWith in haskell?

  • @bsuperbrain
    @bsuperbrain 6 років тому +1

    Is this the same talk from 2016?

  • @xamidi
    @xamidi 3 роки тому

    The code on slide 20 (at 12:20) is not part of the github project and doesn't seem to compile.. Nothing of cx_map.h seems to be used in the project. When I comment all its content out and remove its import into cx_json_value.h, the project still compiles?! Whenever I try to use cx::map, it gives an error "no type named 'type' in 'struct std::enable_if'". (Tried with GCC 7.2.0 as they claimed to use - concrete distribution: MinGW-w64 x86_64-7.2.0-release-posix-seh-rt_v5-rev1.)

  • @intvnut
    @intvnut 6 років тому +1

    Did anyone else catch The Prisoner reference at 51:38?

  • @aDifferentJT
    @aDifferentJT 3 роки тому

    combine is liftA2

  • @outsider1st
    @outsider1st 6 років тому +8

    Wtf are those comments on every vid ;o

  • @connorhorman
    @connorhorman 5 років тому +9

    Next stop, Lua constexpr implementation.

  • @nmmm2000
    @nmmm2000 6 років тому +3

    bit disappointing to see old Jason video in new clothes. Where I can see the source code of this?

  • @robbie_
    @robbie_ 6 років тому +4

    OK, this is just a fun thing to do isn't it (and interesting), but totally impractical. Would be faster/better to write a simple console app to parse json into a C++ structure, running it as a pre-build step.

    • @homomorphic
      @homomorphic 5 років тому +9

      Nope, this isn't just a fun thing to do, it is extremely useful. As is obvious from the talk constexpr still isn't quite ready for prime-time, but when it is it will be extremely useful. It looks like it is getting close, I am guessing that by C++20 it will dripping with awesomeness.

    • @TheFlynCow
      @TheFlynCow 5 років тому +3

      minimizing the steps and dependencies of your build system is key.

  • @Runoratsu
    @Runoratsu 6 років тому +4

    It's very impressive, but honestly? a) You can't debug it properly, really, and thus it's VERY hard to use in an environment with multiple people having to be able to read and understand the code, and b) as soon as your code base grows past a few 100k loc this "bit of compile time overhead" will drive everyone insane (if we assume a relatively constant percentage of constexpr code to runtime code). It's nice to speed up your runtime side, but if every recompile takes (literally!) hours, you can't work on the code base productively anymore.

    • @homomorphic
      @homomorphic 5 років тому +4

      What in this video leads you to believe that this would substantially increase compile time? I think that Ben and Jason made the point that other than debug builds (which is likely due to symbol emission) that compile time and compile time memory usage are not significantly impacted.

    • @VioletGiraffe
      @VioletGiraffe 5 років тому +1

      100k LOC doesn't nearly take an hour, though. More like 2.5 minutes for a full recompile (which you should only need very rarely). /DEBUG:FASTLINK will give you much better productivity than reducing code complexity in the interest of compilation time.

  • @simgesonmez3508
    @simgesonmez3508 3 роки тому +2

    It's out of topic but why always guys??
    I want to see more women on the stage any more especially in this discipline.
    By the way, congrats guys, great talk :)

    • @muhdiversity7409
      @muhdiversity7409 6 місяців тому +3

      Why don't you start? Who exactly is stopping you?