Archive for February, 2006

Paris Forum 2007 : call for papers

Tuesday, February 28th, 2006

The AFUP, Association Française des Utilisateurs de PHP, is proud to announce the upcoming conference “Forum PHP 2007″. For this unique event in France, we are looking for the best French speaking experts, who want to share their know-how and enthusiasm. This two day conference features one technical day, with the most advanced PHP techniques and a business day, with case studies and examples of successful projects. The “Forum PHP Paris 2007″ will take place in Paris on Thursday and Friday the 21th and 22th of November 2007.Please send your proposals at bureau@afup.org. This email must contain the following information: namecompany if applicablea short (4-6 sentences) biography about your PHP experiencecomplete name and addressinclude photo for each speaker (JPEG format)Sessions will typically be 45 minutes long followed by a 10 minutes Q&A session.You are allowed to submit several proposals. The email must then contain the extra information: session titletarget audienceshort description (~10 sentences)

PHP compilers

Monday, February 27th, 2006

The number of implementations of PHP continue to rise and rise. Among those I can list are:

  • Recently, Caucho wrote a PHP5 to Java bytecode compiler and built it into their Resin server. There’s not much information, but in the link, look for thread responses by Scott Ferguson, the compiler author.
  • The experimental Pint, a PHP to parrot compiler.
  • The commercial Roadsend PHP to binary compiler.
  • The .NET framework Phalanger, a PHP to MSIL compiler (added 22 Dec 2005).
  • The original mod_php from php.net.
  • The PHP4Mono compiler for Mono (added 27 Feb 2006).

I am excited about all these implementations. Most computationally intensive compiler benchmarks have shown a 5-10 times speedup over mod_php. Perhaps it is only a matter of time before we see a JIT compiler for PHP to Intel opcodes, built into mod_php…

A more curious question is why there has been so little takeup of these faster technologies. Some speculation here:

  • PHP is fast enough? The bottleneck is the database or the network, and not PHP?
  • PHP 4->5->6 is changing too fast to trust someone else?
  • No formal PHP specification or conformance suite makes switching more risky?
  • Not all PHP extensions or libraries are available on other platform?
  • Lack of knowledge or awareness? Or are we still in early adopter stage?

Why I Like PHP revisited

Sunday, February 26th, 2006

A quick response to all the “PHP sucks” postings listed in PHP Developer that were sparked by Tim Bray’s original PHP rant.

Yawn… been there, said it before.

But given that I like a good controversy, and our memories are short, here’s my view again:

  • When I first coded in PHP, I treated PHP as a better Javascript that I could use on the server-side. True Javascript isn’t perfect either but we all use it for designing user interfaces and web apps. And if we can accept Javascript (an admitted hack by its designer) as a language for enterprise use, then it seemed obvious to me that there was no reason why PHP isn’t suitable for the Enterprise: PHP has a familiar C-style syntax, it scales, PHP has builtin support for the template pattern (the very heart of MVC if you like it), you can write modular code, use inheritance, and code in teams.

    It’s just some people don’t like it and snipe at the edges.

  • PHP is, and not by some twist of fate, good for developing web apps. Allowing HTML and PHP to intermingle in a .php or .inc template is pretty good. It maps to a very natural way of working. So the success of ASP, JSP and PHP are not really by accident. In contrast, you can write pretty awful Python or Java code to output HTML using print or java.io if you don’t use a template pattern, which is built into PHP!

    There have been abuses of the template language, notably PHP Nuke (and not only by others, i’ve been guilty too), driving serious programmers to scoff at PHP. I think they need to do more and read less.

    Take my example: when I first started trying out PHP, I didn’t worry about all the code abuse I saw out there. I’ve coded in Perl, and seen the same shit before. What I did to try PHP was write some web pages to see how easy coding was, wrote some OOP classes (the start of ADOdb), then benchmarked the results. Based on my checklist, i knew it was good enough, and that was in early 2000:

    1. Support for classes and modular code: yes.
    2. Easy to code: yes.
    3. Easy to teach and plentiful docs: yes.
    4. Templates: yes (the first release of Smarty was the clincher).
    5. Speed: faster than ASP based on my benchmarks.
    6. Scalable: near linear scalability based on my apache-bench tests.
    7. Customizable: err, its open source…
    8. Platform agnostic, no anti-Microsoft idealogy: yes, support for Windows not an after-thought.
    9. Large PHP community and high potential for growth: yes and yes.

  • PHP also has a great library of functions for string manipulation, database access, graphics manipulation, and for accessing weird but useful external software such as memcached. Does PHP have library inconsistencies? Yes, probably inevitable given the enormous size of the standard library of extensions and the open source nature of its development. Are the inconsistencies important? Probably not, unless you don’t want to use PHP.

  • PHP breaks down the ivory towers (thank god!) Unlike Java or Python, you can have a team with different skills using PHP. The hardcore programmers build the core libraries, and the web designers and more sociable programmers working on the user interfaces, all coding in PHP.
  • PHP is mainly a string processing language. That makes it really good for manipulating HTML. Features like “0″ == “” and weak-typing work well for text processing(see note 1). Some people have said that PHP’s Unicode support is not fantastic. Agreed, there is not enough native Unicode support outside UTF-8; but despite that PHP has been a fantastic success even in countries using double-byte languages. That cannot be by accident or due to ignorance.
  • The only real PHP gotcha is that PHP cannot do everything. PHP is good for web app user interfaces and business rules, and as a shell scripting replacement. If you look at big PHP apps, the stable core is written in another language, C/C++ (Yahoo), or Java (Ning), or PL/SQL (my company). In a sense, all the interesting techie stuff in PHP is happening at the C level, in the PHP extensions: in pdo, gd, oci8, mysqli, etc. Everything else, PEAR, Smarty, Drupal, Sympony, ADOdb, PHPLib etc, is just fluff :)


    PS: But if you’re really good, you can build 90% of your enterprise app in PHP. See Flickr’s architecture (pdf).

  • If you are looking for a better Java or its replacement, sorry it hasn’t been invented yet. PHP doesn’t come close. I do think that Jython comes close, but it lacks the Java-style syntax required to make it really popular, and there’s no one (that I know) speeding up Jython the way Jim Huginin is tuning IronPython for .NET.

