The Artima Developer Community
Sponsored Link

Java Community News
Kirk Pepperdine: Why Are We Still Dealing with C++ vs Java?

65 replies on 5 pages. Most recent reply: Jun 17, 2006 11:56 PM by Charles Haws

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 65 replies on 5 pages [ 1 2 3 4 5 | » ]
Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Kirk Pepperdine: Why Are We Still Dealing with C++ vs Java? Posted: Jun 5, 2006 8:32 AM
Reply to this message Reply
Summary
In his blog, Kirk Pepperdine compares the average competency level of C++ programmers with Java programmers, and suggests that architecture is usually most important to performance, not raw speed of the underlying language. What are the real tradeoffs between C++ and Java?
Advertisement

In his blog entry, Why Are We Still Dealing with C++ vs Java, Kirk Perpperdine begins by relaying an opinion he enountered that the complexity of a language serves as a competence filter:

I had an interesting conversation this week with someone that believed that the Java world was filled with people who couldn’t code. In his opinion, C++ programmers were much better because of the language. There are many programmers in the Java world that just don’t have what it takes to survive in C++.

Perpperdine suggests that although a language may lead its programmers to be more competent in the features of that language, in his opinion any general competency difference is insignificant:

...is the average level of competency higher for C++ developers then it is for Java developers? This is a question for which I have no data on which to base a judgment though my feeling is there isn’t enough of a difference to make a big deal about it. So what if C++ developers can use pointers better then Java developers can. Java developers can deliver functionality at a rate 2.5 times faster than those working in C++.

This is not a statement about the quality of developers or the languages; it is more a measurement of relative expressiveness of each language. A more expressive language in the hands of a good developer will translate into higher productivity. Now Java may have lowered the so called knowledge bar in that it allows people to code without understanding the complexities of explicit indirection (pointers). However, Java does come with it’s own complexities which means that the need to know different things.

Pepperdine then turns to performance comparison, claiming that dynamic compilation and optimization techniques have brought Java performance on par with C++:

... compiling code after dynamic profiling is proving to be a very powerful technique for optimizing run time performance. Using run time profiling and JIT technologies, Java is now able to run at C++ speeds. But even more important is that in today’s applications the performance limiting factors are often found outside of either the C++ or Java application. ... Bottom line, architecture is often a more the dominant factor in application performance. In these instance speed to market would seem to be a much more important factor in choice of languages. Of course there are exceptions in that there are some things that cannot be so easily achieved in Java and in these instance the only choice will be C++.

At Artima we believe that developers should use the right tool for the job, and try to help our audience understand the tradeoffs of the various choices. Both C++ and Java have huge communities of developers doing important things. What do you believe are the real tradeoffs between these two languages today? For what kinds of situations is each a good fit?


Harrison Ainsworth

Posts: 57
Nickname: hxa7241
Registered: Apr, 2005

libraries / other code Posted: Jun 5, 2006 10:23 AM
Reply to this message Reply
I would think libraries / other code is the biggest factor. Most projects reuse or relate to a significant amount of external stuff. Whatever language dominates that will almost certainly be the only choice.

I wonder if there should be more automation of translation and 'reuse-interfacing'...

Cleo Saulnier

Posts: 77
Nickname: vorlath
Registered: Dec, 2005

Re: Kirk Pepperdine: Why Are We Still Dealing with C++ vs Java? Posted: Jun 5, 2006 11:04 AM
Reply to this message Reply
The biggest difference is that in C++, you have to build your set of libraries yourself. Not write them (necessarilly), but go out and find what packages to use and which ones work well together. For that reason, you become an expert whether you like it or not. In Java, the SDK holds your hand. It may not be the best, and a lot of it is absolutely horrid, but most everything is there. So is Java more productive? If you don't care about quality and just want something done, sure. But evidence shows that 7-15 year experienced programmers, the C++ programmer will absolutely destroy a Java programmer in all areas of productivity, reliability, memory usage and scalability, etc. And this by a factor of 10 to 100, if not more. But if you have programmers less than 5 years experience, the ramp up period is much less in Java.

So in the end, you get what you pay for. Using the right tool isn't just about the language. It's about the libraries and programmer experience. That's why the debate rages on. Java's been around for over 10 years now. And the results are starting to dispell the hype.

