If PHP Were British (2011)

downbad_1 pts0 comments

If PHP Were British | Alone On A Hill

-->

-->

Skip Navigation

If PHP Were British<br>When Rasmus Lerdorf first put PHP together, he - quite sensibly, despite his heritage - chose not to write it in Greenlandic or Danish. Good job too - that would have been rather unpleasant to work with. He opted instead, being in Canada, for a more local tongue. No, not French. Not Canadian English either. No, he went for that bastard dialect of the Queen's English commonly referred to as "US English".

PHP developers in Britain have been grumpy about this ever since. What was he thinking? And more importantly, how do we undo this travesty? How do we developers ensure the traditions of the British Empire continue to be upheld, even in the digital age?

A Slap in the Face

$variable_name<br>The first, but maybe the most important, of many changes that will allow PHP to achieve a more elegant feel is to remove that symbol so beloved by the US and replace it with something altogether more refined. More solid. More ... sterling.

£variable_name<br>Getting Started

How many of today's British programmers have been put off at the outset by the brazen informality of this simple yet obscenely Americanised program, colloquially referred to as "Hello World"? A more Imperial, formal introduction might encourage a greater proportion of young British talent to remain with the language and thus give the broader community a more urbane air.

Abbreviations

Few things are more abhorrent to the British than unnecessary abbreviations. "Text speak" is unheard of on the streets of London, as the natural ingrained British grammarian simply refuses to stoop to sending messages of the "c u soon traffic kthxbye" variety, instead proferring something altogether more elegant: "Dear Sir/Madam. I will arrive as soon as time allows, which I expect to be within the hour. I assure you the horses shall not be spared. Yours respectfully." (slower to type, yes, but we do not like to be rushed).

PHP, on the other hand, is full to bursting with abbreviations and acronyms which are entirely unnecessary:

str_replace()<br>is_int()<br>var_dump()<br>preg_match()<br>json_encode()<br>mysql_connect()<br>The following changes should improve things:

string_replace()<br>is_integer()<br>variable_dump()<br>perl_regular_expression_match()<br>javascript_object_notation_encode()<br>my_structured_query_language_connect()<br>Edit: I have corrected the expansion of "preg_match" - thanks to those who pointed it out.

Eloquence

if ($condition) {<br>// Code here<br>} else {<br>// Code here<br>Shakespeare would be ashamed to see his native tongue twisted into this monstrosity. Brevity is to be applauded in the right context - in some dark corner, where it shall be seldom seen - but not here. The if ... else block is the most used conditional code in all of PHP, so it must be made as inoffensive as possible. There are many options for its replacement, but this may be the strongest:

perchance (£condition) {<br>// Code here<br>} otherwise {<br>// Code here<br>The same naturally applies to the Americanised switch ... case construct, which one can only describe as clunky and unpleasant:

switch ($variable) {<br>case $option1:<br>//Code here<br>break;<br>case $option2:<br>//Code here<br>break;<br>default:<br>//Code here<br>break;<br>Words such as "switch", "break" and "default" are hard on the reader and lack context. The Right Honourable biggerthancheeses was kind enough to contribute a more gentrified suggestion (and has some interesting ideas, particularly around replacement of "include()" with something like "i_might_be_partial_to()", demonstrating a natural talent for the Imperialisation of programming languages):

what_about (£variable) {<br>perhaps £possibility:<br>//Code here<br>splendid;<br>perhaps £other_possibility:<br>//Code here<br>splendid;<br>on_the_off_chance:<br>//Code here<br>splendid;<br>Spelling

imagecolorallocate()<br>serialize()<br>newt_centered_window()<br>connection_status()<br>Words fail me at this point. How is any self-respecting gentleman expected to make head or tail of these "words". It beggars belief that anyone could allow such distortions of words to be entered into a programming language. They, along with the cornucopia of similar errors, should be reverted to their proper forms immediately:

imagecolourallocate()<br>serialise()<br>newt_centred_window()<br>connexion_status()1<br>Manners

try {<br>// Code here<br>} catch (Exception $e) {<br>// Handle exception<br>die('Message');<br>The try ... catch block is an excellent example of PHP's lack of manners. Far too direct to be allowed in the new PHP. Additionally, the word "die" is so very depressing. This new block, although more verbose, is vastly more polite and upbeat:

would_you_mind {<br>// Code here<br>} actually_i_do_mind (Exception £e) {<br>// Politely move on<br>cheerio('Message');<br>Class

Perhaps nothing is as important and ingrained in the British psyche as the notion of class and, while there are few opportunities for change within this part of PHP, the changes that there are to be made here are important.

class Republic {<br>public $a;<br>private $b;<br>protected...

code british break words english important

Related Articles