Would you implement Java in Java?

Published Friday April 7th, 2006
7 Comments on Would you implement Java in Java?
Posted in KDE, Qt, Uncategorized

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. πŸ˜‰

Do you like this? Share it
Share on LinkedInGoogle+Share on FacebookTweet about this on Twitter

Posted in KDE, Qt, Uncategorized


Richard says:

Some people just don’t get it that THEIR solution for THEIR problem is not an UNIVERSAL solution for EVERY problem.

Chase Venters says:

I’m guilty of some bias when it comes to languages — I have a particularly strong dislike for Java.

I’m a mod_perl developer (the fantastic stuff that powers Internet powerhouses like Amazon.com and Ticketmaster.com). Over the recent years as the Sun marketing machine (and the Java movement behind them) have done damage to my profession, I’ve been faced down with clueless managers and developers who almost mock me for choosing anything *but* Java.

I used to tell them that no major customer-facing portal used Java because of the performance implications. Some time recently, someone pointed out the “JAVA Technology” logo that’s been added to eBay.

Amusingly enough, “JAVA Technology” loaded quickly, but eBay.com itself took a full 9 seconds. FOR BROADBAND. Clicking “BUY” took 20 seconds.

But yes, no universal hammer. I’d shudder if I saw a kernel written in C++, just as much as I would shudder if I saw a website written in assembly. So there is such a thing as the ‘right tool for the job’, but there’s also some things I think that serve fine examples of ‘wrong tool for most jobs’.


Noé says:

I see you don’t know Ruby πŸ˜‰

John says:

Unfortunately, with things like Java becoming /cool/, rather than well-understood, this is the way things will go. πŸ™

Chase Venters: The Mac OS X kernel is written in C++. Its actually quite fast and powerful. πŸ™‚


Andreas says:

Well despite the fact that we’ve had hammers for hundreds of years, you still cannot efficiently use them to build a house of cards, regardless of how cool they are. We haven’t seen any programming language conquer the world the last 20 years. I can’t see it happening the next 20 either.

Ben says:

I thought that the point of the article is that you can’t/shouldn’t be writing web/distributed apps in C++ and you shouldn’t be writing processing (3D/image/sound/multimedia) apps in PHP.

I think that whether or not Java is as fast as C++ is a secondary consideration to which language/toolkit will get you to your goal the quickest.


Andreas says:

The examples chosen were there to prove the point of the article, not to serve as the point. Many large distributed apps are written rightfully in C++, and many image processing tools are rightfully written in PHP.

Now, whether C++ or Java is /fastest/ is a crucial part of choosing a language for an app that is very affected by performance. That is regardless of which language will deliver quickest.

Commenting closed.

Get started today with Qt Download now