On 3/14/07, Alan Conway <[EMAIL PROTECTED]> wrote:

If you can identify a subset of the Java codebase that corresponds to
the python client's
functionality, filter out all the comments and get a byte count
difference explainable as
curly braces & newlines I will never mention this again :)


Ok, point conceded. Yes, you can do a lot with one line of python.

For a comparison, I saw in the testlib.py, file a function that scans the
filesystem for tests. Compared with the horrible thing that is
ClasspathScanner.java to do the same in Java and it is obvious that the
python is far more concise. Stuff like:

python:
re.match(regexp, somestring)

java:
Pattern pattern = new Pattern.compile(regexp);
Matcher matcher = pattern.matcher(somestring);
matcher.match();

shows this up well. My reponse? Stuff those three lines of java as a static
in RegexpUtils (ignoring the loss in efficiency by recompiling the regexp
every time). Then do:

RegexpUtils.match(regexp, somestring);

I do this sort of thing all the time, in an effort to write more concise
java.

Rupert

Reply via email to