Ruby on Rails
Ta-da List


November 22, 15:08

Fear, change and a language called Java

A short ecstatic tale of how I feel today after spending the last couple of days discovering Java for web application development (and neglecting responsibilities). It strays in PHP vs Java, using an IDE, initial complexities, and needing the final push to pick up something new.

Despite having worked in a hardcore J2EE shop for the better part of 2001, developing two student Java GUI projects as part of my formal comp sci/business education, and reading an endless amount of articles on various Java technologies, it wasn't until the day before the day before yesterday I really got my feet wet in the pool of web-minded Java.

I create web applications for a living. Primarily in PHP, which by all means is an excellent tool for doing just that. A position I've vigorously held in many a debates with Java developers. PHP even has decent support for object-oriented programming. But (you could smell that coming, couldn't you?). Of course, there's a but.

By the time your web-app programming experience reaches a level where you're constantly seeking to avoid coding the same behavior for the Nth time, much of what made PHP a breeze to pick up (it was my first serious programming language) starts to impose a world of small constraints.

Discussed in separation, there's an acceptable solution to almost any issue you hear PHP being attacked on. Discussed as a whole... Well, the case isn't looking as clear. It's not that it cannot be done. Of course it can. I and others do so every day. Even large corporations do.

But I digress, back to the day before the day before yesterday.

It all started with a desire to give just-released version 3 of IDEA a spin. IDEA is an IDE that helps you program by extending your memory and decreasing your typing.

It extends your memory by remembering all of those small details that you would normally have to look up, such as what's the exact wording for this method and which package did it belong to again? It decreases your typing by providing shortcuts to everything. Building an standard iterator is reduced to "itar" and a TAB. Creating getters and setters for object properties is a right-click and a selection away.

IDEs have been around for a long time and exists for almost all programming languages. Picking one up, though, is often fraught with annoyance. Making IDE's is a delicate balance between trying to do enough to be worthwhile and doing in a way fitting existing behavior. For a long time, I couldn't find anything that could keep that balance in either PHP (trying Zend and PHPEdit) or Java (trying earlier versions of NetBeans and JBuilder).

IDEA, however, instantly felt a perfect fit.

It prompted me to go on to discover Java as an alternative to PHP. And I did. And it too, felt like a fit for so many of the small grievances I've been struggling with over the last year doing "full-time" (while studying) PHP web-app development.

Much of the infrastructure I've labored to create in PHP (like decent Model-View-Control support) exists in much-refined quality in the Java world. On top of that, an overwhelming array of additional solutions to make developer life easier and more productive is available.

Of course, like most advanced tools, it comes with an intimidating price of initial complexity. Which partly explains why it took me so long to actually touch what was right in front of me all along. That and I, as most humans, fear the unknown and change instinctively.

Phew. What a brain dump. Conclusions:

  • IDEs can make you feel like you've discovered the word processor after hand writing 20-paged reports in your "dumb" text editor.
  • Powerful abstractions make for intimidating learning curves.
  • Java should be considered by PHP developers when they start feeling many small constraints comprise large obstacles (but best not before that).
  • Discovering the possibilities of new technology have a tendency to make developers (including this one) ramble euphorically and possibly exaggerate likely gains. Tip: When you get that feeling, chant There's No Silver Bullet ten times.

Challenge by Morten Krog on November 23, 1:25

Hey David

Nice to know you are starting to come around to the java-way. Just a little sad that it is an IDE that changed your mind. IMO it is wise to avoid IDEs _at_ _all_ _costs_ since the drastically reduce the knowledge you need to have and without knowledge no understanding of your tool (here java) is truly possible.


Challenge by David Hansson on November 23, 1:35

I perfectly understand where you're coming from, seeing the effects you mention on a study buddy that started out with JBuilder from day one. There's a lot to be said of going down the hard road once before taking the easy one. Don't do the latter before you know the path of the former.

But I did develop a couple of two-weeks Java projects with a basic editor. And it's not like IDEA is a code-generation tool. It's a code-assisting tool of which there's a great difference. It lowers the learning curve, true, but it doesn't eliminate learning. The learning just happens with less friction and frustration.

PHP naturally still has an important role to play in web development, but probably not so much for projects that can afford it's own dedicated server and where loss of data could be fatal.

But you're certainly right. I have come around a bit. PHP used to be my be-all end-all hammer for web-development. Not so anymore. My shades are being removed :).

Challenge by Morten Krog on November 23, 14:24

On IDE's,

Yeah, but IDEs usually also handles makefile (or ant) configuration. That is rather complicated and in a development situation a good thing to understand yourself. Most IDEs do not addapt well to handwritten makefiles and there are tons of other problems that IDEs can give you. I'm all for syntax-higlighting editors and type-ahead help for the programmer (and I really like the new M$ concept of code concealment where you can fold functions away to give you a better view of your code).

