Thinking Functionally in C++ - Brian Ruth - CppCon 2023

Ғылым және технология

cppcon.org/
---
Thinking Functionally in C++ - Brian Ruth - CppCon 2023
github.com/CppCon/CppCon2023
C++ is a multi-paradigm language, supporting OO, procedural and functional programming styles. Functional languages conjure up thoughts of academic languages; immutable data and mathematical terms like monad and higher order functions. We’ve been told of the advantages of functional languages, specifically when it comes to parallelization and safety, but very few of them are ever used in production code. However, what if we were to take the mindset of functional programming and apply it to existing C++ codebases? How will it change the way we write and think about our code? In this talk, we will explore ways to think functionally about your code and how to modify it using functional techniques. We will explore some of the additions C++ has made to aid in functional programming in the form of views, lambdas and ranges and how those fit into an existing OO or procedural codebase. We will finish up by looking at functional design considerations and their tradeoffs. After leaving this talk you should have the tools to identify instances in your code where using functional thinking will improve its performance, reusability and security.
---
Brian Ruth
Brian has been programming in C++ for over 20 years, working for both small and large companies on a wide variety of projects and technologies. For over a decade he worked with neuroscience researchers and created high speed acquisition, analysis and visualization software. He is currently a senior software engineer at Garmin, using C and C++ on embedded devices such as watches, GPS mapping handhelds and satellite communicators. When he isn’t knee deep in code, he is enjoying a home brewed beer or building some furniture. He has been involved with CppCon since 2015.
__
Videos Filmed & Edited by Bash Films: www.BashFilms.com
KZread Channel Managed by Digital Medium Ltd: events.digital-medium.co.uk
---
Registration for CppCon: cppcon.org/registration/
#cppcon #cppprogramming #cpp #functionalprogramming

Пікірлер: 13

  • @Voltra_
    @Voltra_5 ай бұрын

    The lambda example is actually quite interesting

  • @ABaumstumpf
    @ABaumstumpf5 ай бұрын

    27:04 - at this point you have created an oven that is worse then the original one. I always find it fascinating when people come up with "But now you need to change this every time something new is added" - so? The change has to be done somewhere and having it explicitly inside my file makes it easy to maintain. It becomes easier to add other functionalities, sanity-checks and test - also you are no longer forced by the old C-style API. And it might just be the field i am working with but to me it would seem there is something seriously wrong with the program architectures and the coding approach if you constantly have to change fundamentals of your code

  • @rutabega306

    @rutabega306

    Ай бұрын

    until ur file is 4000 lines long... I think the Open/Closed advice is mainly useful when you have like 10 engineers in the same codebase and you don't want everyone colliding all the time.

  • @RishabhRD
    @RishabhRD6 ай бұрын

    I have read all the books mentioned here

  • @xenobyte2281
    @xenobyte22816 ай бұрын

    This dude actually decided not to use any syntax highlighting for those walls of text...

  • @hemangandhi4596
    @hemangandhi45965 ай бұрын

    This felt like a back to basics talk. Does anybody know why it wasn't marked as such? Did it not make it into the track?

  • @weaponkid1121

    @weaponkid1121

    5 ай бұрын

    what does that mean?

  • @stefanalecu9532

    @stefanalecu9532

    5 ай бұрын

    Why would this be a back to basics talk?

  • @9uiop
    @9uiop6 ай бұрын

    It's not quite clear why go through hoops with the lambdas in the Oven example. For me it's much cleaner to have a class with a function template that forwards the call.

  • @hemangandhi4596

    @hemangandhi4596

    5 ай бұрын

    Agreed, I also feel like `oven_instance.do(oven_set_temperature, 212)` is a better API than `oven_instance(over_set_temperature, 212)`. Also that example felt like it went against the whole "C++ is multi-paradigm" message.

  • @not_ever

    @not_ever

    5 ай бұрын

    “The goal of this talk is to show you different ways of thinking about a problem”

  • @ABaumstumpf

    @ABaumstumpf

    5 ай бұрын

    @@not_ever That implicitly has the notion of REASONABLE ways of thinking attached. Of course you can think of it in other terms too - you could break it down to the chemistry if you want - that would just be retarded. And example for "there are different approaches" should always be one that has at least in principle some benefits - or it is an example of how not to do it.

  • @kuhluhOG

    @kuhluhOG

    3 ай бұрын

    @@ABaumstumpf he EXPLICITLY stated at the beginning of the talk that things may not be best practices Also, "thinking differently" does not imply "thinking reasonable".

Келесі