• Post Reply Bookmark Topic Watch Topic
  • New Topic

What advantage does someone get by choosing java over its alternatives?  RSS feed

 
Monica Shiralkar
Ranch Hand
Posts: 919
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If someone choose to use java over its alternatives, what are the advantages?
Thanks.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37252
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monica,
That's a very general question as there are many languages out there with different pros and cons. For example, an advantage of Java over Go is the vast number of open source libraries and infrastructure.
 
Knute Snortum
Sheriff
Posts: 4079
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java runs almost anywhere, unlike C#.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java is a tool - nothing more, nothing less. Would you ask "what advantage does someone get by choosing a band saw over a crescent wrench?"  If your goal is to tighten a nut, the answer is "none". if your goal is to cut something, the answer is "a lot".
 
Julian West
Ranch Hand
Posts: 91
3
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:java is a tool - nothing more, nothing less. Would you ask "what advantage does someone get by choosing a band saw over a crescent wrench?"  If your goal is to tighten a nut, the answer is "none". if your goal is to cut something, the answer is "a lot".

What if you want to tighten a nut and cut off the part of the bolt that sticks out past the nut? 
 
Monica Shiralkar
Ranch Hand
Posts: 919
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum says
Java runs almost anywhere, unlike C#.


I have read this but did not understand what limitation comes with non java technologies/languages like C#. Does it mean that suppose there is a web application using C#. This can be run on certain machines only? I think that is  not the case.So what exactly is the limitation.
Thanks.

 
Julian West
Ranch Hand
Posts: 91
3
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is the case.  Java is "write once, run anywhere"; other compiled languages are platform-specific.

There are numerous strengths and weaknesses but that's Java's biggest distinctive.
 
Knute Snortum
Sheriff
Posts: 4079
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monica Shiralkar wrote:Knute Snortum says
Java runs almost anywhere, unlike C#.

I have read this but did not understand what limitation comes with non java technologies/languages like C#. Does it mean that suppose there is a web application using C#. This can be run on certain machines only? I think that is  not the case.So what exactly is the limitation.

C# only works with .NET framework, and I'm not sure what OS's it runs on, but it was designed for Windows.  I think C# is trying to be more open but I don't know how well it's succeeding.  Someone who knowns C# better can comment on this.

If you wrote a web application in C#, the server part would most likely run on a Windows machine, but since it is a web app, you could view it on any browser.

The difference with Java is you can bundle it into a jar file, and that jar file can be executed on virtually any OS (Windows, Linux, Mac) provided you haven't written the code to use native calls.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monica Shiralkar wrote:I have read this but did not understand what limitation comes with non java technologies/languages like C#. Does it mean that suppose there is a web application using C#. This can be run on certain machines only? I think that is  not the case.So what exactly is the limitation.

Many years ago, when you wrote a program, you would compile it into a binary file. Binaries are specific to a hardware, OS and often OS level (4.1, 5.2, etc).  Your program would often include precompiled bits of code written by others that again was specific to the hardware.

So if you build a program and compiled it to run on AIX 2.1 (or whatever), you could not take that same file and drop it on a Windows 7 box and expect it to run.  or Linux. or anything but an AIX 2.1 box.

Now...you COULD go to the effort to build a binary for each of Windows 7, Windows 10, Linux...but you spend your entire life building new versions for the newest patched OS, you have to make sure you send the right binary to the right customer for the OS they have...

Now throw in the world wide web.  You have no idea what kind of computer someone might be using. One person might be running XP, and the next using an IBM mainframe...How can you possibly have a binary file ready for anybody who might come along?

the answer is...you can't.

So, the folk at Sun decided to put something in between.  They created the JVM.  This is a program that runs on many different machines, and that IS custom built for each.  So there is a JVM for linux, a JVM for windows, a JVM for an IBM Mainframe...everyone is responsible for getting the right JVM on their own machine.

All the JVMs take the same input - your java class files - and convert it to the right output for the platform they run on.  So you write a single program, convert it to a single set of class files, and then anybody who has a JVM can run your application. 

It a lot of ways, a JVM is like a universal power plug adapter.  Your java has a standard shape plug on one end, and you use this thing in between depending on where you are to connect to the other...

[edit - corrected typo]
 
Monica Shiralkar
Ranch Hand
Posts: 919
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

 
Monica Shiralkar
Ranch Hand
Posts: 919
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky says
For example, an advantage of Java over Go is the vast number of open source libraries and infrastructure.


In java we have these libraries which may not be there in other languages. In that case how is the same functionality achieved in such languages when these do not have libraries. Does that mean in these languages developer himself has to write that code instead of calling the library?
 
Stephan van Hulst
Saloon Keeper
Posts: 7817
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me, the single most important reason to choose Java over any other language is how well the standard API is documented.

Most of the applications I write don't have to operate on a wide variety of platforms. I can do almost everything I do with C# just as well. What I love about Java is how well pre- and post-conditions and exceptions and side-effects are documented.

If my applications has a bug, most of the time I can fix it through generous application of RTFM.

With C#, as much as I enjoy many of the language features, it's much harder to do this, because the .NET standard API is documented a lot less well.
 
Knute Snortum
Sheriff
Posts: 4079
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monica Shiralkar wrote:Jeanne Boyarsky says
For example, an advantage of Java over Go is the vast number of open source libraries and infrastructure.


In java we have these libraries which may not be there in other languages. In that case how is the same functionality achieved in such languages when these do not have libraries. Does that mean in these languages developer himself has to write that code instead of calling the library?

Most languages have some way of doing common things.  For instance, min or max functions.  In Java, there is the Math class that has these functions.  The Math class is a library, but it is imported for you automatically.

But what about something more complex, like date/time handling?  Before Java 8, the date/time handling in Java was not great.  However, there was a third-party library (not written by Oracle or Sun) called Joda Time that solved that problem.  Now Java 8 has excellent date/time handling (based a lot on Joda Time) but before that there was a library.

If a language doesn't have good date/time handling built in, and doesn't has something analogous to libraries, then a developer would have to write their own code to handle this.
 
Monica Shiralkar
Ranch Hand
Posts: 919
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks again
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!