473,503 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

fairly large webapp: from Java to Python. experiences?

I've got a fairly substantial webapp written in Java (plus Tomcat,
Hibernate, Struts, JSP, MySQL) that is a bit of a bear to work with. I
didn't write it. Much of it is only very sparsely documented (if at
all). No design docs anywhere. It's a large webapp with many classes
and fairly deep inheritance hierarchies. There seems to be JUnit test
cases in place.

The possibility of re-writing it has come up, and I must say that,
although it would likely be a ton of work, it could also be a real
pythonic adventure. ;) Reasons for a rewrite are to get better
flexibility, easier maintenance (easier to make changes), and the
possibility of really slimming down the size of the thing. And of
course, it would be nice to work with Python -- possibly significantly
more productive.

Does anyone here have any experience with large(ish) webapps in Python?
I was sniffing around the following A-team of toolkits: CherryPy,
Cheetah, SQLObject, all behind Apache2. Has anyone seen performance
issues with Python webapps?

Could one reasonably expect to have an easier time with maintainence
and future modifications with using Python over Java?

Any tips, stories, recommendations, and/or experiences are most
welcome.

Thanks.

Feb 3 '06 #1
12 2100
To replace a large framework you will probably need a framework. Take a
look at http://www.djangoproject.com or http://www.turbogears.org. They
both use some of the tools you mention but operate on a higher level.

I find Python fairly easy to maintain. Unfortunatly, I do not find it
easy to take a bunch of Java code and move it to Python. But once it is
there, Python is a good choice for web apps. Java is slow and has a big
footprint. Python is reasonably nimble and good design choices pay off.
Plus, you must write many more lines of Java to do what you can in
Python. I do not know the code you are not working with, but a lot of
large Java apps can be poorly written.

I guess you could also look at http://www.jython.org/ and see if you
can somehow make the transition but not all at once.

Good luck,
<http://brianray.chipy.org>

Feb 4 '06 #2
br*******@gmail.com wrote:
To replace a large framework you will probably need a framework.
Well, I'm sure not all web frameworks are created equal, however,
CherryPy does bill itself as a "web framework".
Take a
look at http://www.djangoproject.com or http://www.turbogears.org. They
both use some of the tools you mention but operate on a higher level.
Django looks interesting to me. Would like to try out mod_python.
Taking a look...
I find Python fairly easy to maintain. Unfortunatly, I do not find it
easy to take a bunch of Java code and move it to Python.
Well, I figured it might be better to use the previous webapp
as a *model* to learn from, rather than to directly translate
code from Java to Python.
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.
and has a big
footprint.
Yes.
Python is reasonably nimble and good design choices pay off.
Plus, you must write many more lines of Java to do what you can in
Python.
Yup. The main issue with the current Java webapp seems to be
that it takes a long time to make changes/additions.
I do not know the code you are not working with, but a lot of
large Java apps can be poorly written.


I've found that good documentation is *most* critical. At least
if the docs are good, but the code needs work, you have some
direction as to how to fix the code. If there's no docs, you
spend hours wondering why things are done the way they're done.

Currently having a look at the Django docs. :)

Thanks Brian!
---J
--
(remove zeez if demunging email address)
Feb 4 '06 #3
John M. Gabriele wrote:
br*******@gmail.com 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.


Well, perhaps yes, but not so if you count the fact that recoding
is so easy that you can race several implementations of the same
thing to see which trade-offs work. Java may run the one algorithm
you decide to write faster than Python will run the same thing,
but in Python you may race five algorithms and keep the fastest.
Using programmer resources effectively is Python's secret sauce.

--Scott David Daniels
sc***********@acm.org
Feb 4 '06 #4
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.
--
Giovanni Bajo
Feb 4 '06 #5
jo***********@yahoo.com wrote:
I've got a fairly substantial webapp written in Java (plus Tomcat,
Hibernate, Struts, JSP, MySQL) that is a bit of a bear to work with. I
didn't write it. Much of it is only very sparsely documented (if at
all). No design docs anywhere. It's a large webapp with many classes
and fairly deep inheritance hierarchies. There seems to be JUnit test
cases in place.

