Fog Creek Software
Discussion Board




Tell me again, why Java?

This question is not meant to start a heated debate since this is a sincere question. My question is, why does everyone seem to be using Java for important, server-side web development projects?

I understand that Java is a "quicker" environment to use rather than C++. I also understand that Java is popular and many people want to use it for this reason. However, when designing server-side/cgi programs for my web site, I would think that Perl or Python (et al) would be the lightweight choice and C or C++ (a compiled language) would be the heavyweight choice. I don't understand why anyone would use Java (or C# or VB) for an important site simply because of its severe performance (and some programmatic) limitations.

Again, this isn't a debate thread, I simply want to hear honest answers from people who have made the Java decision and why they made it so I can learn from them.

Tom Fairlie
Friday, February 14, 2003

You're mistaken about Java's performance for server applications.  Good server-side performance comes more from good architecture/design than from language choice.  In addition, most server applications are more I/O-bound than compute-bound, and that's usually more dependent on system and OS capabilities.  Even for compute-heavy applications, however, Java usually has sufficient performance.

As for limitations of the language... sure, Java has limitations.  That doesn't mean it's a "weak" language or a "lesser" language.  I don't, for example, miss multiple inheritance.  IMO it is a very well designed language: it rewards good programming techniques and provides the features necessary to write good code.

The complexity of C++ is great when you need that kind of power and control over the behavior or design.  My biggest "gripe" with it was that you have to use a lot of complexity regardless of whether you need it.

Google a bit for more opinions and information.

-Thomas

Thomas
Friday, February 14, 2003

I have begun an independant study at my school where I chose Java. It's basically a networked app which has a server that talks to the database.

It was a choice between Java and C++ (Wanted to do it very very OO, so C is out, perl is out). Here's why I chose Java:

1) Easy porting. I want a Windows platform one eventually. Java makes this easy.

2) I know Java. I can confidently say I know almost every feature of the language (Though not the huge libraries) and can apply them. I can't say that about Python. Note: I also know C++ well, so this is only why I chose Java above Python and friends.

3) Work: The goal of this independant study is the product. At the end of this semester, I want to *have* this product and use it, and if it'd be more efficiently written in C++, well I can *write* it a whole lot faster in Java.

4) On a similar note as #3, speed and performance. Sure, I could get a fast implementation in pure C or C++, but: it's a DB app, disk access and database stuff will take more time than anything else, and that's in C already (external libraries, not mine). Plus, in Java I can leverage the SEDA framework ( http://seda.sourceforge.net ), a very good framework for writing Java server applications, which is known to perform well. If I were in C or C++, I know of no such mature framework, meaning I'd have to spend time writing it.

In other words, your performance arguments are not entirely valid, and development time means a lot to me.

Mike Swieton
Friday, February 14, 2003

Here is why Java

Actually the "Single point of failure" appears to be a reliance on Microsoft products as evidenced by:
The Joel on Software Forum
A public forum for open discussion of topics raised on Joel on Software.
Provider error '80004005'
Unspecified error
C:\WWW\DISCUSS.FOGCREEK.COM\WEBSITE\JOELONSOFTWARE\..\include.asp,
line 367
        

Nick
Friday, February 14, 2003

Nick,

You have an excellent point, since Java is failure-proof.

Benji Smith
Friday, February 14, 2003

I hate to whine, but I am sooo tired of this kind of threads.

Why you should choose Java? To be truthful, I could not care less. Why should I spend my valuable time trying to convince someone I do not know or have any kind of relationship to why he should or should not use one or another particular technology, that is truly a mistery.
Because, I am sure that if you use Google wisely, you will find a myriad of different articles with all kinds of comparisons between different languages, OSes and web technologies.
And if you are already inclined to any one technology, you will surely find all kind of articles that justify your liking.
And if you are truly want to know, you will surely do some experimenting of your own, and come up with your own decisions.

And you have probably already made your mind up, so why waste our time?  Because in the end, the choice is yours and yours only to make. Sorry if I sound bitter, I've had a bad week.

For the record, I am a long-time Java developer, with a particular liking for Python in web projects. The truth is, I wouldn't know what to choose myself. Python is beautiful and a joy to use, but is interpreted, and has not the polish that Java has, due to Sun pouring money and time into it. Java is slower, but more consistent in its documentation, and has more tools, books and articles available. The only drawback is that it is hard to find 15 U$S a month ISPs that support Java apps. Beats me why though.

