KBD

Keith Devens .com

Friday, October 10, 2008 Flag waving
REMEMBERS- HEEL BARES DURID! BARE DURIDS IS STORNG FREND! – Alamo
← Comment previewing re-enabledAnswers in Genesis webcast →

Daily link icon Monday, April 26, 2004

Why Python is better than Java

Python is better than Java because I've never had a problem with getting classpaths correct in Python. Java's been out for so many years, and I've been using it on and off for years, but I still have problems getting the classpath right.

The Java compiler (actually, the RMI stub (etc.) generator) can't find classes that are part of the base install! It's infuriating.

It's like what Bruce Eckel says about reading files in Java vs. Python. What it comes down to is not just that Java places too high a cognitive load on the programmer... it's that Java's just a pain in the ass. I've had more trouble with Java's class/package management than I've ever had in any other language (and I'd be interested to know if there's any non-joke language out there that takes more lines of code to read from a file than Java does).

Update: Jeremy concurs

Update: One more thing. What was most frustrating about this classpath problem is that the Java compiler was able to find all necessary classes just fine, but 'rmic' couldn't do the same thing.

Also, more discussion at Simon Brunning's site. It seems it may even be simpler to read files using RPG than it is with Java!

← Comment previewing re-enabledAnswers in Genesis webcast →

Comments XML gif

