The Bedrock of the Software World: C++ Programming Language

C++ is one of the most popular programming languages in the world. It’s very fast and used for many high-profile projects, including Google Chrome and Microsoft Office. C++ is a mid-level language that communicates close to the hardware layer while still being easier to program than low-level assembly languages. It offers a unique blend of ease of coding and high-speed hardware control. Let’s take a closer look at C++, how it originated, who uses it, and its advantages over other languages.

The Origins and History of C++

In 1972, Dennis Ritchie of Bell Labs created a language for Unix called C. By the late 1970s, C had become popular for developing operating systems. A number of variations on the original language were developed. In the late 1980s, ANSI Standard C was created.

In 1979, Denmark’s Bjarne Stroustrup modified C by adding classes. He made further refinements by implementing object-oriented features to create C++. He was trying to create a language like Scala, so it would be easy to program large software systems but also fast with low-level hardware control like BCPL. C++ gave him more advanced features than C offered while retaining its flexibility and efficiency. By the 1990s, C++ continued to grow and develop and it was often the first choice for operating systems like Windows, BeOS Haiku, and Syllable. It’s ideal for low-level development, robotic spacecraft, and telephone exchanges.

C++ is a language, development environment, and library in one, used for both object-oriented and procedural programming. It can be modified and extended depending on the goals of the programmer, and there are a number of versions of C++ today. They include Microsoft C++ (Microsoft Visual C++ 6.0); ANSI C++; C++ versions from companies such as Turbo, Symantec, Borland, and others; and platform-specific versions.

C++ uses standards written by an ISO standard committee. C++ is not an implementation itself, but has many variations developed by different organizations and companies. Some variations are open-source depending on the goals and guidelines of the originator — for example, both Clang and GNU are open-source implementations of C++.

The Advantages of C++

C++ is sometimes referred to as a “multi-paradigm” language because it can be used for procedural, object-oriented, or functional programming. It is known for its flexibility and extensibility. In a procedural language, modules communicate by writing and reading state located in shared data stores. It is loosely bound with very little shared code.

With a tightly bound object-oriented language, objects communicate by sending various messages to other objects. Object-oriented programming uses encapsulation, with both code and data acting as objects. It simplifies code using polymorphism, the process of deploying one interface and several entities. C++ code runs faster than most other languages. It is highly portable and is a popular choice for creating multi-platform, multi-device applications. It has a useful function library, allows function overloading and exception handling, and includes classes, data abstraction, polymorphism, encapsulation, and inheritance.

Used in a Variety of Fields

C++ is deployed for tasks that demand high performance, such as video editing and transcoding, high-end computer-aided design (CAD), image processing, games, telecommunications, and business. It is used by companies such as Reuters and Bloomberg for data feeds with low latency, by the military for onboard systems, by Google for Chrome and other apps, and by Microsoft for the Office Suite.

Major airlines use flight control systems written in C++. It is popular for game development — the Torque 3-D game engine, written in C++, is used to develop Xbox and iPhone games. Advanced medical equipment makers use C++, and defense contractors use it for mission-specific software APIs. Well-known tech companies and organizations using C++ include Evernote, LinkedIn, Microsoft, Opera, NASA, and Facebook. Evernote switched from .NET to C++ for more speed and better graphics. LinkedIn uses restclient-cpp, a client written in C++ used for making HTTP/REST requests. Facebook uses it for back end services and regularly modifies C++ standards for custom features.

In addition, Wall Street and the financial industry have long used C++ for trading high volumes at high-frequency levels — they like that it can be easily used for modeling and data simulations. Its popularity in finance can be partly attributed to the fact that it is a major investment to adapt to new technologies and C++ simplifies the digital transformation of creating applications that run on legacy systems. More importantly, more than 70 percent of trading is known as High Frequency Trading (HFT), where software programs can trade tens of thousands of transactions in mere seconds. C++ is favored over other languages in HFT environments because on Wall Street, speed equals millions of dollars of revenue and profits.

