The talk was put on by LAPHP, and the speaker was Rasmus Lerdorf. The topic was "PHP in 2011," and it discussed how PHP fits into the current technology stack, followed by an overview of what you should and shouldn't be doing, along with a summary of new and upcoming features in PHP 5.3 and PHP 5.4.
Rasmus Lerdorf is known for having gotten the PHP project off the ground in 1995 and has contributed to a number of other open source projects over the years. He spent 7 years at Yahoo and has since worked for and consulted with various startups. He was born in Greenland, grew up in Denmark and Canada, and has a Systems Design engineering degree from the University of Waterloo.
The full "slides" for Rasmus's talk are here.
From the moment I found out that PHP is a recursive acronym (standing for "PHP: Hypertext Processor"), I found the language cute. While I personally feel the syntax leaves much to be desired in terms of prettiness, the language clearly gets the job done.
Below are my main observations and notes on the talk.
- Rasmus seemed like a very approachable and down-to-earth guy. Definitely doesn't flaunt nerd celebrity status.
- Not traditional hacker background
- He doesn't even have CS degree.
- Likes solving problems, not writing code
- Hated repeating code
- Wrote PHP to program less and enjoy his weekends
- Wrote language to be functional and easy to grasp
- Web programming was never sexy for good programmers
- Thus, non-technical people had to build the web.
- Made it very easy to just add PHP tags to existing web pages and make them dynamic.
- Wrote documentation before wrote code
- PHP written in C
- Was always speed freak; hated slow calls to perl interpreter
- Wanted to embrace architecture of web: store nothing/stateless approach
- Mosaic first graphical web browser came out; start of real web
- 1993: Started with basic templating system using HTML comment tags
- Used yacc and lex to write PHP v2
- 1995: Introduced <? tag (process instruction from SGML)
- Others said should label his tag (forgot to read that part of SGML) so now <?php. He likes to read only as much to feel like he understands and then moves on (sometimes not the best practice).
- 2003: added classes/OO
- PHP has 1/3 of web market share
- Only .NET close to PHP in market share
- Yahoo switched all to PHP in 2002 across thousands of servers; stateless design allowed parallelization
- FB using PHP
- PHP did not allow you to modify web server like mod_perl so could be shared on ISPs (important for adoption)
- Limiting CPU time, file system access were other strategic features for ISP growth
- Added 5 second Atom parser to print XML content in 1 line
- Geocoded Twitter search example
- Worked at Yahoo for 7 years
- Created YQL: Yahoo Query Language: like SQL selects from various web APIs
- Geocoded Flickr photos example
- New CSS: shadows, rotation of divs, rounded corners example
On his mind for 2011
- PHP 5.4
- Continuous integration
- Node.JS and PHP
- ZeroQM: message queuing
- Gearman worker management in PHP-FPM: offloading jobs to other processes to run in background
- Getting a "real" job :)
- Rewriting 10 year old presentation system
- He also helps startups get going well on PHP
- MongoDB, MySQL, Couchdb
- Redis, Gearman, Memcache, ZeroMQ
- Mod_PHP APC, PHP-FPM APC
- Apache, nginx
- Recommends nginx and PHP-FPM
- Sees a lot out there: nginx for load balancing frontend, Apache for web server
- Doesn't matter which web server you choose
- Latency and throughput both roughly stable
- Other stuff you do in generating dynamic data much more important
- Set error reporting to -1
- Use strace, look for ENOENT (should never happen)
- Look at stat cache to see if fills up
- Use a profiler, callgrind, xdebug
- Use "Inclued" tool to see a picture of include files
- Use Hiphop-PHP to do static analysis (Facebook's compiler for PHP to compile to c++ through g++). Can tell Hiphop just to analyze through --analyze flag to find undeclared variables and dead code.
- Put static assets on different domain/subdomain for CDN
- Keep cookies short and remember MTU size (max transmission unit for 1420-1500 bytes on TCP) for mobile. Includes all headers, so after headers maybe 600 bytes left.
- Don't overload web servers; don't set max serving to 200 (he never goes above 50-60 servers running no matter how beefy of machines; better to just add another machine)
- Use out of band processing: Gearman or custom via ZeroMQ (he prefers Gearman)
- Don't move relational data out of relational database
- Do move huge non-relational tables out of relational DB
- Be very careful about foreign keys. Avoid if possible. Can create deadlocks easily.
- Think hard about ORM, caching strategy
- Get on PHP 5.3
- Tie cookies to www domain
- Use other domain for all static content (helps w/ CDN)
- Better stack
- Constants in read-only memory
- Better exception handling
- Performance improvements
- MD5 faster
- 5-15% overall faster
- Added closures, namespaces, late static binding, garbage collector, nowdoc, restricted goto, ternary shortcut, __dir__, __callstatic, dynamic static calls, improved date extension, date create from format, better date error reporting, spl, FPM, OpenSSL improvements
- His secret: he likes to turn off the garbage collector because he's 1337 and still programs in vi
- FastCGI request handling, better memory handling, startup/shutdown, repeated run-time function binding, string constants, access to global constants, access to static properties, empty hashes, @ operator, unserialize(), removed features, traits, short array syntax, function array dereferencing, binary notation, improved errors, json improvements