My personal take is that Java programmers are usually at a loss if it's not in the SDK. In C++, beginners tend to reinvent the wheel. Who wins? The ones that used both and know the truth. Don't take my word for it, try both. And that, my friends, is the kicker.

Jeff Foster

Posts: 6
Nickname: jefffoster
Registered: Nov, 2004

Re: Kirk Pepperdine: Why Are We Still Dealing with C++ vs Java? Posted: Jun 5, 2006 12:11 PM
Reply to this message Reply
"But evidence shows that 7-15 year experienced programmers, the C++ programmer will absolutely destroy a Java programmer in all areas of productivity, reliability, memory usage and scalability, etc. And this by a factor of 10 to 100, if not more."

Just out of interest where is this evidence? Can you point me in the direction of some references?

Max Lybbert

Posts: 314
Nickname: mlybbert
Registered: Apr, 2005

I vote for C++ Posted: Jun 5, 2006 12:38 PM
Reply to this message Reply
The first programming book I owned was for Java. The first programming "language" I learned (aside from Basic, Logo, etc.) was Perl. I learned far more about computer science reading "Programming Perl" than I did from the various Java books I recently gave away.

I can't really say what did it, but one day I was looking at Java code and realized Java (as a language) doesn't provide me anything I can't get in C++, and in fact brags about getting rid of large portions of C++.

Yes, Java does provide garbage collection; but the C++ standard permits garbage collection, and g++ ships with it. Yes, Java has "interfaces," but C++ has pure virtual base classes. Oh yeah, Java has a portable runtime; but that's not a language issue, it's a platform issue. I honestly haven't seen anything in the last five years that makes me want to switch to Java (the language).

Java's libraries are good. So are Perl's. And I haven't yet had any trouble finding a good C++ library to do what I want.

OTOH, OCaml has tempted me some. But OCaml's syntax is just too weird. I'm currently looking at Haskell, Scala, and similar languages.

Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: Kirk Pepperdine: Why Are We Still Dealing with C++ vs Java? Posted: Jun 5, 2006 1:05 PM
Reply to this message Reply
> "But evidence shows that 7-15 year experienced
> programmers, the C++ programmer will absolutely destroy a
> Java programmer in all areas of productivity, reliability,
> memory usage and scalability, etc. And this by a factor of
> 10 to 100, if not more."
>
> Just out of interest where is this evidence? Can you
> point me in the direction of some references?

Me too. One thing that has been sorely lacking in all of these language debates is results of actual research. I find that when people share their experiences, it is educational and useful. But if there's research going on, that would be very helpful to know about.

Jeff Ratcliff

Posts: 242
Nickname: jr1
Registered: Feb, 2006

Re: Kirk Pepperdine: Why Are We Still Dealing with C++ vs Java? Posted: Jun 5, 2006 1:09 PM
Reply to this message Reply
This idea that a programmer's general competence is related to the language they use is something only junior high students should concern themselves with.

What purpose does such a debate serve other than to pump-up our fragile egos?

Mark Thornton

Posts: 275
Nickname: mthornton
Registered: Oct, 2005

Re: Kirk Pepperdine: Why Are We Still Dealing with C++ vs Java? Posted: Jun 5, 2006 1:27 PM
Reply to this message Reply
> is Java more productive? If you don't care about quality
> and just want something done, sure. But evidence shows
> that 7-15 year experienced programmers, the C++ programmer
> will absolutely destroy a Java programmer in all areas of
> productivity, reliability, memory usage and scalability,
> etc. And this by a factor of 10 to 100, if not more.

I've been programming for close to thirty years and there are few tasks that I do where the difference in performance or memory use would exceed a factor of 2 (and not always in favour of C++ either). Productivity and reliability are harder to quantify, but I suspect the advantage is with Java although perhaps not dramatically so.

Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: Kirk Pepperdine: Why Are We Still Dealing with C++ vs Java? Posted: Jun 5, 2006 1:45 PM
Reply to this message Reply
> My personal take is that Java programmers are usually at a
> loss if it's not in the SDK. In C++, beginners tend to
> reinvent the wheel. Who wins? The ones that used both
> and know the truth. Don't take my word for it, try both.
> And that, my friends, is the kicker.
>
I would say it is hard to generalize about developers, because in my experience there's such a huge difference between individual developers. Some are so much more productive than others. I would guess that those differences outweigh the differences that arise because of the language's difficulty filter.

