| weblogs
come weblogs go |
| The most painful kind of generosity are the promises you cannot
fulfill. The people who were once so grateful then turn on you, and
your self-esteem is sure to take a beating.
Many years ago, in a fit of generosity, Dave Winer offered to
host all early-bird adopters of editthispage.com free hosting of
their weblogs. This included php.weblogs.com. Well Dave Winer
recently announced that he was closing down the weblogs.com and
editthispage.com websites. He no longer runs a company that can
support these sites and they are a personal and financial strain on
him.
I was disappointed, but I had no expectations that Dave would do
this in perpetuity. My momma taught me to keep my expectations low
when it comes to free things. After all, Dave and I have never met,
and I've only exchanged a couple of emails with him.
I had a feeling that something like this was going to happen
because the site has suffering from poor performance this past
month. So my contingency plan was to ship the weblog to a commercial
hosting service like weblogger if need be. During the weekend, just
before the site was cut off, and before any announcement by Dave, I
moved my most important open source project to sourceforge, to http://adodb.sourceforge.net/.
Today I got an email from Lawrence, Userland's webmaster: Subject: php.weblogs.com
From: "Lawrence Lee" deleted#userland.com
Date: Wed, June 16, 2004 1:46 am
To: jlim#natsoft.com
Priority: Normal
Mailer: Microsoft Office Outlook, Build 11.0.5510
We'll be continuing to host php.weblogs.com, we made special arrangements
with Dave to keep it running.
Lawrence
I didn't ask for special treatment, so this is a pleasant
surprise. Apparently the people at Userland decided to host this
weblog and Dave emailed me, saying he had nothing to do with this
decision. Of course I don't expect this offer to be permanent
either, and I will deal with that when the time comes. The website's
performance is still terrible though, and I have no expectations
about this either.
For those who ever wondered what the icon below each post means,
it's a graphic emoticon of how i feel. I think the jazz singer
Billie Holiday is an appropriate image for this post; her songs are
always bitter-sweet. It sure feels like Stormy
Weather or Come Rain
or Shine.
I would also like to thank those of you who emailed me privately
about this issue. RSS seems the best way to access this web-site at
the moment, as it continues to go down at random times.
Discuss (1
response) (Join /
Login first) Edit
permalink: #
|
| ADOdb
and PDO |
| PDO is a new database API that will be part of the official PHP
5.1 release. AFAIK, PDO will not be a full-fledged database
abstraction library, but will provide a standard database API for
PHP.
Here is a sample taken from the PDO download:
<?php
$x = new PDO("odbc:ram", 'php', 'php', array(PDO_ATTR_AUTOCOMMIT => 0));
$stmt = $x->prepare("select NAME, VALUE from test where value like ?");
$the_name = 'bar%';
$stmt->execute(array($the_name)) or die("failed to execute!");
$stmt->bindColumn('VALUE', $value); while ($row = $stmt->fetch()) {
echo "name=$row[NAME] value=$row[VALUE]\n";
echo "value is $value\n";
echo "\n";
} echo "Let's try an update\n"
$stmt = $x->prepare("INSERT INTO test (NAME, VALUE) VALUES (:name, :value)"); $stmt->bindParam(":name", $the_name, PDO_PARAM_STR, 32);
$stmt->bindParam(":value", $the_value, PDO_PARAM_STR, 32); for ($i = 0; $i < 4; $i++) {
$the_name = "foo" . rand();
$the_value = "bar" . rand(); if (!$stmt->execute()) {
break;
}
} echo "All done\n"; ?>
Highlights of PDO include the unified object-oriented API,
compiled statements are now first class objects (the PDOStatement
class), and better support for bind variables, which will give a
substantial speed boost for performance freaks.
Does this make ADOdb superflous? If you are looking for something
that just works with mysql, then ADOdb might not be for you. However
ADOdb still has a big role to play, because:
(1) ADOdb makes it easier to develop PHP apps that work with
multiple databases, with portable handling of data types and
schemas.
(2) PDO does not provide an infrastructure for enterprise
database access, such as recordset caching, sql logging and tuning,
and session management.
(3) If you come from a Windows background (like me), it is easy
to learn ADOdb because it follows many M'soft conventions.
So the next question is, how to extend ADOdb to support PDO? I
think we can retain the existing ADOdb infrastructure, treating PDO
as just another ADOdb driver. At the same time, we will add PDO
specific extensions to the ADOdb PDO driver.
So the classic ADOdb calling conventions will still work:
include('adodb.inc.php');
$DB = NewADOConnection('pdo');
$DB->Connect($host, $user, $pwd, $db);
$rs = $DB->Execute("select * from table where name=?",array('Jill'));
while (!$rs->EOF) {
var_dump($rs->fields);
$rs->MoveNext();
}
And we will add a new ADOdb statement class to support PDO
conventions: include('adodb.inc.php');
$DB = NewADOConnection('pdo');
$DB->Connect($pdo_connection_string);
$stmt = $DB->PrepareStmt("select * from table where name=?");
$stmt->Execute(array('Jill'));
while ($arr = $stmt->Fetch()) {
var_dump($arr);
}
Wez has more PDO
examples. A PDO
discussion at sitepoint.
Discuss (2
responses) (Join
/ Login first) Edit
permalink: #
|
| Catching
Uncaught Exceptions |
| Continuing my belief that the best way to learn the fine art of
programming is to learn from your better looking neighbours, here's
a very interesting article on using exceptions in Java that can be
applied to PHP5. Dr Kabutz (love the name), gives several excellent
real-world examples of how hard it is to handle exceptions.
Of course there are exceptions to the exceptions. Don't use an
exception when:
- the error is not really an error, but a change of state, such
an end-of-file condition. Confusing this point is the most common
beginner mistake.
- you want to write obfusticated code because your job has been
made redundant :-)
- the error is so difficult to fix that you have to write custom
code at the point the error occurred.
- you're still using PHP3, and planning to upgrade to PHP4 next
year :-)
- you are doing something mission-critical, and you want to
enumerate and handle every possible error where it occurs, to
ensure safety and timeliness.
- your very experienced boss tells you that it's better
to return an error code that is ignored than raise an exception
that is ignored :-)
Doug
Ross opinion on exceptions, and my
response. I also stumbled onto Jeff's
response while browsing around.
Discuss (2
responses) (Join
/ Login first) Edit
permalink: #
|
| Apache Penetration in
Asia |
| It's interesting to see that Malaysia is one of the few
countries where IIS is dominant. But it's not a big surprise because
Microsoft is very strongly entrenched in the Malaysian IT mindset,
definitely more so than in Europe or US. And although i'm a
long-time IIS supporter, these figures have made me realize that we
don't really care either way. A rough mental count tells me that 30%
of our websites are on IIS, and 70% on Apache.
| Rank |
Country |
Apache% |
IIS% |
| 1 |
Japan |
73 |
9 |
| 2= |
Indonesia |
70 |
23 |
| 2= |
Korea |
70 |
25 |
| - |
Global average |
67 |
21 |
| 4= |
Philippines |
60 |
24 |
| 4= |
New Zealand |
60 |
30 |
| 6 |
Pakistan |
57 |
28 |
| 7= |
Thailand |
54 |
38 |
| 7= |
Australia |
54 |
38 |
| 9 |
Taiwan |
47 |
46 |
| 10 |
Singapore |
45 |
40 |
| 11 |
Malaysia |
42 |
51 |
| 12 |
India |
41 |
49 |
| 13 |
China |
35 |
56 |
Discuss (3
responses) (Join
/ Login first) Edit
permalink: #
|
| Secret
# 812 of the PHP Kung Fu Masters |
| Keith Devens says: It turns out it's much faster to build
large strings from many smaller strings by concatenating them onto
one string than it is to append to an array repeatedly and then join
that array into a string. I timed it and was surprised by the
results.
But that's not Secret #812. Read what Joshua Paine has to say in
that post's comments.
Discuss (1
response) (Join /
Login first) Edit
permalink: #
|
| Using DataSets
to Lick Web Services |
| There's a debate on web services in the .NET world. Datasets are
XML objects that contain recordset information. You can perform
various operations on them (such as insert/delete/update) and they
can be replicated back to the host database. Developers are using
DataSets for data exchange in web services. MSDN has a good
article on this. Is this a good idea?
Scott Hanselmann doesn't think so, in this post: Returning
DataSets from WebServices is the Spawn of Satan and Represents All
That Is Truly Evil in the World. But Barry
Gervin thinks it's ok.
I agree with Scott, it's a bad idea. Exposing internal details is
usually a lousy idea for web services (or any API that has a public
interface). It defeats the concepts of information hiding and easy
interoperatability between heterogenous systems; it also provides
info that is potentially useful for sql-injection attacks.
What do you think?
Discuss (Join / Login first) Edit
permalink: #
|
| The Fruity
Taste of PEAR |
| You cannot help but like someone like Greg who is honest
and humble:
"I am one of the core developers of the PEAR package who has
joined the game relatively late... The base PEAR class is one
monstrous mistake, and PEAR_Error is pretty close. Everyone knows
this. I designed an error class that is much, much more flexible and
it is part of PEAR 1.3.1 (PEAR_ErrorStack) - check it out. "
Sadly it's just not true that everyone knows that PEAR class is
big mistake (Jeff Moore has more on why
PEAR.php is awful). Given that PEAR is both an important
framework and a worthless class, the confusion in names will
definitely cause the value of the PEAR class to be overestimated.
Just read any article on PEAR and you can see what nice words they
have to say about the base classes :-(
I once said once that too many PEAR developers were journeymen.
This might have offended some people, but I was trying hard to be
diplomatic. I must say that today the PEAR group is definitely more
mature, and they have learnt a lot about library design. What would
really make my eyes light up would be an PEAR2 initiative that kept
the existing classes, but dropped the bad seeds such as PEAR.php
(e.g. the PEAR and PEAR_Error classes).
And in case you were wondering, I do think there's great value in
the PEAR DB API. API's are important for interoperatability. For
example, ADOdb has a PEAR DB compatibility mode. I would certainly
be flattered if PEAR DB had an ADOdb compat mode too :-)
Discuss (1
response) (Join /
Login first) Edit
permalink: #
|
| Accelerating PHP
Applications |
| A great presentation by Ilia Alshanetsky from the International
PHP Conference 2004. The only thing I would like to point out is
that MMCache is still being actively developed, as evidenced by the
CVS
activity at sourceforge.
PS: You might need to use Mozilla to view this. IE sometimes
doesn't work properly. I thought IE was a defacto standard :-)
Discuss (1
response) (Join /
Login first) Edit
permalink: #
|
| The Spice of
Anticipation |
| Apparently PHP5 RC3 is going to be the last release candidate.
This is supposed to be coming out at the end of this week, so PHP5
will probably be released next month.
It's a bit like looking through a window into a candy store. The
sweetener I most look forward to is the improved object assignment
semantics.
Discuss (4
responses) (Join
/ Login first) Edit
permalink: #
|
| MSDN:
The Quest for ASP.NET Scalability |
| A little bit of cross-pollenization never hurt anyone. There's a
lot to be learnt from .NET:
At the height of the dot-com boom in the mid-1990's, many
companies burst onto the scene as Application Services Providers
(ASPs) hoping to capitalize on the wave of Internet success stories,
and rake in some loot. Aside from the unfortunate market collapse
that followed, ASPs had other issues to deal with such as training
staff to effectively build and manage a secure, reliable and highly
available operation.
Today, Web-enabling architecture is prevalent, particularly since
Web services have become a staple for most applications, and the
growing pains of ASPs past are feeding businesses everywhere with a
hunger for successful implementations for 24x7 applications. As
Service-Oriented Architectures (SOA) themes spread across
organizations, applications are now reaching wider audiences than
ever before. Gone are the days where you can sling some code, ship
product, and cross your fingers.
The key points that i see addressed in this article:
- You need to be able to handle long-running jobs, and you can
do that by storing the job in a queue to be handled later by a
background process. In the PHP world, this can be implemented by
storing a queue of jobs in a database table or shared memory. Then
you have a background process monitoring this table for new jobs
to run.
- Distributed processing to spread the load. COM+ is discussed.
In PHP, we could use XML-RPC or SOAP to work with a set of
distributed servers.
- And when you have distributed processing, you might need to
synchronize distributed transactions. This is something that's
difficult to implement in PHP, and it is probably best to
structure your design to allow only a single master software to
perform data synchronization, instead of allowing multiple
masters.
For example, in the typical PHP-distributed MySQL scenario, you
would have one single master database which you write to, and
multiple read-only slave databases to which the changes are
replicated to.
Discuss (Join / Login first) Edit
permalink: #
|
| Return-codes
vs. Exceptions, Part 129 |
| Doug Ross, CTO of BadBlue (which sells a mean web server that
runs PHP), has a nice recap of the debate on how to handle errors.
Should we use error codes or exceptions? Doug weaves a nice story
around several people's opinions. I totally agree with Doug with
regards to real-time software (you want to handle the error as soon
as possible with an error code).
However that's not the way I would want to write financial code
nowadays. With the relational databases we now use, I'm more likely
to throw an exception and perform a database rollback in the
exception handler.
In general, technologies that provide timely automated resource
cleanup (such as database transactions) make throwing exceptions
practical for industrial strength apps.
New: Wez talks about Structured
Exceptions in PHP. Looks interesting, but I would like something
more elegant if possible.
Discuss (2
responses) (Join
/ Login first) Edit
permalink: #
|
| Who Wags the
Dog? |
| I see many popular PHP web sites linking to the recent
nonsensical "Scalable Applications with PHP" article at
linuxjournal.com. Guys and gals, you may think that its your duty to
link to any PHP article that comes out, but you really have to show
more perspicacity. By linking to nonsense articles, you are allowing
the
tail to wag the dog.
Discuss (Join / Login first) Edit
permalink: #
|
| Toy Poodles and
The Real Thing |
| I cannot imagine why anyone would write this dog of an article
called Writing Scalable Applications with PHP (at
www.linuxjournal.com/article.php?sid=7593). There's no real
discussion of scalability at all; the article talks very
superficially about database connectivity. Why bother writing? For
lame bragging rights perhaps? My respect for Linux Journal continues
to drop.
In contrast, George Schlossnagle writes a really good article on
Scaling
Oracle and PHP. Congratulations to Oracle for continuing to
support PHP. And George, you the man!
The only thing I would have liked included in George's article
was a more thorough discussion of Oracle's
Shared Servers (formerly MTS). Unlike George, I have found it a
good connection pooling solution when properly tuned, definitely
better than PHP persistent connections.
Discuss (4
responses) (Join
/ Login first) Edit
permalink: #
|
| Harry
Fuecks: About PHP usage |
| Another (guess) big user group which is largely ignored is
those employing PHP on corporate Intranets / Extranets (that
includes me so I've got opinions). I would hazard a guess that of
the top 1000 companies in the world, 80%+ have PHP in action
somewhere (although probably also unaware of the fact at a
managerial level).
This group faces an entirely different set of problems -
performance is often less important, traffic being relatively low.
Being able to integrate PHP with a whole range of "back office"
systems as well as desktop applications is the biggest issue for
this group, integration with Windows being the #1 problem.
Great post, Harry. Most of my PHP work is on corporate
Intranets/Extranets. Integration with MS Office is the biggest
desktop hurdle we had to face. For reports and document generation,
this can be solved by generating MS-Word files in RTF format or
Excel format. There are several such document libraries available
(both commercial and open source).
PHP allows you to call COM objects. However if integration to COM
objects is required, then writing XML-RPC stubs that communicate
with servers running COM objects is definitely more robust than
calling COM from PHP.
I must admit performance is still an issue, especially if you are
rolling out web applications that are used by large numbers of
users, eg. for online transaction processing. Fortunately, bandwidth
is normally not a problem, except for Extranets that allow
connection via modem.
Discuss (Join / Login first) Edit
permalink: #
|
| Slashdot:
The Hardened-PHP Project |
| Stefan Esser is the author of the Hardened PHP project. Reading
through the feature-list, i cannot help but feel that some of these
features should have been rolled into PHP's standard safe-mode.
Implementing it as a set of patches just means a lot more work for
everyone, particularly the maintainer.
Some of the responses to this post were quite interesting. Among
other things, PHP appears to be a great programming tool for porn.
Discuss (Join / Login first) Edit
permalink: #
|
| Self-replicating
PHP |
| Doug Ross solves this interesting problem in PHP: to write a
source program that, when compiled and executed, will produce as
output an exact copy of its source. This is trickier than it
sounds, because using the file system or intermediate storage is
cheating.
I admit i looked at Doug's code with sheer incomprehension, so I
turned off the computer and went to the shower. If you want to solve
this problem yourself, read no further.
While showering, I thought of various tricks using eval() and
output buffering. They don't seem to work. After mulling over the
alternatives while towelling myself dry, I realized that the
solution involves dividing the code into replication and payload
modules. The payload is the replication code, stored as a string.
The replication code will output the payload twice, once as PHP code
(the replication code replicated), and once as a PHP string (the
payload replicated).
Does the above algorithm sound familiar? It's one that every
virus writer knows by heart!
Discuss (1
response) (Join /
Login first) Edit
permalink: #
|
| The
Business of Software |
| Eric Sink writes a
column on the business side of software for MSDN. Excellent advice.
My favorite quote:
When I was interviewed after SourceGear won the Inc. 500 award
in 2002, they asked me to share the biggest surprise of my
experience as an entrepreneur. I told them my biggest surprise was
that someone could make as many mistakes as I have and still end up
on the Inc. 500 list. :-)
Discuss (Join / Login first) Edit
permalink: #
|
| The
Delphi Team: Why We Blog |
| Secrecy was the norm, to prevent an agile competitor from
"scooping" an idea and bringing it to market first. But today,
development tools and operating systems are so unimaginably complex
that nobody can turn on a dime to scoop anything. There are so many
major platform milestones on the horizon that it's pretty obvious
where the bulk of the tools work must go. I mean, seriously, does
anyone really believe that a Delphi toolset for the "Whidbey" .NET
2.0 platform could not support generic types? Generics are a given,
or die. So are many other platform artifacts.
A great insight into today's IT industry. Of course for niche
players, secrecy will often still be the norm, because it's at the
fringes that the really interesting stuff is done.
Discuss (Join / Login first) Edit
permalink: #
|
| Migrating
from PHP 4 to PHP 5 |
| Derick Rethans discusses the new object model and other changes.
Has an interesting discussion on E_STRICT, which i don't know much
about. Presentation from the recent PHP conference.
Discuss (Join / Login first) Edit
permalink: #
|
| Does Microsoft
care about web standards? |
| As one developer on Microsoft’s Channel 9 blog recently noted
about Visual Studio, "creating xHTML compliant websites is a pain in
the ASP.net".
Though I do not want to support Microsoft here in their disregard
of web standards, I have to point out that striving for xHTML
compliance is meaningless. The idea of xHTML was to make parsing the
contents of a web-site easier, but no one does this - it's too
difficult. Why do you think simpler formats such as RSS or
(god-forbid) Atom are becoming so popular?
Discuss (4
responses) (Join
/ Login first) Edit
permalink: #
|
| AMD beats
Intel in desktop processor sales |
| The only thing constant is change. I'm surprised too.
On another note, the recommended hardware for Longhorn is amazing:
Microsoft is expected to recommend that the "average" Longhorn PC
feature a dual-core CPU running at 4 to 6GHz; a minimum of 2 gigs of
RAM; up to a terabyte of storage; a 1 Gbit, built-in, Ethernet-wired
port and an 802.11g wireless link; and a graphics processor that
runs three times faster than those on the market today.
Discuss (2
responses) (Join
/ Login first) Edit
permalink: #
|
| Martin
Fowler: Can average developers use agile methods?
|
| I've often heard the claim that agile methods can only be
used by the better developers and that average or below average
developers should avoid agile methods. When I get asked this, I have
to answer that I don't know the answer - and that this ignorance is
natural with any new technique.
Two points.
First Martin points out that the
bazaar (open source methodologies) is an agile method. Secondly,
although PHP in itself is not an agile metholodogy (err, its a
language), it has a pragmatic flavour that makes it suitable for
people of all levels.
Two opinions.
I believe the wide growth of open source and even more explosive
popularity of PHP is proof that agile
methods work with people without expensive computer science
degrees. However if Martin is trying to say that you cannot create
great projects with only mediocre contributors, than i agree. Good
leadership is always important. Ask Linus.
Discuss (5
responses) (Join
/ Login first) Edit
permalink: #
|
| Overblown,
overrated, overhyped |
| Too many open source advocates complain about Microsoft writing
terrible buggy software and think that open source developers do it
better. The truth is Microsoft is innovative, has vision, and
executes well. If open source developers can do as well as
Microsoft, it's a big compliment. Smart people like Miguel de Icaza
and Brendan Eich have known this for a long time. Miguel has a
reality check for these innocent virgins, giving his
assessment of the potential of XAML and Avalon.
Brendan (one of the Mozilla leads) has a frank
assessment of Mozilla too. Not too positive. I talked about this
last
year.
However i think that Miguel and Brendan are just hyping things
up. XAML and Avalon may be great technology but no one is waiting
for Longhorn to implement web based apps - everyone is implementing
them NOW!
New: Secondly, Longhorn is supposed to be
out in 2005. Given typical
rates of penetration of operating systems, i would expect
Longhorn to achieve perhaps 30-35% market share in 2008, less if
Linux on the desktop is successful. Would that be considered
critical mass? I don't think so. Instead it means that the browser
market will fragment (DHTML vs Longhorn vs XUL vs Flash), and
developers will have even more confusing choices.
An
introduction to Avalon by Charles Petzold.
Discuss (1
response) (Join /
Login first) Edit
permalink: #
|
| In Praise of
Psyco |
It may be madness to praise Python on a PHP blog, but I just
have to add a pointer to one of the most amazing pieces of software
I have every seen. Pysco is an JIT compiler for Python that is
(nearly) totally transparent. We are using Python for some data
mining apps, and the following 2 lines speeded up our code by 250%: import psyco
psyco.full()
There is an even more amazing post where the author of Psyco
discusses Python
is faster than C because a JIT compiler can better handle
polymorphic data types.
Apparently Pysco will be rolled into the official Python release
when it becomes more mature and cross-platform (it runs well only on
x86 at the moment). It would be wonderful if PHP moves in this
direction in the long run, whether by running on top of Parrot or
another JIT.
Discuss (6
responses) (Join
/ Login first) Edit
permalink: #
|
| Why MySQL grew so
fast |
| This must be MySQL week - no coincidence, given the recent MySQL
conference. Andy Oram, editor at O'Reilly talks about MySQL:
MySQL represents the most impressive market success, exceeded
only perhaps by Apache, in free and open source software. In terms
of installed base, MySQL has left the technically impressive rival
PostgreSQL in the dust. It has marginalized mSQL, SQLite, and SAP DB
(the last of which I'll return to later). It has started to
challenge the proprietary database companies on their own turf, as
already mentioned. Nobody can say why licensing costs for
proprietary databases have plummeted in recent years, but one
suspects that it's due to MySQL's competition, as are the large
discounts Microsoft has offered certain customers.
Discuss (1
response) (Join /
Login first) Edit
permalink: #
|
Friends,
Romans, countrymen, lend me your ears; I come to bury MySQL, not
to praise him. |
| Yesterday we cheered MySQL. Here's the flip side. Ken Jacobs,
Oracle's VP of product strategy is interviewed by eWeek:
Q: What kind of a threat does Oracle see open-source databases
being, say, five years down the road?
MySQL production releases have typically been two years apart,
and the time from alpha [first release] to production is about 1.5
years. They released Version 5.0 in alpha status in December 2003,
so a reasonable expectation for production release of Version 5.0 is
mid-2005.
It should be noted that MySQL Version 5.0 introduced stored
procedures but not triggers or views, both of which are essential
for significant enterprise applications. It appears unlikely that
MySQL could introduce these critical features much before mid-2007.
A whole wide range of additional capabilities including but not
limited to XML and analytic—i.e. business-intelligence—features do
not appear to be on the MySQL radar.
Furthermore, the low level of resources available to MySQL to
fund development and the very small size of their development team
raise questions about the viability of the MySQL business model and
technology development path going forward.
It is unlikely that MySQL can rapidly accelerate development of
their core product while acquiring and integrating disparate
database technologies like the SAP DB (now called MaxDB) or MySQL
Cluster. Indeed, this sort of 'engineering by acquisition' is a
distraction and fragments their development efforts.
Apparently some PostgreSQL developers concur.
Discuss (3
responses) (Join
/ Login first) Edit
permalink: #
|
| MySQL
Conference Roundup |
| Russell Beattie has an excellent MySQL conference roundup.
My notes of their notes:
From Jeremy's
post, it looks as if MySQL Cluster uses a new in-memory table
format, NDB. The benchmarks are impressive on a 72 CPU Sun Fire
server. Has limitations: 8K rows, no online reindexing, etc. Based
on internal R&D from 1996.
Yahoo is using MySQL for some mission-critical apps. There is an
internal battle between Oracle and MySQL advocates for such apps.
LiveJournal discusses memcached, a distributed
caching system. There is a PHP api for
memcached.
Sabre
is extremely impressive.
Discuss (4
responses) (Join
/ Login first) Edit
permalink: #
|
| Refreshing
them jaded eyes: Dan Sugaski writes a parrot compiler
|
| Yesterday i talked about being jaded.
Here's what I find fascinating:
Neither rewriting [DecisionPlus] nor ditching it for someone
else's software was an appealing option, especially given that the
reason to do so was essentially an internal issue and mostly
invisible to the users. We decided instead to do the sensible
thing—we rewrote DecisionPlus. Or, rather, we wrote a compiler that
understood DecisionPlus and, rather than targeting the DecisionPlus
virtual machine and runtime that was causing us problems, we
targeted a newer and less restrictive system.
That may sound mad, but it really was the simplest thing to do,
by far.
However what i found interesting was not the nuts-and-bolts of
implementing a compiler (jaded look again). It's the project
management side of it: why the decision was made, how long it took,
etc. The details on writing a compiler can be found in any text book
(or learn it by reading Zend Engine source if you want to go mad!)
What's hard to estimate is how long it will take, and when you can
justify the project.
PS: People are also writing
compilers that emit PHP code.
Followup
by Dan (20 Apr)
Discuss (Join / Login first) Edit
permalink: #
|
| The inimitable Philip
Greenspun and Software Engineering for Internet
Applications |
Nowadays I admit i hardly have time to read a chapter, let alone
a whole book. Squeezing fresh knowledge from technical books
continues to grow harder and harder. After a while my eyes just blur
as i read about HTTP for the thousandth time. It takes an excellent
writer like Philip to keep these jaded eyes open.
This is the textbook for the MIT course "Software Engineering
for Internet Applications". The course is intended for juniors and
seniors in computer science. We assume that they know how to write
a computer program and debug it. We do not assume knowledge of any
particular programming languages, standards, or protocols. The
most concise statement of the course goal is that "The student
finishes knowing how to build amazon.com by him or herself." Other
people who might find this book useful include the following:
- professional software developers building online communities
or other multi-user Internet applications
- managers who are evaluating packaged software aimed at
supporting online communities--the various chapters contain
criteria for judging the features of products such as Microsoft
Sharepoint or Microsoft Content Management Server
- university students and faculty looking to add some
structure to a "capstone" project at the end of a computer
science degree
If you're confused by the "student knows how to build
amazon.com" statement, we can break it down in terms of principles
and skills. The fundamental difference between server-based
Internet applications and the desktop applications that students
have already learned to build is that server-based applications
have multiple simultaneous users. Coupled with the unreliability
of networks this gives rise to the problems of concurrency and
transactions. Stateless communications protocols such as HTTP mean
that the student must learn how to build a stateful user
experience on top of stateless protocols. For persistence between
clicks and management of concurrency and transactions, the student
needs to learn how to use the relational database management
system. Finally, though, this goes beyond the simple standalone
amazon.com-style service, students ought to learn about
object-oriented distributed computing where each object is a Web
service.
PS: This is a free online book.
Discuss (3
responses) (Join
/ Login first) Edit
permalink: #
|
| Storms on the
Horizon |
| It appears that both PEAR and Java continue to swim in stormy
waters. In two separate stories:
- Harry
Fuecks discusses the pickle over PEAR. IMHO, a small group of
people have control over the direction of PEAR. If you like what
they are doing, then great. If you don't, you get into these
discussions to let off steam.
- James
Gosling responds to Java sellout rumors by Sun. However the
question as to whether Sun can transform themselves into a more
diversified company without imploding remains to be seen.
Discuss (1
response) (Join /
Login first) Edit
permalink: #
|
| Xen
|
| Interesting ideas in Xen in the XML arena. I do admit however
that I'm more interested in Xena
than XML or Xen.
Another article
on Xen.
Discuss (Join / Login first) Edit
permalink: #
|
| Ronco
Spray-On Usability |
| By focusing on Aunt Tillie (the archetypal nontechnical
user), Raymond is ignoring the actual depth of the problem. It’s
easy to say, The open source community needs to do better, we need
to create software Aunt Tillie can use. But they’re so far away from
this right now that even an expert like Eric Raymond can’t figure
out how to use their software.
The strange thing is that there are many successful open source
PHP projects with rich UIs such as phpBB or any of the Nuke
variations that are used by non-programmers every day. To ask C
hackers - especially those who have no respect for users - to write
usable software is perhaps a bit too much. I think PHP coders do
this better.
Discuss (Join / Login first) Edit
permalink: #
|
| Miss
Otis Regrets |
| When you are young and stupid, you can be excused for a lot of
things. One of the most popular articles on this site is 7 Reasons Why PHP is
Better than ASP. The truth is that I cringe everytime i see
someone linking to this in my referer logs.
I wrote this several years ago in my early enthusiasm for PHP. I
now believe that neither PHP nor ASP are better. They are just
choices. Some say to-may-to, others say to-mah-to.
Here's another weird article comparing
PHP and ASP.NET. This time I didn't write it (luckily!) In the
review, ASP.NET gets a "weak" for speed and efficiency. Huh? Where
are the benchmarks? A careful reading also reveals that the author
doesn't even understand how .NET works. And if IIS is a liability,
so is Apache
2.0. Sloppy, sloppy, sloppy.
As i write this at home, American Idol is playing on TV on
Star World. I'm definitely writing under the influence of Simon
Crowell.
Discuss (3
responses) (Join
/ Login first) Edit
permalink: #
|
| Don't
Wait |
| Michael Harrison, an English poet, was once asked how to become
a good writer. He replied, "If you want to be a good writer, write.
You don't wait for inspiration."
Don Box, co-author of SOAP, gives similar advice in the above
link:
- Read fewer specifications,
- write more applications,
- write less code by using tools that generate code
automatically,
- and remember that humans matter, so if you must write a
specification, make it legible.
And John's advice is: "You can be hasty, but keep a backup!"
Discuss (Join / Login first) Edit
permalink: #
|
| Rampaging
Computer Science |
| Russell Beattie (and Jamie Turner) talks about the trouble with
Java, and contrasts it with PHP:
The problem is that much of the Java stuff out
there is just written by really smart morons who seem to love
complexity for complexity's sake... When programmers respect
patterns more than solutions, you know something is broken.
I loaded up my first PHP application the other day (dotProject)
on a test server and dived into the code, you know what? There's
no secret! The code was ugly and embedded and duplicated and
horrible. But it was done, and being maintained and being
documented and basic enough so that everyone could understand it.
:-) The most backhand compliment to PHP i have ever read. It's so
ugly and horrible that everyone can understand it.
Is there a name for this type of development?
Solution-Oriented Programming? Functional Development? Useful
Coding?
I would call it Rapid
Application Development (RAD). The key point of RAD was to use a
4GL or visual tools for speed, have milestones, and to timebox (this
means finishing on time with reasonable quality assurance is more
important than anything else).
Many people have dropped the milestones and timebox requirement,
thanks to expensive marketing such Delphi's or VB's
that claim they are support RAD. So nowadays, any software tool that
allows you to create apps quickly is called RAD.
Jamie Turner's original
article.
Discuss (5
responses) (Join
/ Login first) Edit
permalink: #
|
| Review:
Advanced PHP Programming |
| Reading Advanced PHP Programming by George Schlossnagle feels
like looking into the mind of a true PHP guru. I know George has an
intimate knowledge of the PHP internals and Zend engine, and is an
expert on PHP performance tuning. The book also covers PHP5, and
most of the examples are in PHP5.
Like most of the best gurus, George has a clear style and direct
approach. For example, in the chapter on templates, he says of
Smarty:
Smarty is one of the most popular and widely
deployed template systems for PHP... Smarty has a good bit of
bloat that I think is best left alone. Like many template systems,
it has grown in a number of ill-advised ways that allow complex
logic to appear in the templates. Of course, features can be
ignored or banned on the basis of policy.
And he writes about PEAR:
Throughout the book, I use a number of PEAR
classes. In both this book and my own programming practice, I
prefer to build my own components. Especially in
performance-critical applications, it is often easier to design a
solution that fits your exact needs and is not overburdened by
extra fluff. However, it can sometimes be much easier to use an
existing solution than to reinvent the wheel.
The range of technologies covered is very wide, including
Templates, Caching, Databases, Sessions, RPC, Server Farms, Proxies,
Benchmarking, Profiling, and Zend Internals. All the parts I read
show George has spent a lot of time thinking and designing
technologies in these areas. His discussion on performance tuning
PHP is particular good. In many places, I can remember going through
the same blind alleys he went through. At the end of each chapter,
there is a further reading list - nowadays one book is never enough
to cover everything. I also have a feeling that George is careful to
write about areas in which he has the appropriate expertise. For
example, I did not see any reference to PDF or GD usage in the index
or in the text.
Another thing I like about Advanced PHP Programming is that it is
not merely a discussion on advanced PHP technologies. There are
several chapters on design; these include chapters on PHP coding
styles, design patterns, unit-testing, CVS and packaging, designing
APIs.
In conclusion, this book is a one of the two best books on PHP i
have ever read. The other book is PHP
and MySQL Web Development by Luke Welling and Sarah Thompson,
which is an excellent introduction to PHP and MySQL. Both books
complement each other. Highly recommended.
Discuss (2
responses) (Join
/ Login first) Edit
permalink: #
|
| PHP 4.3.5 just released |
| I'm still at PHP 4.3.3 and have no intention of upgrading as I'm
not affected by these bugs. But you might be interested in the new
release if you need the bug-fixes.
Discuss (Join / Login first) Edit
permalink: #
|
| Benchmarking
PHP with no BS |
| After I posted my XML
benchmarks in February 2004, I was approached by Indu Britto to
convert a discussion of the full benchmarks into an article for PHP Magazine. I kept on postponing
him (correction, 2 Apr 2004: Indu is a her, apologies for the goof),
but in a way, Prophet Mohammed helped me write the article. I'm not
muslim, but the prophet's birthday is a public holiday in Malaysia.
That gave me the breathing room to write the article.
I tried to make the article interesting by not focusing on the
mechanics of the benchmark (yawn), but on useful results that
everyone can use to improve their code. I was very pleased (and
surprised - no one told me beforehand) to hear that the editors
decided to feature it as the main article of the March 2004 issue.
Now that it has been published, i can announce that the source
code of the benchmarking suite and results are available at http://ormestech.com/benchmark_suite/
. The results are static html pages to prevent enthusiatic testers
from bringing our server to its knees. You should download the
source code to try out all its functionality. The benchmarks are
easily extensible also. You just need to add new benchmarking files
and the benchmarking suite will auto-detect the files.
The nice thing about the benchmarks is that it measures relative
performance between algorithms, so you can make meaningful
conclusions across disparate hardware platforms. And if you need
more clarification, you can read it (shameless plug) in PHP-Mag.
Latest: the full article is now available online.
Discuss (1
response) (Join /
Login first) Edit
permalink: #
|
| Zend's New PHP5 Info
Center |
| PHP 5 brings along a host of new features and major
improvements like you've grown to expect from past major versions.
Answering the need for scalable development architectures in the
Enterprise, PHP 5 boasts the new Zend Engine 2, which includes a
brand new object model, allowing for the development of large-scale,
maintainable object oriented applications. PHP 5 also introduces new
revolutionary ways of dealing with XML that make it the ideal
platform for XML processing—no other solution comes even close!
Complementary to the new XML features is the new SOAP module,
allowing interoperability with Web Services via a fast and
easy-to-use API.
The list of goodies in PHP 5 goes on and on: built-in
server-independent SQL support using SQLite, new high-performance
and more secure MySQL support, all-new COM/.NET support, and lots
more.
Given this long list of new features, we're confident that you're
just as excited about the next generation of PHP as we are! To make
things even snappier, we came up with this new PHP 5 section of
Zend.com's DeveloperZone. The section will allow you to get PHP 5
information right from the source, discover PHP 5's various new
features, as well as learn how to migrate from earlier versions of
PHP. -- Zeev and Andi.
This appears to be an excellent resource. Pity I'm too busy at
work to look at it. I have received a copy of George's Advanced PHP
book too. I will try to review it when my schedule permits. Time is
tight. Now where was that cloning device i got for Christmas...
Discuss (2
responses) (Join
/ Login first) Edit
permalink: #
|
| The world's two worst
variable names |
| Bad variables are all over the place. Usually it will be
something like a short variable used for too long, like $n being
used for the duration of an entire subroutine. The programmer might
as well have been working in TRS-80 BASIC, where only the first two
characters of variable names were significant, and we had to keep a
handwritten lookup chart of names in a spiral notebook next to the
keyboard. -- Andy Lester
In my opinion, here are the
world's worst variable names. A $data variable can be very
meaningful if there is a single data input stream. I'm sure Andy was
blind-sided, given his evangelism.
Discuss (Join / Login first) Edit
permalink: #
|
| This
is Intriguing |
| Roadsend Compiler for PHP produces optimized stand alone
applications, libraries, and web applications from standard PHP
source code. The compiler produces native machine code, not PHP byte
code, so no interpreter is required.
They say they currently are in beta. Has anyone tested it out?
Discuss (2
responses) (Join
/ Login first) Edit
permalink: #
|
| .NET
bondage |
| Harry Fuecks posted a very interesting critique of browser-based
event models. Apparently ASP.NET
Server Control Event Model uses a lot of clever javascript in
the browser to dynamically communicate with the web server. However
this is not REST-ful,
which basically means that it does not follow web conventions and is
therefore not linkable.
Discuss (Join / Login first) Edit
permalink: #
|
| PHP5
evolutionary lies |
| Comrades, I'm sick of hearing that PHP5 is evolutionary. If you
believe that PHP5 is evolutionary because it stresses backward
compatibility, then try bending over backwards - you'll find that it
feels very stressful. PHP5 is not going to go down easily. PHP5 is
going to be painful and it is going to be revolutionary. Here's why:
- Revolutions are bloody. Lots of people lost their heads during
the French Revolution. PHP5 is a revolution that will give
developers more room for fisticuffs and swinging debates. OOP or
procedural? Should we port all the Java class libraries to PHP, or
only the useless ones? Stick with Zend Engine or shed some Parrot
blood?
- PHP5 will have OOP for dummies - you don't need to be a
superguru who understands & anymore to correctly implement
classes. Finally the Java princes in the first estate and the .NET
nobles in the second estate will rue the day they learnt how to
compile.
- PHP5 even has XML for dummies - SimpleXML is the best XML API
in the world for people who have no time for XML. That means that
XML will finally achieve total world domination with PHP5. XML ueber
alles.
- PHP5 exceptions are certainly revolutionary - error-handling
was the last bastion of the goto. With exceptions, we can now tell
Mr Goto where to go to. O, i forgot that PHP doesn't have goto.
Never mind, exceptions are revolutionary - trust me...
- PHP5 will have type-hints - which will encourage the worse
forms of racism. How can we live in a democratic open source
utopia and still discriminate by type. And worse, this racism is
not type-checking done properly before a law abiding compiler, but
sneaky type-hints given by informers and spies in the shadows of
function parameters.
- PHP's name was changed from Personal Home Page to PHP
Hypertext Processor, but there are still many traitors who
continue to call it their Personal Hygiene Problem. These unwashed
souls will have to be liquidated when the revolution comes.
Discuss (2
responses) (Join
/ Login first) Edit
permalink: #
|
| News.com:
MySQL addresses PHP license problem |
| On Thursday night, MySQL published a license exception that,
the company said, permits PHP to resume its previous practice of
bundling MySQL components called libraries, said Zack Urlocker,
MySQL's vice president of marketing.
MySQL's exception is "a step in the right direction," said Andi
Gutmans, a PHP creator and vice president of technology for Zend, a
company that sells PHP programming tools. Gutmans also expressed
confidence that other remaining issues will be resolved --
Stephen Shankland
MySQL
Open Source License: As a special exception, MySQL AB gives
permission to distribute derivative works that are formed with
GPL-licensed MySQL software and with software licensed under version
3.0 of the PHP license. You must obey the GNU General Public License
in all respects for all of the code used other than code licensed
under version 3.0 of the PHP license.
Discuss (7
responses) (Join
/ Login first) Edit
permalink: #
|
| ADOdb
driver for ODBTP |
| Stefan Bogdan contributed this ODBTP driver for ADOdb.
ODBTP allows you to connect to Windows ODBC drivers from other
operating systems. So if you want to query MS Access or MS SQL
Server from Linux/BSD/Unix, you can consider this option.
The ODBTP package consists of three components. The first is a
service that resides on a Windows NT, 2000 or XP Pro machine where
the ODBC drivers are installed. The second is a C library of
routines that can be used to create ODBTP client applications. The
third component is a PHP extension that can be used to create
web-based ODBTP client applications with the PHP scripting language.
I don't have ODBTP installed, but i think some of you will be
very interested in this.
Update: Connection code revised (_connect and _pconnect).
Discuss (2
responses) (Join
/ Login first) Edit
permalink: #
|
| NewsFactor:
Will PHP 5 Live Up to Its Billing? |
| In a recent survey conducted by Zend Technologies, about 20
percent of respondents said they planned to upgrade as soon as PHP 5
is released. About 75 percent said they would upgrade within one
year. The rest responded by saying they did not plan to upgrade.
I remember Andi Gutmans that once said in a PHP newsgroup that
both PHP3 and PHP4 became really stable around the x.0.6 release. I
found that to be true for PHP 4.0.6 anyway. It was rock-solid. Will
the same hold true for PHP5?
PS: I did a search on Google but couldn't find the post. Anyone
remember it?
Discuss (1
response) (Join /
Login first) Edit
permalink: #
|
| Beyond
MVC |
| Although the Model-View-Controller design has proven itself
throughout the years to be an appropriate and beneficial pattern for
modeling user-interface components, its use in designing distributed
servlet infrastructures has led to very unfortunate results. Among
these are the advancement of unwieldy, inflexible architectures that
are incapable of being quickly altered to support the ever-changing
demands of the technological and economic environment.
The only time I've ever felt comfortable with MVC was when i was
learning Smalltalk, because that was the natural way to code user
interfaces for that environment. I have never been impressed with
the way MVC has been retrofit for web user interfaces, as it appears
unnatural in the web context. There are many simpler web metaphors
that are viable (For example, see Rasmus' Adding
Structure example or Smarty). MVC is very much in the
over-designed style of J2EE.
The DataSource, Action, Workflow objects the author
suggests looks pretty similar to what my company (we've been doing
workflow since 1997) does internally for our more complicated user
interface scenarios, though i would need a closer look to be sure.
Interesting, provocative, and definitely worth further study.
Discuss (8
responses) (Join
/ Login first) Edit
permalink: #
|
| Do
You PHP? |
| A great overview of PHP by Rasmus Lerdorf published by Oracle
Technology Network.
Some quick notes:
- Is this the first time that MySQL and PostgreSQL's been
mentioned without disdain on an Oracle web-site?
- "There is nothing wrong with direct database calls' making
use of all the tricks and cheats your chosen database has to offer,
to tweak as much performance as possible out of it." This may
surprise some people, but I agree with this. I do make direct
database calls when i need the speed. But i don't think that Rasmus
has to use 5 different and quirky databases at work.
- Perhaps why I like PHP so much is because I find so little that
I disagree with in the opinions of the original designer of PHP:
Despite what the future may hold for PHP, one thing
will remain constant. We will continue to fight the complexity to
which so many people seem to be addicted. The most complex
solution is rarely the right one. Our single-minded direct
approach to solving the Web problem is what has set PHP apart from
the start, and while other solutions around us seem to get bigger
and more complex, we are striving to simplify and streamline PHP
and its approach to solving the Web problem.
This gives me a warm fuzzy feeling in my belly!
Discuss (5
responses) (Join
/ Login first) Edit
permalink: #
|
| Contract-Driven
Development meets XP |
| I think there are two kinds of people interested in
test-driven development. First, there are people who are very happy
not to have to write a specification. If that's what you hope to get
from Extreme Programming (XP), I don't think you'll get much
improvement. But then there are people who are more seriously
applying the idea of test-driven development, the way at least I
would consider applying it, where the tests are really
systematic. -- Bertrand Meyer
Discuss (Join / Login first) Edit
permalink: #
|
| I
wish i could spell George Schlossnagle without
copy-and-paste |
| George Schlossnagle has contributed a lot to PHP. And he's got a
new book out, Advanced
PHP, that i look forward to reading. I only know George through
email, but there's another side to him that's reflected in his blog
that's probably more interesting than his contributions to PHP.
George worked in Nepal for the Peace Corps, and developed some
close friendships there. He writes about some tragic
discoveries he just made. It's sad to see that this
young girl is no more. And he worries about this
young lady. It seems almost beyond belief that she could have
grown up to become a bomb-throwing terrorist...
Discuss (Join / Login first) Edit
permalink: #
|
| ADOdb and
SourceForge |
| Recently I had a couple of requests to place ADOdb, the PHP database
abstraction library I maintain, in a public CVS. I agreed, and tried
to register adodb at SourceForge, since it provides a free CVS
service.
To my surprise, someone had already registered ADOdb at
SourceForge, in 2001! There was even an old version of ADOdb in CVS.
I just don't get no respect! I quickly emailed him, and I must have
sounded quite violent in my email, because he quickly agreed to
relinquish control of the project (actually he sounded very nice in
the short emails we exchanged).
Now I started looking into setting up CVS at sourceforge. It
seems that all CVS check-ins are done via SSH, an encryption
protocol. I use WinCVS, a
windows-based CVS client and it looks tricky to set it up to use
SSH.
The beauty of Unix has always been that it provides an extensive
bundle of tools to do anything. You can hook SSH functionality to
CVS by some obscure commands. However as the tools are not
pre-packaged on Windows, setting up each tool becomes a real pain.
And even if you have SSH and CVS installed on Windows, it won't work
unless you have an assurance they can interoperate. For example, I
use PuTTY
for SSH; can WinCVS use it?
Another problem is that i have several modified versions of ADOdb
lying around, which i manage using my internal CVS. But if I move
the main branch of ADOdb to public CVS, what do i do to keep the
customized versions of ADOdb synchronized and keep them private?
So I'm afraid i have to put the idea of having a public CVS of
ADOdb on hold for the moment, unless anyone out there has a better
suggestion?
PS: ADOdb 4.20 is out. AXMLS 1.01 included. Oracle,
Ifx, MSSQL and Postgres improvements. Perf Monitor fixes. Property
$conn->dateHasTime changed to $conn->datetime.
PPS: Apparently there is a guide to using PuTTY
with WinCVS.
Discuss (8
responses) (Join
/ Login first) Edit
permalink: #
|
| Official Migrating
from PHP4 to PHP5 Docs |
PHP 5 and the integrated Zend Engine 2 have greatly improved
PHP's performance and capabilities, but great care has been taken to
break as little existing code as possible. So migrating your code
from PHP 4 to 5 should be very easy. Most existing PHP 4 code should
be ready to run without changes, but you should still know about the
few differences and take care to test your code before switching
versions in production environments. -- Nuno Lopes
Andi Gutman points this out:
>Paragraph: Classes must be declared before used
>is no longer true. For most cases this is allowed now.
To be accurate, we solved the BC issue but for people who want to use the
PHP 5 features (such as implementing interfaces), they will have to declare
the class before using it.
Discuss (2
responses) (Join
/ Login first) Edit
permalink: #
|
| A stroll in the
park with PHP5 beta 4 |
| Over the past few days, I have had an opportunity to do more
testing with PHP5b4.
I'm glad that most of my testing was on Windows because I don't
have to compile anything on Windows to get PHP5 working. But I had
to try things out on Linux too because I'm writing an article for
PHP-Magazine.
Testing on Linux was really painful. One gotcha is PHP4. After
compiling PHP5 on our Linux box it kept on crashing when I restarted
apache. Finally I remembered that you can run the command line
interface version of PHP (in php5/sapi/cli/), which gives somewhat
more helpful error messages, and discovered that PHP5 was trying to
load PHP4's php.ini.
Apart from the PHP4 gotcha, I had to download a
newer version of libxml2 for PHP5 to compile. I downloaded the
latest libxml2, only to find that out 2.6.6 was not supported by
PHP5 (it wouldn't link). I had to rollback a few versions and
retrieve libxml2.5.11 instead. - I must have screwed up
something else, PHP5b4 works fine with libxml2 2.6.6.
Now i don't dare recompile PHP4, because it probably requires
libxml2 2.4. Ugh, the joys of Unix development.
More highlights of PHP5b4:
I'm not a big fan of XML, but I have been trying out simplexml,
and it really is as simple as promised.
I also did some benchmarks. I'm pleasantly surprised that in some
operations, such as looping, PHP5b4 is already faster than PHP4.
Discuss (3
responses) (Join
/ Login first) Edit
permalink: #
|
| The second coming of
PHP |
| It seems that many members of our congregation are under the
impression that PHP5, the second coming of the son of our lord, will
save their souls. Well, I'm here to tell you otherwise. - Rev
Jim
Discuss (1
response) (Join /
Login first) Edit
permalink: #
|
| Testing
PHP5 |
| Now that PHP5 beta 4
has been released, it might be useful to share how we do our testing
of different PHP versions.
We find it quite bothersome to reconfigure our web server(s)
everytime we want to switch between different versions of PHP4 and
PHP5. So we have automated all our testing on Windows using the
command-line interface to PHP5.
PHP5 beta 4 allows us to define a php.ini configuration file in
the same directory as the php.exe executable. We will first modify
php.ini, setting extension_dir and include_dir, and enable the
appropriate extension=* settings. Then we have a standard DOS batch
file that will run php.exe and unit-test ADOdb (the database
abstraction library for PHP that I maintain). The output is
generated to rez.html.
The last line of the batch file opens the resultant html file in
IE. The "start" command will attempt to open any file if the
extension mapping exists, e.g. "start rez.html".
The only disadvantage of this approach is that you are not
testing PHP5's long-term interaction with the web server, and you
need to have an existing set of unit tests that can be automated.
This might not be possible if you testing mostly user interface
code.
And what do i think of PHP5 beta 4? Two thumbs up. Didn't have to
change anything in ADOdb to make it work with beta 4.
Sample DOS Batch File
Note: Each release of php5 is kept in its own sub-directory
(c:\php5\php5b1, c:\php5\php5b2, etc). Tests are in
d:\php\adodb\tests. c:
cd \php5\phpb4
del *.html
d:
cd \php\adodb\tests\
c:php test.php testmysql > c:rez.html
c:php test.php testoracle > c:rez2.html
c:
start c:rez.html
start c:rez2.html
Discuss (Join / Login first) Edit
permalink: #
|
| John's PHP Benchmarking
Suite (ZIP) |
| My benchmarking suite. Apart from XML, it also benchmarks string
handling, looping (foreach vs for), output buffering, etc. And it's
easily extensible too.
I wrote it when i was thinking about writing a book on optimizing
PHP, and realized i would need a benchmarking suite to test various
performance hypotheses. Its not OOP, but i think it demonstrates how
far you can make procedural programming extensible in PHP.
The benchmarking engine scans sub-directories, and each
sub-directory is treated as a test suite. A .php file in a
sub-directory is one test. Every .php file in a sub-directory can be
run stand-alone, and when running stand-alone debugging output is
generated so you can verify the correctness of the code you are
measuring.
To install, just unpack in a web server directory, and open up
index.php from your web browser.
Requires PHP 4.3 or later.
Discuss (6
responses) (Join
/ Login first) Edit
permalink: #
|
| High Speed XML
Parsing is Not Intuitive |
| For a PHP weblog, there haven't been many PHP articles or
links recently. This is because I feel most recent PHP articles I
read have nothing fresh to say, repeating material I linked to 2 or
3 years ago. Perhaps I'm getting jaded. So to keep things fresh,
here's a new article, mostly original, and hopefully of some
interest to everyone!
Last year, Tim Bray, one of the co-authors of the XML spec,
mentioned that he used Perl regular expressions to parse
XML.
Now here's the dirty secret; most of it is
machine-generated XML, and in most cases, I use the perl regexp
engine to read and process it.
I was struck by this because I would have thought XPath or SAX
would provide better performance as they are APIs tuned specifically
for XML.
I decided to do some benchmarks to determine which techniques
were better. I also wanted a realistic test, so I benchmarked
parsing the RSS
feed of this web-site, searching for the contents of all title
tags, and returning the contents as an array. The RSS file is from
Nov 2003 (yes i did this benchmark that long ago), and is about 20K
and has 12 title tags, so the returned array will have 12 title
strings.
The techniques used were:
1. Regular expression:
preg_match_all('/<title>([^<]*)/',$rss,$titles_arr))
2. Explode('<title>', $rss) then strip the matching
</title> tag using strpos() and substr().
3. XPath, using $title_nodes = $ctx->xpath_eval("//title");
4. SAX, wrote an element handler function that matched and
processed the title tag.
5. DOM, using $titles =
$dom->get_elements_by_tagname('title'). Intuitively, this should
have been the slowest, as the whole tree is generated.
Results
Here are the timings for processing the RSS file 1000 times.
Faster is better.
seconds Relative
to REGEX
REGEX 0.1080 1.00
EXPLODE 0.1696 1.57
DOM 6.3212 58.53
XPATH 8.3417 77.24
SAX 10.0851 93.38
Conclusion
Intutively, I would have thought that XPath would be the fastest
as XPath expressions can be compiled and tuned for XML. But the best
performance was achieved using regular expressions, which is
what Tim is using.
It appears that the DOM, SAX and XPath libraries remain immature
(compared to the Perl-compatible regex library) and are not highly
optimized. Strangely enough, DOM performance is better than XPath
and SAX! Perhaps someone else can explain why.
If anyone is interested, i have posted the
source.
Test platform: Windows 2000, PHP 4.3.3. I also tested on Linux,
PHP 4.3.2, with similar results.
Discuss (13
responses) (Join
/ Login first) Edit
permalink: #
|
| Why C Is
Not My Favourite Programming Language |
| Brian Kernighan, the documenter of the C programming
language, wrote a rant entitled Why Pascal is Not My Favourite
Programming Language. I can picture him thinking to himself smugly
as he repeatedly strikes facetiously at Pascal by describing a few
of its small flaws over and over again.
Unfortunately, time has not been kind to Kernighan's tract.
Pascal has matured and grown in leaps and bounds, becoming a premier
commercial language. Meanwhile, C has continued to stagnate over the
last 35 years with few fundamental improvements made. It's time to
redress the balance; here's why C is now owned by Pascal. -
James Joyce.
James appears to be more fond of PHP than C. No objections there!
And if you don't take it all too seriously, the responses are
quite amusing.
Discuss (Join / Login first) Edit
permalink: #
|
| Another look at
PHP and Python |
| Postscript: Some people have got the impression from this
article that I am moving away from PHP. That is far from the truth.
I will continue to use PHP extensively today, tomorrow and for the
forseeable future.
I find Python harder than PHP.
It could be because we are programming multi-threaded networked
servers in Python, and that could be inherently harder than coding
dynamic web-sites. Another reason could be lack of familiarity with
Python. For example, I couldn't find the equivalent of htmlspecialchars and
other functions, so i had to roll my own.
Despite all these issues, we are continuing to develop this in
Python because (AFAIK) PHP does not have stable networking
frameworks.
So what do I like about Python?
- Neat Syntax
The use of indentation for compound statements discourages deep
nesting, and thus more modular code.
- More Safety Checks
In PHP, when you search using a regular expression, an
associative array is returned. In Python, a typed object, "match" is
returned when a regular expression search is performed, and not a
generic dictionary. You cannot perform arithmetic on strings, an
explicit cast is required; neither can you concatenate numbers with
strings, explicit typecasts are needed.
- Supports Multi-Threaded Apps
There exists a global lock in Python that prevents
multi-threading from working effectively on multiple processors -
nevertheless Python has reasonable thread support and allows me to
develop reasonably responsive servers.
- Python's Compiler is Standard
Python has a standard compiler and byte-code format. There is no
such standard in the PHP world, and most ISP's don't support Zend or
Turck MMCache encoded PHP. Better still, a debugger is included in
the package too.
- Python Fully Supports Unicode
Python 2.0 and later has full support for unicode. For example to
convert big5 to unicode is the simple:
unicode_str = unicode(tw_chinese_string, 'big5')
In contrast, see how complicated it is to perform
double-byte to unicode conversions in PHP (see User Notes).
The only issue i had with the unicode support is that it doesn't
come with a complete set of double-byte decoders (eg. big5, gb).
After a 20 minute google search, i found this set of python cjk decoders.
And what I dislike about Python
- Python Is Not Rapid Enough?
I think that PHP is a better tool for rapid application
development, especially for web-sites. Minor type issues are handled
for you transparently in PHP. In Python, once a variable is set,
stricter type-checking is performed on most operations.
So you can argue that Python is safer. But PHP coding is
definitely more rapid.
Another thing i dislike is that Python's import/load facility
does not check .py file modification dates. If i modify a .py file,
Python's run-time environment will not recompile it until i restart
Python, or perform a reload manually from the command-line
interpreter.
- Database Access
Python does not have official database drivers, and you have to
select and download these drivers yourself. It's easy to get it
wrong. For example, only after coding the adodb_odbc module using
PythonWin odbc extension did i realize how awful PythonWin odbc was.
I then found the mxODBC extension - unfortunately the mxODBC
requires commercial licensing ($75 per CPU).
- Python is Not That Popular
Popularity is relative. There are lots of Python programmers -
but there are perhaps 3 times more PHP programmers than Python ones.
In Malaysia, the ratio of PHP to Python programmers is probably much
worse (10:1?). And there are many training centers offering PHP
courses. AFAIK, there are no centers in Malaysia offering Python
training. A quick search in monster.com reveals the following
(numbers might change over time):
PHP: 131 jobs http://jobsearch.monster.com/jobsearch.asp?q=php&re=0&sort=rv&tm=&fn=660&vw=b&cy=US&brd=1%2C1862%2C1863
Python: 41 jobs http://jobsearch.monster.com/jobsearch.asp?q=python&re=0&sort=rv&tm=&fn=660&vw=b&cy=US&brd=1%2C1862%2C1863
Discuss (5
responses) (Join
/ Login first) Edit
permalink: #
|
| The
software that .NET forgot... |
| For some reason, Microsoft's brilliant and cutting-edge .NET
development environment left out one crucial tool... a tool that has
been common in software development environments since, oh, about
1950, and taken so much for granted that it's incredibly strange
that nobody noticed that .NET doesn't really have one. -- Joel
Spolsky
And what is the software that PHP forgot? The compiler-cache of
course...
Discuss (5
responses) (Join
/ Login first) Edit
permalink: #
|
| ODBTP, connect to Windows
databases from any platform |
| ODBTP version 1.1 has been released is available at http://odbtp.sourceforge.net/
Many new functions and enhancements have been added to the odbtp
extension. The changes make it the best PHP solutiion for connecting
to MSSQL, Access, FoxPro and other Win32 ODBC accessible databases
from any platform.
Its native connection pool eliminates the need for persistent
connections.
All of the functions from the mssql extension are optionally
supported. This means that existing PHP scripts that use the mssql
extension would not have to modified to use ODBTP. The odbtp/mssql
hybrid extension's performance and capabilities exceed both the
FreeTDS (UNIX / Linux) and DB-Library (Win32) versions of the mssql
extension. ODBTP uses Microsoft's ODBC driver for SQL Server, which
is superior to FreeTDS and DB-Library when connecting to SQL Server
2000 databases. And, unlike the mssql extension, the odbtp/mssql
extensinn's behaviour is exactly the same on all platforms.
While the functions from the odbc extension are not supported,
the odbtp extension provides better support for ODBC. Most of the
odbc extension's limitations are caused by its use of ODBC 2 instead
of ODBC 3, which is used by ODBTP. The odbtp extension is also
considerably faster.
-- bob
Another interesting solution to connecting to Windows databases.
I'd be interested in your feedback as to how it performs.
Discuss (Join / Login first) Edit
permalink: #
|
| .NET
reality check |
| Here's my point, enough with the "this Whidbey, Longhorn,
XAML is so cool you should stop whatever it is you are doing and use
it". Small problem, we can't. Please help us by remembering that
we're still using the release bits, not the latest technology.
-- Michael Earls
Microsoft teaches us about "over-promise, under-deliver"?
Discuss (Join / Login first) Edit
permalink: #
|
| Just Hack It
Again |
| First learn computer science and all the theory. Next develop
a programming style. Then forget all that and just hack. --
George Carrette
I posted this
comment a few weeks ago, but i never clarified what i thought of
this quotation - until now...
Let's say you learnt a subject really well, and were asked to
teach others. You enjoy teaching and others admire your teaching
style. Then one day, you throw away all your notes, and teach
off-the-cuff, entirely from memory.
We'll that's what I think George Carrette meant by "Just Hack".
If you don't know your stuff inside-out, upside-down and
every-which-way, "Just Hack" is probably not for you.
Discuss (Join / Login first) Edit
permalink: #
|
| ADOdb for Python
Released |
| In my work with Python, I found that there's no good database
abstraction library, so I wrote my own. Looks familiar, doesn't it?
| PHP |
Python |
include "adodb.inc.php";
$conn = NewADOConnection('mysql');
$conn->Connect('server','user','pwd','db');
$rs = $conn->Execute('select * from tab);
while (!$rs->EOF) {
print_r($rs->fields);
$rs->MoveNext();
}
$rs->Close();
$conn->Close();
|
import adodb_mysql;
conn = adodb_mysql.adodb_mysql()
conn.Connect('server','user','pwd','db')
cursor = conn.Execute('select * from tab)
while not cursor.EOF:
print cursor.fields
cursor.MoveNext()
cursor.Close()
conn.Close()
|
It also supports the iterator protocol: cursor = conn.Execute('select * from table')
for row in cursor:
print row
Python does have the DB API, but it's similar to ODBC in that it
provides a very minimal layer, without abstracting SELECT ... LIMIT,
LOBs, string quoting, etc. Download
zip.
I will try to post a comparison between developing in Python and
PHP when I have more time.
Discuss (3
responses) (Join
/ Login first) Edit
permalink: #
|
| The Simplest Thing
That Could Possibly Work |
| Coding up the simplest thing that could possibly work is
really about this: If you can't keep five things in your head at one
time and make a decision, try keeping three things in your head. Try
keeping just one thing in your head, and see if you can make a
decision. Then you can think of the next thing. And amazingly, when
you write some of this dumb, straight-ahead code, it often turns out
that it was all that was required. It works great.
When a second programmer comes back later and reads the code she
might say, "The people who wrote this are morons. They just wrote a
simple linear search here. This thing's ordered, so they could have
done a binary search. They could have used a hash table here. Why
are they doing a linear search?" Well, because a linear search
worked.
And when the other programmer looked at the linear search, she
understood it in a minute. -- Ward Cunningham
I couldn't resist this quote. Perhaps the best example of Just Hack I have
ever read.
Opponents of extreme
programming will point out that this example is exactly the
problem with extreme programming - no proper planning,
opportunistic design.
To itch his own.
Discuss (2
responses) (Join
/ Login first) Edit
permalink: #
|
| Chinese New
Year Holidays |
| In Malaysia, the big holidays are the Muslim Raya holidays and
Chinese New Year. Well Chinese New Year is coming up on the 22nd, so
there's not much more to say but wish everyone the same. Among the
chinese, 'tis the season for ang pow, and drinking, eating and
gambling.
I'll be going home to Penang, so I won't be posting much.
Discuss (Join / Login first) Edit
permalink: #
|
| The State of
Perl Development |
| Perl 6 and Parrot do not represent our future, but rather our
long-term insurance policy. When Perl 6 was announced, the Perl 5
implementation was already about seven years old. Core developers
were leaving perl5-porters and not being replaced. (We didn't know
it at the time, but this turned out to be a temporary lull.
Thankfully.) The source code is quite complex, and very daunting to
new developers. It was and remains unclear whether Perl can sustain
itself as an open source project for another ten or twenty years if
virtually no one can hack on the core interpreter.
Today, over three years later, the Perl development community is
quite active writing innovative software that solves the problems
real people and businesses face today. However, the innovation and
inspiration is not entirely where we thought it would be. Instead of
seeing the new language and implementation driving a new wave of
creativity, we are seeing innovation in the libraries and modules
available on CPAN -- code you can use right now with Perl 5, a
language we all know and love. -- Adam Turoff
An interesting and reflective survey of Perl, CPAN and its
possible future directions. Some well known PHP developers pour
scorn on CPAN because the quality of contributors is uneven, but as
Adam points out, its diversity is a core strength of Perl.
Discuss (Join / Login first) Edit
permalink: #
|
| Just
Hack |
| First learn computer science and all the theory. Next develop
a programming style. Then forget all that and just hack. --
George Carrette
Reminds me of the time the Malaysian government sent a software
team to Canada to do technology transfer for a flight simulator
system. After spending 2 years in Canada, they returned, and i asked
one of the team members how the Canadian coders designed this
powerful and complex system. I was expecting some detailed software
methodology involving multiple phases. He told me, "they just hire a
bunch of talented programmers, teach them the physics, and tell them
to hack!"
Discuss (Join / Login first) Edit
permalink: #
|
| Is my
language really better than yours? |
| If you group the languages out there by intended market
(e.g.: web development, low-level programming, and so on) and by
type (e.g.: procedural vs. O-O), you'll notice that there is perhaps
a 5% variance in the functionality offered by each language compared
to the others. In fact, one could comfortably convert code between
one language and pretty much any other with minimal effort.
Procedural PHP to Perl? No problem. VBScript to PHP? So easy there
is even an automated tool to do it.
In the end, all procedural web languages share the same traits.
They all have functions, or subroutines, or however you want to call
them. Most of them share the same (or very similar) data types,
including variants. Conditional constructs are virtually identical,
even though the syntax changes slightly.
The real differences, and perhaps the only area, together with
stability and performance, where a "this is better than that"
decision can be made is in the library of functions offered by the
platform to which the language belongs. For example, PHP disposes of
an excellent out-of-the-box library with more than 6,000 functions.
Perl has an excellent repository of classes. .Net disposes of a vast
class hierarchy. -- Marco Tabini
Marco Tabini is a great guy and brings out some good points. But
it's like saying a Ferrari and a Honda Civic are basically the same
because they have an engine, brakes, seats, 4 wheels and get you
from A to B. Technically correct, but not quite right.
Along with the library of functions mentioned above, other key
differentiators that i see for web languages include:
a. Style - do you like embedding in tags as in cold fusion or
prefer a more conventional programming language? Do you believe in
TMTOW?
Do you want procedural or pure OOP?
b. Portability - Some languages/platforms are more portable than
others. For example, .NET has subtle Win32 assumptions. Other
languages work better on Unix. And PHP has been ported to biological
computers - it runs in real-time in my brain.
c. Acceptance - How many vendors are there? Is it open sourced or
you don't care? Can you find programmers easily? Are these
programmers expensive? Will the opposite sex like me? See the next
point...
d. Sex appeal - Coding in PHP makes me look cool. But I'm sharper
with C#. Aww, JSP gets me the chicks. Ahem, VB boosts my
testosterone level.
PS: I admit I don't understand his last statement that it's the
platform that matters, not the language. This is because languages
are strongly tied to specific platforms. Java is strongly tied to
JSP. C# and VB are strongly tied to ASP and .NET. PHP is strongly
tied to LAMP. Python to Zope. And Cold Fusion is linked to, err,
Cold Fusion.
Discuss (1
response) (Join /
Login first) Edit
permalink: #
|
| Hinges and
integration |
| At the end of the XIX century, a screw company called Stanley
started selling hinges, and quickly became the largest hinge maker
in the market.
Their hinges were almost the same as any other, the hinges were a
mature technology, they had no price advantage, no hinge-making
experience, and no manufacturing difference with the competition.
How did they do it? They packaged the screws along with the
hinges. Since anyone who bought a hinge needed the screws anyway,
they sold more product, and the buyer was happy because he didn´t
need to find matching screws.
There´s an obvious lesson there: If the consumer always needs two
products at the same time, they are not two products, they are one,
and selling them together should make sense.
How can we apply that (now) obvious lesson to software
development, and open development in particular?
-- Roberto Alsina
Interesting analogy, but I cannot help but suspect that the
screws and hinges that Stanley made probably worked better together
because they came from one source. Just like software from Microsoft
is tightly integrated with the operating system and Microsoft
Office. Or Apple's software is tied to their hardware.
However, Roberto has a good point. Given a base library of
sufficient power and flexibility, people will not reinvent the
wheel, but promote interoperatibility by sharing a common code base.
This is something that PHP still needs to work on. There aren't any
accepted standards for so many issues. For example, PEAR is so
fruitful that it provides us with multiple templating engines and
database abstraction libraries. Too fruitful perhaps?
Discuss (Join / Login first) Edit
permalink: #
|
| Challenge
to Open Source: Innovate, Don't Copy |
| Why would anyone with excellent computer skills want to work
long hours (for free) to create code so that millionaire executives
at IBM can use it to sell expensive mainframe computers and
middleware with six-figure licenses? - Jim Fawcette
Well I have an oblique answer. Recently on a plane to Australia,
I was asked by an Indian expat why I preferred to work in Malaysia,
when I could easily migrate and work in more advanced countries such
as Australia, USA or Europe.
Allow me to ask you the same question; why would anyone with
excellent computer and social skills prefer to work in places that
are poorer paying, more primitive, wasteful and corrupt than USA or
Europe? I think the answer to that will illuminate Jim Fawcette's
question.
Discuss (Join / Login first) Edit
permalink: #
|
| Looking back at PHP
in 2003 |
| By popular demand here is the PHP Look Back 2003. Just like
last year I look back at the most interesting (and sometimes funny)
happenings on the PHP mailinglist... As a small disclaimer: This
might not always be a totally objective look back, as this is not an
official thing. For now, have fun; we start in January. --
Derick Rethans
Discuss (2
responses) (Join
/ Login first) Edit
permalink: #
|
| Python
Revisited |
| Happy New Year! Let's talk shop as usual.
Recently, we've been looking at developing some server software
in Python. This is my first serious look at Python since 1999, and
I'm impressed with the improvements. It's a couple of years older
than PHP, and certainly more mature. Python has a reputation for
being more rationally designed than PHP or Perl, and in general
that's true; but you can still see Python's age in the fact that
there are many APIs that do the same thing (eg. the string
functions).
PHP is still a better language for web development because it is
a simpler language, easy to teach to Java or Javascript programmers,
has more flexible string processing, and designed to work well with
templates.
But as a general programming language, Python has its advantages.
You can easily embed the Python interpreter into a C program. There
are versions of Python that emit Java and IL bytecode. You can build
sophisticated networking software with Python that supports threads
and asynchronous connections with reasonable efficiency (though
Python doesn't really take advantage of multiple CPU's due to an internal
global lock).
Python is also a good source of design ideas. I have noticed that
others
have realized that many good Java ideas do not translate well to
PHP. There is an impedance mismatch; many things that are hard in
Java are easy in PHP. It makes sense to create an elaborate
framework in Java to do something that's hard in Java, but to apply
the same to PHP suggests more energy than sense. In contrast, I
suspect that Python and PHP are more complementary than we all
suspect...
PS: We also had a look at developing the same server software
using .NET. However .NET doesn't have builtin support for open
protocols such as POP3 and IMAP. I continue to be amused at the
(intentional?) omissions in the .NET framework.
Discuss (4
responses) (Join
/ Login first) Edit
permalink: #
|
|
|
Get your site hosted using Manila! |
| Free Software
|
A high quality database library: ADOdb 4.22 download New Netezza, LDAP and odbtp_unicode drivers.
ADOdb for Python
ADOdb Help
& Dev Forum
ADOdb Documentation: - English -
Francais
- Korean Tutorial:
- English -
Chinese
- German
- Italian
- Polish
- Russian
- Spanish
- Thai
3rd Party Tutorials: - MelonFire
Part 1 - MelonFire
Part 2 - PHPFreaks
- Database
Journal Part 1 - Database
Journal Part 2
FAQ
ADOdb Articles: - PHP4 Sessions with
ADOdb - Cool ADOdb
applications - ADOdb
testimonials - Comparing PEAR
DB and ADOdb - Writing Portable
SQL - Web
Services with ADOdb - ADOdb date
library
-Commercial data component: phpLens
|
| PHP Advocacy
|
Interviews Michael
Kimsal Zeev
Suraski
-Comparing PHP with .NET -PHP versus ASP -Why PHP is better
than ASP -PHP versus Cold
Fusion -PHP versus Perl -What's wrong with JSP? -PHP,ASP,JSP,CFM
Popularity -PHP
Humor
|
| Enterprise PHP
|
-Enterprise PHP
scalable, high availability -Writing Reliable
Software -PHP
Application Variables -Sessions in a Server
Farm with ADOdb -PHP, FastCGI
and IIS
-Optimizing
PHP: tips, methodologies and examples. -Tuning PHP and
Apache: many tips and links.
|
| PHP Articles
|
-PEAR Tutorials
& Links -PHP Windows/Unix
Editors -PHP Caches &
Debuggers
-XML-RPC Web
Services -ActiveX on
Linux -PHP: COM
& ADO -GD on
Windows -Using
mail()
Some notes comparing PHP, JScript, VBScript and
ASP that might be useful 1. Language
Basics 2. Functions,
Classes 3. ASP Objects and
PHP
-My
Favorite Articles -CVS
on Windows
|
Put the following ADODB logo on your website if you like!
John Lim Malaysia Natsoft Juris Legalpro iJuris
mydevotion Tips Juris
LensServer Ormes Technologies.
|