Lambdas: The Functional Programming Companion of Modern C++

location_city Bengaluru schedule Nov 15th 04:00 - 04:45 PM place Meeting Room 1 people 18 Interested

C++ as a Programming Languages had ruled the programming world for quite some time. It was so much synonymous to Object Oriented Programming that when functional programming came into the picture, nobody initially thought of C++ as a candidate for the same.

Fortunately, the C++ Standardization ( committee had a different idea and they later came up with C++11 which was a paradigm shift in the language. C++ now not only allows programmers to write functional code, but it has also evolved the language into a meta programming language.

The core of these changes which enables functional programming in C++ revolves around the introduction of Lambdas. Suddenly, with lambdas, we’re not only writing functional code in C++ but can also have functional threads, functional locks, and functional memory management.

The beauty of lambdas can also be judged from the fact that it has also made many of the STL (Standard Template Library) algorithms functional which, along with the concepts and ideas of Closures makes C++ an ideal candidate to be considered for writing functional codes which includes immutability, Partial function specialization, and pattern matching.

In this talk, I’ll take you on the journey of functional Programming in modern C++ and how to write awesome and simple C++ code which conforms to all tenets of Functional Programming.

The talk shall contain full fledged examples which shall be made available to participants post conference

We’ll also see how the language has evolved and why it’s still a favorite for doing performance intensive jobs which we can, of course, do in a functional way


Outline/Structure of the Talk

Here is the proposed outline of my session and expected amount of time it will take

  • Introduction of functional programming and C++11 (Changes, History & Future) - ~ 7 - 10 Mins
  • Lambdas and Closures in C++ ~ 5 Mins
  • Immutability and Partial function Specialization - ~8 - 10 Mins
  • Functional MultiThreading with Lambdas. - ~8 - 10 Mins
  • Lambdas in STL - ~ 7 - 10 Mins
  • Interesting Addons like Pattern Matching with Lambdas - ~ 5 Mins
  • Q & A ~ Rest of the available time

Learning Outcome

The participants of this talk shall be able to understand the changes that makes C++ a functional programming language. They will also be able to understand how to write functional code in new C++

Target Audience

Programmers acquainted with basics of Object Oriented Programming in C++ or Functional Programmers of any other language

Prerequisites for Attendees

General awareness of C++ Programming is required to understand this talk. However, people with knowledge of languages like Java & Scala can also understand the contents.

schedule Submitted 4 months ago

Public Feedback

comment Suggest improvements to the Speaker
  • Nikhil Barthwal
    By Nikhil Barthwal  ~  4 months ago
    reply Reply

    You proposals talk a lot of about Lambda's but I think the submission could be improved by:

    • Adding immutability by using const keywords. Trivial use of const is common knowledge but to my understanding, const can be used in a lot of ways to achieve immutability though the code (e.g. making return parameters immutable). Good to have examples like that.
    • Touch upon Pattern Matching. C++ 14 provides some sort of pattern matching ( and I do know there have been libraries that provide significant pattern matching (e.g. by Bjarne Stroustrup & others) to write functional style code.
    • Would be nice to see if how one can implement functional patterns like partial applications.


    • Deepak K [Daksh] Gupta
      By Deepak K [Daksh] Gupta  ~  4 months ago
      reply Reply

      Dear Nikhi

      Thanks for your comments on my proposal.  It was my intention to cover pattern matching at a glance since it was not directly related to FP, but I sense that it will be interesting for people to know about it.  Thanks for that, I've updated my abstract

      Hope it's much clear now

      Best Regards

      Deepak K [Daksh] Gupta

      • Naresh Jain
        By Naresh Jain  ~  4 months ago
        reply Reply

        Hi Daksh,

        Thanks for updating your proposal.

        Could you please update the outline with a time break up of each topic? I'm concerned that we are trying to cover too many topics and it would be more of a touch and go. From an attendee's point of view, it would be better if they learn one or two concepts in-depth, which they can apply back at work.

        • Deepak K [Daksh] Gupta
          By Deepak K [Daksh] Gupta  ~  4 months ago
          reply Reply

          Dear Naresh

          Thanks for your comment. I did a small dry run of the topics and updated the approximate time each topic will take.

          I did remove metaprogramming topic as you've mentioned in your comment that touch and go may not be good for the participants.  I totally agree.

          Rest of topics are in the absolute sequence where each is built upon earlier ones.  For example, Partial function Specialization will lead to Functional Multithreading which will, in turn, leads to STL so ~30 mins must be okay

          I hope the reply answers the queries to your satisfaction


          Deepak k [Daksh] Gupta

          • Naresh Jain
            By Naresh Jain  ~  4 months ago
            reply Reply

            Thanks, Daksh.

            Will you be using a specific usecase to demonstrate how these concepts were implemented in your code and how they have helped? 

            I hope you understand that attendees can go online and read about the theory and basic code samples. What will really help them is a real-world example.

            • Deepak K [Daksh] Gupta
              By Deepak K [Daksh] Gupta  ~  4 months ago
              reply Reply

              Dear Naresh 

              Thanks for your comment.

              I understand your point and most of the times the participants are more interested in knowing why should we choose this way and not the (multiple) other ways around and I believe all conference speakers try to answer this question prominently.

              The proposed session of mine shall be concentrated more on the usability and performance aspects of these constructs of C++. 

              Yes, I'll certainly tell the use cases where it can be used and where it's not a good idea.

              For example, what are the scenarios where Functional Multithreading is better than nonfunctional ones et. al.  I'll also provide all the codes via my github so that participants can go back and check the same.

              Hope this helps


              Deepak K [Daksh] Gupta