-
Book Overview & Buying
-
Table Of Contents
Software Architecture with C++ - Second Edition
By :
Are you familiar with imperative versus declarative coding styles? The former is when your code tells the machine how to achieve what you want step by step. The latter is when you tell the machine just what you want to achieve. Certain programming languages favor one over the other. For instance, C and Pascal are imperative, while SQL, HTML, and CSS are declarative, just like many functional languages. Some languages allow you to mix the styles—think of LINQ in C#.
C++ is a multi-paradigm programming language supporting procedural, object-oriented, and functional programming. Is there one you should prefer? It turns out that when you’re writing declarative code, usually a higher level of abstraction is kept, which leads to fewer bugs and easier-to-spot errors. So, how can we write C++ declaratively? There are two main tactics to apply.
The first one is to write functional-style C++, which is where you prefer a pure functional style (no...