[Tutor] impact of OO
Danny Yoo
dyoo@hkn.eecs.berkeley.edu
Thu, 4 Apr 2002 18:00:23 -0800 (PST)
> But everywhere I used to read about programming would talk about how OO
> had revolutionized programming. Now that I know what it is, although I
> really appreciate it and will use it whenever I can (it's so... clean
> compared to what I was doing before), but I still don't really see how
> it's that big a deal -- it's simply a different way of organizing code,
> as far as I can tell.
Yes. *grin*
Actually, it's not a unified opinion that OOP is the best thing since
sliced bread. Paul Graham has some good reasons why it might not be
revolutionary on his web site:
http://www.paulgraham.com/noop.html
http://www.paulgraham.com/reesoo.html
> PS: Also, I have heard someone say that "in Java everything is an
> object". What does this mean?
They may be referring to the idea that all Java classes inherit from a
single base class called "Object". Everything in Java (functions,
variables, etc.) needs to be in a class, and in that sense, Java's classes
act sorta like Python's modules... except Java classes are very strict.
I'm not sure it's perfectly true that everything is an Object in Java:
there are primitive values in Java, like 'int' or 'float', that just don't
like being treated as objects:
//////
ArrayList l = new ArrayList(); // An "ArrayList" in java is similar to
// Python's list.
v.add(42); // But this won't work. 42 is an integer,
// a primitive type, and primitive types
// aren't a subclass of Object.
v.add(new Integer(42)); // Java uses a class "wrapper" to get
// around this situation.
//////
So there's a great divide between primitive types and Objects in Java.
> I think I am interested in learning Java, especially since there are
> many employers in my area (Boston) advertising an interest in Java
> programmers (and I will be out of a job as soon as my project is
> finished). Sadly, much more than Python or PHP. But it seems like a
> big language to learn.
You might be interested in the Jython project:
http://jython.org/
You can leverage what you're learning in Python directly toward Java:
Jython allows you to write Java classes in Python.
Good luck!