FB Series: Java Guy starting with FB development

I recently started with PHP development. Although I have had some small exposure to the
language before, this was my first real project.

What are the big differences to the Java (web) development experience?

  • interpreted (no compiler to check for errors, just a parser)
  • dynamically typed (->no “parse-time” type checking in the IDE ..)
  • essential procedural, object handling completely rewrittten from version 4 to 5 now basic oo functionality
  • hunderts of statically callable base function; e.g. very easy to download & store a file: $contents = file_get_contents($url). However you see that many things grew historically without a overall concept: how do you test the existence of a substring in a string strstr | strrpos | stripos (hint 0 equals false))
  • Very “close” to the HTTP request-response model
  • the script execution is determined by the HTTP request (e.g. check ignore_user_abort )
  • MySQL and Postgres integration modules for persistence
  • Caching, Pooling is different due to the fact that a PHP process in its pure form only lives during one Web request:3 ways a PHP can run in a Web Server:
    - as CGI wrapper: instance of the php interpreter created and destroyed for every page request
    - module (e.g. mod_php, mod_fastcgi) in a multiprocessor web server like Apache. Apache/FastCGI can reuse php instances
    - plugin to web server

    This means that connection pooling is not really possible.
    Caching:
    - page scope: not necessary in php. All variables within includes are acessible
    - request scope: not supported natively, but can be implemented via session
    - session scope: see PHP Session. Data stored within a text file in php/tmp or similar. Data must be serializable (It is not possible to serialize PHP built-in objects!)
    - application scope: does not exist

  • Generally faster code-test iterations.
  • Quick infrastructure setup: Apache, php, Apache-php integration (e.g. mod_php), Editor.
  • More difficult to manage complex/larger projects because:
    - interpreted & dynamically typed: errors only found at runtime
    - Exception handling difficult
    - OO-shortcomings
    - …

This is just a short list of my thoughts, not striving to achive completeness.

This entry was posted in facebook, php and tagged , , . Bookmark the permalink. Both comments and trackbacks are currently closed.

One Comment

  1. Posted December 3, 2009 at 8:18 pm | Permalink

    interesting, my experience is similar but the other way round. I know php in dept and have recently moved into java. not to say the least, java is a beautifully designed language.
    I’ve never done a facebook app however and was reading the dev guides and got the link to your post there. FBML and and everything else seems to tie in quite nicely, knowing java and php in combination has made it easier for me to start working on a fb app. At least i think so anyway.
    nice post btw….