On Feb 8, 2004, at 9:31 PM, [EMAIL PROTECTED] wrote:
Java requires even more verbosity.
This is my general impression of Java. Is the verbosity a good thing
or not? It seems verbose to the point of redundancy. Is this
helpful, or does it just get in the way?
The answer to that is that it's a matter of perspective, but I don't
think that Java would be as successful as it is if a majority of people
found it -too- redundant. There's no doubt about it -- the verbosity
of Java is overkill for simpler tasks like what you've accomplished
with your Python script, especially when there are languages like
Python, Perl, Ruby, and bash which can make this kind of thing a lot
easier. And, if you know you'll only ever invoke the program on a Unix
machine, you can do what another poster suggested and simply glue a
bunch of existing Unix tools together like awk, sed, grep, find, et
cetera, reducing the burden of actually programming the task to a level
of merely asking other tools to perform certain actions on the text.
But when things get a bit more complicated, this verbosity can be
helpful. (see below)
It took longer to write, even though I had already
prototyped the design in Python (the two designs are nearly
identical),
Was it just the verbosity of Java which made it take so long?
Yes and no. No if you mean did the verbosity take longer to type.
Yes, because Java requires a great deal more syntax to say the same
thing that can be said with less syntax in Python, and subtle issues
surfaced when trying to compile the code and then run it. For
instance, there were numerous times I was attempting to use a class
without having imported it first. Another thing is that the verbosity
of Java means that there is more text to be conscious of using
correctly, so that right there leads to greater potential to make a
mistake.
I wrote that Java implementation in a text editor, which is a useable
but relatively primitive tool for a language that can be as verbose as
Java. It would have been faster to use an IDE. At work we use WSAD,
which speeds development by automatically importing any classes I
attempt to use, automatic method completion, popup API documentation
(sparing me a trip to the docs), realtime compiler error-checking, and
other luxuries. So, using a text editor, I'd make a change and then
jump back to the shell and type the command to compile the file. This
doesn't take long, because I use keyboard shortcuts and the command
history, but then I have to examine the compiler output when there's a
problem and jump back to the text editor and fix the mistake -- an IDE
will highlight the erroneous code, making it much faster to figure out
what you've done wrong.
But Python offers the interactive interpreter, which is a godsend when
trying to debug a problem or even just sketching out the script. If
you write a python script and invoke it with the -i option (python -i
scriptname), then after the script completes you are automatically
dumped into the interactive interpreter and any variables in your
script are now local to your python session so you can invoke functions
using arbitrary arguments, evaluate the values of variables, and other
conveniences.
(Yeah, I know that Real Programmers (tm) use vi/emacs/ed, but Real
Programmers also don't consider Java a Real Programming Language. ;)
and IMHO would also be more work to modify/extend. That said, if
handed a several million-line application written by some other
development team, I would rather the application be written in Java
than Python.
Why? Performance, cleaner code, more robust language? What makes
Java better than Python for some things? What types of things is
Java best at?
In this particular case, the reason I say that is because Java is a
statically typed language, and Python is dynamically typed. There are
a lot of arguments about which is better, and I won't say one is better
than the other for all occasions -- but I happen to find a statically
typed language like Java to be easier to read once the application
exceeds a certain level of complexity. I anticipate some dissent on
this topic, mind you. But when I'm trying to navigate my way through a
twisted legacy framework of poorly-written source code to find a bug,
it's nice to see the type declarations reminding me that foo is a
FileManager and bar is a BufferedXmlMessage.
Of course, static type declarations are a pain in the ass in smaller
programs, or programs that I'll be writing entirely myself, since I
can't enjoy such flexibilities as this:
for item in iterableSequence:
item.doSomething()
Where iterableSequence could be a reference to a file object (so item
would be a line), or a database resultset object (so item would be a
row), or an object representing a list of users (so item would be a
user), etc. Unlike Java, Python doesn't require that your objects
actually declare that they implement a specific