Stéphane TRAUMAT (http://www.scub.net) wrote:

Well..
You know Java is powerfull
You want something more simple for small programms

Why don't you use http://groovy.codehaus.org/ ?
You can use the syntax you already know, the power of java to create simple software better than with Python.

∴ Stéphane TRAUMAT | 26-Apr-2004 11:08am est | http://www.scub.net | #4421

213.86.175.69 wrote:

You mean Java's a non-joke language? ;-)

∴ 213.86.175.69 | 26-Apr-2004 11:12am est | #4422

Adam Vandenberg (http://flangy.com/) wrote:

Syntax schmyntax.

∴ Adam Vandenberg | 26-Apr-2004 12:05pm est | http://flangy.com/ | #4423

Keith (http://keithdevens.com/) wrote:

Are you saying that it's just syntax so it's no big deal, or are you being sarcastic and mocking the claim that it's just syntax so it's no big deal? And, are you referring to Java vs. Groovy or Java vs. Python, or something else? Smiley

Keith | 26-Apr-2004 12:45pm est | http://keithdevens.com/ | #4424

asdfasdf wrote:

By your logic, all I would have to do is find one case in which Java exceeds over Python to prove that Java is the superior language. And then what do you do?

Please.

I find it a pain in the ass to have to pass "this" (or whatever) to Python methods. So. Retarded.

Each language has it's features and annoyances. Only a fool would make blanket claims of the one-true-language.

∴ asdfasdf | 26-Apr-2004 2:58pm est | #4425

Keith (http://keithdevens.com/) wrote:

Come on asdf, you're taking things too seriously. My post wasn't meant in absolute terms -- obviously I don't think that just this makes Python (or Perl, etc.) a better language that Java. My post title was meant to be "sensational"... I think that's obvious.

Also, with regards to your comment about Python: I pointed out within the post that it's not just Python, but essentially every other language that works better than Java in the ways I mentioned. Clearly this post is meant more as a criticism of Java than as a "language X is better than language Y" flame. Give me some credit here.

Keith | 26-Apr-2004 3:21pm est | http://keithdevens.com/ | #4426

Tomas (http://jogin.com/weblog/) wrote:

I hate Java with a passion. And perhaps I'm biased here, but I think there is actually proof that the Java language sucks ass. The proof is that there are many many examples of projects/people trying to leverage the Java platform without actually having to deal with the horrible mess that is the Java language; Jython, JRuby, Groove, etc. Well, perhaps that's not proof for you, but it is for me, so there, neener-neener.

∴ Tomas | 26-Apr-2004 4:46pm est | http://jogin.com/weblog/ | #4427

Adam Vandenberg (http://flangy.com/) wrote:

I actually prefer Python syntax. I do mostly C# programming at the moment, and it has C/C++/Java style syntax, and VS.NET is set up to do all sorts of auto-indentation every time you type a brace.

The auto formatting is nice, but it would just be nicer without all the braces in the first place.

But that's just me.

∴ Adam Vandenberg | 26-Apr-2004 4:51pm est | http://flangy.com/ | #4428

Alan Green (http://cardboard.nu) wrote:

The Java APIs just weren't written with ease-of-use in mind: they were written for performance, extensibility, architectural elegance and ease-of-documentation - but not ease-of-use.

∴ Alan Green | 26-Apr-2004 7:59pm est | http://cardboard.nu | #4431

Victor Ng (http://crankycoder.com) wrote:

This Python "rah-rah!" is bullshit.

Python has serious problems with importing packages and modules - namely circular references.

I've posted some sample code that demonstrates the problem:

http://crankycoder.com/archives/000169.html

If anything - Java's packaging system is superiour to Python's. I say this as a person who programs in Python for a living and as someone who really dislikes Java after having done the Java dance for a couple years.

∴ Victor Ng | 26-Apr-2004 11:45pm est | http://crankycoder.com | #4432

Jonas Galvez (http://jonasgalvez.com/blog) wrote:

Kevin, I've given up trying to convince people about this. I have a friend, who's a Java programmer - I've seen him working on big projects very closely and there were a few moments that I thought "shit, this guy must be a masochist!".

But you know what, the whole issue is pretty simple. Java has a great market. I've never seen a programming language with such a great branding. And Java is, indeed, a powerful language. I mean, you can get stuff done with it (in a very painful way, but you can). And actually, this friend of mine is making big bucks with Java. I've talked with him over and over and he has absolutely no interest in trying out Python, or any other competitive technology. He hasn't even bothered to download it! All I can do is hope that he will eventually get it someday.

I'm not saying Python is the one true language. Far from it. I just think people should be a little more open-minded when it comes to programming languages. I understand that the Java world (even .NET world) might get very comfortable over time, but whenever I see someone defending Java or .NET, it's always the same kind of passional arguments. And they always attack some insignificant little problem from the alternative technologies in question, or just throw something like "There's no place for open hax0r3d technologies in our company".

I've done Java. I've done .NET too.
For now I'm sticking to Python.

∴ Jonas Galvez | 27-Apr-2004 2:22am est | http://jonasgalvez.com/blog | #4435

Keith Gaughan (http://talideon.com/) wrote:

Heck, I just sit back, laugh, and hack away in O'Caml. Mwa hwa hwa!

∴ Keith Gaughan | 27-Apr-2004 7:20am est | http://talideon.com/ | #4437

l.m. orchard (http://www.decafbad.com/blog/) wrote:

One thing I do like in Java over Python, with regard to namespaces and packaging, is this:

In Java, you can compose your namespace from a slew of JARs and classpaths. org.apache.* can come from 15 different locations, if you want.

But in Python, unless I'm missing something, there can only be one filepath to org.apache.*. You can't have /opt/python/org/apache/__init__.py and /home/deusx/lib/python/org/apache/__init__.py.

Makes it kinda hard to mix & match modules from different sources in the same namespace.

∴ l.m. orchard | 27-Apr-2004 11:18am est | http://www.decafbad.com/blog/ | #4438

mark (http://www.pagefall.com) wrote:

Classpaths in Java can be a pain but managed properly they soon become second nature. I regularly use both languages (although its quite telling that although I use python AND java at work I never do any personal work in Java) and my feeling about the packaging is that Python is a little too free and easy and Java can be over the top but not by much.

On a small project Java is a total pain - there are no two ways about it. But as soon as a project grows in size the whole packaging becomes a GOOD thing.

One clue is NEVER to use the CLASSPATH environment variables. Use batch files or shell scripts to set everything up as required. This way you know the version of everything and where everything is.

This seems like a pain in the arse but I've had issues with Python projects that as they've grown. Their environments have become unmanageable and needed the application of this kind of mechanism anyway. And yes its nice to be able to put classes in any file no matter the name and more that one class in a file but again this doesn't scale.

On any decent size project you need to manage the enviroment. Java makes you do it from the start which adds a lot of overhead to small projects. Python lets you do things in a very adhoc way which means you have a pain point later.

Me - Now I start as mean to go on whether its enforced or not.

∴ mark | 28-Apr-2004 5:53am est | http://www.pagefall.com | #4447

Dave (http://www.davtri.com) wrote:

I totally agree. I've been using Java since version 1.0 and it seems to be getting more and more convoluted. Things aren't made for ease of programming and in some cases, doing something simple is a total pain in the ass. Groovy looks interesting, and I will be keeping an eye on it from time to time, but Python is a lot easier to get projects completed with in a fast way.

The performance hit is usually negligable and sometimes non-existant. Having to pass "self" in python classes is a pain in the ass, but asside from that, it's really no big deal. I've used Python on large and small projects and they've all come out just fine and been completed much faster than with Java.

There is a lot of power built right into python that makes the programmer's job much easier to accomplish, and as stated above, Bruce Eckel has a very valid point that with Python, you can usually figure out what a decently written package does just by looking at what objects/functions it extends and not having to dig into API docs (which may or may not be written well, take a look at the apache net package as only one example of missing API docs).

Python does have some small issues, but word from inside says the next release will include major performance increases as well as a fair few added features. For overall productivity and elegance, Python wins hands down.

∴ Dave | 28-Apr-2004 9:16am est | http://www.davtri.com | #4451

mark (http://www.pagefall.com) wrote:

Aye, can't wait for Python with something like hotspot built in. It will be hard to justify NOT using it for a lot of projects then.

∴ mark | 28-Apr-2004 9:48am est | http://www.pagefall.com | #4452

Dave (http://www.davtri.com) wrote:

Yeah, although, with continued speed increases in the cPython implementation, who knows if we'll need a hotspot like runtime. It would be interesting to have a native compile feature though. That could possibly shut down the last arguments about speed and such. It would probably be a major untertaking to achieve it, but it would be a close out for such arguments.

I would personally like to see a good packaging solution though, like with Jar files on Java. And it would also probably bring more mainstream (read commercial) support if you could just distribute the byte-code files and not have to worry about them being usable with a different version of Python.

All said and done though, Python is definitely a major player and a lot more elegent for the programmer to use than most of the alternatives.

∴ Dave | 28-Apr-2004 12:36pm est | http://www.davtri.com | #4453

Keith (http://keithdevens.com/) wrote:

Having to pass "self" in python classes is a pain in the ass

Well, I'd call it a minor nuisance. Smiley Really not that big a deal.

Also, Victor's circular import problem seems really hairy, and I'm glad he's publicising it. Maybe it can be fixed soon. A few things I'll note about it, however, are that: A. it seems like it's just a plain bug, not something fundamentally wrong with the language. I'd be interested to see if Jython exhibits the same problem. And B., at least Python can find the classes it needs, even if it has a problem with importing them recursively. Java can't even find its own base classes, which was my original complaint. That blows my mind.

Keith | 28-Apr-2004 10:26pm est | http://keithdevens.com/ | #4456

Jeff Hinrichs wrote:

self is good, explicit is better than implicit. If you search the python list archives you'll see that it solves a number of edge case problems. But at least no one is bashing indentation.

>>import this

∴ Jeff Hinrichs | 29-Apr-2004 1:41am est | #4461

Dave (http://www.davtri.com) wrote:

You know, I have never had the recursive import issue. I am wondering if it isn't a bug that only happens when coding in a very specific way.

As far as self goes, personally, I find it annoying, but I've gotten used to it. I think it would be better from a design stand point though if you could declare what the self variable is in the class and not have to put it in as the first call to every function. Something like:

class Spam:
    """
    test class
    """"
    def __init__:
        classref('self')
    def loadEmployee(empid=0):
        """
        Load employee data from database where empid == eid
        """
        ...

I think something along those lines would be much nicer, especially in huge class files with a lot of functions. I don't mind having to use self to reference instance objects, methods, etc. but having to put it into every method definition can be a bit of a pain. I find that about 2/3 of my debugging is usually going back and adding self as a method argument, heh heh (usually when I've been working late at night).

Even as it stands now though, I much prefer Python over Java. Groovy looks promising, but I'll still hang with Python.

∴ Dave | 30-Apr-2004 9:23am est | http://www.davtri.com | #4468

Phillip J. Eby wrote:

Victor's circular import issue isn't a bug, it's a natural consequence of the Python language's definition. Python doesn't have declarations, and module code is executed sequentially, from top to bottom. Those two principles are sufficient in and of themselves to create the issue with circular references to module contents.

But this is desirable! Python favors readability and comprehensibility quite highly. If you have to read each module "first" to understand the other, how will you ever start reading? If you run into the circular import issue, you've simply been shown that your code needs a little reorganizing, so that somebody other than you can read it with a chance of comprehension.

∴ Phillip J. Eby | 1-May-2004 6:28pm est | #4473

Rafael Alvarez wrote:

Funny, nobody commented this before. The rmic compiler has a known bug that causes the classpath not being passed to the javac compiler during the stub generation/compiling. It was supose to be fixed on 1.4, but haven't checked.

∴ Rafael Alvarez | 13-May-2004 9:21am est | #4574

Keith (http://keithdevens.com/) wrote:

What!? So, if the classpath doesn't work, how are you supposed to use the thing??

Keith | 13-May-2004 1:26pm est | http://keithdevens.com/ | #4575

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

October 2008
SunMonTueWedThuFriSat
 1234
567891011
12131415161718
19202122232425
262728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 6 posts

Recent comments XML

Call a function from a string in Python

?!code:
some_object.__getattribute​__('method_name')()
?!/code

is​the s...

Patrick Corcoran: Oct 8, 3:53pm

Spider solitaire

I have won 185 games of Spider​Solitaire at the "Difficult" level.​ What is...

75.179.28.113: Oct 8, 12:42pm

Sed one-liners

Hi.

I wanted to let you know​that I wrote an article "Famous Sed​One-Lin...

Peteris Krumins: Oct 8, 3:05am

Timesheet Calculator

Hadn't seen it before now, but my​company already uses a time​tracking prog...

Keith: Oct 7, 10:44am

Girls, please don't get breast implants

Hey everyone, 

I am new to this​blog and I have enjoyed reading all​your...

Sarah.M.: Oct 6, 9:45am

Generated in about 0.253s.

(Used 8 db queries)

mobile phone