On the other hand, when I read Kirk's post this morning, what he said he'd heard about C++ and Java reminded me of things I've heard about C++ or Java compared to scripting languages such as Perl, Python, Ruby and more visual IDE-based ones like Visual Basic. Because scripting and VB-like languages make programming easier, they enable less sophisticated people to use them. This is a good thing, because it in theory allows more smart people who aren't programmers to program, such as people who design airplane wings. I've also seen people who could program OK in VB who we (my at-the-time C++ programming peers) didn't feel were capable of programming in C++. So I think the language difficulty does act as a filter. But whether I go out to hire a C++, Java, or Ruby programmer, it is still tough to find a good one, so I'm not sure of what use it is to worry about to what extent language complexity acts as a competence filter.

What I'm really getting at in this post is today, in 2006, what are the real tradeoffs betweeen C++ and Java? Back in 1996, when I first started working with Java, I was switching from contract programming to consulting/writing/training. Java back then was the hyped, up-and-coming technology, and I wanted to get in on the ground floor and use it to launch a consulting/writing career. As I was just doing toy examples in Java in those days for articles, books, and seminars, it didn't matter to me that Java at that time was way slower than C++. If I'd been planning to build something real then, I'd have used C++. More recently, however, Java is plenty fast enough for server applications, and for various reasons I chose Java to build Artima's new architecture. But my wife's company uses C++, and it feels to me very much like the correct choice for their application because they need to squeeze as much raw speed out of the system that they can.

One of the main reasons I chose Java for Artima's new arxchitecture was the active community of innovation. I get to take advantage of Tomcat and Lucene and Hibernate and Jini and refactoring IDEs and a whole bunch of other things for free, not to mention things that are available commercially. Many of these things, or reasonable facsimiles, are available in other languages, but my perception is that Java has both open source and commercial momentum that keeps advancing, and I wanted to be able to make use of that. That coupled with our familiarity with Java, and our existing Java codebase, made it an easy choice over C++.

