Tag: functional

C++ Boost::Range vs .NET LINQ vs Scala

In my day-job most of my development is in C++ so I’m always comparing ideas from other languages against what’s available in C++. I’ve been experimenting with boost::range, a C++ library that makes it easier to compose algorithms in a functional style. I’m comparing it to .NET LINQ and to for-comprehensions in Scala. My example: List of orders, each order has a discount and list of order-items. We want the total cost of all Bread items with discounts applied. Scala for-comprehension def orders: List[Order] = List( new Order( 25, List( new OrderItem("Eggs", 12, 0.50), new OrderItem("Bread", 4, 1.25) ) ),…

Read More »

Functional Programming in C++

This is not a new topic, and there have been plenty of comments recently from various C++ developers. But most comments are only about lambdas and using them as higher-order functions.  While I can’t claim any deep knowledge of functional programming (some experience with functional techniques in Scala, F# and C#) I can’t help think the real functional programmers are laughing at us for missing the point. Yes it’s called function-al programming, functions are in the name, but that doesn’t mean functions are the only important feature to consider before we can make use of functional techniques in C++. Possibly…

Read More »