Find the answer to your Linux question:
Results 1 to 7 of 7
I would like to know how PHP, Python and node. js compare, when it comes to performance on the server side? Is there anyone here who's actually used all 3, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User
    Join Date
    Mar 2013
    Posts
    318

    Trying to pick a server side language


    I would like to know how PHP, Python and node.js compare, when it comes to performance on the server side? Is there anyone here who's actually used all 3, and can give me a comparison?

    I have Used PHP myself, and I understand how it works - it essentially lives inside your webserver. So how do the others do it? What are the RAM footprints?


    I'm also (of course) concerned about what node and Python are like - are they easy to learn, and fun to program IN?


    Thanks for all your help.

  2. #2
    Linux Engineer
    Join Date
    Apr 2012
    Location
    Virginia, USA
    Posts
    886
    I have not worked with node.js, so I cannot help you there. It's definitely and up and comer, but I don't see any special advantages for using it.
    PHP is tried and true. Developing in PHP will allow you to deploy your content to just about any traditional hosting environment. PHP is fine, millions of sites use it no problems.

    Python, IMO, is the way of the future. It's just too popular and too easy to use. Python is usually developed in one of a few of the major frameworks available. This is because unlike PHP, Python itself has to handle a lot of the lower-level stuff like parsing the http requests themselves. There are different ways to deploy python, a popular way is Apache+mod_wgsi + your python framework. Since this is not a common setup, you will likely require a VPS or similar type of hosting to develop Python, though some hosts support python by using FastCGI or other means. You can also run python as a cgi script from cgi-bin as you would perl, for simple tasks.

    Other options for python deployment include Google App Engine or Heroku. These are referred to as 'Platform as a Service' or PaaS. PaaS provides all the runtime and webserver parts of your stack, you just write your application.

    If you are considering PHP, consider using Yii. It's a newer framework, but it's really easy to learn and use. If you decide to go Python, consider flask. Django is another option for Python, but I feel it tries to do too much.

  3. #3
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,182
    You're comparing apples and oranges and snakes.

    Node.js is a platform, PHP and Python are languages with Python being a general purpose language. Their performance will depend on what they are being used for, the platform they are being used on and/or the engine that is driving them.

    I'm guessing your interest is in web applications and PHP is the easiest of these to learn for that purpose. PHP is run as a CGI application and whatever platform you use it conforms to a certain specification. Overall performance and footprint will depend on the system.

    Python is a programming language. You could write a web server from the ground up in it but it's unlikely to perform well. A specification for Python CGI has been written so it can be used with various platforms -- performance and ease of use will depend on the platform. It will take more to learn Python but you can do more with it.

    Node is designed to make it easy to write servers that perform well. Javascript is an easy language to learn but with Node you have a lot of details to consider. There are web servers that you can download and install to use with node and that can reduce the curve considerably. The performance of the end product will depend on too many factors to write about here but it is possible to create applications that work well on the platform but it requires learning more then Javascript.

    The most fun of the three is probably Python. It is an all purpose language and there are hosted environments available for web projects. PHP will be the easiest but is mostly useful for web projects though it does have a CLI. Node is really a different beast since it is an environment not a language. Javascript is a very useful language and node has gone a ways to making it more general purpose.

    I've used and do use all three professionally but Python has been the most useful for me. There is a wide range of applications that it is suited for.

    Of course some peoples idea of fun is to quickly get a web page up and PHP is good for that - a standard LAMP install and your off and running. My idea of fun is writing system software in C and I only use PHP when paid to do so.

  4. #4
    Linux User
    Join Date
    Mar 2013
    Posts
    318
    Thanks, you guys!
    mizze, a couple of questions - what is the "runtime"? Also, how exactly do you spit out HTML in Python - is that done by one of the frameworks you mentioned? Or do you have to put it in PRINT statements - I once did a site in Perl this way, it was an absolute NIGHTMARE! NOTHING I wish to repeat.

    One more question - if I'm specifically going to be making an ecommerce site, which is the easiest langauge in which to process the payments, I mean the actual accepting of the credit card and making sure it's not a fraud or whatever?


    Thanks.

  5. #5
    Linux Engineer
    Join Date
    Apr 2012
    Location
    Virginia, USA
    Posts
    886
    Quote Originally Posted by resetreset View Post
    Thanks, you guys!
    mizze, a couple of questions - what is the "runtime"? Also, how exactly do you spit out HTML in Python - is that done by one of the frameworks you mentioned? Or do you have to put it in PRINT statements - I once did a site in Perl this way, it was an absolute NIGHTMARE! NOTHING I wish to repeat.

    One more question - if I'm specifically going to be making an ecommerce site, which is the easiest langauge in which to process the payments, I mean the actual accepting of the credit card and making sure it's not a fraud or whatever?


    Thanks.
    Runtime refers to the ability to run/interpret your computer code. My usage of the word is not technically strict; it can be read as 'computing environment' or similar phrase.

    If you write a Python script as a CGI script, then it would be written much like a perl script using print statements. It can be a nightmare for large projects, I wouldn't recommend doing a whole website this way. It is a very handy tool if you just need to process a couple of web forms or something though.

    Alternatively, if you develop in a framework, most frameworks come with are can be coupled with a template engine. In fact, you could use a template engine with CGI scripts as well.

    As far as an ecommerce site, both PHP and Python would be fine choices. I find Python easier to write than PHP, but PHP is widely used, you don't have to re-invent the wheel all the time. With processing credit cards, you typically will have to use a payment processor's API. This will vary by processor, but PayPal is an easy one to get started with.

  6. #6
    Linux Engineer docbop's Avatar
    Join Date
    Nov 2009
    Location
    Woodshed, CA
    Posts
    924
    Quote Originally Posted by mizzle View Post
    Runtime refers to the ability to run/interpret your computer code. My usage of the word is not technically strict; it can be read as 'computing environment' or similar phrase.

    If you write a Python script as a CGI script, then it would be written much like a perl script using print statements. It can be a nightmare for large projects, I wouldn't recommend doing a whole website this way. It is a very handy tool if you just need to process a couple of web forms or something though.

    Alternatively, if you develop in a framework, most frameworks come with are can be coupled with a template engine. In fact, you could use a template engine with CGI scripts as well.

    As far as an ecommerce site, both PHP and Python would be fine choices. I find Python easier to write than PHP, but PHP is widely used, you don't have to re-invent the wheel all the time. With processing credit cards, you typically will have to use a payment processor's API. This will vary by processor, but PayPal is an easy one to get started with.
    I llike Python as well but PHP seems to be the language of the most popular frameworks like Drupal, Wordpress, Joomla.

  7. #7
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,864
    I use PHP, but I've not used Python for any server-side scripting stuff. I'd echo what docbop and mizzle say above, I'd not be inclined towards python for a large scale implementation.

    I wrote my own PHP->html framework using the class infrastructure and I use it all over the place. But I know there are several about out there, I just never liked any.

    If you're considering this for a new website, you might want to consider Ruby. I've heard only good things about it (and I work with a team of software developers), and it would be high on my list if I needed to do a whole new deployment.
    Linux user #126863 - see http://linuxcounter.net/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •