Caughtrandomly
30-05-2013, 01:50 PM
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:
$variable = false;
if(!$variable) {
return true;
}
Where the syntax for Python can be:
variable = False
if not variable:
return True
Another example I'll post was if I wanted a function to return false if the input is right
function test($input) {
if($input == "yes") {
return true;
} else {
return false;
}
}
Whereas in Python it would be
def 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)
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!
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:
$variable = false;
if(!$variable) {
return true;
}
Where the syntax for Python can be:
variable = False
if not variable:
return True
Another example I'll post was if I wanted a function to return false if the input is right
function test($input) {
if($input == "yes") {
return true;
} else {
return false;
}
}
Whereas in Python it would be
def 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)
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!