I'm Michael Suodenjoki - a software engineer living in Kgs. Lyngby, north of Copenhagen, Denmark. This is my personal site containing my blog, photos, articles and main interests.

Updated 2011.01.23 15:37 +0100


Lambda Redux in C++

Granted, when I for more than 15 years ago learned functional programming at the University - hey I've even excelled in teaching it, I never imagined that it would become so popular and would lead the programming trends as it does these years and probably will for some time in the future.

Everything seems to be about functional programming, lamba calculus - functions without names - and funny ways to express these.

The C++ programming language is posed to be extended in the upcoming C++0X standard with syntactic sugar which makes it a sweat to express lambas.

Just see today's announcement of the preview-release of the next Visual C++ version and the blog entry Lambdas, auto, and static_assert: C++0x Features in VC10, Part 1 .

I'm not in doubt that functors/lambdas will help us write more advanced programs in less code, but you'll always need to consider the maintainability. If it is difficult to read - it will also be difficult to maintain. You can already today express functors/lambdas using template programming and helper libraries, e.g. boost.lambda, but they are not always ideal to maintain. The new lambda sugar will hopefully help.

That is also why I have some reservations about the auto keyword, allowing you to declare variables "automatically", deduced by the compiler at compile time. You will still get compiler errors, but I suspect the code will be more difficult to maintain.