Common reasons of using namespaces in C++ projects

Namespaces were introduced to the C++ Standard in 1995 and usually they are defined like this:

A namespace defines a new scope. They provide a way to avoid name collisions.

Namespaces in C++ are most often used to avoid naming collisions. Although namespaces are used extensively in recent C++ code, most older code does not use this facility.  Continue reading “Common reasons of using namespaces in C++ projects”

“Effective Modern C++” from Scott Meyers Review

This month a new book from Scott Meyers has become available, it’s the latest one of his Effective software development series (More Effective C++, Effective STL and Effective C++).

In this book Scott Meyers focuses on the new C++11 and C++14 standards which have been covered just by very few books so far. Given the fact that many resources are available on the web discussing these new standards, why do we need to read this book?

Continue reading ““Effective Modern C++” from Scott Meyers Review”

Optimization lessons to learn from the V8 javascript engine

V8 is Google’s open source high-performance JavaScript engine, written in C++ and used in Google Chrome, the open source browser from Google.

It’s very interesting to discover what makes V8 so fast and which solutions were used to achieve this goal.
Continue reading “Optimization lessons to learn from the V8 javascript engine”

The first enemy of C++ is its past.

During  the last few years we talk about the “C++ Renaissance”. We have to admit that Microsoft was a major actor of this movement, I remember this video where Craig Symonds and Mohsen Agsen talked about it.

In 2011 Microsoft announced in many articles the come back of C++, and Microsoft C++ experts like Herb Sutter did many conferences to explain why C++ is back and mostly recommend the use of Modern C++. In the same time the standard C++11 was approved and we begin to talk about  C++ as new  language. Continue reading “The first enemy of C++ is its past.”

Exceptions is one of the controversy mechanism in C++. Should I use them?

More that 20 years ago, the exception handling was added to C++, and after many years of using this feature by the C++ developers, we have a very interesting feedback of their pros and cons.

Let’s discover the opinion of some C++ actors, and what they think about the use of the exception mechanism. Continue reading “Exceptions is one of the controversy mechanism in C++. Should I use them?”

Make the most of Pmd, Findbugs and CheckStyle results.

Many Java static analysis tools exist right there, each one focus on a specific area and has its advantages, we can enumerate:

  • Pmd which is a static rule-set based Java source code analyzer that identifies potential problems like:
    • Possible bugs—Empty try/catch/finally/switch blocks.
    • Dead code—Unused local variables, parameters and private methods.
    • Empty if/while statements.
    • Overcomplicated expressions—Unnecessary if statements, for loops that could be while loops.
    • Suboptimal code—Wasteful String/StringBuffer usage.
  • FindBugs which looks for bugs in Java code. It uses static analysis to identify hundreds of different potential types of errors in Java programs.
  • Checkstyle defines a set of available modules, each of which provides rules checking with a configurable level of strictness (mandatory, optional…). Each rule can raise notifications, warnings, and errors.

Continue reading “Make the most of Pmd, Findbugs and CheckStyle results.”

C++ needs to modernize its legacy #include mechanism to be really a new language

C++ was stagnated for many years, and many developers was confident that the language will have the same destiny as  Cobol, Fortran and VB6. No new projects will be developed with it  and  C++ developers will do just the maintenance of existing projects. But against all odds C++ reborn from its ashes and the new standards changes a lot how the language is used.

But the legacy  #include mechanism still there.  After the modernisation of the language, it became the  next weak link to improve. Indeed, it has many disadvantages, here are some of them from this interesting document.

Continue reading “C++ needs to modernize its legacy #include mechanism to be really a new language”

Three easy steps to modernize your C++ algorithms

Algorithms are used for calculation, data processing, and automated reasoning. Programming them is not always an easy task and it depends on their complexity. In C++ many efforts was done to simplify their implementation and to make them more powerful. Indeed, during the last ten years many C++ experts promotes the use of “Modern C++ Design” to improve the quality of the C++ project design and implementation.

In this post we will discover three steps to modernize a C++ algorithm, for that we take as example the quick sort algorithm. Here’s a classic implementation: Continue reading “Three easy steps to modernize your C++ algorithms”

What makes Clang so special?

It’s proven that Clang is a mature compiler For C and C++ as GCC and Microsoft compilers, but what makes it special is the fact that it’s not just a compiler. It’s also an infrastructure to build tools. Thanks to its library based architecture which makes the reuse and integration of functionality provided more flexible and easier to integrate into other projects. Continue reading “What makes Clang so special?”