fairly large webapp: from Java to Python. experiences?
Fabio Zadrozny
fabioz at esss.com.br
Mon Feb 6 07:15:38 EST 2006
I agree that python code is usually smaller... but what you did is too
unfair (the code below would be more suitable for the comparrison).
python:
print "%10.2f" % 10
java:
System.out.println(String.format("%10.2f", 10.0));
-- altough for me it would be the same, as I have defined a print
method... so, it is always something as:
print ("%10.2f", 10) in java for me :-)
What I'm trying to say here is that if you already have a big java app,
sometimes spending some time trying to refactor it for better
understanding is more useful than scrapping what already exists
(especially if you have good test cases)... altough I would reccomend
jython for new development on that same application.
I guess that the main difference is that python usually makes you do the
right thing, whereas in java you need to know a lot more about it to
manage to do the right thing...
Cheers,
Fabio
--
Fabio Zadrozny
------------------------------------------------------
Software Developer
ESSS - Engineering Simulation and Scientific Software
www.esss.com.br
PyDev - Python Development Enviroment for Eclipse
http://pydev.sf.net
http://pydev.blogspot.com
Giovanni Bajo wrote:
>John M. Gabriele wrote:
>
>
>
>>>But once it is
>>>there, Python is a good choice for web apps. Java is slow
>>>
>>>
>>Slow? They're both dynamic languages, but Java is statically
>>typed (with less work to do at runtime). For long-running processes,
>>I'd guess that Java bytecode executes faster than Python bytecode.
>>
>>
>
>
>It's not the raw computing performance that counts in this case. I got this
>joke in my mail today:
>
>Python:
>print "%10.2f" % x
>
>Java:
>java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
>formatter.setMinimumFractionDigits(2);
>formatter.setMaximumFractionDigits(2);
>String s = formatter.format(x);
>for (int i = s.length(); i < 10; i++) System.out.print(' ');
>System.out.print(s);
>
>Let alone the time it takes to write this routine, I'm hundered percent sure
>that the Python's version is also faster at runtime. Python lets you write
>pretty expressive code which is easy to maintain and where the computation cost
>is easily at the C level. Also Python code is pretty bare-metal, so that
>file.write or socket.write go to the syscall immediately. Try that in Java and
>you'll find 30 layers of complex abstractions for doubtful benefits and obvious
>slowness.
>
>
More information about the Python-list
mailing list