C++ vs. Other Languages

Programming languages offer different advantages depending on the goals of the project. At Google, for example, C++, Java, and Python dominate. Here’s how they compare:

  • Java: C++ compiles to bytecode at the system level, while Java compiles to Java Virtual Machine bytecode. As a result, there are many cross-platform libraries associated with C++ because different platforms have different compilers. Because Java Virtual Machine is essentially an abstraction layer, Java programs can be run on any device that supports Java. Java is memory safe, but C++ is not. Java has a disciplined system for detecting errors, whereas C++ has unchecked casts and relies on the developer for memory management. Java is a complete object-oriented language, while C++ only utilizes certain OOP elements. Java uses interfaces to provide multiplicity — C++ offers multiple class inheritance.

  • Python: Python differs from C++ in that C++ is a compiled language, while Python is a scripting language. Python’s types are much simpler, and it has a distinct lack of declarations. Types in C++ are bound to names, explicitly declared, and checked when compiled. C++ is a mid-level language that offers lots of power and subsequent complexity. Python is simple to code and understand, which leads to quicker development and easier troubleshooting.

Garbage collection was originally intended to be included in C++, but there were too many technical problems to integrate properly with the rest of the code. However, the lack of garbage collection is an example of the power C++ gives you to customize the language for your purposes — you can easily add garbage collections with smart pointers. Unlike some other programming languages that have garbage collection built in, C++ was developed with speed and efficient infrastructure as its primary goals. It offers many advantages over other languages, with the caveat that you must have a working understanding of low-level programming to get the most out of it.

Is C++ a Good Investment for the Future?

C++ remains a solid investment for the future because of its power, versatility, flexibility, and prevalence in a number of industry verticals. It is still one of the most popular languages for game development, and is a favorite of the scientific community and financial industry. Further, it is often used for creating device drivers, software-defined networking, operating systems, and embedded software.

Handling the Back End at Google

Back end software operates on servers in the data center. C++ is often used for back end computing because it is ideal for heavy number crunching. It is fast, reliable, and compact. It also uses fewer resources per transaction, which is critical when you’re processing thousands of requests at the same time. For instance, Google web applications generally use JavaScript for the browser and Java for servers on the front end, while back end services and data repositories use C++. Google’s back end repository uses BigTable, and it uses MapReduce to handle large amounts of data processing.

The Go-to Language on Wall Street

Part of the reason that C++ is popular on Wall Street, and for quantitative finance in general, is due to its historical presence in the industry. Many developers in the finance industry “grew up” on C++ in the early part of their careers, so it became ubiquitous. Many financial programmers are able to develop in C++, and there’s a plethora of resources and communities to support it. Further, there are extensive math and quantitative-oriented libraries available.

Beyond that, it offers superior performance compared to other solutions such as Java or .NET. In addition, popular C++ libraries such as Boost have made C++ simpler and faster. Also, C++ templates potentially make code easier to optimize than Java or C. There are useful packages such as Rcpp, which adds R functions to C++, and RInside, which adds the R interpreter using a C++ wrapper class.

A Favorite of Game Developers

For a long time, C++ was the only choice for creating high-performance programs such as games. As a result, it’s become a standard solution, with lots of investment in game engines and libraries.

Game developers like C++ because it provides lots of control over hardware. It offers a powerful blend of high-level ease of use, high speed, and low-level hardware access. It is highly deterministic, a quality that is not always true for languages that operate in virtual machines or garbage-collected languages. Many games used to be written in Assembler, because you needed to access the hardware directly to get the best performance. With today’s computers, C++ makes code development faster while still allowing plenty of control over the machine layer.

Monitor Performance

With a powerful language like C++, application performance management is critical. AppDynamics offers C/C++ application performance monitoring that identifies and resolves performance problems in dynamic and distributed environments. The SDK discovers application topology, allowing you to trace transactions from application behavior. It correlates your C++ and C apps with programs written in other languages such as PHP, Node.js, and Python, and it lets you monitor databases, web services, and other back-end functions.