The possibility of re-writing it has come up, and I must say that,
although it would likely be a ton of work, it could also be a real
pythonic adventure. ;) <snip> Any tips, stories, recommendations, and/or experiences are most
welcome.


A class-to-class and method-to-method rewrite will give some but likely
not the full benefit of moving to Python. A redesign might be necessary
- making it more 'Pythonic' in the process. In my experience, many cruft
classes that exist in a Java design simply disappear when ported to
Python. See also http://dirtsimple.org/2004/12/python-is-not-java.html

Cheers,
Shalabh

Feb 4 '06 #6
Shalabh Chaturvedi wrote:
jo************@yahooz.com wrote:

A class-to-class and method-to-method rewrite will give some but likely
not the full benefit of moving to Python. A redesign might be necessary
- making it more 'Pythonic' in the process. In my experience, many cruft
classes that exist in a Java design simply disappear when ported to
Python. See also http://dirtsimple.org/2004/12/python-is-not-java.html

Cheers,
Shalabh


Great link Shalabh. Thanks. :) Googling around, I'd also come across
that one.

---J

--
(remove zeez if demunging email address)
Feb 5 '06 #7
Giovanni Bajo wrote:
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.


+1 QOTW
(I'd recommend the whole post but it might be too long.)

Cheers,

AdSR

Feb 5 '06 #8
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.

Feb 6 '06 #9
Fabio Zadrozny wrote:
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));


Though String.format() is new in Java 1.5 so in older code or for
backward compatibility the longer code may be found. OTOH Python has
supported % formatting since at least version 1.4 released in 1996.
http://www.python.org/doc/1.4/lib/no...00000000000000

In my experience the original point is valid - Python is usually
(always?) more concise than equivalent Java code, and often dramatically
so. Python makes common operations easy; Java sometimes seems to go out
of its way to make them awkward.

Kent
Feb 6 '06 #10
Kent Johnson wrote:
Fabio Zadrozny wrote:

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));


Though String.format() is new in Java 1.5 so in older code or for
backward compatibility the longer code may be found. OTOH Python has
supported % formatting since at least version 1.4 released in 1996.
http://www.python.org/doc/1.4/lib/no...00000000000000

In my experience the original point is valid - Python is usually
(always?) more concise than equivalent Java code, and often dramatically
so. Python makes common operations easy; Java sometimes seems to go out
of its way to make them awkward.

Kent


Yeap, I agree with the original point too (as I explained in the rest of
my comment)... just didn't think it was a 'fair' comparisson. ;-)
-- me? When I use java I write 1.5 code and 'retroweave' it to be
compatible with java 1.4 (Pydev is done this way) -- and I use Python at
work -- and I'm very happy with it... I just think that a language is as
a tool, and each may be suited better for a different occasion.

The 'usually smaller' I mentioned is because sometimes java code gets
smaller because of the already-existing codebase... E.g.: for developing
an IDE, Eclipse already has a huge codebase, so, if I wanted to do all
that was already done in it in python just because Eclipse was in java,
I think I would be doing the wrong decision, and besides, I could use
jython for it if I wanted to...

And from what I understood, the original poster had a large codebase in
java already, so, I'm not sure that changing everything to python would
be the way to go (altough that DOES depend a lot on the original
codebase quality).

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
Feb 6 '06 #11
> Any tips, stories, recommendations, and/or experiences are most
welcome.


Just one suggestion, read the article "Things You Should Never Do, Part
I" first (
http://www.joelonsoftware.com/articl...00000069.html). Quoting
from the article:

(Netscape made) "the *single worst strategic mistake* that any software
company can make: They decided to rewrite the code from scratch."

As much as I find python more maintenable and fun to work with in the
long run, I would be *very hesitant* to start a complete rewrite,
especially given the insufficient documentation of your webapp and your
lack of experience with a pythonic web framework.