Yablan
Friday, February 14, 2003

Writing server software is complex work. You have issues like scalability, security and correctness to worry about. If you write a desktop app - and it crashes - the user just restarts. If your server process crashes, there will be hell to pay.

Java lets you pretend that you don't have to organize your memory usage, algorithms, bottlenecks and general application design. Think you can't leak memory in Java? You can, it just goes by a different name.

Look at some big sites, like Amazon or eBay and then look what they're using. They're all C++ solutions. Is C++ heavy? Maybe, until you need a particular feature that only it provides (destructors, templates, memory control, multiple inheritance, etc). Then one changes their tune pretty quickly and learns to love C++.

If it seems I'm slamming Java heavily, it's because I've used it for many years and for various types of projects. Over time, I've gotten to see (and hate) the shortcomings of the language, virtual machines and core API.

I'll now proceed to shamelessly plug my own C++ infrastructure that aids in the development of large web applications :)

http://ninjacoder.com/quadron/technology.html

Shinobi
Friday, February 14, 2003

Great reply Yaban

Crusty Admin
Friday, February 14, 2003

"However, when designing server-side/cgi programs for my web site, I would think that Perl or Python (et al) would be the lightweight choice and C or C++ (a compiled language) would be the heavyweight choice. I don't understand why anyone would use Java (or C# or VB) for an important site simply because of its severe performance (and some programmatic) limitations."

Yes if you are developing CGI then Java is out, but java doesn't need cgi to be a web app, we have JSP and Servlets (orion,tomcat...)

Daniel Shchyokin
Friday, February 14, 2003

Tom:

"...when designing server-side/cgi programs for my web site, I would think that Perl or Python (et al) would be the lightweight choice and C or C++ (a compiled language) would be the heavyweight choice."

Not true.  For example, every CGI request spawns an entire new process, while most servlet containers are multithreaded (aka light weight processes), providing for lighter usage of server side resources.  And in general, compiled languages are going to be "lighter" than interpreted languages anyway.


"I don't understand why anyone would use Java (or C# or VB) for an important site simply because of its severe performance (and some programmatic) limitations. "

What limitations are you referring to?

"Again, this isn't a debate thread, I simply want to hear honest answers from people who have made the Java decision and why they made it so I can learn from them."

That's cool.  In general, I say go with what you know extremely well if you know it can get the job done correctly.  You'll probably end up doing a better job because of it.

