python, i like the snake
90% of my development work during the last few years was done in java. i had to create a little project for the OLPC about a year ago. OLPC is using python very heavily and so i developed the tool in python. before that, i did only a few very simple things in python. a few weeks ago i started to develop webapplications in python. here are a few ideas and a list of packages/ software i used.
because WSGI is a very low level interface it’s best to use a proper webframework. there are lots of them. the most are full blown frameworks and i am a bit allergic to them, i like it when i can put together the tools i want and doesn’t have to be pushed to use a certain way (forced, you are never. with full blown frameworks it’s the same as with certain girlfriends. they tend to give subtle hints about something but don’t force you, they are open to everyting but you get afraid what awaits you if you really go with something else then her preferred way). the only one i kind of liked was web.py. i’ts not the most beautiful but well built and it lets you do whatever you want if you like to. i use it mainly for mapping urls to code and webstuff like redirecting, send errors and stuff.
to access a database there are different packages available. i checked for orm mappers and found quite a lot of different implementations. the two best (as much or less as i can judge it) are Storm and SQLAlchemy. both are flexible, easy to use and have lots of functionality who doesn’t get in your way if not used. compared with hibernate it’s a dream.
to render html or whatever, i was looking for a good template language. there are many of them and i decided to use Jinja2. its the one i liked most but, hey it’s a template language, they are almost all usefull, properly built and support about the same featureset.
if i remember properly, thats all i needed, at least for the web aspect of the applications. python also has many very useful modules included, therefore you don’t need to include lots of modules. no crappy apache commons jars who give some functionality they missed to implement in the standard library.
python versus java
compared with java, python is IMHO not as clean. it isn’t as “designed” as java is. but compared with, for example PHP, it’s a hyper clean and intuitive language. java is static typed and although also bytecode compiled like python, it needs an explicit compilation step. this makes developing python programs a bit more agile. for java and python there are lots of libraries/ packages available. as much as i have seen the python ones seems to be usually higher quality, but this can just be the selection i made and doesn’t need to be a general thing. the most important point in using python for webapps instead of java is that the python programs are usually fewer lines of code compared to the java programs. as much as i have seen till now i think this is also possible while having at least the same readability of the code like java programs. on the other hand you can write more easyli horrible code in python than in java. so python needs a bit more discipline. i will use python mainly for little not so critical projects, at least until i am fluent with it.what did i use for webapps
with java i usually used an apache with mod_jk to connect to tomcat. i looked for a similar setup in python and found that there are a lot of possible ways but the most promising thing was the WSGI standard. there was a module for apache2 and so i was happy. WSGI is short of WebServer Gateway Interface and it sits somewhere between the webserver and python. compared with java where a application server is used who shares a common context for all servlets/ requests, WSGI-python scripts are loaded in a context for each process (apache processes i think), so caching and communication with other requests is not possible. but, if you are used to develop your applications with a cluster in mind it doesn’t hurt. you can use memcached for a cache.because WSGI is a very low level interface it’s best to use a proper webframework. there are lots of them. the most are full blown frameworks and i am a bit allergic to them, i like it when i can put together the tools i want and doesn’t have to be pushed to use a certain way (forced, you are never. with full blown frameworks it’s the same as with certain girlfriends. they tend to give subtle hints about something but don’t force you, they are open to everyting but you get afraid what awaits you if you really go with something else then her preferred way). the only one i kind of liked was web.py. i’ts not the most beautiful but well built and it lets you do whatever you want if you like to. i use it mainly for mapping urls to code and webstuff like redirecting, send errors and stuff.
to access a database there are different packages available. i checked for orm mappers and found quite a lot of different implementations. the two best (as much or less as i can judge it) are Storm and SQLAlchemy. both are flexible, easy to use and have lots of functionality who doesn’t get in your way if not used. compared with hibernate it’s a dream.
to render html or whatever, i was looking for a good template language. there are many of them and i decided to use Jinja2. its the one i liked most but, hey it’s a template language, they are almost all usefull, properly built and support about the same featureset.
if i remember properly, thats all i needed, at least for the web aspect of the applications. python also has many very useful modules included, therefore you don’t need to include lots of modules. no crappy apache commons jars who give some functionality they missed to implement in the standard library.