George

Feb 7 '06 #12
jo***********@yahoo.com wrote:

(snip)
Does anyone here have any experience with large(ish) webapps in Python?
Depends on the definition of "large(ish)". If you use KLOC as a metric,
you can expect a Python solution to be 5 to 10 time smaller, so what's a
'large' app in Java may end up as a small/medium app with Python !-)
I was sniffing around the following A-team of toolkits: CherryPy,
Cheetah, SQLObject, all behind Apache2.
If you plan to run behind Apache2, you may want to have a look at
Myghty. It's somewhere between a framework and a templating system, and
the architecture is based on Perl's HTML::Mason, which has proven to be
successful. It adds to Mason the possibility to take a clean MVC
approach (as well as the more ServerPage oriented approach of Mason),
and can be deployed as either a mod_python handler, fastcgi, plain old
cgi, WSGI, and even as a standalone app (with a Python HTTPServer) for
developpement.

You may also want to take a look at Turbogears (CherryPy + SQLObject +
Kid + Mochikit) or Subway (CherryPy + SQLObject + Cheetah).

Has anyone seen performance
issues with Python webapps?
Actually, only with Plone or CPS (or other ZopeCMF based app). Zope
itself is pretty usable, but the whole CMF part is a monstruosity IMHO.
Could one reasonably expect to have an easier time with maintainence
and future modifications with using Python over Java?
Err... It of course depends on first having well written code and a
sensible design, but when it comes to agility - and as long as you stay
away from Zope's CMF !-) -, I bet that Python beats Java hands down.
Any tips, stories, recommendations, and/or experiences are most
welcome.


It took me about one month to write my first Zope application - an
ad-hoc mix of an online catalog and basic CMS (pages, news,
downloadables files, ...), with LDAP and PostgresSQL in the mix,
fulltext and advanced search, newsletter subscription, a 'members' zone
etc. I had to learn Zope during the process, and I guess I could
actually rewrite the whole thing in less than 2 weeks with a much better
design - but what, the app is in production for 2 years with near zero
corrective maintenance (the biggest problem we had was with system
updates messing with the psycopg adapter...), gives full satisfaction to
the customer, and has for now proven to be very easy to modify and
evolve (so easy that we didn't even bothered to bill the customer for
much of the modification requests)... And Zope is certainly not known
as the most agile or lightweight Python web framework/application server !-)

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Feb 7 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2079
by: Tim Churches | last post by:
I am asking this on behalf of a Java enthusiast who is interested in using ZODB and other Python assets from his Java code: a) Has anyone used JPE (Java-Python Extension - see...
23
3382
by: assaf__ | last post by:
Hello, I am beginning to work on a fairly large project and I'm considering to use python for most of the coding, but I need to make sure first that it is reliable enough. I need to make sure...
9
2400
by: limor | last post by:
Hi, I am considering using Python in a new testing tool application we intend to build for out product. I must get references before starting develope in this language , since although lots of...
36
6322
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
2
1579
by: Anakim Border | last post by:
App servers such as quixote, webware and skunkweb (just to name a few) offer a clean environment to develop Python webapps. I have some problems, however, understanding their security model. My...
1
2581
by: Adriaan Renting | last post by:
I think the point you want to make is that Python needs vastly less lines of code as a similar application written in C++. I think Python might on average be 50-60% of comparable C++ code, but not...
4
1555
by: Jimmy Zhang | last post by:
I am having some trouble processing some large file (40mb) in Java. For the problem I have, I have tried to use SAX, but doesn't find it suitable (well, coding just becomes a little complicated)....
11
5836
by: CSN | last post by:
Is it possible to iterate over an array in plpgsql? Something like: function insert_stuff (rel_ids int) .... foreach rel_ids as id insert into table (rel_id, val) values (id, 5);
28
4287
by: liorm | last post by:
Hi everyone, I need to write a web app, that will support millions of user accounts, template-based user pages and files upload. The client is going to be written in Flash. I wondered if I coudl...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4688
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.