Are PHP libraries linked dynamically or statically?

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

    Are PHP libraries linked dynamically or statically?

    Hi,

    When a PHP program links to a library using include or require (or their
    _once variations), is the library then linked dynamically or statically?

    While it might seem irrelevant from a technical point of view, the
    linking method is important when it comes to licencing issues as some
    licences, like GPL, differ between those kinds of linking when it comes
    to viewing the library as a derivative work of the main program.

    Therefore it is quite important to know what kind of linking is in
    effect when including libraries, and I hope someone in this group can
    shed some light on this matter.

    Thank you very much in advance,
    Martin
  • NC

    #2
    Re: Are PHP libraries linked dynamically or statically?

    On Jul 19, 4:14 pm, Martin Larsen <martin+spamfre e+lar...@bigfoo t.com>
    wrote:
    >
    When a PHP program links to a library using include
    or require (or their _once variations), is the library
    then linked dynamically or statically?
    Neither. include/require is not a linking mechanism; it is a way to
    assemble a complete block of source code prior to its interpretation.
    Any static linking takes place at the server process start-up (i.e.,
    before any include/require can happen); dynamic linking (if any)
    occurs during execution (i.e., after the source code has been
    interpreted, and, therefore, after any include/require).
    it is quite important to know what kind of linking is in
    effect when including libraries,
    Only if the libraries are true libraries (i.e., those compiled into
    native executable code). With PHP "libraries" , using include/require
    does not imply any linking...

    Cheers,
    NC

    Comment

    • Toby A Inkster

      #3
      Re: Are PHP libraries linked dynamically or statically?

      Martin Larsen wrote:
      When a PHP program links to a library using include or require (or their
      _once variations), is the library then linked dynamically or statically?
      Dynamically.

      --
      Toby A Inkster BSc (Hons) ARCS
      [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
      [OS: Linux 2.6.12-12mdksmp, up 29 days, 14:30.]

      Parsing an HTML Table with PEAR's XML_HTTPSax3

      Comment

      • Martin Larsen

        #4
        Re: Are PHP libraries linked dynamically or statically?

        Thanks NC,

        I understand that PHP is very different than say a Windows executable,
        and perhaps linking is not the right term for what happens.

        Anyway, in your opinion, does the mechanism rememble dynamic or static
        linking most?

        Btw, if I were to get an "official" statement, do you by chance know who
        I should contact?

        Martin

        Comment

        • NC

          #5
          Re: Are PHP libraries linked dynamically or statically?

          On Jul 20, 12:34 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
          >
          I understand that PHP is very different than say a Windows
          executable,
          >
          PHP isn't (it can be a Windows executable). PHP scripts are.
          >
          Not quite true. The PHP interpreter (php.exe) itself is executable.
          My point exactly. I guess I should have written "PHP interpreter"
          rather than just "PHP"... :)

          Cheers,
          NC

          Comment

          • Martin Larsen

            #6
            Re: Are PHP libraries linked dynamically or statically?

            NC wrote:
            >Btw, if I were to get an "official" statement, do you by
            >chance know who I should contact?
            >
            The PHP group: http://www.php.net/contact.php
            Thanks for link. However, that page actually refers to this newsgroup or
            the webmaster for website related comments.

            Is there a way to contact the PHP Group directly?

            Thanks again,
            Martin

            Comment

            • Martin Larsen

              #7
              Re: Are PHP libraries linked dynamically or statically?

              Hi Henk,
              This may be true from a strict technical definition, but juridical
              reasoning may not be that strict.
              Thank you for making clear what I was trying to say. It is in fact a
              juridical matter.

              If we agree that the term linking might not be entirely irrelevant,
              which kind of linking would you say is in effect when a PHP program
              links to a script: dynamically or statically.

              The reason why this is important is that dynamically linking is often
              seen as a licence boundary
              (http://en.wikipedia.org/wiki/Library...ynamic_linking)

              Regards,
              Martin

              Comment

              • Jerry Stuckle

                #8
                Re: Are PHP libraries linked dynamically or statically?

                Martin Larsen wrote:
                Hi Henk,
                >
                >This may be true from a strict technical definition, but juridical
                >reasoning may not be that strict.
                >
                Thank you for making clear what I was trying to say. It is in fact a
                juridical matter.
                >
                If we agree that the term linking might not be entirely irrelevant,
                which kind of linking would you say is in effect when a PHP program
                links to a script: dynamically or statically.
                >
                The reason why this is important is that dynamically linking is often
                seen as a licence boundary
                (http://en.wikipedia.org/wiki/Library...ynamic_linking)
                >
                Regards,
                Martin
                And despite what Henk posted, has absolutely nothing to do with PHP.

                NC is correct in his discussion. You need to paying attention to what
                he is saying.


                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===

                Comment

                • Jerry Stuckle

                  #9
                  Re: Are PHP libraries linked dynamically or statically?

                  Martin Larsen wrote:
                  NC wrote:
                  >
                  >>Btw, if I were to get an "official" statement, do you by
                  >>chance know who I should contact?
                  >>
                  >The PHP group: http://www.php.net/contact.php
                  >
                  Thanks for link. However, that page actually refers to this newsgroup or
                  the webmaster for website related comments.
                  >
                  Is there a way to contact the PHP Group directly?
                  >
                  Thanks again,
                  Martin
                  Why?

                  If you understood the technology, the answer would be clear. Rather, I
                  suggest you visit your local library or bookstore and find out how
                  interpreters work.

                  --
                  =============== ===
                  Remove the "x" from my email address
                  Jerry Stuckle
                  JDS Computer Training Corp.
                  jstucklex@attgl obal.net
                  =============== ===

                  Comment

                  • Toby A Inkster

                    #10
                    Re: Are PHP libraries linked dynamically or statically?

                    Jerry Stuckle wrote:
                    Unless you have implemented a PHP optimizer, every PHP file is
                    interpreted every time you load the file. There is no intermediate code.
                    There normally *is* an intermediate form, but it's discarded after each
                    execution unless you have a PHP cache, such as eAccelerator.

                    That is, on each execution, the PHP interpreter:

                    1. Opens up the file;
                    2. Tokenises it, storing the token stream in memory;
                    3. Parses it into a form of byte code, storing that in
                    memory too; then
                    4. Executes the byte code.

                    Most smart interpreters (and I assume PHP is included here) will also
                    perform a bit of code optimisation around stage 3 too. Code optimisation
                    trades off execution time for parsing time, so interpreters (optimise once,
                    run once) tend not to optimise as much as compilers (optimise once, run
                    many) do.

                    --
                    Toby A Inkster BSc (Hons) ARCS
                    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
                    [OS: Linux 2.6.12-12mdksmp, up 30 days, 12:01.]

                    Parsing an HTML Table with PEAR's XML_HTTPSax3

                    Comment

                    • Rami Elomaa

                      #11
                      Re: Are PHP libraries linked dynamically or statically?

                      Martin Larsen kirjoitti:
                      Hi Henk,
                      >
                      >This may be true from a strict technical definition, but juridical
                      >reasoning may not be that strict.
                      >
                      Thank you for making clear what I was trying to say. It is in fact a
                      juridical matter.
                      >
                      If we agree that the term linking might not be entirely irrelevant,
                      which kind of linking would you say is in effect when a PHP program
                      links to a script: dynamically or statically.
                      >
                      The reason why this is important is that dynamically linking is often
                      seen as a licence boundary
                      (http://en.wikipedia.org/wiki/Library...ynamic_linking)
                      Looking at this definition:

                      "Dynamic linking means that the subroutines of a library are loaded into
                      an application program at runtime, rather than being linked in at
                      compile time, and remain as separate files on disk."

                      Based on that I'd say php "linking" resembles more dynamic linking than
                      static linking, since there is no separate "compile time" per se, a
                      script is each time recompiled at runtime. Plus the included scripts are
                      separate files on disk, they are not "built" into one executable.

                      And the reason I say it _resembles more_ is the basic problem that
                      neither of these terms can really be applied to php scripts, what you
                      need is a new term: call it including.

                      --
                      Rami.Elomaa@gma il.com

                      "Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
                      usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze

                      Comment

                      • Andy Hassall

                        #12
                        Re: Are PHP libraries linked dynamically or statically?

                        On Fri, 20 Jul 2007 01:14:02 +0200, Martin Larsen
                        <martin+spamfre e+larsen@bigfoo t.comwrote:
                        >When a PHP program links to a library using include or require (or their
                        >_once variations), is the library then linked dynamically or statically?
                        >
                        >While it might seem irrelevant from a technical point of view, the
                        >linking method is important when it comes to licencing issues as some
                        >licences, like GPL, differ between those kinds of linking when it comes
                        >to viewing the library as a derivative work of the main program.
                        >
                        >Therefore it is quite important to know what kind of linking is in
                        >effect when including libraries, and I hope someone in this group can
                        >shed some light on this matter.
                        Have you seen the following - not sure if it helps, or muddies the waters
                        further:



                        In particular the final two paragraphs:

                        "Another similar and very common case is to provide libraries with the
                        interpreter which are themselves interpreted. For instance, Perl comes with
                        many Perl modules, and a Java implementation comes with many Java classes.
                        These libraries and the programs that call them are always dynamically linked
                        together.

                        A consequence is that if you choose to use GPL'd Perl modules or Java classes
                        in your program, you must release the program in a GPL-compatible way,
                        regardless of the license used in the Perl or Java interpreter that the
                        combined Perl or Java program will run on. "


                        The implication appears to be that loading Perl modules is treated as "dynamic
                        linking" for the purposes of the license (pure technical definitions aside).
                        Perl modules are often "pure-Perl" and so very closely match "require/include"
                        for PHP libraries.

                        --
                        Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
                        http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

                        Comment

                        • Toby A Inkster

                          #13
                          Re: Are PHP libraries linked dynamically or statically?

                          Jerry Stuckle wrote:
                          Ah, but OpenOffice is not MS Word. And just because OpenOffice
                          implements something one way doesn't mean Word does.
                          No, no -- the quotes from the OpenOffice.org developers were regarding
                          the MS Word ".doc" file format -- which they had to reverse engineer --
                          they were not on the subject of OpenOffice.org' s behaviour.

                          --
                          Toby A Inkster BSc (Hons) ARCS
                          [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
                          [OS: Linux 2.6.12-12mdksmp, up 32 days, 4:23.]

                          Parsing an HTML Table with PEAR's XML_HTTPSax3

                          Comment

                          • Martin Larsen

                            #14
                            Re: Are PHP libraries linked dynamically or statically?

                            Jerry Stuckle wrote:
                            Martin Larsen wrote:
                            >Is there a way to contact the PHP Group directly?
                            Why?
                            >
                            If you understood the technology, the answer would be clear. Rather, I
                            suggest you visit your local library or bookstore and find out how
                            interpreters work.
                            Ok, I will tell you why. I had hoped it was not necessary, but here it is...

                            I do in fact know how interpreters work. I have actually written one
                            myself. Being a professional windows programmer for ages, I have also
                            learned the hard way the distinct difference between dynamic and static
                            libraries: missing DLL files on the end user's computer preventing the
                            programs from even starting.

                            I deliberately asked the question in a simple minded manner as I did not
                            want my own view of the matter to bias the replies. The thing is that
                            the core team behind a major CMS (Joomla) has recently changed their
                            mind about non-GPL plugins (or scripts, if you like). Until then they
                            accepted and welcomed proprietary plugins, but now they say that since
                            the CMS is GPL, the plugins must also be GPL to comply.

                            Now, I don't wish this thread to be for or against GPL. I only want to
                            discuss the reasoning behind their claims. The point is that they argue
                            that most extensions are *derivative work* of the CMS (even though they
                            normally don't include a single line of code from it) because they are
                            statically linked to the CMS. If they were dynamically linked, the
                            matter would be different.

                            Yep, that is what they say. While you and I can agree that it doesn't
                            make much sense to talk about linking for interpreters, they
                            nevertheless use it in their argumentation. And that is why I asked the
                            question: Are PHP libraries linked dynamically or statically?

                            In my opinion they make two mistakes: the first is to talk about linking
                            at all, the second is to claim that the plugins are statically linked.

                            As I see it, even when we are not really talking linking, the
                            characteristics of the processes involved in the INCLUDE more closely
                            resembles dynamic linking than static linking. Which means that their
                            argumentation is wrong no matter what.

                            As it happens, we (third-party developers for Joomla) have tried hard to
                            make them see that their arguments are wrong. But they keep claiming
                            that the scripts are statically linked and thus derivative works of the CMS.

                            And now to my question: Is there a way to contact the PHP Group directly?

                            I have an idea that if we could get a "official" statement of the
                            linking or non-linking involved, they might be more prone to listening.

                            And again, I certainly don't want the PHP Group or any other to comment
                            on the good or bad of plugins being GPL because that is entirely
                            irrelevant. I just sincerely believe that their technical resoning is
                            entirely wrong.

                            Thanks,
                            Martin

                            Comment

                            • Jerry Stuckle

                              #15
                              Re: Are PHP libraries linked dynamically or statically?

                              Martin Larsen wrote:
                              Jerry Stuckle wrote:
                              >
                              >Martin Larsen wrote:
                              >>Is there a way to contact the PHP Group directly?
                              >
                              >Why?
                              >>
                              >If you understood the technology, the answer would be clear. Rather,
                              >I suggest you visit your local library or bookstore and find out how
                              >interpreters work.
                              >
                              Ok, I will tell you why. I had hoped it was not necessary, but here it
                              is...
                              >
                              I do in fact know how interpreters work. I have actually written one
                              myself. Being a professional windows programmer for ages, I have also
                              learned the hard way the distinct difference between dynamic and static
                              libraries: missing DLL files on the end user's computer preventing the
                              programs from even starting.
                              >
                              Wow. A WINDOWS programmer. So you've been programming for what - 15
                              years, maybe? And you've programmed for ONE OS? Wow.

                              And you wrote an interpreter? Golly, Gee, Batman. I guess that makes
                              you an expert on everything! ROFLMAO!

                              I deliberately asked the question in a simple minded manner as I did not
                              want my own view of the matter to bias the replies. The thing is that
                              the core team behind a major CMS (Joomla) has recently changed their
                              mind about non-GPL plugins (or scripts, if you like). Until then they
                              accepted and welcomed proprietary plugins, but now they say that since
                              the CMS is GPL, the plugins must also be GPL to comply.
                              >
                              You got answers to the question you asked.
                              Now, I don't wish this thread to be for or against GPL. I only want to
                              discuss the reasoning behind their claims. The point is that they argue
                              that most extensions are *derivative work* of the CMS (even though they
                              normally don't include a single line of code from it) because they are
                              statically linked to the CMS. If they were dynamically linked, the
                              matter would be different.
                              >
                              This has nothing to do with PHP programming. I suggest you take it over
                              to the Joomla newsgroup.
                              Yep, that is what they say. While you and I can agree that it doesn't
                              make much sense to talk about linking for interpreters, they
                              nevertheless use it in their argumentation. And that is why I asked the
                              question: Are PHP libraries linked dynamically or statically?
                              >
                              That's their problem. If you understood as well as you say, you would
                              have the answer to your question.
                              In my opinion they make two mistakes: the first is to talk about linking
                              at all, the second is to claim that the plugins are statically linked.
                              >
                              That could be. But it's not a topic for this newsgroup.
                              As I see it, even when we are not really talking linking, the
                              characteristics of the processes involved in the INCLUDE more closely
                              resembles dynamic linking than static linking. Which means that their
                              argumentation is wrong no matter what.
                              >
                              It resembles INCLUDES. It has nothing to do with linking.
                              As it happens, we (third-party developers for Joomla) have tried hard to
                              make them see that their arguments are wrong. But they keep claiming
                              that the scripts are statically linked and thus derivative works of the
                              CMS.
                              >
                              Then build your own CMS.
                              And now to my question: Is there a way to contact the PHP Group directly?
                              >
                              Why? They can't change Joomla's mind, either. Nor are they going to
                              change Joomla's terminology.
                              I have an idea that if we could get a "official" statement of the
                              linking or non-linking involved, they might be more prone to listening.
                              >
                              This has nothing to do with their use of terminology. It is a licensing
                              issue, and they have a write to require licenses for their CMS to follow
                              their rules.
                              And again, I certainly don't want the PHP Group or any other to comment
                              on the good or bad of plugins being GPL because that is entirely
                              irrelevant. I just sincerely believe that their technical resoning is
                              entirely wrong.
                              >
                              You're discussing legal issues, and should be talking to an attorney.
                              But historically Joomla is on solid legal ground. The terminology they
                              use is not important. The fact your tools ARE derivative works is.
                              Thanks,
                              Martin
                              Please don't bring your argument over here. We're not interested.


                              --
                              =============== ===
                              Remove the "x" from my email address
                              Jerry Stuckle
                              JDS Computer Training Corp.
                              jstucklex@attgl obal.net
                              =============== ===

                              Comment

                              Working...