Learn from Doxygen source code how to optimize the memory usage.

When the processes running on your machine attempt to allocate more memory than your system has available, the kernel begins to swap memory pages to and from the disk. This is done in order to free up sufficient physical memory to meet the RAM allocation requirements of the requestor.

Excessive use of swapping is called thrashing and is undesirable because it lowers overall system performance, mainly because hard drives are far slower than RAM.
Continue reading “Learn from Doxygen source code how to optimize the memory usage.”

Domain Driven Design, Immutability and C++

There is a powerful and simple concept in programming that is widely underused: Immutability

Basically, an object is immutable if its state doesn’t change once the object has been created. Consequently, a class is immutable if its instances are immutable.

There is one important argument in favor of using immutable objects: It dramatically simplifies concurrent programming. Think about it, why does writing proper multithreaded programming is a hard task? Because it is hard to synchronize threads access to resources (objects or others OS resources). Why it is hard to synchronize these accesses? Because it is hard to guarantee that there won’t be race conditions between the multiple write accesses and read accesses done by multiple threads on multiple objects. What if there are no more write accesses? In other words, what if the state of the objects accessed by threads, doesn’t change? There is no more need for synchronization!
Continue reading “Domain Driven Design, Immutability and C++”

Learn from Folly source code the new C++11 features.

Two years ago Facebook released  their C++ library named Folly , it’s a large collection of reusable C++ library components that internally at Facebook are used extensively.

But many mature C++ open source libraries exist, why introduce another one ? Here’s the motivations from their website behind  its utility:

Folly (acronymed loosely after Facebook Open Source Library) is a library of C++11 components designed with practicality and efficiency in mind. It complements (as opposed to competing against) offerings such as Boost and of course std. In fact, we embark on defining our own component only when something we need is either not available, or does not meet the needed performance profile.

Continue reading “Learn from Folly source code the new C++11 features.”

Feedback about the C++ developers choices after the analysis of many C++ open source projects.

Since 2008 we did many test to validate the CppDepend results, and for seven years we analyzed more than 100 C++ open source  projects. We get them mostly from github and sourceforge. We had chosen the projects randomly, some are small, others are big. Some are very popular, others are just downloaded by few developers.

In this post, we will share some feedbacks concerning their design and implementation. Continue reading “Feedback about the C++ developers choices after the analysis of many C++ open source projects.”

Discovering Jigsaw, the new major java 9 feature.

The goal of Project Jigsaw is to design and implement a standard module system for the Java SE Platform, and to apply that system to the Platform itself and to the JDK. It was postponed many times, it’s planed now for java 9 and until now no announcement from oracle that it’s postponed again.

Here’s what Mark Reinhold said about the motivations behind the Jigsaw modular system:

A standard module system for the Java Platform will ease the construction, maintenance, and distribution of large applications, at last allowing developers to escape the “JAR hell” of the brittle and error-prone class-path mechanism.

Continue reading “Discovering Jigsaw, the new major java 9 feature.”

Some reasons why “Modern C++” adopted the generic programming

As Bjarne Stroustrup points out, “C++ is a multi-paradigmed language.” It supports many different styles of programs, or paradigms, and object-oriented programming is only one of these. Some of the others are structured programming, and generic programming. In the last few years C++ experts like Andrei Alexandrescu, Scott Meyers and Herb Sutter promotes the uses of the generic programming and they qualify it as Modern C++ Design.

Here’s what say Andrei Alexandrescu about the Modern C++ design:

Modern C++ Design defines and systematically uses generic components – highly flexible design artifacts that are mixable and matchable to obtain rich behaviors with a small, orthogonal body of code.

Continue reading “Some reasons why “Modern C++” adopted the generic programming”

What Clang can tell you about your Visual C++ projects

Each compiler could report after the build many warnings. These warnings won’t keep your code from compiling except if you decide to treat them as errors. Don’t hesitate to take a look as these warnings instead of ignoring them. Indeed compiler warnings are often indicators of future bugs that you would see only at runtime.

Clang is a C/C++/Objective C compiler with many interesting features, here are some major end user features:

  • Fast compiles and low memory use
  • Expressive diagnostics
  • GCC compatibility

Continue reading “What Clang can tell you about your Visual C++ projects”

Tracking hidden duplicate code

It’s known that the presence of duplicate code has negative impacts on software developmet and maintenance. Indeed a major drawback is when  an instance of duplicate code is changed for fixing bugs or adding new features, its correspondents have to be changed simultaneously.

The most popular reason of duplicate code is the Copy/Paste operations, and in this case the source code is exactly similar  in two or more places , this practice is discouraged in many articles, books, and web sites, however sometimes it’s not easy to practice the recommendations, and as  usual in the real world there are many constraints. Here’s a story to show one of the possible constraints:

Continue reading “Tracking hidden duplicate code”

Learn basic “C” coding rules from open source projects

Every  project has its own style guide: a set of conventions about how to write code for that project. Some managers choose a basic coding rules, others prefer very advanced ones and for many projects no coding rules are specified, and each developer uses his style.

It is much easier to understand a large codebase when all the code in it is in a consistent style. Continue reading “Learn basic “C” coding rules from open source projects”