Have you tried Eclipse from (originally an IBM product but now open source). It is a very good IDE for java IMO. I just use it as an editor though.


Problem is just that java-based web-solutions seems to have a lower peak performance than more raditional scriptbased solutions. If you can afford the hardware this is not a problem, but in most cases hardware prices and hosting costs in a major part of the cost considerations in a professional project.

Challenge by David Hansson on November 23, 14:44

Re: IDE,
IDEA features excellent Ant integration that'll allow you to completely control the build process from an external (hand-written) Ant script. Again, not wizard-style, but assisting-style. IDEA doesn't try to hide the complexities and possibilities of Ant-building, just assist it.

IDEA also features code concealment (which they dub "code folding") in the newest version 3.0. And boy, does it rock. It's incredible for the overview to collapse import statements and all the stuff you don't need to tinker with much while coding (especially import statements since IDEA will alert you when using classes from pacakages not already included).

And yearh, I downloaded Eclipse, but have some problems getting it to run (I need to reinstall shortly anyway). And Eclipse is also getting a lot of good attention, but from what I've read, it's like a 80% IDEA without a lot of the neat touches (especially when dealing with JSP and tag libraries). Not that a 80% IDEA is a bad thing when you get it for free, but the $99 student license or even the $299 commercial one seems to be worth it for the final 20% (this is though based on second-hand opinions from smart people).

Re: speed and PHP,

Actually it really isn't that bad if you pick the right combination of JDK and Servlet engine. At least not according to Caucho (makers of the Resin Servlet engine), which has a simple benchmark on their site comparing Servlets to Perl, PHP, and ASP. The benchmarks explains a 10x difference in picking the right combo for Java. All to be taken with a grain, though.

You're right that there aren't as many hosts offering Servlet support as PHP, but there are still plenty. A google on Servlet Hosting reveals 53k results. Just picking the top one has Servlet hosting starting at $25/month. Not too shabby.

Challenge by Morten Krog on November 23, 16:36

RE: IDEA vs Eclipse
Don't know IDEA at all, but a quick view on their websites seems to indicate that their features are more or less the same as those in Eclipse. Maybe they have slightly better tools for web-development, but they are on the way in Eclipse too. They seem very similar to me.

RE: speed, php and hosting
In my experience jps/servletes cannot compete with php with respect to speed and resource usage. I have tried resin out and it did not impress me. PHP and jsp may show slightly more equal behaviour under windws than linux... I don't know. When used under linux the one-process-a-thread implementation offered by SUN fails to php (even if different requests to a php-site is answered by individual threads as well).

With respect to hosting: I wasn't talking about companies that required a hosting center to provide jsp/servlet support or php. I was simply talking about the cost associated with hosting 5 rack servers running jsp/servles as opposed to two or three running php. But it all depends on the requirement of the service being implemented here.

Challenge by David Hansson on November 23, 20:44

IDEA: From what I've read, the goods is in the galvanizing. Features will look alike in a list, but polish is only revealed on closer inspection. And it seems that all the different spots of polish amounts to a big difference.

With regards to web-dev, I don't think you want to wait on what might or might not be coming in a future version, if help's available now elsewhere (and as cheap $299 -- you don't have to save a lot of time to justify that expense).

PHP: I don't have any hard data on PHP vs Servlets for performance, but I'd think that your bottlenecks will often not lie in execution speed of the code. Database connections (the all-consuming bottleneck on content sites like Daily Rush), which it appears Servlets handle more intelligently, third-party web services (as the Amazon web services I use on Singlefile Books), and general systems architecture probably makes for a bigger difference.

Besides, I'd venture that having to buy two extra servers (if that was the case) would be a small part of your expenses if you're developing a service that needs that kind of firepower. More likely, the costly part will be developer time. Especially that expensive kind that buys you knowledge on concurrent systems design.

Take all this with a grain (or even a shovel) of salt, though. I've done a lot of PHP development, but my Java experience is very limited. I'm primarily aggregating the opinions of smart people (spicied up with a small week of trial'n'error and reading a few books) until I can get more hands-on experience.

PHP isn't a bad choice for web-development. Far from it. It's especially useful when you have developers of varying degree of technical know-how. But I believe that Java most likely is better suited for medium-sized and above solutions where you have control over your environment.

Hence, if you want to make a weblog package that people should install on their own server, J2EE will probably be a bad choice. But most of the solutions I work on for a living, such as Singlefile, extra/intranets, makes for excellent candidates.

Challenge by Ade on November 29, 1:09

Thought you might like to know that code folding has been around for decades.
The first implementations were on the Inmos Transputer back in the early 1980s. Take a look at for a guide to the history of this idea.
It's taken a couple of decades for this to get into the mainstream with editors like Scintilla/Scite. Hopefully it won't take another couple of decades for the mainstream to catch on to some of the ideas related to code folding such as code slicing and control structure diagrams.

Challenge by H-away on April 04, 23:53

Little chips light great fires.