Wednesday, January 04, 2006

PHP is a great language!

One thing I have noticed, is that quite often, PHP developers who are seeking for new PHP features are prematurely trying to implement them in C. Although, there are definitely cases where you want to write your code in C, I think in some cases PHP is too quickly dismissed. Developing features in PHP not only takes less time, but is also less prone to bugs, easier to maintain, and more stable and secure. Also, in the majority of cases, whether such a feature were implemented in C or PHP, would not make a significant different to overall application performance.

It is for this reason, and for reasons of ease-of-deployment, that in the Zend Framework we are actually taking full advantage of the PHP language. We want to showcase what the language can do, and not drop into C when we feel challenged. Also, the fact that we are implementing everything in PHP will make it also much easier to deploy, as we will aim not to have dependencies on non-standard extensions. Of course we will depend on what we consider mainstream PHP 5 extensions such as SimpleXML, DOM, PCRE, sessions etc.

ZSearch, one the components we presented in the php|architect Webcast, is a great example of this. Despite the fact that a Lucene implemention does a lot of bits and bytes file access, we implemented it fully in PHP. Is it as fast as a C implementation? Most definitely not. Is it good enough for use on high-traffic Web sites. We believe so. Same can be said for our PDF implementation, ZPdf. As we wanted to make it eas easy as possible to manipulate Pdfs, without requiring users to have to recompile PHP, we decided to implement it 100% in PHP. Not only are we implementing the creation of Pdfs, but we are also going to enable reading Pdfs, traversing them, manipulating and then writing the changed document back to disk. The implementation will even include a PHP-based LZW implementation needed to support the latest Pdf standard.

I believe PHP is a great language and from my experience a lot of needed functionality can be written and maintained much better on the PHP level, and except for limited examples, we all know that most often the bottlenecks in Web apps don't lie in a bit more or a bit less code, but in a lot of variants of the stack such as database , file system and network acccess, and more...

Long live PHP!