C++ is a fast, reliable, powerful language with few peers in game development, quantitative finance, banking, military and defense, back end systems, and many other applications. It offers a unique blend of hardware control while still being easy to program. Because of these advantages, the future is bright for C++ as it continues to adapt and improve in today’s modern computing environment.

Learn More

Learn more about our C++ performance monitoring solution today.

Instrumenting C/C++ application performance monitoring

With the AppDynamics Winter ’16 Release, AppDynamics now supports monitoring of C/C++ applications via a monitoring SDK that enables the same real-time, end-to-end, user-to-database performance visibility as other supported languages, for rapid root-cause analysis and issue resolution.

C/C++ has been around a while, and it’s regarded as the language for high-performance applications primarily because it compiles to machine code and directly interfaces with the operating system without an intermediate layer.

While the application complexity has exploded over the years and modern languages have evolved and become more popular due to various reasons, C/C++ based applications are still a core part of business critical application environment for many enterprises. As these applications become increasingly critical to the business, it’s more important than ever to have a simple, yet fast way to monitor, diagnose, and resolve application problems before they affect revenue.

Introducing AppDynamics C/C++ Application Performance Management Module

AppDynamics C/C++ Application Performance Management (APM) module provides end-to-end business transaction-centric management of C/C++ applications in the most complex and distributed environments to deliver exceptional user experience by proactively identifying and resolving performance issues.

As a key module of AppDynamics Application Intelligence Platform, C/C++ APM module monitors the C/C++ applications via a monitoring SDK that enables the same real-time, end-to-end, user-to-database performance visibility as other supported languages, for rapid root-cause analysis and issue resolution.

cpp-application-performance-monitoring-Fig1.png

Fig 1: C/C++ Application Performance Monitoring

You can instrument your C/C++ application code using the SDK, recompile the code and deploy in production to get real-time visibility of performance and find the root cause of code bottlenecks in seconds, all with minimal overhead. AppDynamics C/C++ application monitoring SDK enables automatic discovery and mapping of all tiers that service and interact with the C/C++ applications, automatic dynamic baselining, data collectors, and health rules, as well as managing key metrics including application load and response times, and system resources including CPU, memory, and disk I/O.

Instrumenting C/C++ application for monitoring

It’s pretty straightforward to instrument a C/C++ application code for defining and monitoring business transactions, capturing snapshots, distributed transaction correlation, backend monitoring, error Monitoring and collecting data from methods.

For example, in order to define and monitor a business transaction like what you see in Fig 1, you just need to enclose the code that constitutes the request that you want to monitor between appd_bt_begin() and appd_bt_end()calls. Please see code sample before and after instrumentation below where you will notice just two line of code required to get the code monitored as a business transaction.

Example of code before instrumentation:

AccountOpResult AccountMgr::CreateAccount(const std::string& username, const std::string& password)
{
    AccountOpResult result = AOR_OK;
    if (utf8length(username) > MAX_ACCOUNT_STR)
    {
        result = AOR_NAME_TOO_LONG;
    }
    else if (GetId(username))
    {
        result = AOR_NAME_ALREADY_EXISTS;
    }
    else if (!loginDB.PExecute("INSERT INTO account(username,pass_hash) VALUES('%s','%s')", username, CalculatePassHash(password)))
    {
        result = AOR_DB_INTERNAL_ERROR;
    }
    return result;
} 

Example of code after instrumentation:

AccountOpResult AccountMgr::CreateAccount(const std::string& username, const std::string& password)
{
    AccountOpResult result = AOR_OK;

 appd_bt_handle bt = appd_bt_begin(__func__, NULL);

    if (utf8length(username) > MAX_ACCOUNT_STR)
    {
        result = AOR_NAME_TOO_LONG;
    }
    else if (GetId(username))
    {
        result = AOR_NAME_ALREADY_EXISTS;
    }
    else if (!loginDB.PExecute("INSERT INTO account(username,pass_hash) VALUES('%s','%s')", username, CalculatePassHash(password)))
    {
        result = AOR_DB_INTERNAL_ERROR;
    }
 appd_bt_end(bt);
    return result;
} 

