What is better as a scripting language: PHP-CLI or Python?

2 points by gauravgupta ↗ HN
What is better as a scripting language: PHP-CLI or Python?

My website already runs PHP for it's UI. I now need to code some scripts which will fetch data from certain URL's on a daily basis, parse the XML it fetches and populate the database with the data it extracts.

If PHP 5, with its enhanced object oriented features and rich libraries is on par with Python on the command line, then wouldn't it make better sense for me to use PHP for both web and CLI/GUI development?

But, I can't ignore the fact that people do use python almost exclusively for high level CLI/GUI scripting.

Which of them is a better choice?

3 comments

[ 2.5 ms ] story [ 20.4 ms ] thread
Although I've heard 5.3 fixes some of the issues, PHP is often not suitable for long-running scripts due (I believe) to memory consumption (when using OO code). I believe it is an issue w/ garbage collection of objects.
PHP CLI is brilliant and once I found out about it writing scripts and cron jobs became a lot simpler.

I have php scripts that run on the command line that run for long periods of time. I have also found a lot of ways to reuse code originally written for our website.

I don't know about memory consumption problems, but I have php scripts that are coded functionally (not OO) that run for an hour (processing HUGE amounts of data).

yes -- scripts I have had memory problems with stopped having such problems when I rewrote them as procedural (not OO) code.