PHP is a baroque seriffy language, and that's why I like it

PHP is a baroque seriffy language, and that's why I like it

June 1, 2013 - by Patrick van Bergen

Tags:

baroque

I have tried to put to words why it is that I like PHP so much.

"In typography, serifs are the small lines tailing from the edges of letters and symbols, such as when handwriting is separated into distinct units for a typewriter or typsetter. A typeface with serifs is called a serif typeface (or serifed typeface). A typeface without serifs is called sans serif or sans-serif, from the French sans, meaning “without”." -- Wikipedia

I like the fact that PHP's variables start with a dollar-sign. It makes you feel rich, on some subconscious level. It also makes them stand out and improve readability.

"Amount of stock: $stockAmount"

I like explicit scoping. I like curly brackets: They physically keep a block of code together.

foreach ($names  as $name) {
  // this is a block of code
}

I like arrows better than dots in method calls. They give me a sense of direction.

$Webshop->getAttribute('categoryThumbnailWidth');

I even like the backslash namespace separator:

use probase\modules\webshop2\lib\Configuration;

It gives the code that slightly amateurish look, that makes you feel just a little bit better about your own achievements.

"The Baroque is a period of artistic style that used exaggerated motion and clear, easily interpreted detail to produce drama, tension, exuberance, and grandeur in sculpture, painting, architecture, literature, dance and music." -- Wikipedia

I want built-in functions to have short and strange-looking names (strlen, arsort). That way I can search for them and I don't have to type so much. They also keep you awake.

When a function is a function, I want to write the word "function" to make that absolutely clear.

PHP is probably the only language that allows you to allow a trailing comma at the end of an array definition, when no elements follow. Just to invite other programmers to add more elements.

$members = array(
    'sjoerd',
    'kenny',
    'bart',
);

I like the required expression parentheses in if-statements and loop-functions. They decorate the code.

if ($cosyExpressionInParentheses) { /* code */}

I can never remember the difference between the functions array_slice and array_splice but that... Hm, no, that's just nasty.

For a web-language, it is a good feature that it is very hard to write code that does not leak memory. It keeps you from writing a single monolithic web-app that doesn't scale.

"Form follows function is a principle associated with modern architecture and industrial design in the 20th century. The principle is that the shape of a building or object should be primarily based upon its intended function or purpose." -- Wikipedia

I think it's important that different language functions look differently. And also that everything you do, you do explicitly. There should be no magic going on in the code. And PHP does a very good job at that.

To sum up: No, PHP does not look like that smooth enterprise-level programming language. But you know what? It is. And that's why I like it.

Share this post!

Comments

Leave a comment!

Italic and bold

*This is italic*, and _so is this_.
**This is bold**, and __so is this__.

Links

This is a link to [Procurios](http://www.procurios.nl).

Lists

A bulleted list can be made with:
- Minus-signs,
+ Add-signs,
* Or an asterisk.

A numbered list can be made with:
1. List item number 1.
2. List item number 2.

Quote

The text below creates a quote:
> This is the first line.
> This is the second line.

Code

A text block with code can be created. Prefix a line with four spaces and a code-block will be made.