java.lang vs java.util

  • Thread starter Lawrence D'Oliveiro
  • Start date
L

Lawrence D'Oliveiro

Until you provide a design document you may wait for a while.

See, that’s what I mean by lack of agility. It’s not enough to figure out
what the code does, you need some kind of specification document filled out
in tedious detail and no doubt signed off in triplicate before you will
write a single line of code.

And they wonder who I’m referring to when I talk about “corporate code-
cutter drones†...
 
J

Joshua Cranmer

Which reminds me, I’m still waiting for someone to show how they can do this
<http://groups.google.co.nz/[email protected]> better
in Java.

public void dumpToCSV(Writer out, Connection conn) throws IOException {
Statement stmt = conn.createStatement();
ResultSet res = stmt.executeQuery(query);
FormattedResulter.printCSV(res, out);
}

I'm sure somebody essentially wrote the class that does the last line
for me, which, quite frankly, is correct enough given the information
you've provided. If you cry foul, I'd like to point out that you gave
only a very vague description of what goes on in the python code, plus
you've clearly used other libraries in your own code.
 
D

David Lamb

See, that’s what I mean by lack of agility. It’s not enough to figure out
what the code does, you need some kind of specification document filled out
in tedious detail and no doubt signed off in triplicate before you will
write a single line of code.

I wouldn't have phrased it Arved's way, but I'd ask a similar question.
It's unlikely that directly translating a piece of code from one
language to another will give you the best way of solving "the problem"
in the 2nd language. Many of us have experience writing code in
multiple different languages, and have learned that one solves problems
in different ways depending on what facilities the language provides.

We need to know what "the problem" is that you're trying to solve in a
particular way in the 1st language. It's nothing to do with being
corporate drones: it's about knowing from long experience that
understanding what someone else is talking about takes work on both sides.
 
D

David Lamb

public void dumpToCSV(Writer out, Connection conn) throws IOException {
Statement stmt = conn.createStatement();
ResultSet res = stmt.executeQuery(query);
FormattedResulter.printCSV(res, out);
}

I'm sure somebody essentially wrote the class that does the last line
for me, which, quite frankly, is correct enough given the information
you've provided. If you cry foul, I'd like to point out that you gave
only a very vague description of what goes on in the python code, plus
you've clearly used other libraries in your own code.

Sigh. It would be perfectly fair for Lawrence to ask what the body of
printCSV looks like, if that's where the core iteration functionality
belongs (I haven't and won't read the python code 'cause I'm a novice in
that language).
 
L

Lew

Patricia said:
You will never get fluent in Java if you think Python code is a
reasonable specification for your Java code.

This is a problem I've seen many times in people moving from language to
language. Every language has its own idioms, its own ways of expressing
things. Translation from code in language X to code in language Y leads
to very stilted, awkward code in Y. In effect, the code is written in a
dialect of Y that contains only those features of Y that correspond
closely to features of X. Such a dialect can be very frustrating.

It is not unique to Python and Java. I've seen it, for example, in

It's not even unique to computer languages.
people moving from assembly language to C. I expect it would happen to
someone who had got too locked in on Java who tried to write Python code
from Java code, rather than by finding out what the code is intended
to achieve.

I've sometimes had to try to reconstruct a specification from code, but
it is a messy process, liable to include things that are not required
and miss other requirements. Why do that, when there is someone who
presumably knows exactly what it is meant to do?

Having a design document other than the code itself does not mean
"filled out in tedious detail and no doubt signed off in triplicate". It
means having one at about the level of detail you would have had in your
own mind before writing the Python code.

I do not think that you will be happy with Java if your main criterion
for good code is short code. Java's main advantages to my mind are
readability, portability, and a tendency to catch typos at compile time.
It is not a compact language.

There is a perhaps apocryphal tale of an early natural-language translation
program taking "out of sight, out of mind" from English to Russian, then back
to English as "invisible and crazy".
 
L

Lawrence D'Oliveiro

You will never get fluent in Java if you think Python code is a
reasonable specification for your Java code.

I did C++ and TCL before I did Python. I did Perl and Java before that. And
C before that.

I am as fluent in Java as I want to be—the main learning curve right now is
the Android APIs. The day I can rely on most Android devices to have a
Python implementation built-in, guess what I’ll be doing...
I do not think that you will be happy with Java if your main criterion
for good code is short code.

My criterion is not short code, but MAINTAINABLE code. Data-driven code is
best: then you can usually make changes just to data tables, with minimal
need to change any actual code. This needs a language that can easily
construct elaborate data structures, preferably with a functional notation.

That Python example I posted illustrates this: it needs to pull out a long
list of fields from one table. But any change to that list of fields only
needs to be made in one place; all the rest of the code for constructing the
query and formatting the output will automatically adjust to that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top