Why C++ is the perfect choice for modern app development
It feels a bit ironic to be discussing, in 2014, if C++ is a viable, or more importantly, a great choice for multi-device, multi-platform app development. It’s ironic in the sense that despite the attention Objective-C, Java, and C# get for app development, most of the software we use on a daily basis is written in C/C++ and after all these years represents the largest community of developers.
There are many reasons to use C++ for your current and future app development and I will discuss five key reasons after a brief history.
A Brief History of C++
Bjarne Stroustrup, at Bell Labs designed C++ in the early 80s, as an object oriented language based on the C language, which powered pretty much all systems software since its creation in 1972. The need for an object-oriented language, at Bell Labs, was clear — large systems software needed language facilities for better organized and architected apps as capacity and performance requirement increased. C++ was quickly adopted for all types of development and in particular in the telecommunication industry given its heritage from Bell Labs and is still widely used today to power the switching systems and operating systems that enable this widely connected world we live in today. C++ became an international ANSI/ISO standard in 1988 and has been update by the standards committee several times over the years, most notably with a major update in 2011 the publication of the C++11 standard, which focused on improving the usability of the more complicated aspects of the language. And, in my opinion, it succeeded.
Despite the popularity of Java, C#, and Objective-C, C++ remains the most widely used language in the world. A recent report from Evans Data Corporation, that closely tracks worldwide language usage, found that over 11 million professional developers know and use C++ regularly. There was a reason Java and C# borrowed their syntax heavily from C++, there are a lot of developers who know the language. This means finding (or training) resources for C++ will not a problem. It also means there is plenty of C/C++ support for any functionality you may need to integrate into an existing application.
Figure 1: Global Developer Population of Languages Used.
C++ was built specifically for platform independence and as such is found on every single operating system in existence. Your typical mobile user may know that Android apps are written Java and iOS apps in Objective-C, but what many don’t know is that there is more C/C++ code in memory on your devices than anything else. C/C++ drives much of the technology of small devices (like the kernel, which interacts with the hardware, as well as typical run time libraries) and the telecommunications networks that enable these devices. More importantly for a development team, is that there are C/C++ interfaces and libraries for anything you need to do on any device and platform. The Android NDK toolset is a great example of full C/C++ support that was added originally for game development teams to enable them to get the best possible performance out of the device by avoiding Java and the Android Java runtime Dalvik, the virtual machine on which Android Java code is executed on. It has been regularly improved to enable every Android service.
C++ has the best compatibility with C of any language
Many of the libraries available on these devices are exposed via C functional interfaces. One example is POSIX, which outside the C/C++ RTL/STL is one of the most widely used and supported libraries on every platform because it provides a common C API for standard platform services. Another example is OpenGL/ES, which is the graphics library supported on every operating system out there. These libraries are trivially easy to use directly in your C++ app as there is no need to create language bindings, marshal data types, or to otherwise do any runtime conversions; just #include the needed header and link the associate library and you’re done.
C++ isn’t just for client side development. Although as mentioned above, the Android NDK is a great example of exposing C++ for the best performance possible on the device, C++ is widely used for server side applications too. In fact, it was originally focused on large backend systems in telecommunications, finance, engineering, etc. — any industry that required optimal performance. During the early embedded device days, C++ became very popular for apps on devices due to many of the attributes already discussed, like C compatibility and platform support, and runtime performance. Since C++ is a compiled language it runs directly on the CPU and is well regarded as the best performance language. Which is why game developers love it! However, the client isn’t the only tier that can benefit from great performance; middleware servers, backend systems, are all part of the modern mobile app ecosystem and contribute directly to the overall user experience. C++ delivers just as well for all these tiers.
In the early days of C++ we used to joke that C++ is such a powerful language it gives you enough rope to hang yourself. It took extra consideration to write safe code and meant dealing directly with memory and writing a lot of code to interact with the super powerful Standard Template Library (STL). The most recent published C++ standard, C++11, put a big emphasis on usability to address some of these more challenging programming practices. This has made C++ much more accessible to a broader range of developers such that there is no reason to be scared of the language. It can be as simple or as powerful as you need, especially when working within an app development framework, that provides a common API for additional services like UI controls on multiple devices using Android, iOS, Windows, and Mac OS X operating system platforms.
C++ has been around a while and it has solved countless industry challenges — it is the primary language that drives the mobile experience today. In addition to high performance server and middleware, C++ is a great choice for client side development on the two most popular mobile platforms Android and iOS and the two most popular desktop platforms, Windows and Mac OS X. With the recent introduction of developer tools that enable, among other things, visual design for clients, middleware, and server side apps; C++ is extremely productive and makes really makes it a great choice for modern app development.
John Thomas is Director of Product Management, Embarcadero Technologies.
Published under license from ITProPortal.com, a Net Communities Ltd Publication. All rights reserved.