12 comments:

  1. I understand the reasoning behind writing the framework in PHP and I agree with it totally. However, I do think that there will eventually be room for PHP extensions to implement parts of the Zend Framework at the C level for performance improvements, once the API has stabilized. PDO and SPL both seem to prove that it is at least feasible to implement PHP classes in C.

    I suppose ZSearch is where I would first expect a drop-in replacement / enhancement as a PHP extension. Lots of folks out there seem to be eyeing this part of the framework and salivating almost as badly as I am. There are numerous ways I'd like to use ZSearch instead of the database, but I simply can't if it's not as fast as the DB.

    Of course, there's not even a beta release yet to give us an inkling of the performance of ZSearch, and it can certainly be refactored to fix performance issues later if it needs it, but I still think we're likely to see some people implement parts of the framework in C to speed things up if it's needed.

    ReplyDelete
  2. Hi Gabriel,

    Yes, I agree that there might be certain sub-modules where implemention in C might make sense. But the idea is that you should only optimize after you verify that something is a bottleneck and not write everything in C ahead of time. Optimizing ahead of time can lose you a lot of brain cycles which could be better used by implementing more value on top.

    Andi

    ReplyDelete
  3. I'm very much looking forward to seeing the Zend Framework, though I don't think I'll be able to convince my employers to start using it. I'll definitely be playing with it for my own private projects.

    Maybe it's because I don't have a true programmer background, but I never look at anything other than php and maybe some simple shell scripting for my stuff. PHP is currently still the only language I know (though I'll soon be getting a JSP course from work). and even though I'm excited to start learning JSP, PHP is and will always be the main language for me.

    ReplyDelete
  4. you made my day,

    var_dump('01'=='1.'); // bool(true)
    var_dump("foobar" == 0); //bool(true)

    is realy great. Entreprise great!

    ReplyDelete
  5. Tobias Struckmeier1/05/2006 02:13:00 AM

    Hi Anonymous:

    var_dump('01'==='1.'); // bool(false)
    var_dump("foobar" === 0); //bool(false)

    ReplyDelete
  6. "we all know that most often the bottlenecks in Web apps don't lie in a bit more or a bit less code, but in a lot of variants of the stack such as database , file system and network acccess, and more..." -- Andi

    I really, really have disaggree here... Why? I've seen uncached parsing of 100kb sized xml file upon each request on applications which have 100 request/sec on 6 server cluster and guess where the bottleneck is?

    ReplyDelete
  7. To paraphrase Thies:
    "The purpose of the PHP Engine is to be so fast that we can implement all new features in PHP itself".

    I agree to a large extend. The problem is that the only real standardization institution we have is php internals itself. PEAR has done some work in this area, but definately not sufficient. eZ Components and the Zend Framework might also, but those are all separate entities and for standards you really need one.

    Especially since alot of standards are not about technical superiority but are simple cooperation enabler. Obviously you can say "competition will sort it out". But that too is short sighted. PHP developers are the type that need to get the job done and move on. As such it is simply not in the nature of our userbase to proclaim a winner and fix their code accordingly. This means that competing standards are likely to live on and are likely to cause issues as you want to take the best of each of the different eco-systems.

    ReplyDelete
  8. Christopher Thompson1/05/2006 09:21:00 PM

    Nice writeup and I think the goal of building everything in PHP is great. Totally in the spirit of PHP.

    I know many people are anxious to see and participate the Zend Framework. I note that it says January 2006 several places. Two questions:

    - Is there a timeframe for the first public betas of the Framework?

    - It there a timeframe for signing the CLA to join the development effort?

    ReplyDelete
  9. would be nice to have a threading extension for PHP, to make it more usable for general-purpose scripting. If you have threads, then you can start making a few things "event based".. like sockets (the way TCL implements it). That would be awesome

    ReplyDelete
  10. Andi, oh, I certainly agree that optimization should follow the implementation. I suppose I thought you were saying in general terms that there was no need for any of the code to be implemented in C.

    Anonymous, while I would concede that general purpose programming is possible using PHP, that is really not its intent. Perl, Python and Ruby already exist.

    ReplyDelete
  11. histoire erotique metro histoire salope bite chatte cul jouir nichon histoire x erotique histoire tunisie livre meilleure histoire drole histoire souris grenouille et cochon histoire de france en image cours histoire de l art histoire sans fin histoire ouest france gothic drole histoire blog histoire erotique maman histoire recits erotique gratuit histoire coquin gratuite histoire cochon de lesbienne histoire recit x erotique nouvelle histoire illustree enfant image et histoire drole histoire taboues histoire drole enfant histoire livre tueur fenetre histoire politique france 18e siecle contes et histoire pour enfant histoire maison edition monde histoire ville valence espagne histoire de la musique celte kevin cave histoire gay memoire sur histoire cinema histoire erotique sex 2nd histoire les fondements du monde contemporain info sur telephone portable histoire inventeur deug histoire de l art par correspondance reviser histoire niveau seconde monde grec histoire de la ville de paris histoire de femme attachee histoire cinema belge herbier and histoire and monde histoire and de and fessee histoire sexe antiquite histoire and sm histoire and aviation histoire domination sexuelle femme histoire parc disney land paris histoire image maternelle histoire costume assyrien antiquite assyrienne histoire sex pistols anneau intime histoire sm histoire cinema pornographique jeune garcon asiatique homme asiatique nu asiatique nu site groups.msn.com asiatique massage luxembourg photo fille asiatique photo asiatique acces et utilisation gratuit massage asiatique sexe restaurant asiatique rennes photo transsexuelle asiatique asiatique site rencontre photo asiatique poil rencontrer salope asiatique toulouse fille asiatique video gratuite de sexe asiatique de rencontre gratuit pour asiatique petite asiatique nu nouvelle escorte girl asiatique sur paris asiatique jeune belle fille blonde sexe asiatique mature video sexe asiatique amateur jeune asiatique nu gratuit dvd porno asiatique chat fille asiatique soin massage asiatique sexuel beauty asian boys video asian nude asiatique recoit jolie chat avec asiatique book asian boys free asian sex asian school girl asian big pussy asian amateur sex asian xxx girl asian mature nude sex asian college asian 4 you asian mature young boutique arme blanche asiatique asian hardcore video asian ass fuck little asian lesbian hot asian couple asiatique transsexuel asian black asian girl sexy asian ts free preview fucked pussy asian asian sex enjoy teen asian ass asian pussy fucked asian girl in bed asiatique en chaleur asian x epicerie asiatique paris xxx asian porno bizarr gallery hot asian asian lesbian free pics asian girls kiss asiatique recoit jolie young asian pussy asian young pussy asiatique charme nude asian fuck asian cum asian and dub and foundation asian teen pussies asian free porn film hot asian picture asian lady boy pre teen asian asian x model

    ReplyDelete
  12. Certainly a fantastic piece of work ... It has relevant information. Thanks for posting this. Your blog is so interesting and very informative

    ReplyDelete