Tuesday, November 9, 2010

More Impressions of Python (from a Java developer)

Jeff Bail has just written an article on his first impressions of Python. I've been teaching myself Python for the last two weeks as well and I generally share Jeff's impresssions. I just wanted to add some more.

Compared to Java

Python is not that different from Java. Generally it is said that Python is easy to learn. For Java developers it is probably even easier. It's not that different like a Lisp for example. Language constructs are similar. It's object-oriented, you got packages, classes and methods, for-loops and so on. But it's dynamic, so it's a bit more like Groovy.

Object-orientation

Object-orientation seems a bit clumsy (a bit like JavaScript). For example the attributes of a class are declared in the constructor (dynamically) and there is no this keyword, instead a self parameter is passed to the methods of a class to get hold of the instance. I don't know exactly but it feels like object-orientation wasn't part of Python from the beginning. Nonetheless, Python's dynamical nature makes object-orientation very flexible.

Functional Programming

Python supports functional programming. Functions are first class citizens and can be passed around as parameters to other functions for example.

Django

After reading a book about Python I wanted to actually use it in a simple web project with Django. Django is a web application framework similar to Ruby on Rails or Grails. One great feature of Django is it's O/R-Mapping and querying features. A little drawback, but that's more a matter of personal taste, is that it's MVC and template based with a templating language. I've used that in Java with Spring MVC and Freemarker long time ago, but meanwhile I mostly prefer component-based frameworks like Apache Wicket.

Conclusion

I haven't gotten really deep into Python by now, but my first impressions are generally very positive and I already feel comfortable with it. I will also have a look at some other web frameworks in the future, any recommendations?