Download presentation
Presentation is loading. Please wait.
1
J2EE vs Python for web development David North @northoxford www.dnorth.net
2
● Java and Python both reasonably mature object oriented programming languages ● So, suppose we had a web app to write and a choice of either (say because we wanted to host it on Google App Engine...) ● Let's dive in
3
Java (J2EE) ● Ignoring the silly naming... import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println(" "); out.println(" Hello World "); out.println(" "); out.println(" Hello World "); out.println(" "); }
4
Python - WSGI def simple_app(environ, start_response): status = '200 OK' response_headers = [('Content-type','text/plain')] start_response(status, response_headers) return ['Hello world!\n']
5
This is all a bit tedious and low-level... ● Let's find ourselves a higher-level framework ● We can use whatever bits our languages have to offer for DB access, image generation, sending e- mail, etc... ● What we need is an abstraction layer for handling HTTP requests ● And some way of generating blingsome javascripty web pages easily
6
Java web frameworks ● Java: ● Play – their website was crocked last time I checked. Not a good start, but allegedly has some nice features. ● Spring – a lot of tools to make back-end dev more pleasant, plus some integration with... ● Google Web Toolkit – compiles Java -> JS + allows RPC / ajax calls to the server from the resulting rich UI
7
Python web frameworks ● Python: ● Django – high-level framework, evolving fast, but no help on the client side apart from templating HTML etc. ● Pylons – similar, not much help on the client side ● Turbogears – glues together a bunch of existing technologies all the way from JS lib of your choice on the client to ORM on the server
8
Gradients and AJAX Web 2.0 ● How to write a blingsome web-based UI? ● Maintaining lots of javascript by hand is tedious... ● GWT is a slightly sick idea, but unlike a few years ago, the browsers can handle that much JS, so... ● There was an attempt to make a Python equivalent of GWT, but it sank without trace ● Maybe the existence of jQuery UI is enough
9
Pros and cons ● None of the java frameworks I've used, nor basic J2EE, make it easy enough to have a clean, sane URL structure. Django et al do (stole RoR's best ideas on this) ● Nothing I've used in the Python world makes it easy to generate rich web pages / AJAX without hand-crafting lots of javascript or using other libraries, which bring other tools + complexity with them ● The Java tools/IDEs are more helpful, but this is counterbalanced by make an edit, recompile, zzzzz vs python's edit and there you go
10
Deployment and hosting support ● Java – has a (not entirely undeserved) reputation as a memory hog => pricier hosting ● Python – support for WSGI and stuff built on it still pretty thin on the ground... ● mod_wsgi for apache works really well, but not too many hosts offer it yet ● Costs: app engine – free for low to medium traffic (but no uptime guarantees) ● There are some ~£10/month options out there for hosting both ● And you can always get a virtual server for relatively little
11
Verdict? ● Depends on individual taste and the project being undertaken ● Neither world offers perfection out of the box ● Both are still evolving ● So take your pick :) ● Or use both! I'm planning a GWT / Django hybrid project. Your sysadmin will hate you, though ● I'd still take either of them over PHP...
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.