I also considered Ruby and Python. Trouble here was my perception that Java still leads in the APIs to chose from (especially in Ruby's case), and that Ruby and Python have traded off some runtime performance potential for productivity. I was more bummed I couldn't use these languages than C++ (because they are fun and I need all the productivity I can get), but figured I could use them here and there. I have used both Ruby and Python occasionally at Artima, but have found it difficult to find opportunities given that everything else is in Java.

One clear difference I see in C++ and Java apps is Java has some startup time if the VM isn't already running. This doesn't matter for server apps, but it sure does for little short-lived desktop things. Also, dynamic optimization is most effective for long-running applications, like servers. So that's one thing. Java also forces you to use garbage collection, and on the Mac at least I get perceptible pauses while using IntelliJ. I'll put up with it, but I don't like it. Frank tells me that on Windows he never sees a GC pause, so we figure that VM on Windows is better in that regard.

Those are a few differences I can see between Java and C++ today. Do you see others?

Mike Petry

Posts: 34
Nickname: mikepetry
Registered: Apr, 2005

Re: Kirk Pepperdine: Why Are We Still Dealing with C++ vs Java? Posted: Jun 5, 2006 6:14 PM
Reply to this message Reply
C++ has been looking better to me lately.
However, memory management is a concern. Protocols, heuristics and idioms are used in place of language support. For example, Microsoft COM's memory management is largely based on programmers guidelines. COM pointers always point to dynamic objects and are always freed by the client.
Another popular heuristic is that "he who allocates, shall deallocate". This seems safe but gyrations are required to make sure that the allocater is in position to deallocate.

Java has garbage collection, but even better, it has references [only]. C++ has references and pointers. The pointers may point to dynamic or automatic variables.
I used to dislike the idea that some C++ classes where created to provide automatic scoping for dynamic variables. But I have been getting over it, because this is how C++ does garbage collection.
Stroustrup says "C++ doesn't need garbage collection because there isn't any garbage." The art of C++ memory management is the skillfull use of automatic variables and the stack, the computer's natural garbage collector. Idioms like smart pointers are used heavily in libraries like Boost.

Also, Java seems to decrease portability and flexibility. Once I code Java, I am limited to execution within the Java VM. Interoperating with applications running outside the VM becomes problematic.
Examples of possible problems:
1. How do I synchronize when there are no kernal synchronization objects?
2. How do I manage access control between the Java sandbox and my native apps?

In the end, I feel like my investment in mindshare goes further with C++.

Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Re: Kirk Pepperdine: Why Are We Still Dealing with C++ vs Java? Posted: Jun 6, 2006 12:35 AM
Reply to this message Reply
> This idea that a programmer's general competence is
> related to the language they use is something only junior
> high students should concern themselves with.
>
> What purpose does such a debate serve other than to
> pump-up our fragile egos?


I agree that language has not that much to do with general competence. In fact, a good programmer knows several languages fairly well, and therefore can decide what language to use for a given job (provided he's given that freedom).

I'd definitely say that not only the availability of APIs, but the existence of standards-based high-level APIs and infrastructure is also important in choosing a language for a project. That's especially (or perhaps only) an issue, of course, if one were to adhere to such standards. For instance, J2EE is one such standard in Java - if you are willing to live within the bounds of that framework, you have plenty of implementations and tools that can make your work very productive. In fact, those tools can make even below-average programmers more productive, too. (Even more productive, perhaps, than an above-average programmer who refuses to use such tools because, well, he is above avarege).

Also, few applications today are written from scratch - most apps must live within some existing context, and you have to hook new stuff into that existing fabric, or implement something within a given enterprise framework. In those situations, Java has a huge advantage, because many of its standard APIs and frameworks are aimed squarely at core enterprise computing tasks.

At the moment you leave the standard path, however, the productivity of a language's APIs and frameworks are less helpful, and hence developer productivity must rely more on core language productivity features, as well as more on developer competence.

As far as performance goes, much more difference in performance can be attributed to the choice of algorithms or tools than to whether an app is written in C++ or Java. Many Java apps, because they take advantage of high-level frameworks, rely on multiple levels of indirection, and hence are far from using optimized algorithms for a given task. Many organizations are willing to live with that compromise in the name of increased developer productivity, and just throw some computing resouces to the problem.

Partly as a consequence of using such high-level frameworks, many Java developers may not be much concerned these days with core computer science issues, such as algorithmic efficiencies (or even correctness, in the case of distributed operations). When I was writing C++ and C apps, even Perl apps, I know I was much more attuned to those sorts of issues. I can even say that Java sort of "corrupted" me in that regard, because, I just rely so much on someone else's API. Writing Java code often feels like stitching together some existing framework, and the main concern of development becomes how new code will fit those frameworks, not so much what, the language can express and how to best express that. The Java language, as it is increasingly used, is becoming a glue that ties various framework elements together. Just consider the preponderance of annotations in Java EE 5. The main concern of working in that environment is not the programming language, but the bits of magic that the annotations bring about.

The other issue is that many applications nowadays must concern more with scalability than with raw performance. That's especially the case for server applications, where Java is so heavily used. In other words, instead of optimizing on performing, say, more transactions per second on a singly processor, an application can handle more transaction throughput by distributing its operations across multiple processors. That sort of renders the raw performance argument a lot less important, and instead focuses, again, on API and tools support for that sort of scalability.

Anyway, here's a question to ponder. Who's the smarter programmer: one who knows all his algorithmic theories, is able to manage pointers in his sleep, is very detail oriented and conscientious - or one that may not know all that much about computer science or even programming languages, but knows instead where to turn for the right tools to get the job done quickly and cheaply?

My take is that both are smart, in their own way, and the world needs both kinds. It's not a question of choice over one or the other in absolute terms. However, it's often a question of choice in specific contexts. And, indeed, the smartest of all is the one who can combine these sides, knowing when to use VB or Java or C++.

Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: Kirk Pepperdine: Why Are We Still Dealing with C++ vs Java? Posted: Jun 6, 2006 1:30 AM
Reply to this message Reply
> Stroustrup says "C++ doesn't need garbage collection
> because there isn't any garbage." The art of C++ memory
> management is the skillfull use of automatic variables and
> the stack, the computer's natural garbage collector.
> Idioms like smart pointers are used heavily in libraries
> s like Boost.

Mr Stroustrup has never been called to implement a program with a complex object model that has cyclic dependencies which are only known in the run-time (and thus one can not predict were to use weak or strong ptrs).

I never understood why mr Stroustrup is so much against garbage collection. GC is a tool, just like anything else. For some projects, it may be good. For some others, it may be bad. C++ is advertised as a language where "you do not have to pay for what you do not use", yet in C++ a programmer has to make the triple effort compared to other programming languages, in order to program and test all the copy constructors, assignment operators, memory allocations etc.

And before someone says "use Boehm's collector", I would like to say that Boehm's collector is largely inefficient, and it would be much faster if only the GC knew were its pointers are. And you can not do weak ptrs with Boehm's collector, which is really important for MVC patterns.

Microsoft has very efficient garbage collection in managed C++, by introducing a new kind of pointer (^). The compiler knows where gc pointers are, and collection is very efficient...which shows that C++ can have true garbage collection, and the only thing that keeps C++ from having GC is the stubborness of the C++ commitee.

damien morton

Posts: 15
Nickname: dmost
Registered: Jan, 2004

Re: Kirk Pepperdine: Why Are We Still Dealing with C++ vs Java? Posted: Jun 6, 2006 6:57 AM
Reply to this message Reply
When all is said and done, Java still isnt the language of choice when developing rich-client applications.

All of the client-side Java applications I have seen, and I include Eclipse in this, are slow, bloated, monstrosities.

The only reason why Java survives in a server environment is because consumers of Java applications have been trained to accept slow response times.

bug not

Posts: 41
Nickname: bugmenot
Registered: Jul, 2004

Re: Kirk Pepperdine: Why Are We Still Dealing with C++ vs Java? Posted: Jun 6, 2006 7:53 AM
Reply to this message Reply
Mr Stroustrup has never been called to implement a program with a complex object model that has cyclic dependencies which are only known in the run-time (and thus one can not predict were to use weak or strong ptrs).

Please justify this in light of his publications page (http://www.research.att.com/~bs/papers.html). As a young researcher you end up implementing the things you write papers about.

And before someone says "use Boehm's collector", I would like to say that Boehm's collector is largely inefficient, and it would be much faster if only the GC knew were its pointers are.

Any numbers on that?

Max Lybbert

Posts: 314
Nickname: mlybbert
Registered: Apr, 2005

I still like C++ Posted: Jun 6, 2006 8:32 AM
Reply to this message Reply
/* More recently, however, Java is plenty fast enough for server applications, and for various reasons I chose Java to build Artima's new architecture. But my wife's company uses C++, and it feels to me very much like the correct choice for their application ...

One of the main reasons I chose Java for Artima's new arxchitecture was the active community of innovation. I get to take advantage of Tomcat and Lucene and Hibernate and Jini and refactoring IDEs and a whole bunch of other things for free, not to mention things that are available commercially. Many of these things, or reasonable facsimiles, are available in other languages, but my perception is that Java has both open source and commercial momentum that keeps advancing, and I wanted to be able to make use of that. ...

I also considered Ruby and Python. Trouble here was my perception that Java still leads in the APIs to chose from (especially in Ruby's case), and that Ruby and Python have traded off some runtime performance potential for productivity. ...

One clear difference I see in C++ and Java apps is Java has some startup time if the VM isn't already running. This doesn't matter for server apps, but it sure does for little short-lived desktop things.
*/

So you're suggesting that there are tradeoffs to be considered in language choice? Heretic!

Even so, I generally think I can do better than Java ( http://opal.cabochon.com/~stevey/blog-rants/lisp-wins.html ). I generally consider implementation details more than general "C++ for the desktop, Perl for CGIs." For instance, if I believe I'll need strong typing (with automatic type conversions), I'm very likely to go with C++ ( http://discuss.joelonsoftware.com/default.asp?joel.3.254498.13#discussTopic257106 ). If, on the other hand, I want to build up and tear down lots of sockets, I'll go with Perl. Right now I'm considering the concept of monadic parsing combinators (basically the practice of taking a language like Haskell or OCaml that lets you overload functions on regular expression matches, and using those functions to implement a parser).

But, you're right that the correct question is "C++ or Java for this particular app that I'm writing right now."

Flat View: This topic has 65 replies on 5 pages [ 1  2  3  4  5 | » ]
Topic: Kirk Pepperdine: Why Are We Still Dealing with C++ vs Java? Previous Topic   Next Topic Topic: Gavin King Explains JBoss Seam

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use