C++ Generic Coding vs. Java Frameworks

Why are there so many things that C++ developers should do by hand?

Intelligent flash storage arrays

Column As an ardent C++ developer, I’m often traumatized by the amount of potentially useful software infrastructure that simply doesn't exist.

When working in Java there are multitudes of frameworks and reusable libraries that allow many problems to be solved at high levels of abstraction without reference to the underlying technology. So why are there so many things the C++ developer must do by hand, which a Java developer can do by reusing existing code?

Is the lack of these frameworks and libraries one of the reasons why the language is losing ground to Java? In this article, I shall examine these points to see if they’re true; and attempt to determine the obstacles to greater code reuse in C++.

Before we start out, let's get a common picture of what type of code we want to reuse. We’ll start by making a distinction between two types of reusable code; a plain old library containing factorised code and the more interesting case containing tools, code-generators and support libraries that provide a means of transforming between the different domains of a data model. An example of the second is an SQL abstraction framework that takes a representation of the SQL schema and generates classes so that the relational data model can be manipulated in the object oriented domain.

In general, the problem of manipulating data in a foreign domain is tedious and time consuming. One approach to interfacing with databases is to call an interface library, perhaps ODBC or even something more proprietary. Such libraries will present everything needed to access the data in its relational form; the code to maintain integrity in the relational model [in purist terms, a proper RDBMS - relational database management system - should maintain its own integrity without relying on the programmer – ed] and the deletes and update code must be written by hand.

This hand-written code is tedious, time-consuming to write and if not carefully managed it will create dependencies on the database interface library everywhere. With an SQL abstraction framework, we use a description of the data model to generate both the SQL and all the code mentioned above.

In other words the mapping from relational to object model is now expressed in generated code, which means, firstly, that it doesn’t need to be written by hand; and, secondly, that the details of handling relational data and interfacing with a database are hidden behind an object oriented interface. Most of us will agree that generating this data model transformation is a significant saving in time compared to writing it by hand. In addition, using the generated object oriented interface means that the code using the database can focus on what it needs to do rather than the details of handling relational data and interfacing with the database.

An example of such a framework in Java is Hibernate. Similar tools for XML and other technologies are plentiful in Java. In C++ this infrastructure is harder to find; it exists but normally needs to be paid for or isn’t as dependable as the Java equivalent. So why is it that we see more of such infrastructure in Java as opposed to C++?

Is it just that Java is the obvious choice of technology for anything involving XML or databases and these frameworks don’t exist in C++ because nobody would use C++ for this type of problem? I’m not sure that this is so self-evident; the languages are not so different that something modelled in one cannot be modelled in the other with more or less the same level of difficulty.

However, just as portability is often a strong argument for using Java for a problem, there is also often a performance argument for using C++; and, for this reason, you could expect that some programmers in any problem space where Java is applied would sometimes prefer C++ solutions.

Secure remote control for conventional and virtual desktops

More from The Register

next story
Nexus 7 fandroids tell of salty taste after sucking on Google's Lollipop
Web giant looking into why version 5.0 of Android is crippling older slabs
Be real, Apple: In-app goodie grab games AREN'T FREE – EU
Cupertino stands down after Euro legal threats
Download alert: Nearly ALL top 100 Android, iOS paid apps hacked
Attack of the Clones? Yeah, but much, much scarier – report
SLURP! Flick your TONGUE around our LOLLIPOP – Google
Android 5 is coming – IF you're lucky enough to have the right gadget
Microsoft: Your Linux Docker containers are now OURS to command
New tool lets admins wrangle Linux apps from Windows
Bada-Bing! Mozilla flips Firefox to YAHOO! for search
Microsoft system will be the default for browser in US until 2020
prev story


Why cloud backup?
Combining the latest advancements in disk-based backup with secure, integrated, cloud technologies offer organizations fast and assured recovery of their critical enterprise data.
A strategic approach to identity relationship management
ForgeRock commissioned Forrester to evaluate companies’ IAM practices and requirements when it comes to customer-facing scenarios versus employee-facing ones.
High Performance for All
While HPC is not new, it has traditionally been seen as a specialist area – is it now geared up to meet more mainstream requirements?
Managing SSL certificates with ease
The lack of operational efficiencies and compliance pitfalls associated with poor SSL certificate management, and how the right SSL certificate management tool can help.
Top 5 reasons to deploy VMware with Tegile
Data demand and the rise of virtualization is challenging IT teams to deliver storage performance, scalability and capacity that can keep up, while maximizing efficiency.