h1

Syntax without Syntax

April 22, 2011

Some complex object orientated systems amount to building one language
on top of another. For instance, in a PHP framework,
methods on objects need to be called in a particular order. They have
syntax style dependencies of possibility necessity and order. In that
sense they have syntax, but it is not defined as such explicitly. That
is what I mean by syntax without syntax. Virtually all programming languages allow
semantic extension (ie they allow new variables and functions to be defined), and
many support that flexibility with “define” keywords, type systems and the like. But the creation
of new syntax is not so supported: most languages lack constructs that enforce ordering and logical dependencies between newly defined messages and function calls (“call this function before that”).

For instance, a PHP framework might require a page to be initialised, so that there is (in effect) a rule that “The page must be initialised before any other anything else is done with it”).

It could be argued, concretely, that the initialise-first rule
could be implemented by setting some static flag mechanism. It could be argued abstractly that any other language can be implemented in a general-purpose language.(For instance, object orientation can be implemented in pure C, but with a certain amount of programmer disciple, and without convenient syntactic sugar). But we don’t
write everything in assembler! High-level languages are about combining power with safety and convenience. Adding a framework to to something like PHP, python or Ruby adds power, but there is not convenient way of adding safety, the enforcement of the syntactic rules of the higher level language, for all that there are inconvenient ones.

Advertisements

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: