Tag: c++

Faster Visual C++ Builds

I always knew precompiled headers mattered if you were using Visual C++. I didn’t know how much they really mattered. What’s a precompiled header? I’ve worked in a number of places. Where I am now is probably the biggest codebase I’ve worked on, well over a million lines of code with many projects in a large Visual C++ solution. Most of the places I’ve worked have been C++ and Windows shops so I’m used to Visual C++ creating a pre-compiled header by default for each project with the usual Windows headers. I knew the Windows headers were huge so compiling…

Read More »

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 »

Divide in C++ resource management

There seems to be a divide in ideas about C++ resource management, which I’m going to grossly exaggerate and call the “Stroustrup” and the “Sutter” positions, based on comments by these titans in recent online videos.  These are of course not opposing positions, merely shades of opinion that depend on the application domain and target environment.  But there does seem to be an underlying difference of emphasis on how resource management, and memory management in particular, are best dealt with in modern C++. To summarise: “Stroustrup” “Sutter” Focus on stack object managing resource Focus on heap object conveniently managed by…

Read More »

Dependency Injection in C++ – cppdepinject

While I’ve seen plenty about Dependency Injection and IOC containers in C# and Java, I recently had a reason to use one in C++. There are some existing IOC containers in C++ but they are not widely used. While there are differences in the types of software written in C++ compared to other languages I think the largest difference is the way the community works. The Java and C# communities grew up with the Internet and open-source code and expect to use code and ideas from various sources and the style of their applications has changed rapidly. The C++ community…

Read More »