PDA

View Full Version : What's the usefulness of Java?



Contero
07-14-2006, 05:35 PM
I have been messing around with C/C++ for years and it's pretty much the only language I've learned save for a little bit of perl. What I've noticed as I've been taking a lot of community-college level programming classes is that computer science here is becomming more and more focused on Java. The year after I took AP computer science in high school they switched from C++ to Java. Pretty much every other community college around here only offers Java for programming classes. The one school that I'm at has just a handful of dedicated profs teaching the advanced C and C++ classes, which are usually pretty empty.

My friend has taken a bunch of Java classes and he showed me his final program for the class: a program that would draw bunnies on the screen in random places with random colors. My C++ final program was a nice 700 line program using all kinds of memory allocation, standard conversion, exception handling, inheritance and all sorts of fun stuff.

With such a huge emphasis on Java, what is it actually used for once you're out of school? I've always seen the immediate application for C/C++, but I could never really imagine what Java could actually do aside from fun little applets on websites.

eshbach
07-14-2006, 06:12 PM
java's biggest usage: server-side web programming.

you never see it, because you never see it. :) that's the beauty of server-side web-programming.

JSPs, servlets, beans... they make the internet work.

you don't have to do memory management in java, since pointers are unsafe and objects are garbage collected.

as for inhertiance and exception handling, we learned those in my comp sci 101 course, which was java, first semester of my freshman year.

the main reason schools use java to teach is because it is an "academically superior" language to C++. Java is more object-oriented than C++, and it is more strongly typed. In Java, all code must be contained within a class, and everything inherits from java.lang.Object with the excpetion of the primitive types. Combine that with platform independance and a standardized API, which has a great official reference online, and you have a perfect language for teaching programming.

C# would be even better and I think we'll start to see more schools switching to C# as time goes on. C# is even more object oriented than java, since even primitives inherit from the object class.

Mikey32
07-18-2006, 01:21 PM
I'm a British university student doing a Mathematics degree (masochistic, I know). Like your friends, I was taught Java rather than C++. Actually I taught myself Java, and then winced at the lecturers attempts to explain it, but you get the point. I think the people on the Computer Science course do study C among many others, but I'm not 100% sure if they study C++. I have several friends on civil and mechanical engineering courses, and they use C++. I say 'use' rather than 'taught' because they usually just change values in existing programs. I'm not aware of anyone studying C# yet.

eshbach is right, Java is more pure and more idiot proof, which recommends it as a teaching tool for sure. I suspect also that a lot of places decided to switch to Java because it was new and appeared to be the language that would replace C++. To be fair, a lot of what you learn in Java could be applied to C++. While I've never written a C++ program of my own, I can usually follow C++ programs written by others. Java has the added bonus of being useful for applets.

I think eshbach is also right about most Java applications being server-side and therefore invisible - it's a good point and one that had never occured to me. I too have wondered about when and where Java is used in the real world. It seems to have shot itself in the foot by having no facility to compile to machine code (or does that facility exist now?), so where someone may have considered Java, they would instead opt for C++. I don't know of any well known software written in Java either.

A final thought about the purity of Java - ever heard of Self? It's a programming language that never saw general release where EVERYTHING is either an object or a behaviour. I don't blame you if you're not interested, but I did some research on it which can be found here:
http://www.bath.ac.uk/~ma3mp/SelfHome.htm
The home page is a sort of introduction and should be fairly readable, the rest gets a bit heavy!

NoYd
07-18-2006, 06:17 PM
Cross platform programming is a hell of a lot easier with Java.

pH(x)
07-18-2006, 09:30 PM
Cross platform programming is a hell of a lot easier with Java.
I'll get an Amen to that! rofl

:p:

NoYd
07-18-2006, 10:47 PM
I'll get an Amen to that! rofl

:p:

I would still program rather program in a C variant or BASH scripting or something, it's just more fun to me. Plus Java can be a total resource hog.

eshbach
07-19-2006, 10:20 AM
The Azureus BitTorrent Client is written in java. That's the first "popular program" that comes to mind.

Something Sexy
07-19-2006, 12:37 PM
I would still program rather program in a C variant or BASH scripting or something, it's just more fun to me. Plus Java can be a total resource hog.


The major conception of Java is that it is slow compared to other languages. It really isn't anymore, Java can be just as fast as anything out there now. And this isn't a bias comment, I am pro C/C++/C# all the way but my new job is all in Java and you would be quite suprised all small, fast and little memory you can use to create advanced programs.

