Why C++?

When I was selecting a language for my product Segito, I considered most languages I knew and finally settled on C++ for a variety of reasons. The languages I considered were C++, Java, C# and Python, while others like Ruby and PHP were not in the running.
The reasons for choosing C++ are listed below, in no particular order:

Cross platform support

The biggest issue I had with the non C++ languages was support and availability of the dependencies. For each of those languages, there was at least one platform that did not support it, or had only sketchy support.
  • The JRE is not available on iOS (there are plans to support it by Sun/Oracle) and Symbian
  • .NET is not available on Android, although there is a recent commercial Mono 3rd party port.
  • Python for iOS is available only as a 3rd party port.
C++ on the other hand, enjoys native OEM support on Windows, Linux, OSX, Android, iOS and Windows Phone 7 (speculated for 8 as well). Sadly, all VM based languages were developed with the intent of providing cross-platform support.


The second biggest advantage C++ has over the rest is size, including dependencies. The current win32 release of Segito is about 1.5 Mb (800Kb installer) while the OSX .app package is about 2.5Mb.
For everything else, while the size of the executable would have been small, the runtime environment would have been significantly larger.
  • The latest JRE for Windows is about 15Mb
  • The .NET 4 runtime for Windows is about 24Mb
  • The Mono runtime for OSX is 84Mb
C++ allows us to write bare metal apps that contain nothing more than what is needed.


Almost all target platforms have free, native OEM supported IDE's for C++, while the rest have at best, third-party support.
  • Windows has Visual Studio Express Edition which is extremely fast and lightweight. The 2008 edition running in a Windows VM on OSX starts up in less than 1 second and a full rebuild of the whole app takes less than 30 seconds.
  • OSX and iOS has Xcode, although it is a bit of an acquired taste for someone from a Windows/Linux  background.
  • Linux has KDevelop and QtCreator, which although third-party, are both excellent IDE's in their own right.
A big disadvantage here, however, is the need to maintain multiple projects but that is outweighed by the rest of the advantages.

Static typing

While static typing in programming languages may not seem like a significant factor, very often the business importance is missed. Dynamically typed languages are very useful to churn out applications quickly - one can use Python to write an application much faster than using C++.

But what happens when the start-up gets funded and goes to the next level? When the initial founder-developers are replaced by a team of 20 new developers, the new team does not have the familiarity with the code base like the original developers did. This is when the bug count start increasing. For example, it becomes easy to call functions with parameters of incorrect type and this will result in subtle bugs that will never get discovered until they bomb at run time. If you are lucky, they will get caught in the QA phase, and if not, your customer will find it, resulting in loss of productivity and goodwill.

As the team size grows and/or there is a churn in the team, such bugs in the code will increase exponentially. 

With statically typed languages, these errors get caught at compile time. No doubt, good software engineering is the sum-total of many different best practices, but this is one class of error that can very easily be eliminated by letting the compiler do the work.

One common counter to this is that such errors can be caught by writing good unit tests, but in my opinion, that's a self defeating argument. If you are going to save time using Python and spend it writing unit tests, you have achieved nothing.

Skill-set availability

This is an advantage and a disadvantage at the same time, more of the latter. Most educational institutes teach C++, but most organizations use anything but C++. So the probability of finding good and experienced C++ programmers is quite low, but c'est la vie!
The advantage is that C++ training is not a viable mass-market business for software training institutes so although the number of resumes processed will be low, the hiring-to-interview ratio will be much higher.


That said, I am not a hardcore all-or-nothing C++ fanatic. The above was my thought-process for selecting a language for a product that is expected to run on a wide variety of desktop and mobile platforms. The enterprise server component of Segito is written in C# and there will almost certainly be a Java version in the near future.

I like to compare C++ with the English language: both have their own warts, both have more exceptions than rules, both can be extremely frustrating to learn and people complain about both endlessly. But if your business depends on a community and you need a common language that everyone understands, it is the only option available to you. No matter how perfect your native language may be.


Open source analogy

Very often, I get asked about the reliability of open source, and have wondered what is the best analogy to explain it. I had an epiphany the other day - medical science.

When we are ill we go to the doctor, who makes a prescription. And when we hold a pill and a glass of water in our hand, on what basis do we have the confidence that this pill will cure us, or at least that it won't kill us? After all we haven't personally verified it, have we?

It is on the basis of the transparency in the process of developing it. This includes basic research, publications, open peer review, criticism, field trials on animals, government approvals, human trials, well defined standards in the manufacturing process, etc.

Likewise, the open source software development process provides transparency. You may not be able to personally verify the source code for the product you are using, but if it is popular enough you can be assured that it has been seen by developers and other experts around the world, and unless there was a global conspiracy involving all of them, the product you are using is reliable.