aspose file tools*
The moose likes Beginning Java and the fly likes Why Java at all? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why Java at all?" Watch "Why Java at all?" New topic
Author

Why Java at all?

Jerry Van
Greenhorn

Joined: May 03, 2008
Posts: 20
Hi All,

I'm new to this board, and a new student of Java. I just came from a course in Python, and now Java. It seems to me, at first sight anyway, that Java is a whole heck of a lot more complicated than Python. With its separate files for each class and all. So, just a question to stir up some discussion, why Java? Why is Java so popular, and why do so many people like it? The Java field is so huge, I don't think I'll ever get my brain around it. So, I was just wondering, why is Java so popular at all? What makes Java so special?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11407
    
  16

java came along much earlier. there was a well established community in java before anyone heard of python.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Gary Morris
Greenhorn

Joined: Apr 29, 2008
Posts: 8
OK, once you've used procedural languages and switch to OO programming, things seem to get a LOT more complicated, and fast! I've tried several of them, including the .NET system, and have learned a whole lot of new stuff that I can't even imagine NOT using OO to program now. Fact of the matter is, a new programmer who learns on a simpler, more procedure-oriented language will have a time with OO languages (I know this from experience), however in the long run it will do you a lot of good to get used to Java, C++, .NET and several others IF you ever want to program for a living. It's the thing of the present and future. I've even played around with Pascal some, and found it to be fairly easy to understand even if it is not a full-fledged OO language (at least in the older formats). Once you "get it", the whold concept of OO will become fascinating, and the only way to really grasp it is to apply it to all sorts of real-world scenarios and just practice. I'll admit, I was skeptical at first, and it did take a couple of years to shed all of the old "habits" of procedural programming, but now I'm extremely glad that Jave (and others) exist and are in popular use.

