• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1105
  • Last Modified:

PHP vs. Python

Hi all,

I am going to build a website by using LAMP. Now the problem boil down to php vs python. It seems to me that php is pretty popular. But I heard that python is the best and php is messy compared to python. I am also aware of of framework issue if we want to use python, heard that webpy could be a good start in WSGI.

Please comment on this issue. pro and con of using php vs. python.
Thanks,
RDB
0
ResourcefulDB
Asked:
ResourcefulDB
  • 3
  • 3
  • 2
  • +3
5 Solutions
 
MacAnthonyCommented:
Both are very capable languages to build everything from the most modest websites to very high volume, enterprise scale web applications. The argument you see about php being messy has to do with a lot of inconsistency in many of the libraries php uses that they don't use uniform naming conventions and can get confusing. Python is different in that it is whitespace formatted so that the whitespace dictates the control structures. Some people have a hard time with this.

PHP is probably the most prominent language on the web due to so many hosting providers offering it as an option. Digg, wikipedia and facebook all use php pretty extensively so I think they are testaments to what can be done with that language.

Both are things you just get used to using the languages. I think it's better to make decisions on which has the support for things you will be looking for. Personally, I would choose the language I was more comfortable with or if I was to choose some a particular CMS or other application, the language that was required for that.
0
 
farzanjCommented:
Python is much cleaner, probably than ANY other scripting language.  It is easy to learn as well.
Python is among the fastest scripting languages--bench marks showed comparison with Perl.  But PHP is among the slower ones.
Python also does have good web interfaces.

BUT:
PHP is common and widely used.
0
 
Rance_HallCommented:
I've been a PHP coder for years, and have just started learning Python.

In my experience so far I would say that there is no real difference between the two that really matters.

I have yet to find a project that both of them could not do.

How they each do things is different and in some ways it really comes down to a matter of personal preference.

One major difference in python is that python FORCES you to write nice looking code.  In most languages white space is silently ignored and is just there for human readability.  As a result humans get sloppy and don't take advantage of the white space and write code that is hard to debug later.

Python forces you to tab and indent and so forth because these things do matter.  I notice I write better looking PHP code as well now that I have that Python habit as well.

I think that python makes better use of memory and other system resources by being modular.  In PHP you compile all the options you will ever need at compile time and then each PHP script you write has the overhead and support needed to connect to a database even if this particular script wont be doing that at all.

You start a python script by importing all the modules you will need for this particular script so each program has the resources it needs and no more.

One other thing to note is that it is easier to write cross platform code in Python as opposed to PHP.

The modular nature of python allows you to import the os module and you get a different os module depending on the os you are running on, but python doesn't care because the custom os modules handle the heavy lifting for you.

The downside to modules is that sometimes the modules you want are not available.  When python moved from 2.x to 3.x many of the third party modules had not been updated yet.

All in all I'd say that I like Python more, but most web sites still have PHP code in them and it will be a long time before it is ever replaced (if ever)  

If you want to learn something new go with Python, but if you want to learn something that you can make money on, learn PHP there are more job opportunities with PHP right now.  I'm confident that Python will catch up in this measure, but that is the current state of things.

HTH.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Mohamed AbowardaSoftware EngineerCommented:
0
 
farzanjCommented:
Well, here is the kind of bench mark I looked at. I read many studies and all of them had similar results.  Only the Perl monks were competing with Python geeks.  Other scripting languages were much behind in speed.

http://xodian.net/serendipity/index.php?/archives/27-Benchmark-PHP-vs.-Python-vs.-Perl-vs.-Ruby.html
0
 
Ray PaseurCommented:
Speed will be determined by how well the data bases are normalized and indexed, not by whether you use PHP or Python.  Among my community of developers, Ruby on Rails is a popular way to do rapid prototyping.  I would choose PHP over Python because you can find more programmers who work cheap in PHP.
0
 
ResourcefulDBAuthor Commented:
Thank all for the comments. Here are two follow up questions.

If php ever get replaced, will it be replace by python, or something like c/c++?
How are those WSGI, webpy things in python? is that what make python clearer?

Thanks,
RDB
0
 
MacAnthonyCommented:
Trying to guess what language or technology that will cannibalize php I think isn't something that should considered with this decision. Any guess is purely speculation. I think it's just as likely that something that isn't even really on the radar may be the next big thing. Maybe node.js. Who knows. It will change eventually, but guessing what and when is really that - a guess.
0
 
Mohamed AbowardaSoftware EngineerCommented:
PHP is web programming language was made in C++, there are alot of web programming languages you might consider such as Python, Perl, PHP and ASP.NET, all of them can almost do the same things.
0
 
Rance_HallCommented:
PHP might get replaced, but it wont be for some time.  Its just too entrenched right now.

I really like the model used by the PERL and Python, extensive use of modules means that basic scripts dont have to have all the overhead required to bring all those features to play.

But MacAnthony is right, any comment with a name is speculation at best or wishful thinking.
0
 
ResourcefulDBAuthor Commented:
Sorry that I did not make last comment clear. When I said replace php, I did not mean php be replaced by other script language in building future website. I meant when the website get way too large, we need to go deeper and rewrite the whole website to make it perform better.

I am not sure if this happened at all in the real word. Is there something out there was first written in php and later on become too large and everything was rebuild in c/c++? What is google written of? What about amazon, skype, etc?

Thanks,
RDB
0
 
Ray PaseurCommented:
Facebook was written in PHP.  Performance of PHP only became an issue last year when they had about 300,000,000 users.  So until you have 300,000,000 users you will be OK with PHP.  Or with Python.

Are you writing the scripts yourself?  If so, choose the language you like best.  If not, ask your paid developers what language they would use for your project.  That will take you down the path of least resistance.

Good luck with your project, ~Ray
0
 
ResourcefulDBAuthor Commented:
Thank you Ray, I follow your logic. The path of least resistance is the key.
Another important aspect to consider is how easy I can get code on the web to jump start. I believe there are many great examples to create generic stuffs, such as how to use php and mySQL to build a email verification user login, etc. Can you recommend some of those site, or modula?

Thanks,
RDB
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now