If PHP Were British

  Dave        2011-12-01 02:36:55       2,996        0    

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 at the time, for the local tongue. No, not French - that bastard dialect of the Queen's English commonly referred to as "US English"1.

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

  1. $variable_name

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.

  1. £variable_name

Getting Started

  1. <?php
  2. echo 'Hello World!';
  3. ?>

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.

  1. <?php
  2. announce 'Good morrow, fellow subjects of the Crown.';
  3. ?>

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:

  1. str_replace()
  2. is_int()
  3. var_dump()
  4. preg_match()
  5. json_encode()
  6. mysql_connect()

The following changes should improve things:

  1. string_replace()
  2. is_integer()
  3. variable_dump()
  4. perl_regular_expression_match()
  5. javascript_object_notation_encode()
  6. my_structured_query_language_connect()

Edit: I have corrected the expansion of "preg_match" - thanks to those who pointed it out.

Eloquence

  1. if ($condition) {
  2. // Code here
  3. } else {
  4. // Code here
  5. }

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:

  1. perchance (£condition) {
  2. // Code here
  3. } otherwise {
  4. // Code here
  5. }

The same naturally applies to the Americanised switch ... case construct, which one can only describe as clunky and unpleasant:

  1. switch ($variable) {
  2. case $option1:
  3. //Code here
  4. break;
  5. case $option2:
  6. //Code here
  7. break;
  8. default:
  9. //Code here
  10. break;
  11. }

Words such as "switch", "break" and "default" are hard on the reader and lack context. The Right Honorable 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):

  1. what_about (£variable) {
  2. perhaps £possibility:
  3. //Code here
  4. splendid;
  5. perhaps £other_possibility:
  6. //Code here
  7. splendid;
  8. on_the_off_chance:
  9. //Code here
  10. splendid;
  11. }

Spelling

  1. imagecolorallocate()
  2. serialize()
  3. newt_centered_window()
  4. connection_status()

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:

  1. imagecolourallocate()
  2. serialise()
  3. newt_centred_window()
  4. connexion_status()2

Manners

  1. try {
  2. // Code here
  3. } catch (Exception $e) {
  4. // Handle exception
  5. die('Message');
  6. }

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:

  1. would_you_mind {
  2. // Code here
  3. } actually_i_do_mind (Exception £e) {
  4. // Politely move on
  5. cheerio('Message');
  6. }

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.

  1. class Republic {
  2. public $a;
  3. private $b;
  4. protected $c;
  5. }
  6. $example = new Republic;

To begin with, the current system has no place for class hierarchy and this is unacceptable. So we shall begin by giving classes specific levels - upper, middle, working - and no class can access the methods of one of a higher level without the explicit permission of the higher order class (of course, though it might then have access, it would not be a true member of the higher order and could not itself grant higher order access to other lower order classes). "Public" and "Private", in the British class system, are often synonymous (see, for example, school system nomenclature), so these must be adjusted, as should the "Protected" property visibility. The word "new", while passable, has a much more appropriate replacement in matters of class.

  1. upper_class Empire {
  2. state £a;
  3. private £b;
  4. hereditary £c;
  5. }
  6. £example = nouveau Empire;

The Sun Never Sets ...

It is hoped that these few simple changes will improve the reputation and status of PHP among other languages. No longer will it be the poor American cousin - instead it can take its rightful place as the - British - King of the scripting languages.

Thanks

Many thanks to Mark and Pat, colleagues at GSBA, who started this resurrection of the British Empire in the pub on Friday.

Source: http://www.addedbytes.com/blog/if-php-were-british/

PHP  CLASS  BRITISH  STATEMENT  ENGILISH LIKE 

       

  RELATED


  0 COMMENT


No comment for this article.



  RANDOM FUN

Why no traffic coming in? Damm