Study and use Java for a while. If you don't "get it" after a decent period of time, you probably weren't meant to be a programmer in the first place. The whole idea is to simplify (even if it doesn't seem like it) the programming experience. I'm glad we have Java, and it's free. I can still give you a run for the money with VB6 or even QBASIC, etc., but OO is far superior to anything else out there. Check it out..
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

Originally posted by fred rosenberger:
java came along much earlier. there was a well established community in java before anyone heard of python.

I'm not sure about that. Python started in 1991, so it's at least as old, probably even a few years older than Java.

There are a number of differences between Python and Java. One of the notable differences is that Python is dynamically typed, while Java is statically typed. There are pro's and con's to either approach, see Type system for details. Python is also weakly typed (it uses duck typing) while Java is strongly typed.

Personally, I think that if you'd write a large, complicated application in Python, it would turn into a hard-to-maintain mess quicker than Java (I don't have direct experience, but it's just what I suspect would happen) - Java, because of its strong typing, would work better for large, complicated systems.

On the other hand, programming languages such as Ruby (which looks a lot like Python) are becoming more and more popular, and people start to realize that duck typing in practice doesn't lead to big problems when a system gets larger and more complicated.

One of the reasons why I think Java became so popular is that it looks a little bit like C++; in fact, James Gosling intently designed it in such a way that it would be easy to learn for C++ programmers.

Note that if you want to be a software developer, it's good to know more than one language, so it won't hurt to study both Python and Java.
[ May 04, 2008: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39408
    
  28
Welcome to the Ranch, Jerry.

Jesper Young is right that it is worth trying several languages, and it is worth trying different paradigms, eg declarative/procedural, logical, procedural and OO.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11407
    
  16

Python started in 1991
I had no idea python was that old. mea culpa.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Gary Morris:
OK, once you've used procedural languages and switch to OO programming, things seem to get a LOT more complicated, and fast!


Python is a fully-fledged OO language.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Jerry Van
Greenhorn

Joined: May 03, 2008
Posts: 20
Originally posted by Campbell Ritchie:
Welcome to the Ranch, Jerry.

Jesper Young is right that it is worth trying several languages, and it is worth trying different paradigms, eg declarative/procedural, logical, procedural and OO.


Thanks for the welcome, Campbell. I have no doubt that knowing more than one language is beneficial for a professional programmer. But, as I said, my only past experience is with Python. I actually found Python fun after I got used to it. And, when I was comparing Java to Python, what I had in mind was the fact that Python is also an OO language. It's just that Python doesn't put every class in a separate file. That's the part that seems very odd to me. Is there any real tangible benefit to doing that? What was the reason for that design?

I'm sure once I "get the hang" of OO, and Java, I'll come to appreciate Java more and more. It's just that right now I'm going through a lot of growing pains.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Jesper Young:
Personally, I think that if you'd write a large, complicated application in Python, it would turn into a hard-to-maintain mess quicker than Java (I don't have direct experience, but it's just what I suspect would happen) - Java, because of its strong typing, would work better for large, complicated systems.

On the other hand, programming languages such as Ruby (which looks a lot like Python) are becoming more and more popular, and people start to realize that duck typing in practice doesn't lead to big problems when a system gets larger and more complicated.


I'd say people are re-realizing this. A lot of quite large systems have been written in Smalltalk long before Java was invented.

And I know a lot of experienced developers who say that they can write a big Java system with one fifth of the Smalltalk code. I don't find that hard to believe.

One of the reasons why I think Java became so popular is that it looks a little bit like C++


Another reason is that Java had better marketing. There was a time when your website wasn't worth a pence when it didn't have at least one Applet on it... :roll:
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39408
    
  28
. . . and "growing pains" or something similar occur to everybody starting programming, or learning a new language.
Jerry Van
Greenhorn

Joined: May 03, 2008
Posts: 20
Originally posted by Campbell Ritchie:
. . . and "growing pains" or something similar occur to everybody starting programming, or learning a new language.


Understand. That was not a complaint, just a statement. Actually I enjoy the "growing pains". It means I'm, "growing".
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Jerry Van:

It's just that Python doesn't put every class in a separate file. That's the part that seems very odd to me. Is there any real tangible benefit to doing that? What was the reason for that design?


Are you talking about the source code (.java) or the byte code (.class) files here?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

Originally posted by Jerry Van:
It's just that Python doesn't put every class in a separate file. That's the part that seems very odd to me. Is there any real tangible benefit to doing that? What was the reason for that design?

If you're talking about having to put each public class or interface in its own source file with the same name: That's a question that people have asked before, and someone dug up an answer that said it was done to make it easier for the compiler for Oak (a precursor to Java). (That's hardly a valid reason to have this feature in Java...). Anyway, I regard this as an advantage, because it forces you to organize your source files which makes it easy to find the source for a certain class. In other programming languages, a class could be defined in any source file, and if you have a large project it can be hard to find the definition of a class in the thousands of source files.
Gary Morris
Greenhorn

Joined: Apr 29, 2008
Posts: 8
Originally posted by Ilja Preuss:


Python is a fully-fledged OO language.


Are you sure about that? I studied it for a while and it seemed like just a regular procedure-oriented language to me. I will check into it again (I lost my Linux system, so the only way I can do that is to research the 'net!). If I'm wrong, well I guess I learned something today..

The thing that bothers me is, if Python is a TRUE OO language, the original author of the post must have been able to avoid the OO features or something in order to come to the conclusion that Java is so difficult!

EDIT:

Ahh, I just realized that I was thinking about another of the Unix/Linux languages. I get them confused sometimes as some are just basically script-like languages, and others are high-level, even compilable. Still, I'm now downloading a copy of Python for Windows so I can get a good look at it again, and while doing so I am reading the docs online. Sorry about the confusion, I'm just a bad person for doing that, and I despise myself for being such an insensitive SOB. Hate me, loath me, but whatever you do, DON'T EVER forgive me. I suck.
[ May 05, 2008: Message edited by: Gary Morris ]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39408
    
  28
Originally posted by Gary Morris:
I'm just a bad person . . .
Rubbish.

You made a little mistake. That's all.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Originally posted by Gary Morris:
Are you sure about that? I studied it for a while and it seemed like just a regular procedure-oriented language to me. I will check into it again


Python doesn't force you to write OO the way Java does (i.e. all java code has to be in a class declaration). Python's OO features aren't as complete as Java's (information hiding?) and there's bits hanging out around the edges (you have to include a "self" reference in method declarations), but it's there for you to use if you like.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19719
    
  20

There is information hiding in Python. If you add __ before a method or field, and do not append __, it will become private.

Of course that means you have to use those ridiculous names.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jerry Van
Greenhorn

Joined: May 03, 2008
Posts: 20
Originally posted by Jesper Young:

If you're talking about having to put each public class or interface in its own source file with the same name: That's a question that people have asked before, and someone dug up an answer that said it was done to make it easier for the compiler for Oak (a precursor to Java). (That's hardly a valid reason to have this feature in Java...). Anyway, I regard this as an advantage, because it forces you to organize your source files which makes it easy to find the source for a certain class. In other programming languages, a class could be defined in any source file, and if you have a large project it can be hard to find the definition of a class in the thousands of source files.


I was thinking about the source, .java, files. But, now that I think about your reasoning, it makes sense, for the reasons you mention. I can see how that following your reasoning it would make organizing large programs easier.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

I can attest from extensive experience with both Java and Python. Python is slowly replacing Perl as my language of choice for quick-and-dirty - it's sort of the "Visual Basic" for Linux.

You can hack out apps a lot faster in Python than in Java, but the problem is, they will be just that - hacked out. The late binding is a killer, since programs can carry dormant bugs more easily - a whole raft of type-related bugs is filtered out at compile-time in Java. I call it my Law of Conservation of Pain - you can pay now or pay later, but unless you can skip out early, you'll still pay.

Aside from the perils of late binding, the other major concern I have about Python for mission-critical apps is that the Python designers didn't include a posse of security paranoids the way Java and JEE did, so exploits are potentially more possible.

Of course, the easy of entry and lack of a complex VM environment have their advantages as well - some famous Python apps include Anaconda (Red Hat's boot-time configuration utility), the control code for the Xen Virtual Machine facility, the YUM software package updates and other useful and popular tools.

On the downside, the Python language is still evolving and the next release promises to break stuff on the same scale of magnitude as the infamous VB6/VB.Net transition. Java has been very scrupulous about compatibility - it's the only language system I know of that allows you to gracefully phase out stuff using the deprecation facility.

One final parting shot - Python supports what looks like a Java-style package structure. Looks can be deceiving.


Customer surveys are for companies who didn't pay proper attention to begin with.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Tim Holloway:
You can hack out apps a lot faster in Python than in Java, but the problem is, they will be just that - hacked out.


Well, they surely will, if you hack out apps. No surprise here...

The late binding is a killer, since programs can carry dormant bugs more easily - a whole raft of type-related bugs is filtered out at compile-time in Java.


And a whole raft of bugs is not filtered out at compile time. I don't have much experience with dynamically typed languages, but people I trust report that the tests they write to prevent those other bugs also prevent the type related bugs, anyway.

(As an aside, late binding is not the problem here - Java also uses late binding for instance methods.)
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Joe Ess:

Python doesn't force you to write OO the way Java does (i.e. all java code has to be in a class declaration).


All java code in a class declaration is not what makes code OO to me. I have seen the worst procedural code being written in Java. And you *can* write OO code in C, it's just so much more painful.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Originally posted by Ilja Preuss:
All java code in a class declaration is not what makes code OO to me.


What I ment was that Gary had an excuse for not knowing Python was OO because Python's OO features are not as obvious as Java's. You can go a long way writing procedural code in Python.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why Java at all?