On Tue, 30 Jun 2009 09:16:41 -0700, Brion Vibber wrote:
As many folks have noted, our current templating
system works ok for
simple things, but doesn't scale well -- even moderately complex
conditionals or text-munging will quickly turn your template source into
what appears to be line noise.
And we all thought Perl was bad! ;)
There's been talk of Lua as an embedded templating language for a while,
and there's even an extension implementation.
One advantage of Lua over other languages is that its implementation is
optimized for use as an embedded language, and it looks kind of pretty.
An _inherent_ disadvantage is that it's a fairly rarely-used language,
so still requires special learning on potential template programmers' part.
An _implementation_ disadvantage is that it currently is dependent on an
external Lua binary installation -- something that probably won't be
present on third-party installs, meaning Lua templates couldn't be
easily copied to non-Wikimedia wikis.
There are perhaps three primary alternative contenders that don't
involve making up our own scripting language (something I'd dearly like
I was thinking about something similar this weekend, although I'd thought
about different languages:
1 - XSLT
Since the syntax is XML (like the extensions tags) and XPath (vaguely
similar to template syntax, although it's XML that calls XPath, the
opposite of what we have) It would be reasonably consistent with current
syntax. It also should also already be fairly well locked down, and the
interface seems fairly clear - present template parameters as stylesheet
parameters, and other magic words as an input document. We may just need
a few simplifications to make it easier to use.
Should be easy to write a parser for if needed, since the grammer is so simple,
and it should be relatively simple to lock down or extend as needed.
Of course, those are both a bit more esoteric than your recommendations.
Perl is nice for getting useful results from short code, if we're not
bothered by one parser with no grammer specification calling another one. Tcl may
be a reasonable compromise; a less esoteric, imperative language which is often
used as an extension language.