mat128
07-19-2006, 01:11 PM
In my college, we're taught C#. It's foolproof enough, so to say. In the first year, we've seen inheritance and GDI+ (along with the basic stuff). The previous year (I wasnt there yet) they were taught java. I guess my school's decision was mostly based because they support everything "microsoft". My first year was both networking/programming. I took networking for next session but people in programming will still be doing C#. I think they will have a year of java just so they see some different stuff but that's it. Final project for people in programming was in ASP.NET and it was a store for a computer shop.

uOpt
07-20-2006, 06:50 AM
My current opinion on Java, excuse the cut'b'paste.

Java is a moderately clean and moderately annoying language.

Language:
---------

Considering only the language but not the implementation you will see
that it offers some nice and safe capabilities, and potential for
almost-fast execution (much better than real scripting languages but
not in the same ballpark as C/C++/Fortran/hardcore Lisp). The
inability to have an easy printing mechanism ala C's printf is very
annoying, IMHO but bearable.

The need to manually cast things that comes out of collections is a
very serious misfeature. The lack of any kind of generic programming
has shown to be a plain mistake, and in Java 1.5 Sun corrects this
mistake. Unfortunately all the libraries out there are ignorant of
generics and use the old style, which leads into a mess. Very similar
to C++ in the 80ties. Some actually good features like inner classes
and specified introspection.

Implementation:
---------------

Java has basically been killed as "the" universal language by Sun
publication mistakes, backstabbing by Microsoft and lies about the
performance potential. Compared to those the deficiencies in the
language are minor.

Sun refused to make the JVM OpenSource. That very seriously hampered
it's distribution with Linux distributions that insist on clean
licenses, it's availability on important server platforms like FreeBSD
and brought up some of the non-marketing wrath of Microsoft against
Java. As a result a number of influential groups that could have
pushed Java into the mainstream turned to fight Java, and successfully
so.

