Mihaela Popa
15 Dec 2021
•
4 min read
A few days ago we spoke with Ivan Čukić, a core KDE developer and a senior software engineer at KDAB who often dabbles in teaching advanced C++ and functional programming techniques. Ivan is also the author of the book Functional Programming in C++. We asked him more details about his book, his thoughts about C++ and Functional Programming.
My parents started teaching me to code quite early on - the first rudimentary code examples I ran were on a Commodore 64 before I got into the elementary school. But the moment I got really interested in coding was when we got a computer that was able to run graphical programs. I started toying around with everything I could get my hands on - Borland Delphi, VisualBasic, Borland C++ Builder, and later on even with Java using some IBM tools I forgot the names of.
After that initial period of fascination, I started writing programs as a means to get some income - my alternative to having 'a paper route' often seen in the US films.
All that evolved through high school, and then university during which I joined the KDE project which is the largest free/open source C++ project in the world which made my focus on C++ more than other languages.
All that has led me to start attending and speaking at C++ conferences, and that led to me writing the 'Functional programming in C++'.
Manning did.
I always loved reading practical FP-related books and articles, and was quite sad that we don't have that many functional materials on C++. But I never really considered I should be the one to write a book on the topic until I was contacted by someone from Manning with the offer.
My gut reaction was to say no because I wanted to read a book on functional programming in C++ and not write it. But I quickly realized that if everybody said 'no' for the same reason, that we'd never get a book like this one.
To paraphrase Jason Turner when he read my book "I don't see why this is FP, this is just good C++".
Functional programming as an alternative approach to solving problems is valuable regardless of whether the programming language you're using is considered functional or not. It gives you new tools you can use to attack problems. Those tools are not always the best ones, but they often can be.
The Functional programming in C++ was written to be highly practical. I wanted a book that explains things that people can use in their regular C++ lives, and not yet another book that talks about FP, with it being different just for the C++ syntax instead of Haskell or Scheme.
It was initially aimed at experienced C++ developers - people that have used C++ professionally to see a few alternative idioms that can be useful when writing C++.
It also proved to be useful to my students. This is not to say that it is beginner-friendly - we have a C++-heavy program in Belgrade, so they might have been in a better starting position to understand the book than a random student in the world.
While it is focussed on C++, I'd also say that it can be useful for developers using other languages to take out the book from the local library and just skim through the examples and ideas presented in it.
This is a difficult question.
C++ is evolving faster than ever and the new things that get introduced into the language are a bit hit-and-miss. To me, there are more hits than misses, but I know people that would be the happiest little campers if C++ didn't evolve at all.
There are quite a few really neat FP-adjacent features that came up since I wrote the book. We got monadic operations on std::optional
. We got some of the range transformations I wrote about in the standard library, while the rest is planned for inclusion into C++23.
The coroutines that were added in C++20 are heavily inspired by the unavoidable big M, so every once in a while you get articles online which talk about handling optional values with coroutines (partiality monad), simulating exceptions without using the C++'s exception mechanisms (expected type and the exception monad), using coroutines for writing monadic parsers and such.
There are quite a few interesting features planned for the next few versions of C++.
C++ is still one of the most used programming languages in the world. I often (semi-jokingly) say that C++ is the most popular functional programming language in the world.
What people don't often realize is that apart from the obvious places you can find C++ in such as gaming, medical devices, the automotive industry, that C++ is omnipresent under the hood everywhere - virtual machines for other languages, web browsers and even some operating systems are largely implemented in C++.
So, yes, I’d say that even a basic knowledge of C++ can be a useful skill to have when searching for a new job.
We would like to thank Ivan for chatting with us and hope to have inspired you to learn more about Functional Programming in C++. You can buy Ivan's book here. Use our code nlfuncwrks21
at checkout to get 35% off!
And if you would like to read more interviews like these, be sure to sign up to Functional Works!
Ground Floor, Verse Building, 18 Brunswick Place, London, N1 6DZ
108 E 16th Street, New York, NY 10003
Join over 111,000 others and get access to exclusive content, job opportunities and more!