All posts in "Expressive code"

tee: Debug Info With Little Impact On Code

Published September 29, 2017 - 9 Comments
tee C++ debug log

I’d like you to meet tee, a little companion for retrieving targeted runtime info, with very, very little impact on the code. It’s simple, but I find it very convenient. You can put tee in your code wherever you need to know what’s going on, and tee will spy it for you. Its most basic implementation is […]

The Expressive C++17 Coding Challenge

Published September 25, 2017 - 12 Comments
Expressive C++17 coding challenge

The ink is dry on C++17! Actually it had dried a few times already. But the drier the ink, the sooner we get to use this new standard in production code. Now how do we learn all those new additions to the language? And how do we know to use them to write even more […]

A Summary of the Metaclasses Proposal for C++

Published August 4, 2017 - 16 Comments

A couple of weeks ago, Herb Sutter posted his proposal about metaclasses, triggering a wave of enthusiasm among the C++ community. And for good reason. His proposal gradually introduces the reader to the impressive potential of metaclasses, in particular to improve the expressiveness of current C++ idioms. I think everyone should be aware of the […]

Do Understandable If Statements Run Slower?

Published July 25, 2017 - 6 Comments

Aadam, my esteemed teammate, walked down to me right after reading the last post on Fluent C++, How to Make If Statements More Understandable, with a question. In fact this post made quite a few people think and get back to me with feedback and questions, for which I’m very grateful. If it did just […]

How to Make If Statements More Understandable

Published July 21, 2017 - 10 Comments

If statements are necessary to build our code. Granted, some ifs are bad, like those that try to emulate polymorphism by testing a series of types. Those, you want to stay away from. But the ones that implement domain rules are good, and even an opportunity to make your code more expressive by showing how […]

The Vector Monad in C++, Without the Ugly Stuff

Published July 14, 2017 - 3 Comments

Now that we’ve got our feet wet and have a feeling of the vector monad in C++, let’s use modern C++ to make a more elaborate implementation of the vector monad, but that leads to cleaner code. You’ll note that the way of thinking here has a lot in common with the optional monad in […]

Dealing with Multiple Paths with the Vector Monad in C++

Published July 11, 2017 - 2 Comments

After having explored how to deal with multiple error handling with the optional monad in C++, let’s take inspiration again from the functional programming world, and see our familiar std::vector from a very unusal perspective. Although this is an application of the concept of monads, we will focus on how to write code in C++, […]

The Optional Monad In C++, Without the Ugly Stuff

Published July 7, 2017 - 2 Comments

The last post on Fluent C++ showed how several functions that could fail could be chained together by encapsulating the checks into an optional monad, so that the calling code doesn’t have to worry about checking each function call. That post stirred up a lot of reactions. Some people found it interesting and inspiring. Other […]