But if you're starting from square one, Java on the server-side (and increasingly on the client-side) represents a very attractive choice as it has many great APIs offered for this.  I'd say it is definitely the best choice for responsive, platform independent server side development (assuming you're not a level 10 guru in something else) if these things are important to you.

Crimson
Friday, February 14, 2003

I use Java for server-side apps because of all of the libraries that are available.  Hibernate allows for easy persistence, and Tapestry for quick web app development.  GLUE for web service-izing things, etc.

I chose Java over scripting solutions because with a pre-compiled solution (no JSPs) I don't have to worry as much about cross site scripting and other security issues (at the web app level).

I chose Java over C++ because I am lazy / it's easier for me personally / performance is good enough.

I am NOT saying this is the only right way to do things, just answering the question.

Scot
Friday, February 14, 2003

I'd like to answer your question, of 'why Java' by comparing it with some other choices. 

With regular perl, you need to create a process for each request--not lightweight.

With mod_perl, each apache process has a perl interpreter embedded in it.  However, these processes don't share information with each other.  If you want to store some information in something like a session, whatever you do must write out that session information to a disk or the database each time the user requests a page, otherwise, the information in the session won't be available if the user gets a different process the next time they request a page.

If you use VB, then you must contend with the apartment model for threading, which doesn't scale all that well.

If you use C++, you have plenty of power, but you must do your own memory management.

David Sheth
Friday, February 14, 2003

A while ago I worked as an architect of a huge web site (millions of registered customers, 20+ terabytes of user data, etc.), written in Perl (Apache+mod_perl+Oracle). We had absolutely no problem with the system performance or scalability. However, by marketing reasons, it was decided to rewrite the site engine in Java. Well... We spent literally millions of dollars on software, training, consultats, and a year of time. At the point when we implemented about a third part of the old system features, the new system already required about 10-20 times more resources and performed significantly worse under our real load (10s of millions of hits per day). In short, the Java project is dead now. The old Perl engine was licensed to a major international consumer electronic corporation 2 years ago and is still in use, unchanged.

Just for the record - the Perl system had about 100k lines (which is probably an equivalent of 1+ millions of Java lines of code) and we had absolutely no problems with maintenance, contrary to a popular misconception.

It's not a critique of Java. I just want to show that Perl solution could also be viable.

raindog
Friday, February 14, 2003

<quote>
My question is, why does everyone seem to be using Java for important, server-side web development projects?
</quote>

Not everyone uses Java for Web Apps! For those who do, they probably do so because there's an extensive API and a lot of Webserver software for using Java. Another reason is companies think its chic--they want to be able to tell others they use the sexist, most hyped technology.

<quote>
I would think that Perl or Python (et al) would be the lightweight choice and C or C++ (a compiled language) would be the heavyweight choice
</quote>

All things being equal, a program that is compiled directly into machine code (as in C and C++) is going to run a lot quicker then a program that has to be interpreted (Perl and Python). It's just not very practical to write a Web App in C or C++.


<quote>
I don't understand why anyone would use Java (or C# or VB) for an important site simply because of its severe performance (and some programmatic) limitations.
</quote>

What performance limitations? In most cases (not all) Java, C# or VB.NET will perform better then an interpreted language, since they're compiled into intermediate bytecode.


Typically choosing a Web Application Platform will not be made solely on performance. You must also consider what tools your developers are familiar with and which tools are more concussive to short, rapid development cycles. Writing your web app in assembly may give the best performance but it'll take significantly longer to write.

When discussing different web app platforms, I always like linking to the Yahoo slideshow which shows there thought process to decide on using PHP:

http://public.yahoo.com/~radwin/talks/yahoo-phpcon2002.htm

Jeff

Jeff
Friday, February 14, 2003

raindog brings up a good point.  in many if not most cases there is no need for the expensive solutions that many people think are required for a solid web app.

Scot
Friday, February 14, 2003

Jeff, it was said many times -- the difference between interpreted and compiled languages can't be easily defined. If you consider Java to be "a compiled language", one can say that Perl or Python are compiled as well. The difference is that command-line Perl program is compiled and then executed at one step, while Java stores intermediate byte-code on disk.

For web applications, the combination of apache + mod_perl works this way: it loads the perl once into memory and never needs to load it again. Each perl program is only compiled once. The compiled version is then kept in the memory and used each time the program is run. In this way there is no extra overhead when hitting a mod_perl page. 

raindog
Friday, February 14, 2003

I have found that if you use a language long enough, it becomes second nature. So don't worry about choosing a language because you worry you won't grok it. If you spend 5-10 years on any language--you'll grok it so well it will literally handicap your ability to learn another (because you are so god darn used to it everything else looks slow)

Lots of folks worry about learning monster languages like Java, C++, c#, and Perl because of this. CPAN is very intimidating!! So is the countless of .java files out there on google.com. And no one expects the dot net library to shrink and simply over time :D But if you hack at it professionally long enough--don't worry so much about such issues.

If you are conservative, pick a popular language. If you believe in yourself and want to less popular language to own in your own personal non-business geek space--pick anything.

In the end, it's terribly boring and pointless to compare languages though. It's all about your ability to get work done. 90% of the major languages will not get in your way if you work long enough at it. :-)

-- David

Li-fan Chen
Friday, February 14, 2003

First of all, "everyone" doesn't "seem to be using java", their using J2EE, which is a HUGE suite of classes that allow for rapid development (in theory) and easy scalability.  So no, companies aren't picking the lanugage "java" to use, they're picking teh suite of tools and Design patterns that were developed for java.  I'm sure if there was a good alternative in another language (like C++, or even perl), companies would look at that too. 

Also, unless your Ebay, C++ is NOT a cost effective way to develop web applications. Sure its a "faster" language, but do you think your coders can write a better transaction mangement system that operates across multiple servers (or anything else that j2ee or ASPX provides)? Maybe, but even still, its going to take a long time.

Vincent Marquez
Saturday, February 15, 2003

/s/their/they're

Vincent Marquez
Saturday, February 15, 2003

*  Recent Topics

*  Fog Creek Home