Back to Blog home

Would you implement Java in Java?

Published on Friday April 07, 2006 by Andreas Aardal Hanssen in Qt Uncategorized KDE | Comments

When I was at the Trolltech booth at LinuxWorld Expo in Boston, two guys stepped up to our booth, showing interest to our slogans about productivity gain. I asked them about their business, and whether they were in development, adminstration or management. "Development", they said. So I asked how familiar they were with Qt. Then one of the two looks at me with a grim face and goes "C++ is a pretty hard hitting language. We write governmental prototype software in JSP.". And then they rushed away. Sigh. Then, another guy shows up and talks about how everything is moving towards PHP and Ajax.

"Because everyone has a browser!"
"What about the back-button?", I asked.
"PHP scripts will be able to disable that button in the future.", he said.
"Better not hit the bookmark-button!" I warned.
"PHP scripts will be able to disable that button in the future.", he said.
"So are you talking about thin clients, or about the programming language PHP?"

Programming languages, are tools. Let's just agree on that. I love Java for all it's worth, PHP is wonderful, and I love working with C++. What I can't stand is language protagonists. ;-) People who seriously think that one tool can solve all problems. Nothing good comes from that. Or as they say in the US, that once you've got the perfect hammer, everything looks like a nail. C++ is not perfect for embedded web development. PHP is good for that. Java is no good for performance-critical applications. Use C++ for that. Applets? Servlets? Yes, please, please, go with Java. Or use PHP. Or C++. Just please know that these are all different tools that you can choose amongst.

I'm seeing most protagonism (?) in the Java world. Java isn't a language, it's a movement.
But if you take away one essential feature, say, implicit memory management in Java, and replace it with explicit management (a.k.a. delete and pointers), what does Java give you? Now, we're talking about syntactic sugars like .h+.cpp vs .java, and features of the toolkit. Java is a programming language. Implicit memory management is a tool. It cannot solve all problems but it certainly solves many of them. And Java is actually really really ridiculously fast. That's what I hear all the time. Actually, they say, it's really really fast. The JIT compiler can in theory generate code that's faster than what any C++ compiler can do. And I think that when P = NP, it certainly will! But until then, we will not see Matlab, Mathematica, 3D studio or Photoshop written in Java. Why? Not because people in theory want fast code, but because they know what they get when they use C++. Your average high-performance Java application typically contains tons (or, as they say in the US, miiillions ;-)) of tricks to bypass the GC (as nobody wants a GC sweep in the middle of heavy calculation, real-time rendering and such). And then there's tricks to ensure that certain parts of the code are unrolled to ensure that the JIT kicks in.

When you as a Java programmer make an effort to bypass your favorite Java features in order to write an application in Java that is not suited for Java. And when you as a PHP programmer write tons and tons of code to make your web application looks like a true, native application with tray icons and window decorations, strip away the navigation controls and bookmark handling. That's when you know you've become a language protagonist. ;-)

So please, choose the right tool. You're a great programmer! But that doesn't mean you have no options. ;-)

Subscribe to Our Blog

Stay up to date with the latest marketing, sales and service tips and news.

The blog comment system has been migrated to a new platform. If you face any issues, please let us know via feedback@qt.io.