PHP vs Python

I do programming in both php and python when I program websites. I have tried to figure out why I'm attracted to python more then php, and here's what I think.

PHP (in my opinion) is not very well planned out. There are way too many core functions in the language, most of them are something like module_real_do_something. I don't even understand why those aren't in classes. It's very easy to slip up and have a security vulnerability in a script, and the solutions they provide just don't cut it. Things like magic quotes add another step when it doesn't help anyone except the idiot programmer who doesn't know about SQL injection. Differences between php 4 and 5 are a massive pain because the language is not planned out. It's not very flexible; you can't mix in new methods to a class, among other things. Classes are hard to use to begin with. I find that you have to do a lot of 'hacks' in order to get certain things working, usually copy and pasted from a comment on the php documentation site. In my honest opinion not very ergonomic. The only plus side of PHP that I can see is that it is installed on most web servers, and it uses (in most cases) less memory then python.

Python (other then javascript) is my favorite programming language. The syntax is much more readable and easier to type. The language is much more flexible. I love how there are so many magic functions for classes. Everything is modularized. In PHP, you have to import/require EVERYTHING, and it was just a pain, especially like when you import a script, and that script imports something with a relative path, but php acts weird and starts looking in the wrong directory, and it's just a mess. You can make your own connection handler that will map a url to a function, or you can use mod_python's built in connection handlers. Since python is also used to make cli and gui programs too, it has a lot more modules to use then PHP. The down side of python is that it's installed on less webhosts, mostly because it takes much more work to configure so that it's stable, but also because you may need access to httpd.conf in order to set something up. I think the mod_python developers know this, and they will hopefully find a solution to these issues one day.

So, for now it looks like I'm stuck using PHP. It's very painful for me. If I had the option I would never code another line of PHP again, but I know that's probably not going to happen for a while...

No votes yet