Python vs. Perl vs. PHP?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fazer

    Python vs. Perl vs. PHP?

    Hello,

    I am an avid user of PHP and I am just fooling around with Python for
    now. I originally wanted to know which one is faster. As in, works
    faster. So far, I think PHP is the fastest for dynamic web-content.
    Am I wrong?
  • Wilk

    #2
    Re: Python vs. Perl vs. PHP?

    faizan@jaredweb .com (Fazer) writes:
    [color=blue]
    > Hello,
    >
    > I am an avid user of PHP and I am just fooling around with Python for
    > now. I originally wanted to know which one is faster. As in, works
    > faster. So far, I think PHP is the fastest for dynamic web-content.
    > Am I wrong?[/color]

    yes for two reasons, one relative, one more objective :

    - you'll write cleaner and shorter programs with python, so more easy to
    optimize
    - when you'll really need speed, you'll write standalone web-server with
    python, and so a lot more eficient and fast in high trafic.

    I've rewrite my "high" trafic web site from php to python and gain 10x of
    speed.

    --
    William Dode - http://flibuste.net

    Comment

    • Diez B. Roggisch

      #3
      Re: Python vs. Perl vs. PHP?

      Fazer wrote:
      [color=blue]
      > Hello,
      >
      > I am an avid user of PHP and I am just fooling around with Python for
      > now. I originally wanted to know which one is faster. As in, works
      > faster. So far, I think PHP is the fastest for dynamic web-content.
      > Am I wrong?[/color]

      Definitely. See here:



      Python is place 13, with a speed index of 578. PHP is second last (before
      bash) and has a speed index of 197.

      Besides that, PHP is a really ugly language - not only to the eye (which is
      admittedly a matter of taste), but a friend of mine currently implements a
      PHP->C-Compiler had delved deep into the language implementation - and it
      _is_ ugly.

      I expirienced mayor flaws in PHP 4.0.x, where my declared functions in a
      6000 line include vanished from time to time - repeating the request
      sometimes solved the problem. That was really nasty.

      Regards,

      Diez

      Comment

      • Wilk

        #4
        Re: Python vs. Perl vs. PHP?

        "Diez B. Roggisch" <deets_noospaam @web.de> writes:
        [color=blue]
        > Fazer wrote:
        >[color=green]
        >> Hello,
        >>
        >> I am an avid user of PHP and I am just fooling around with Python for
        >> now. I originally wanted to know which one is faster. As in, works
        >> faster. So far, I think PHP is the fastest for dynamic web-content.
        >> Am I wrong?[/color]
        >
        > Definitely. See here:
        >
        > http://www.bagley.org/~doug/shootout/craps.shtml[/color]

        has somebody tried to run this bench with python2.3 ?

        --
        William Dode - http://flibuste.net

        Comment

        • Fazer

          #5
          Re: Python vs. Perl vs. PHP?

          "Diez B. Roggisch" <deets_noospaam @web.de> wrote in message news:<bg3qkk$lm [email protected]>...[color=blue]
          > Fazer wrote:
          >[color=green]
          > > Hello,
          > >
          > > I am an avid user of PHP and I am just fooling around with Python for
          > > now. I originally wanted to know which one is faster. As in, works
          > > faster. So far, I think PHP is the fastest for dynamic web-content.
          > > Am I wrong?[/color]
          >
          > Definitely. See here:
          >
          > http://www.bagley.org/~doug/shootout/craps.shtml
          >
          > Python is place 13, with a speed index of 578. PHP is second last (before
          > bash) and has a speed index of 197.
          >
          > Besides that, PHP is a really ugly language - not only to the eye (which is
          > admittedly a matter of taste), but a friend of mine currently implements a
          > PHP->C-Compiler had delved deep into the language implementation - and it
          > _is_ ugly.
          >
          > I expirienced mayor flaws in PHP 4.0.x, where my declared functions in a
          > 6000 line include vanished from time to time - repeating the request
          > sometimes solved the problem. That was really nasty.
          >
          > Regards,
          >
          > Diez[/color]

          Wow, thanks for link! I will use it as hard proof to lure some of my
          friends in using Python! ;-)

          This is a little off-topic, but I wish to know how would you turn a
          string (or data from a text-file) into an array? For example, maybe
          turn each \n into an array.

          So a string like:

          "This is line 1
          This is line 2
          This is line 3"

          And so when you read that into a list called text text[0] would the
          "This is line 1".

          Thank you once again.

          Comment

          • Fazer

            #6
            Re: Python vs. Perl vs. PHP?

            Nevermind. I RTFM :-) .

            Comment

            • Aahz

              #7
              Re: Python vs. Perl vs. PHP?

              In article <7b454334.03072 81742.10274598@ posting.google. com>,
              Fazer <faizan@jaredwe b.com> wrote:[color=blue]
              >
              >This is a little off-topic, but I wish to know how would you turn a
              >string (or data from a text-file) into an array? For example, maybe
              >turn each \n into an array.
              >
              >So a string like:
              >
              >"This is line 1
              >This is line 2
              >This is line 3"
              >
              >And so when you read that into a list called text text[0] would the
              >"This is line 1".[/color]

              s.split('\n')
              --
              Aahz (aahz@pythoncra ft.com) <*> http://www.pythoncraft.com/

              This is Python. We don't care much about theory, except where it intersects
              with useful practice. --Aahz

              Comment

              • Graham Breed

                #8
                Re: Python vs. Perl vs. PHP?

                Diez B. Roggisch wrote:
                [color=blue]
                > http://www.bagley.org/~doug/shootout/craps.shtml
                >
                > Python is place 13, with a speed index of 578. PHP is second last (before
                > bash) and has a speed index of 197.[/color]

                Those benchmarks are doubly useless for the question at hand. Firstly,
                they only test command line applications. Secondly, PHP is compiled
                without optimizations because the rules state that only the default
                configuration can be used. See question 8 of the FAQ:




                Graham

                Comment

                • Gerhard Häring

                  #9
                  Re: Python vs. Perl vs. PHP?

                  Fazer wrote:[color=blue]
                  > [...] I am basically looking for a FAST
                  > alternative to PHP meaning the responce time is fast. Do you think
                  > that Python with using the CGI module is a good solution?[/color]

                  No, CGI is not a good solution in this case, no matter what the language
                  (except those perverts who use something like C with dietlibc for this).

                  The base technology to make web requests fast in Python is something
                  like mod_python or a Python application server. On top of this I'd
                  recommend you use a Python web framework, of which there are numerous
                  ones. The hard part is to evaluate them and choose one.

                  FWIW I'm currently using Quixote running with mod_scgi against Apache,
                  mostly because I was fed up with the (lack of) Webware documentation,
                  which I tried first.

                  -- Gerhard

                  Comment

                  • Fazer

                    #10
                    Re: Python vs. Perl vs. PHP?

                    Gerhard Häring <[email protected] > wrote in message news:<mailman.1 059640670.9792. [email protected] >...[color=blue]
                    > Fazer wrote:[color=green]
                    > > [...] I am basically looking for a FAST
                    > > alternative to PHP meaning the responce time is fast. Do you think
                    > > that Python with using the CGI module is a good solution?[/color]
                    >
                    > No, CGI is not a good solution in this case, no matter what the language
                    > (except those perverts who use something like C with dietlibc for this).
                    >
                    > The base technology to make web requests fast in Python is something
                    > like mod_python or a Python application server. On top of this I'd
                    > recommend you use a Python web framework, of which there are numerous
                    > ones. The hard part is to evaluate them and choose one.
                    >
                    > FWIW I'm currently using Quixote running with mod_scgi against Apache,
                    > mostly because I was fed up with the (lack of) Webware documentation,
                    > which I tried first.
                    >
                    > -- Gerhard[/color]


                    Thanks for the reply! I think I am going to give mod_python a try.
                    Would I have to be root to install mod_python? Because that's one of
                    my biggest concerns. I don't have root and I don't want to work on my
                    windows machine since I am kind of more comfortable working on a Linux
                    platform.

                    Basically, most of my Python scripts would just be accessing the MySQL
                    database and just printing out various data.

                    Comment

                    • Gerhard Häring

                      #11
                      Re: Python vs. Perl vs. PHP?

                      Fazer wrote:[color=blue]
                      > Thanks for the reply! I think I am going to give mod_python a try.
                      > Would I have to be root to install mod_python?[/color]

                      Either that or you need to have the privileges to compile Apache +
                      mod_python and run it on a nonprivileged port (> 1024).
                      [color=blue]
                      > Because that's one of
                      > my biggest concerns. I don't have root and I don't want to work on my
                      > windows machine since I am kind of more comfortable working on a Linux
                      > platform. [...][/color]

                      mod_python works on Windows as well. The harder part is finding a web
                      hoster that will host mod_python apps (pythonhosting. com comes to mind).
                      I personally find it much easier to learn about system administration
                      and get my own dedicated server for EUR 39/month.

                      -- Gerhard

                      Comment

                      • Diez B. Roggisch

                        #12
                        Re: Python vs. Perl vs. PHP?

                        Hi,
                        [color=blue]
                        > Compared to Apache 2.0 with PHP/Zend & Accelerator? I honestl don't think
                        > so. When PHP is compiled to native code it is as fast as Java or C.[/color]

                        There is no such thing like a native compiler for PHP. If you're speaking of
                        the ZEND compiler - AFAIK that one just does some parse tree caching. As I
                        mentioned before, a friend of mine works on a php->C (and then native, of
                        course) compiler.

                        One thing he has to do is to recreate all the library bindings. These are
                        really slow implemented in PHP - has something to do with the
                        parameter-passing. And thats something the ZEND compiler doesn't speed up.

                        Another thing is PHP session mechanism - the simply persist every session to
                        the filesystem. Sure, there are FS-Caches, but neverless thats not as fast
                        as imaginable...

                        And what do you mean by "As fast as Java or C"? There is a huge difference
                        in speed between these two.

                        Not that I think that speed matters much here - usually, the bandwidth,
                        process creation time and database queries are the bottlenecks.

                        Regards,

                        Diez

                        Comment

                        • Diez B. Roggisch

                          #13
                          Re: Python vs. Perl vs. PHP?

                          >> Definitely. See here:[color=blue][color=green]
                          >>
                          >> http://www.bagley.org/~doug/shootout/craps.shtml[/color]
                          >
                          > has somebody tried to run this bench with python2.3 ?[/color]

                          I just picked a few (heapsort.pytho n, methcall.python , objinst.python) tests
                          and run them on my local machine using 2.2 and 2.3.

                          The results are that 2.3 seems to need 60-70% of cpu time. Looks good!

                          time heapsort.python 2.3 80000
                          real 0m4.779s
                          user 0m3.540s
                          sys 0m0.000s

                          time heapsort.python 2.2 80000
                          real 0m5.655s
                          user 0m5.510s
                          sys 0m0.030s

                          Mind you: I didn't do a full benchmarking and didn't even try so!



                          Diez

                          Comment

                          • Fazer

                            #14
                            Re: Python vs. Perl vs. PHP?

                            > I personally find it much easier to learn about system administration[color=blue]
                            > and get my own dedicated server for EUR 39/month.[/color]

                            39? Where do you get such a good deal?

                            Comment

                            • Wilk

                              #15
                              Re: Python vs. Perl vs. PHP?

                              faizan@jaredweb .com (Fazer) writes:
                              [color=blue][color=green]
                              >> I personally find it much easier to learn about system administration
                              >> and get my own dedicated server for EUR 39/month.[/color]
                              >
                              > 39? Where do you get such a good deal?[/color]

                              15EUR/month on http://lost-oasis.fr i write about them because they make a lot
                              of contributions to open-source...

                              --
                              William Dode - http://flibuste.net

                              Comment

                              Working...