WordPress Shortcodes Point the Way to Declarative Web Language

Chromed Up WordPress Logo

Wordpress Shortcodes: Towards a Declarative Web Language?

You may have heard me banging on about declarative Web languages

I contest that in the near future it will not be possible for an untrained author, to simply read a small specification of the language, open a text editor and create a page; simply uploading the result to the Web…I am not suggesting a “Luddite” like, return to the old days of Web authoring, but instead, am calling for a simplified all-in-one Web language (either declarative or meta) which can be learnt in a short amount of time, by untrained programmers, who can use a text editor as the creation tool. I realise that the complexities will need in some degree to be hidden, but assert that this trade-off will neither be missed or required by the majority of authors working predominantly in the “long tail”.

Now, one good example of the kind of thing I’ve seen recently relating to this are WordPress Shortcodes. These are written by providing a handler function. Shortcode handlers are broadly similar to WordPress filters: they accept parameters (attributes) and return a result (the shortcode output). Some examples:


[gallery id="123" size="medium"]

// [bartag foo="foo-value"]
function bartag_func($atts) {
'foo' => 'no foo',
'bar' => 'default bar',
), $atts));

return "foo = {$foo}";
add_shortcode('bartag', 'bartag_func');

What do I mean be declarative? Well a procedural programming language provides a programmer a means to define precisely each step in the performance of a task. The programmer knows what is to be accomplished and provides through the language step-by-step instructions on how the task is to be done.  Now a declarative programming expresses what needs to be done, without prescribing how to do it in terms of sequences of actions to be taken. So in this case the declarative keywords are backed up by more complex procedural components however the blogger never needs to see these. They can avail themselves of the declarative shortcode and expect output to be generated in whatever way the procedural code says – they just say what they want and where they want it.

So if we took the shortcodes view of things how would we do something like generate an initial layout and then refer back to generated components of that layout… hum let me think.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s