C++ Generic Coding vs. Java Frameworks

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

Choosing a cloud hosting partner with confidence

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.

Remote control for virtualized desktops

More from The Register

next story
Euro Parliament VOTES to BREAK UP GOOGLE. Er, OK then
It CANNA do it, captain.They DON'T have the POWER!
Download alert: Nearly ALL top 100 Android, iOS paid apps hacked
Attack of the Clones? Yeah, but much, much scarier – report
NSA SOURCE CODE LEAK: Information slurp tools to appear online
Now you can run your own intelligence agency
Post-Microsoft, post-PC programming: The portable REVOLUTION
Code jockeys: count up and grab your fabulous tablets
Twitter App Graph exposes smartphone spyware feature
You don't want everyone to compile app lists from your fondleware? BAD LUCK
Microsoft adds video offering to Office 365. Oh NOES, you'll need Adobe Flash
Lovely presentations... but not on your Flash-hating mobe
prev story


Driving business with continuous operational intelligence
Introducing an innovative approach offered by ExtraHop for producing continuous operational intelligence.
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.
Why CIOs should rethink endpoint data protection in the age of mobility
Assessing trends in data protection, specifically with respect to mobile devices, BYOD, and remote employees.
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?
Mitigating web security risk with SSL certificates
Web-based systems are essential tools for running business processes and delivering services to customers.