Leo's Technical Blog

Comparing Django with Servlets+EJB: Lines of source code

Introduction

user

Leo Soto


python, django

Comparing Django with Servlets+EJB: Lines of source code

Posted by Leo Soto on .
Featured

python, django

Comparing Django with Servlets+EJB: Lines of source code

Posted by Leo Soto on .

There are too much areas to make a comparision between languages and web frameworks. We have seen from hard perfomance benchmarks to much more soft happiness measures. But as I have too little time and interest to make a serious and complete comparision, I will focus on results coming from the real world department.

On my work we have rewritten a semi-application previoulsy written in Java to Python + Django. I've called this applications as "semi", because it was not finished, but at the time we had the feeling that rewritting it on Python would take less time than finishing the work on Java.

Three weeks has passed and the application is almost done. It has more features than the Java version, so the comparision is not 100% fair, but it's very interesting anyway.

Hard Data

  • Java application, Total Lines of .java files: 8314
  • Java application, Total Lines of non-generated .java files:_ 3859_
  • Just the Struts part of the Java application, Total Lines of non-generated .java files: 1625
  • Python application, Total Lines of .py files: 566This data comes directly from "wc -l". It includes comments, documentation and empty lines.

The Java app was made using CMP Entity EJBs and we used Xdoclet to avoid the boring coding and xml manual configuration. So, as far as I have seen, it had much less lines of code than the typical Java app.

Conclusion

So, We have written more features in less than a sixth of code. That sounds great :), and it's more than what I initially expected (that's why I'm writing this!). The estimation book I've been reading indirectly says (on pag 202) that Perl code is 2.75 times shorter than Java, and I suppose than Perl and Python are somewhat comparable here.

I could also write some boring extra information about this unscientific 'study', or repeat some known benefits of having less code hanging around, but that could be left for comments, if someone ever finds this blog.