Can Python installation be as clean as PHP?

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

    #1

    Can Python installation be as clean as PHP?

    I like Python but I don't really like Python's installation.
    With PHP, I only need one file (on Linux) and maybe two files
    on Windows then I can run my PHP script. This means no installation
    is required in most cases. I just copy the file and I get PHP.
    Extending PHP is fairly easy, too, just by copying a few DLLs
    and modifying the php.ini a bit.

    With Python, things are really messy. I have to run the installer
    to install dozens of directories and hundreds of files, and I don't
    really know if all of them are necessary. Plus, lots of libraries
    are in .py, which is of course not as efficient/clean as having all
    of the core functions built-in in the C/C++ core, like in PHP.

    Then again, I do like the Python language. It would be great if
    Python (or a variation of Python) can be made the PHP way, one
    executable file, and you get everything.


  • malv

    #2
    Re: Can Python installation be as clean as PHP?

    If this bothers you, why don't you stick to a linux distro with Python
    installed.
    Very few don't.

    Comment

    • Rene Pijlman

      #3
      Re: Can Python installation be as clean as PHP?

      Jack:[color=blue]
      >I have to run the installer to install dozens of directories and
      >hundreds of files,[/color]

      That's not unusual and not considered a problem by most people.
      [color=blue]
      >and I don't really know if all of them are necessary.[/color]

      Don't let that bother you. Life's too short.
      [color=blue]
      >Plus, lots of libraries are in .py, which is of course not as
      >efficient/clean as having all of the core functions built-in in
      >the C/C++ core, like in PHP.[/color]

      Performance-critical parts _are_ implemented in C/C++. But not everything
      falls into this category. Yes, there's probably room for more performance
      improvements. Just like there is with PHP. Did you know, for example, that
      PHP doesn't store and re-use compiled versions of the scripts by default?
      With PHP you need to fiddle with eAccelerator, Zend and the like. The
      Python interpreter does this automatically.

      There are advantages to having library code in Python too, such as being
      able to seemlessly debug it in a Python debugger. Also, Python API's tend
      to be a lot cleaner than PHP's. This probably reflects the language
      they're implemented in.

      --
      René Pijlman

      Comment

      • Diez B. Roggisch

        #4
        Re: Can Python installation be as clean as PHP?

        > With Python, things are really messy. I have to run the installer[color=blue]
        > to install dozens of directories and hundreds of files, and I don't
        > really know if all of them are necessary. Plus, lots of libraries
        > are in .py, which is of course not as efficient/clean as having all
        > of the core functions built-in in the C/C++ core, like in PHP.
        >
        > Then again, I do like the Python language. It would be great if
        > Python (or a variation of Python) can be made the PHP way, one
        > executable file, and you get everything.[/color]

        You have a somewhat distorted view of things. I've been cursing PHP
        quite a few times exactly for that monolitic nature. If you need e.g.
        oracle support, you have to recompile the whole lot, not just a module
        as it has no no C-module concept - so you can't add functionality
        besides using PHP-includes. So much for efficiency.

        Diez

        Comment

        • Carl Banks

          #5
          Re: Can Python installation be as clean as PHP?

          Jack wrote:[color=blue]
          > Then again, I do like the Python language. It would be great if
          > Python (or a variation of Python) can be made the PHP way, one
          > executable file, and you get everything.[/color]

          True, sometimes it can be a real convenience to have this. There are
          solutions that implement your solution to some degree. For instance,
          for Windows there's Moveable Python (it costs a scant 5 pounds):

          http://www.voidspace.org.uk/python/movpy/

          I don't believe it's a single file, but it is "installationle ss".
          Py2exe and PyInstaller can let you distribute programs as single-file
          executables. PyInstaller works on Unix too, IIRC.

          If you're good at tweaking stuff and have some knowledge of Python
          internals; it's possible to make a minimal distro just by copying files
          out of a regular installation by hand (and maybe zipping some them up).
          This can be a security and bug risk, so be careful.


          Carl Banks

          Comment

          • G. Monzón

            #6
            Re: Can Python installation be as clean as PHP?

            Please don't compare PHP with Python... They are very different worlds.

            Maybe not all the Python's core functions are implemented in C, but
            Python is really a lot more efficient than PHP in every case you want
            to compare.

            If you "look inside", there's nothing to compare... they are extremely
            different worlds... they are like hell and heaven, from the awesome
            brilliant C Python implementation, to the ugly C PHP hack... (after all
            it is my personal opinion, I've worked with PHP for more than 4 years,
            for websites and console scripting).

            Python is more efficient than PHP in every aspect... I don't know why
            got (and still is) so popular, IMHO Python should have taken its place
            as the best "web scripting language".

            OTOH, my php install have lots more than a single executable file.
            Perhaps you don't use any php extension? don't think so... do you use
            pear? and pecl? you need lots of files too, and until you don't know
            what do they are and what you need or not, you will be in the same
            issue as you're with Python. I think you will get it early, as you
            find everything is more straightforward than you thought.

            Gonzalo Monzón.

            Comment

            • Carl Banks

              #7
              Re: Can Python installation be as clean as PHP?

              G. Monzón wrote:[color=blue]
              > Please don't compare PHP with Python... They are very different worlds.[/color]

              I'm not. I was simply agreeing that the single executable way the OP
              claimed PHP does it can *sometimes* be preferrable in Python, and
              giving him recommendations thereto.

              Carl Banks

              Comment

              • Ravi Teja

                #8
                Re: Can Python installation be as clean as PHP?

                PHP and Python are different languages. They do things differently. You
                are just familiar more with one than the other. Give it some time.

                The many file approach is the modular design of Python. Having the
                standard library separate from the main Python DLL is an advantage, not
                a disadvantage. For example, it allows me to pick just the libraries I
                want to distribute when I make a single file executables. It allows me
                to distribute just the parts of the standard library I want when I
                embed Python in another application. Not to mention being able to debug
                right into the source.

                Most languages take the Python approach. Have you looked at your C
                compiler and counted the include and library files? Have you seen Perl
                or Ruby to check how their library is distributed? I can think of only
                a few languages that take the PHP approach... early BASIC interpreters,
                Shells, DSLs and some lesser known interpreters and compilers... none
                of which are exactly reputed to be flexible.

                How is manually copying files and editing configuration files easier
                than clicking through standard distutils installers or typing "setup
                install" or better ... using eggs through EasyInstall? BTW, you can
                manually copy Python libraries too in most cases to install and PEAR
                does offer a package manager for PHP.

                Installation has never been a problem for me with Python, if not the
                easiest. In fact, among the languages I regularly use, Python is the
                only one that includes installer support right in the standard library
                (distutils) and I find it surprising that you managed to find it
                wanting all because there are more files :-).

                Comment

                • Ravi Teja

                  #9
                  Re: Can Python installation be as clean as PHP?

                  Addendum:
                  Python has zip imports (similar to Java's jar files). You can put all
                  your *.py files in a zip file and access them from it if this means so
                  much to you.

                  Comment

                  • G. Monzón

                    #10
                    Re: Can Python installation be as clean as PHP?


                    Carl Banks wrote:[color=blue]
                    > G. Monzón wrote:[color=green]
                    > > Please don't compare PHP with Python... They are very different worlds.[/color]
                    >
                    > I'm not. I was simply agreeing that the single executable way the OP
                    > claimed PHP does it can *sometimes* be preferrable in Python, and
                    > giving him recommendations thereto.
                    >
                    > Carl Banks[/color]

                    Sorry Carl, my reply was for the OP. I pressed the wrong reply
                    button... doesn't meant you did any comparation!

                    I said that about comparing, as the OP thought Python coded in Python
                    approach for a lot of core libraries isn't as efficient as in PHP
                    'cause they are all coded in C. And that's not true.

                    Yes, it could be obvious for some people that it "should" run faster
                    than Python, having all core functions coded in C, yes, but in overall
                    performance matters, that's not true in any case.

                    Python has all the primitives C coded as said in this thread. PHP
                    "primitives " are no more than hash-tables and lots zvals... far away
                    from the hi-tuned advanced data-types Python exposes. That makes a big
                    performance improvement over PHP, regards C or Python coded core
                    functions -let language implementation details apart-. Major loss of
                    performance in Python and PHP is on translating data values to C side
                    and all the functions calling done for as little as a value assignment
                    to a variable. So, sometimes, to code a function in C or let it be
                    Python, makes no more than a 1us per call difference...
                    I'd like to see this value compared to PHP. That's why PHP need a C
                    implementation for all core functions, as if they would be PHP coded,
                    performance would be even a lot worse.

                    And I would't say PHP is slow. But It depends on what you need to do.
                    'Cause PHP can be really slow and ultra-high memory consuming. While
                    you had this troubles with PHP, is nice to see how Python performs:
                    consumes a lot less of memory and goes 50 % more fast.

                    About a single executable file, I thought PHP is being distributed in
                    windows and linux as an executable plus an dinamic link library, that's
                    the minimum thing you need to run scripts. So OP is wrong, there is not
                    a single executable file. You need two files at least + php.ini +
                    extensions to run almost any PHP script.

                    And a PHP or Python without extensions or batteries, wouldn't be very
                    handy... oh well, that depends on the task to do.

                    Anyway, PHP isn't a bad tool for a *lot* of web-side scripting, but I'd
                    prefer if I could use Python in many of my work projects. :-) I'd feel
                    happier !

                    Regards,
                    Gonzalo.

                    Comment

                    • XBello

                      #11
                      Re: Can Python installation be as clean as PHP?

                      It's possible to work with php just with these single file? Maybe I'm
                      doing the wrong thing, because to start to program I needed to install
                      a web server too (a large bunch of files). Also I've been looking into
                      http://www.modpython.org/, which appears to be a modular kind of python
                      with less than 400kb.

                      Thanks,
                      Xabier.

                      Comment

                      • Ravi Teja

                        #12
                        Re: Can Python installation be as clean as PHP?

                        No! mod_python needs Python. It is simply an integration module for
                        Apache and Python, not an interpreter.

                        Comment

                        • Edward Elliott

                          #13
                          Re: Can Python installation be as clean as PHP?

                          XBello wrote:[color=blue]
                          > It's possible to work with php just with these single file? Maybe I'm
                          > doing the wrong thing, because to start to program I needed to install
                          > a web server too (a large bunch of files).[/color]

                          PHP can be run from the command line too. On ubuntu/debian it's available
                          by installing the php4-cli package. Not sure about other systems, I didn't
                          see any any obvious links on the php website.

                          Comment

                          • Peter Maas

                            #14
                            Re: Can Python installation be as clean as PHP?

                            Jack wrote:[color=blue]
                            > With Python, things are really messy. I have to run the installer
                            > to install dozens of directories and hundreds of files, and I don't
                            > really know if all of them are necessary.[/color]

                            PHP has LOTS of functions in a single namespace. I don't know wether
                            they are in separate files or packed in the exexutable but I'm sure
                            that you don't need them all ;)
                            [color=blue]
                            > Plus, lots of libraries
                            > are in .py, which is of course not as efficient/clean as having all
                            > of the core functions built-in in the C/C++ core, like in PHP.[/color]

                            Python is faster than PHP in most situations (2-3x). Look at
                            http://dada.perl.it/shooutout for win32 and
                            http://shooutout.alioth.debian.org for linux.

                            Peter Maas, Aachen

                            Comment

                            • Fredrik Lundh

                              #15
                              Re: Can Python installation be as clean as PHP?

                              Ravi Teja wrote:
                              [color=blue]
                              > Python has zip imports (similar to Java's jar files). You can put all
                              > your *.py files in a zip file and access them from it if this means so
                              > much to you.[/color]

                              Python also supports "frozen" modules, where the module bytecode is
                              linked into a Python interpreter as data. by combining frozen modules
                              and static linking of extension modules, it's relatively easy to create a
                              single-file python interpreter.

                              and to make things even simpler, you can get tools and ready-made
                              single-file distributions for a variety of platforms here:




                              </F>



                              Comment

                              Working...