I just thought I'd post a small article on why I've chosen Python over PHP, so let me start by saying I have been coding now for around 8 years and my first programming language I learnt was PHP (or scripting language depending on peoples opinions)
Anyway back to the point, I love PHP and I found it to do everything I wanted, it was widely used meaning there were many different ways to solve problems, etc., I liked that PHP is so easily accessible and that most hosting comes with it, but then I look into Python.
After working with Python for just over a year I found that the syntax was much cleaner (in my opinion), for example:
In PHP if I wanted to do a if statement and return true if its false, I would do:
Where the syntax for Python can be:PHP Code:$variable = false;
if(!$variable) {
return true;
}
Another example I'll post was if I wanted a function to return false if the input is rightCode:variable = False if not variable: return True
Whereas in Python it would bePHP Code:function test($input) {
if($input == "yes") {
return true;
} else {
return false;
}
}
I just overall found the syntax to be much cleaner and I know some people disagree as they would prefer to use the curly brackets instead of white spacing (Which is what most programming languages use)Code:def test(input): if input == "Yes": return True else: return false
I also have several other reasons why I choose Python over PHP, for example, the framework Django, but I'd like to hear your opinions before I go onto that.
Just wondering what other peoples opinions are on this?
Please note, I'm not trying to start a programming language war, just curious!





Reply With Quote




Has Python got the versatility that PHP has?
