jd:/dev/blog

Our hopes and expectations, black holes and revelations.

Aller au contenu | Aller au menu | Aller à la recherche

jeudi, mars 27 2008

PHP applications code quality

Ah, Erich, that IS so true. I never found a well written PHP application anyway, or it was only 10 lines long.

I guess that's primarily the language fault. It permits to do a lot of stuff and does not simplify, help nor force the simplest implementation methods like MVC which should be the base in Web developement.

Well, take as example what we would do with Python and GTK+ if they were like PHP and HTML (I do not have the API reference so it will be somewhat improvised):

#finally we do not need this module I wrote everything myself
#import somemodule
def main():
    # Well we want to do some printing
    window = GtkWindow()
    # Connect to the database without any abstraction, that sucks
    db = mysql.connect()
    data = db.query("select RANDOMLYTYPEDDATA from MYONLYTABLE");
    while data:
        # Ah, we do not have include() so we cannot reuse code
        # I'm a PHP developer, I do not know functions
        import somestuff
    window.print(somestuff.result)
    # Obviously, forgot to close db connection, etc.
    if form.data.field == "hello":
        # The user asked for hello, print hello
        window.print("hello")
    # debug
    print data[0]
    if form.data.anotherfield[0] == "morning":
        data = db.query("select anotherdata from MYONLYDATA")
    else:
        sys.exit(42)
    label = GtkLabel()
    # Yes know we construct the view!
    window.add(label)
    label.print(data)

That is typical PHP code: we just take randomly typed data from our DB eng... no wait, from MySQL (remember that's LAMP!!! Not LAPP or anything else, bitches!), then we print some HTML code with data, and we do tests on environment, forms, etc, and we get back data, reprint them, do not use functions but include() multiple times thousand of files and then do not close/free anything.

It's so easy to do bad code that lot of people coming from nowhere and who did not learn anything from other languages are doing it.

Another hypothesis coming from my experiment: PHP is a language which can be developed under any OS since it's server-side executed. A link between mostly brain dead "developers" from the Microsoft world and whose from the Free Software world. A clash.

I apologize to some of my coworkers doing better PHP all the day. :-)

mardi, décembre 4 2007

rebuildd demo

I've set up a quick rebuildd demo. It may allow you to rebuild one of your package on etch/lenny/sid and for amd64/i386 as you wish. You will get build log by email.

I've just wrote the PHP page in 2 hours. I just hate Web interfaces and PHP is crap, seriously. For the record, I've tried to use DataGrid, and after having lost 1h to get it work with no PHP/PEAR error printed or available, I managed to have it working with a big pear upgrade-all. OMFG.

vendredi, mars 10 2006

php-sqlite3

I just packaged php-sqlite3 for Debian today, because I need it. Both PHP4 and PHP5 versions are available. It is uploaded in unstable and packages are available here, while the ftp masters moderate my packages.