tags:

views:

1814

answers:

12

I always hear that programmers try to pick the right tool for the job. I've never programmed in Java, so I was wondering What are its benefits? Why is it so popular? What should I use it for?

I just program recreationally. Is there anything about it that makes it particularly fun??

+2  A: 

Cross platform is in my opinion the most relevant benefit.

The main goal of Java was to create a programming language that could run anywhere. The target was GUI apps. This however never happen because the environment was too slow at the beginning ( now it has been improved ) but it prove true in the server side where the cost of development reduced a lot because the product development can be done in PCs and the deployment in very expensive hardware.

It brought easy of development also, because it was designed to have C++ like syntax but running on a virtual platform to avoid platform specific code. At first the penalty was the execution speed, because it was interpreted, but release after release the interpreters became more and more faster that even MS model its next generation of development after java and call it .net

Additionally You can have a read of the Java design goals here

OscarRyz
Java is not interpreted...And MS modelling .NET after java isn't exactly true, not at least in the last few years, MS has really taken the lead in innovation.
FlySwat
Actually Java is sort of interpreted. It's in the original white papers as one of the primary goals :P How that interpretation is done is dependent on the specific implementation, and JIT is one of the big optimizations.
Gerald
Or rather, the platform-independent bytecode is interpreted.
Gerald
Java is NOT interpreted??? .. And I guess you would say managed .NET apps are not interpreted either. Please read about for CLR, CLI before. The fact it is compiled in and intermediate code does not imply it is not interpreted. http://java.sun.com/docs/white/langenv/Intro.doc2.html
OscarRyz
.NET Code has never been interpreted. It is compiled from IL to native code, one method at a time. That is not interpretation. The method pointers are then modified to point at the compiled method, so that future calls always call the native code. Additionally, you can preJIT the entire assembly.
FlySwat
What he probably meant was that during execution it's not usually interpreted, which is also true for .NET apps. CLR and most JREs now JIT compile the Java bytecode into native code the first time it's executed.
Gerald
With the introduction of the Hotspot VM, Java has the same JIT abilities that the CLR has always had. Yes, original Java was slow and interpreted, it is not now (Note your link is timestamped from 11 years ago).
FlySwat
Well that IS from MY point of view an INTERPRETER. From yours it is not, that's fine. But one set of bytecodes are "interpreted" totally different in Windows, Linux, and MacOSX, that's the job of the JVM. If the interpreter creates assembly then is a terrific one! But still an interpreter.
OscarRyz
Uh no, its a just in time compiler.
FlySwat
Interpreters NEVER generate native code.
FlySwat
Just to throw a bit of fun into the mix, Hotspot *does* actually interpret code the first time it runs it. That's more efficient for code which will only ever be run once (e.g. argument parsing). It quickly decides to compile it into native code where appropriate though.
Jon Skeet
Jonathan Holland: Python isn't interpreted either. Its compiled to native code one instruction at a time. ;)
jsight
@Jonathan Holland - "With the introduction of Hotspot VM, , Java has the same JIT abilities that the CLR has always had." -- You do realize that Hotspot predates .net by YEARS, right?
jsight
Please don't feed the trolls.
erickson
+9  A: 
  • Portability
  • Incredible breadth of libraries
  • Bottom-up security
  • Performance
  • Robustness
erickson
you forgot "good looking" :)
Mark
Heh, especially the original logo with the "steamy" subliminal image.
erickson
+13  A: 

I think after 12 years or so, the "write once, run anywhere" mantra is almost true. Writing Java code pretty much isolates you from the platform dependent aspects of the systems on which you deploy it.

Greg Hewgill
Don't all high-level languages mostly do that? or does Java really do it well? I'm trying to decide whether it will be uniquely worthwhile to write in..
Sophie
Not very many languages do that. A lot of languages are standardized so that you can often write code that will compile on most platforms, but not so that you can compile them once and run them on any platform.
Gerald
Not all high level languages. Some do. Java does it well.
Vincent Ramdhanie
"Write once" is definitely a mantra, even a bromide. Being unable to abstract over type constructors, you have to be prepared to write the same things over and over again in subtly different ways.
Apocalisp
Yes, lots of high level languages and platforms do it to some degree. With Python, Perl, Ruby, or PHP it will work perfectly on every platform until you need a 3rd party lib that is difficult on your platform. For .Net, Mono is a 85% solution. Java is more like a 99.99% solution.
jsight
In answer to jsight, I have to say, I don't think Java is a 99.99 solution. It is a better solution in some cases, but you end up with exactly the same problem, if for instance, you want to use a different renderer, or you want to access some non-java system...
Aaron H.
@aaron - Its true, if you want to access something that is inherently non-portable (os/platform specific), you end up with nonportable code. Thats true no matter what you are coding in. But you hit that a lot less in Java than other languages (how many C# apps P/Invoke vs. Java JNI?).
jsight
For "recreational" programming, the RWRA mantra is probably not applicable.
Ken Liu
python runs anywhere too, so does ruby, and all interpreted languages I've heard of
hasen j
+6  A: 

Massive communities, the amount of help, libraries, IDE's, is huge (and thats a good thing).

Mark
+1  A: 

There are only two reasons to use Java:

  • The Java Virtual Machine (Hotspot).
  • The huge amount of available libraries and tools.

There are other languages that run on the JVM and make better use of Java libraries than Java does, however.

Apocalisp
+6  A: 

For a casual programmer Java can teach a lot about object-oriented programming, and encourage good programming habits in general, without the need to worry about as many of the "messy" details (pointers, memory management) as, say, C++.

It's also a bit easier to debug "catastrophic" errors.

Adam Liss
these may be true, but other modern programming languages do better than java on these points.
Ken Liu
@Ken Liu: Very true - so why not add some value to your comment by suggesting a few?
Adam Liss
+3  A: 

Java is really good at integration - there are specifications and implementations for integrating with many kinds of systems that you're likely to run into in an "enterprise" environment.

It's not really a "fun" language relative to popular high-level languages.

wrumsby
+3  A: 

This seems to be getting healthy answers, but you might also want to look at "Why do people use Java?"

Jon Skeet
+2  A: 

Java is a good language, but that is secondary to the importance of the standard library that comes with it. The jdk may not be the most elegant kit ever built, but it is extensive, powerful and reliable. Programming in Java the language is simple. Programming with appropriate reuse of the jdk is what it is all about.

dongilmore
+1  A: 

After using Java for some time, I've come to the conclusion that it's fun to write in, limited in some very irritating ways, and it's performance is good though it seems that many programs are crippled by poor design.

I'm not sure if the latter is a function of Java, or an effect of Java.

In either case, in addition to all of the above stated benefits it's very useful for doing "net" related things. Treating resources with a simplified interface regardless of "where" the particular resource is, etc...

It is by no means a universal hammer.

Aaron H.
+1  A: 

I want to add one point: Java keeps a good compatibility to earlier versions. That means, your Java-projects are compile and run in most cases without any problem on newer versions. That seems to be a little point, but this stability in API's and language helps to build a big community around Java, including good tool-support.

Others already mentioned other important points:

  • good portability
  • lot's of libraries for nearly anything
  • easy debugging and easy to catch problems
Mnementh
A: 

oop provides like encypsilation ,inheritance,polymorphism not available in traditional programing .oop is closer to real life presentation of the programming 1. Relation ships can be representation using inheritance 2. Programme developement become easy due to increased modularity

prasanna