> > What I'd really like is a way to "statically link" a PHP application. While > > this is somewhat possible today, PHP's dynamic nature makes this difficult > > to fully realize. For example, it can be cumbersome on the developer to > > check in multiple places if APC is available, what files are cached, what > > should be included, etc. > > Hans, can you give more detail what you mean by statically link a PHP > application and how it's possible to do it? I'm interested in hearing > about that.
Well, honestly, I'm not 100% sure either :) It's not an easily solvable problem. >From the Facebook talk, and other comments I've heard in general, PHP's highly dynamic nature is a good thing and a bad thing. While flexible, there is the overhead, both from a I/O perspective and from a internals perspective. As applications become large, as the gentlemen from Facebook pointed out, it gets increasingly difficult to manage and optimize all those PHP files. I suppose fundamentally, each PHP source file is its own program in a sense. It could be executed (with whatever result) as its own script, ie, the classic .php vs .inc problem in the document root. As a result, it's the responsibility of the programmer - or framework in some cases - to ensure these code files are put together in the correct way - and for EVERY request. This is tedious. The flip side, of course, is a compiled language, where this assembly of the program is done beforehand. It seems as though (and again, this is very ballpark), that some happy medium could be done. For example, let's look at a APC use case. -- the first request of an application is performed after a server restart -- the APC cache is empty, so the application realizes this and requires/includes files as needed to fulfill the request -- in a well written application, there will always be some of the same set of assembly required -- on subsequent requests, this assembly, however, is still always performed. Granted, it's improved because the source files are being read from memory and cached, but the legwork is there still. What might be useful, would be the ability to store the block of cached code as a single entity - let's call it a "library" for example. Upon subsequent requests, the application would already have this core already available with a single "link" statement, rather than having to do the legwork each time of assembling all the blocks. Perhaps, afterall, it's more of a dynamic link model? :) Hopefully, though, this makes some sense. At the end of the day, as applications get larger and more complex, there's always a common set of code that's needed. While some things in the PHP world have attempted to help manage this, I guess it comes down to - maybe compiling PHP isn't such a bad thing :) H _______________________________________________ New York PHP User Group Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk http://www.nyphp.org/show_participation.php