wiki:MoodleAsPlatform

Wen's reason for favoring Python than Php

There are heaps of discussions about PHP vs Python: We don't need to go down here to compare which language is better. Everyone has his own favorite pet and it is very difficult to tell fairly through individual's point of view.

We know moodle to some extent, we had analyzed moodle's database architecture and we use its library from time to time. We use php to do rapid web developments. The points why we choose python are the following:

  • py2exe, you can package your scripts into a self executable file in windows/mac environment. We want to lower to technical requirement for installation. Therefore, eXe could be easily installed in user's desktop.
  • in cgi programming, we also need the ability to deal with a single name for multiple variables ( see idevice template editor http://newped.auckland.ac.nz/idevice_template). Php seems to lack these kind of setting like keep_blank_values .... snip here.( Before I tried using name like xxx[], this kind of naming is ok in html, but while doing javascript dom processing this will cause problem )
  • better xml support: this section is python or java's domain. php is still not sophisticated enough to easily handle various kinds of xml format. In python, there are many libraries http://pyxml.sourceforge.net/topics/software.html( pyxml, beautiful soup, xmlreader ) already and are very easy to use. Current we use xmlreader to parse xml file and store the information into a dictionary. This make our xml programming very easy. However, php XMLreader seems to be good too.
  • better string processing in template and script: Python has tuple( set ) object, lamda, list [ (x, y)for x in a for y in b...]; a dictionary/list/tuple can contain all kinds of data format( functions, list, tuple, dictionary..... ). You can reference a function like this cm.class.dict[cmd]( cm, query ), you can reference a variable in a dictionary like this self.page_url_list[ self.current_page + 1 ][0].split("&" )[-1].split( "=" )[0].replace( "identifier","" ). Save a lot of headache.
  • everything is a reference

php vs python

Last modified 10 years ago Last modified on 2009-05-22T06:11:07+09:00