Note 1: You use strlen($str) == 0 to check for empty strings - that’s a fundamental string-matching pattern in PHP.

Also see Harry Fuecks pro-PHP rant.

Inserting Multiple Rows with One Database Call Using PHP and Oracle Collections

Friday, February 24th, 2006

How to use Oracle collections to improve the efficiency of PHP scripts that feature multi-row inserts

Is PHP4 the new perl?

Tuesday, February 21st, 2006

Tim Bray, one of authors of XML, voices concern about PHP:

If you want your ears bent back, have a listen to Zend CEO Doron Gerstel; he’ll tell you that half the websites in the world are powered by PHP and that there are 2½ million developers and that the war is over and PHP won. So here’s my problem, based on my limited experience with PHP (deploying a couple of free apps to do this and that, and debugging a site for a non-technical friend here and there): all the PHP code I’ve seen in that experience has been messy, unmaintainable crap. Spaghetti SQL wrapped in spaghetti PHP wrapped in spaghetti HTML, replicated in slightly-varying form in dozens of places.

But in the big picture, it feels vulnerable to me.

Vulnerable? I think Tim Bray misses a key point…

The fact is that most Javascript, HTML and PHP (or ASP or Perl for that matter) out there is messy, unmaintainable crap. And that’s why all the above technologies are so popular. They can be used by ordinary people with minimal training. Conversely, you can write clean, maintainable Javascript, HTML and PHP too, but it takes education, discipline and willpower — not everyone is creating enterprise web-sites where everything is rigorously defined. Read the discipline of PHP.

As a corollary, one of the probable reasons the takeup of PHP5 is so slow is because PHP4 provides sufficient hacking power already. I think PHP5 is more attractive to people who want to code with rigor.

So is PHP4 perl for the web? PHP can be used or abused, just like perl. The abuse is what makes it popular :)

Yahoo! Goodies: UI Library and Design Patterns

Sunday, February 19th, 2006

Yahoo has recently released their Design Pattern Libary. As they mention on their site:

Welcome to the Yahoo! Design Pattern Library. We are very happy to be sharing our library with the design and development community. This is our first drop of what we hope to be a monthly release cycle for the publication of patterns. In many cases we have bundled the patterns with pointers to related code from the Yahoo! User Interface Library.

I had a look at some of the patterns. Navigation, breadcrumbs, pagination, auocompletion… Not quite what i expected: these are user interface guidelines, not coding patterns that explain ways of implementing these guidelines. Useful, but don’t be misled.

The User Interface Library includes libraries for drag and drop, animation and othehr interesting stuff under a BSD license. Widgets provided include Calendar, Slider and Tree View. The widgets don’t seem particularly interesting (there are good alternatives out there), but the attractive thing about these libraries are that they have probably been thoroughly tested on more browsers than I could possibly test on.

PHP Life : The Oracle

Tuesday, February 14th, 2006

After a short break the PHP Life team are back. In this strip we look at the Zend/Oracle deal. If Oracle do buy-out Zend then let’s hope things fare better for the Zend staff than Oracle staff at the moment!
Continue reading “PHP Life : The Oracle”

PHP @ FrOSCon: Call for Papers

Wednesday, February 8th, 2006

The Free and Open Source Conference (FrOSCon) 2008 is a two-day conference on free software and open source. It will take place on August, 23th and 24th 2008 in Sankt Augustin near Bonn, Germany.The PHP Usergroups Dortmund, Köln/Bonn and Hamburg are cooperatively organizing the PHP track as a sub-conference of the FrOSCon. The call for paper is now open.

Improving Performance Through Persistent Connections

Thursday, February 2nd, 2006

The concept of persistent database connections is a question mark for many PHP developers. When exactly is it a wise decision to use them?