appd_bt_begin() returns a handle to use in subsequent routines that affect that business transaction. If you are creating a business transaction that correlates with an upstream business transaction, pass the correlation header of the upstream transaction so the new transaction that you are creating can correlate with it.

By inserting similar code, you can do distributed transaction correlation, backend monitoring, error monitoring and collect data (key/value) from methods

Hopefully this gives you an overview of C++ monitoring solution and gets you started. Learn more about the configuration, instrumentation and additional details of the C/C++ monitoring SDK in the AppDynamics documentation.

Dressing for dinner with Oracle Tuxedo

Can you imagine a world where you have a single, centrally managed, platform instrumenting and collecting data from your whole IT landscape in real-time? Allowing you to troubleshoot issues, analyze their business impact, and even track the flow of business operations (order shipments, transaction settlements, phone line installations, etc.) in real time? We can at AppDynamics, which is why we have adopted the “Application Intelligence Platform” moniker.

The breadth and depth of this vision is a perfect illustration of how far we have come from our genesis as merely just a Java performance troubleshooting solution.

Of course, the world is not just composed of Java, which is why we now support heterogeneous applications composed of not only Java code, but also any combination of .NET, PHP, C++, and Node.js.
Screen_Shot_2014-07-17_at_3.42.47_PM-960x0 (2)

This composition of supported runtimes covers the majority of modern (post Y2K) application platforms large enterprise environments use, where the biggest challenges exist. However, of course, the technology landscape in most business environments has magnified over the decades, not been built anew since Java roamed the earth, which takes me back to my past…

So, what is Tuxedo, then?

Today, if you want to write an application that serves a user base of any size, you wouldn’t hesitate to put it into an application runtime of some sort (a Java app server, or a plugin to a web server for PHP, .NET or Node.js). Since this takes care of a lot of the issues raised by multiplexing a single application between multiple users, and provides facilities for things like database connection pooling on the back end.

Back in the 90s, however, there was no such thing as an app server. Mainframe applications were coded in assembler and COBOL and had TP Monitors like CICS to provide these capabilities. UNIX applications were implemented in C for the most part but had to reinvent all these non-functional wheels every time (or used a 2-tier architecture with a fat client connected directly to a database, an approach which scales very poorly as the application user population grows).

In a nutshell, Tuxedo is an application server which allows you to write C/C++ or COBOL applications on UNIX (or Windows). Until the dot-com boom swept Java to pre-eminence, it was the only game in town for creating scalable UNIX based applications. Many people today are Tuxedo users without even realizing. Use PeopleSoft? Clarify? Amdocs? To name a few. All of these packaged apps have Java application server based web-facing tiers, but a large proportion of the application logic is implemented in Tuxedo-based back-end services.

So, the net of this is that many “complex, distributed, modern (post 1990) applications” use Tuxedo to provide the necessary distribution and other runtime services.

Now for the good news

One piece of news announced at AppSphere is that AppDynamics have just gone into beta with support for a new application runtime, C/C++ on Linux or Windows. Moreover, our approach allows instrumentation of C/C++ applications purely via configuration, not requiring development time code-changes or application rebuilds. The only tool that can boast this. Although an SDK is also available, so you can hand-instrument the application code if you are feeling “old-school”.

Now for the better news

The better news still is that since the constraints Tuxedo imposes on the applications using it means there are a well-known set of APIs that can be used to identify transactions entering a Tuxedo environment and trace them through it, the configuration is near identical for all Tuxedo applications.

So, what next?

To cut a long story short, AppDynamics now provides the capability to trace transactions end-to-end across a hybrid Java / Tuxedo environment. In the next article, I will present a simple demo application and walk step-by-step through what’s required to achieve this feat, without a introducing any AppDynamics dependencies into the application code!

Try AppDynamics Java monitoring for FREE today!