Microsoft deliberately created incompatible JVMs, partly out of
arrogance ("we can do it better and we don't care whether it's
portable") and partly out of valid concerns about Sun's clearly
misguided policies for Java. Microsoft then resolved the issue by
switching to C# which basically does the same thing.

The performance claims of Java (and partly C# although they are much
more honest) that have been made also damaged Java. The truth is that
you can write any trivial program - such as small benchmarks - in Java
in a way that a JIT comes up quick enough. But that real-world,
abstract, complex programs with huge user-defined collections, deep
call stacks and basically all running like dogs. It doesn't help that
calls into foreign code (C) have to have proxy functions and that
converting data to C data uses proxies, too.

The performance as such wouldn't be such a big deal if Sun hasn't
started out lying about the performance potential. As a result,
users first turned to Java believing the lies and then had to realize
that it won't go where they claimed. This very seriously damaged a
lot of people's careers who first pushed Java in their organizations
and later were (correctly) blamed for insufficient performance of the
applications after deployment. These people are not exactly
supportive of Java now.


Libraries:
----------

The biggest feature for Java are the libraries available. There is a
lot of useful stuff out there, more than for any other language.

However, the quality of many of the libraries is insufficient, and
noticeably lacking compared to equivalents for C/C++, in particular in
the OpenSource world. C/C++ libraries are harder to write but
apparently the people who actually do this have higher standards.

A particular annoyance about Java libraries and partly about Java in
general is policies for thread-safety. It is nice that so many things
are thread-safe, but there is some serious overkill going on in many
libraries, leading to excessive multiple locking and hence to further
performance degradation of Java programs in the real world.

I also like (not!) that downloading a random Java library and printing
it's documentation very often leaves you with very good-looking,
perfectly edited and formatted documentation, compared to the
plain-ascii junk that usually comes with C/C++ libraries.
Unfortunately, those polished Java documents seem to be very prone to
bad proofreading and correctness. Almost always you can type in code
examples (note "type" since you can't cleanly copy'n'paste out of the
PDF) that don't compile due to straight syntax errors, upper/lowercase
errors or obviously idioticy by non-programming last editors (such as
line breaks introducing new "-" where none should be).

Secondary features:
-------------------

Java is not only under pressure from the C/C++ side.

There's also scripting languages such as Python and also Perl, VB,
Ruby, TCL and a few others.

Java can be very cumbersome for quick tools programming, even more so
than C/C++, and the real scripting languages wipe the floor with Java
here.

Tools/features:
---------------

Java is strong here. There are a lot of good IDEs out there. Even if
it only runs on one OS you write portable code that runs on the other
platforms. The Eclipse IDE is probably the best portable IDE out
there that even die-hard Emacs fans can like (because they can write
modules for it).

C/C++ environments usually are bound to non-portable constructs (such
as Visual Studio only working with Visual C++ which is not a very
standard-compliant compiler) or they have very steep learning curves
(which of course C++ has, too).

Still, it makes Java a good learning language. It's a "fast"
language, although not a high-performance language, it is safe and it
has nice tools for a smooth entry without locking people into vendors
or platforms.

Forget about all that object-oriented "pureness" rubbish. All
languages considered here except C and perl5 have good enough OO
capabilities than you can do "pure" OO oriented development if that is
your thing. All of them allow non-cooperative programmers to shoot
your OO design into the head. And OO programming is just one of many
paradigms out there, it's not a holy grail by far, contrary to what
the UML teaching mafia wants you to believe.

the
07-20-2006, 08:49 AM
Xpand rally is written in Java, superb game. dl the demo and check it out.

eshbach
07-20-2006, 09:52 AM
My current opinion on Java, excuse the cut'b'paste.

Forget about all that object-oriented "pureness" rubbish. All
languages considered here except C and perl5 have good enough OO
capabilities than you can do "pure" OO oriented development if that is
your thing. All of them allow non-cooperative programmers to shoot
your OO design into the head. And OO programming is just one of many
paradigms out there, it's not a holy grail by far, contrary to what
the UML teaching mafia wants you to believe.

in order to do, as you say "pure OO development", i think, at a minimum, I need to be able to do something like this (C#):



int i;
string c = "c";
i = int.Parse(c);
c = i.ToString();


that won't work in C++. that won't work in java either. there are very few languages that are pure object-based. those old languages were good in their time, but as a whole, the application development world needs to say goodbye to languages that were written in the 60's, 70's, and 80's and step in to the present. there's no excuse to be writing programs with potential memory leaks, or to be using unchecked excpetions.

that's not to say there's no use for C or C++ or LISP. If i was writing a hardware interrupt handler, I'd use C for sure.

but most programs these days could be written in Java or C# and not have any downside. You'd have code that's easier to maintain, easier to port, easier to reuse, faster to develop, every bit as functional, and safer for users.

Something Sexy
07-20-2006, 10:04 AM
but most programs these days could be written in Java or C# and not have any downside. You'd have code that's easier to maintain, easier to port, easier to reuse, faster to develop, every bit as functional, and safer for users.


I would never want to play a video game written in C# or Java.

uOpt
07-20-2006, 10:37 AM
Actually a new 3D turn-base (not real-time) tactical game "Panzer Command" is written in C#.

It's a support nightmare because you need to install the .net runtime and it's interface to DirectX which many users think they don't need to have the PZC installer do for them and then complain.

But it does run well, certainly within a CPU speed factor or 2 or 4 of the similar "Combat Mission" game from 2000 which is written in C++. Hard to compare performance since Panzer Command uses simpler combat resolution but in the end you can say it feels similar - much slower but not annoyingly so given the current computer speeds.

So I rate it as doable if you can waste that 2-4 or somesuch factor.

eshbach
07-20-2006, 11:17 AM
I would never want to play a video game written in C# or Java.

perhaps not, but video games probably account for < 1% of all programs written...

Mikey32
07-21-2006, 01:24 PM
I've just found another program written in Java completely by accident. I wanted an XML browser and found one called eXchaNGeR on SourceForge. It also functions as an editor.

The readme file has this to say:
"The eXchaNGeR application is a 100% java application and is
currently developed with Java 2 SDK V1.4. This means it needs a
Java Runtime Environment to run, this Runtime Environment can be
found in the full Java 2 Software Development Kit V1.4 or can be
downloaded on its own as the Java 2 Runtime Environment V1.4."

I've just this second downloaded it, so I don't know how much 'fun' I've just let myself in for trying to get it running. Should be OK once I have the Java Runtime Environment, but it's undeniably more effort than something compiled to executable.

But anyway, there's another example of something Java has been used for

surenw
07-30-2006, 04:37 PM
jave: multiplatform, easier to learn (once u grasp OOP concepts), webprogramming, server side development, works smoothly with linux, unix and thats ace cos windows sucks balls.

and also, because most corporate information systems use linux, unix, mostly sun solaris, java is real handy. java based interfaces are key because you can provide remote web based access as well as local physical access.