Correct by Construction: APIs That Are Easy to Use and Hard to Misuse - Matt Godbolt [ C++ on Sea ]

Поділитися
Вставка
  • Опубліковано 12 вер 2024
  • C++ gives us an awful lot of powerful constructs to use when designing APIs: strong types, RAII, templates, virtual functions and more. Some are easier to use than others, and some might be easy to use but easy to misuse. In this talk, Matt will cover some of the techniques you can use in your API and code in general to make it more difficult for users to make mistakes. You'll leave the talk with some new ideas to try out in your code bases: your future users (maybe yourself the very next day...) will thank you!
    -------
    Matt Godbolt is the creator of the Compiler Explorer website. He is passionate about writing efficient code. He has previously worked at a trading firm, on mobile apps at Google, run his own C++ tools company and spent more than a decade making console games. When he's not hacking on Compiler Explorer, Matt enjoys writing emulators for old 8-bit computer hardware.
    -------
    C++ on Sea is an annual c++ and coding conference, usually held in Folkestone, Kent in the UK. The 2020 conference was moved to a virtual event due to social distancing requirements.
    Produced and Edited by Digital Medium Ltd: events.digital...
    Enquiries: events@digital-medium.co.uk

КОМЕНТАРІ • 13

  • @CaptainOachkatzl
    @CaptainOachkatzl 4 роки тому

    the "Tinkerable-Wrapper" is exactly what i needed a lot of times but didn't know how to do it. thank you for this great solution!

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

    "terribly named RAII" is the most accurate statement ever.

  • @markcr00knz
    @markcr00knz 4 роки тому

    Excellent points and well explained, thank you Matt Godbot!

  • @PCSoftware
    @PCSoftware 4 роки тому

    That && modifier on methods is 420 IQ. I never would've known about it if not for this lecture.

  • @marcpawl
    @marcpawl 4 роки тому

    Thanks. The default trick is one I might actually retrofit to some existing code. I will find it hard to not change working code to use subscriber as CADR. I cannot believe I didn't think of that before.

  • @Voy2378
    @Voy2378 4 роки тому

    43:50 kind of a minor error: it does not mean object has been moved from, just that it has been casted to ShaderCompiler&&

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

    44:07 To not tempt programmer with "-fpermissive", you can =delete the single ampersand version

  • @amitm1157
    @amitm1157 4 роки тому

    There seems to be a bug in your code at 27:44. You are returning a type in a void function. According to a coding rule in some coding standard, void functions shouldn't return any type. The other topics seem correct and they show safe practices. Your tips are also called development error tracing methods which check for errors such as incorrect range, type conversions and other potential bugs while code is being developed.

    • @speedstyle.
      @speedstyle. 10 місяців тому

      He said 'calling another void function'

  • @JensDoll
    @JensDoll 4 роки тому

    Regarding the question about the missing std::move(): Just return the ShaderCompiler at line 5. Thus it will be automatically a r-value. Calling compile() is then just a matter of "auto compiled = getShaderCompiler().compile();" without any invocation of std::move().

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

    CompiledShaders compile() &&;
    You can probably re-create Rust's borrow and mut borrow using that in some way. C++ has Rust hidden away in it?

  • @Wimpielef
    @Wimpielef 4 роки тому

    55:26 Did you mean BOOST_SCOPE_EXIT?
    www.boost.org/doc/libs/1_73_0/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT.html

  • @abhisheksingh-li6zo
    @abhisheksingh-li6zo 4 роки тому

    Lol godbolt is wearing formal