FW: [PHP Classes] MetaL - a XML based meta-programming language developed using PHP 
Author Message
 FW: [PHP Classes] MetaL - a XML based meta-programming language developed using PHP

Hi all,

I've received this message on the PHP classes mailing list. It concerns
languages in general, and scripting languages in particular. Tcl is
mentioned as one of the potential bindings.

In short it describes a meta-language built upon XML. The current
implementation is written in PHP. It theoretically allows for any code
written in a given language to be translated in virtually any other
language, using an intermediary meta-language. IIRC, meta-programming is the
technique used by Andreas Otto for his Tcl->C compiler.

Happy reading

"Theory may inform, but Practice convinces"                      George Bain

----- Original Message -----

Sent: Monday, June 18, 2001 2:20 AM
Subject: [PHP Classes] MetaL - a XML based meta-programming language

developed using PHP

PHP Classes site newsletter


For the last two years the PHP Classes repository has been a privileged
site for distributing PHP components to a community that is eager to learn
and use the components that many PHP developers are willing to share.  I
started this site with the intention just described and I am very pleased
with its success.

Assuming that you continue to be interested in other PHP developments that
greatly contributed to the success of this site, I think it is about time
to unveil another ambitious project that I have been keeping secretly for
the last 2 years.

It is a meta-programming language (more on that below) and although I am
not yet ready to fully announce it to the public in general, I decided to
announce to you, PHP Classes site subscribers, in first place because I
thought many of you would be interested to know and eventually attend the
presentation session that I am going to give in the O'Reilly Open Source
Convention - XTech 2001 - XML Bleeding Edge sessions.

I am checking with O'Reilly and since the PHP Classes site and its
subscribers form an O'Reilly user group, you may be entitled to a 20%
discount.  If you are interested in the discount, just let me know so I
check for you with O'Reilly User Group manager.

In the future more information on MetaL will be available at:


Below follows a little glimpse on the talk on MetaL - the meta-programming

Thank you for your time and patience,
Manuel Lemos

Type of talk: New technology

Title: MetaL - XML based Meta-programming language technology

Abstract of the talk:

This talk is meant to be a presentation of a Meta-programming technology
named MetaL.  I have been developing this technology and using it in real
world projects for the last 2 years and it is going to be released soon
as an Open Source project.

MetaL is a language defined with XML tags.  Each MetaL XML tag has a
meaning that depends of the context within it is used.  The context of
tag is defined by modules of the MetaL compiler.  Each module may define
actions to associate to several XML tags.

When the compiler execute a MetaL XML tag, it invokes the module that is
assigned to implement the associated function actions.  The function
may be immediate actions, like creating a file, or may be generating
some output, like generating the lines of code of a program written in a
language into which the input MetaL source code is being translated to.

This way, the compiler is capable of translating source code defined with
MetaL tags into source code of potentially any language.  With a tool like
the MetaL compiler that can translate code to multiple languages, a
developer can do what is known as "Meta-programming".

The proposed talk is intended to:

- Motivation for development of a Meta-programming technology.

- Present in more detail how MetaL works and what are its advantages.

- What is the state of development of MetaL.

- Examples of real world applications.

- Present new opportunities to other developers interested to cooperate to
further develop MetaL for the benefit of the whole Open Source community.

Speaker: Manuel Lemos

Speaker resume:
Please look at http://www.*-*-*.com/

Extended abstract:

o Motivation

About a couple of years ago I entered in a partnership with some business
people to develop a modular integrated system of applications for business
management based on the Web.

The system was very ambitious and soon I realized that the development
needed to be based on very objective methods that would allow me to
quickly bring up a usable version of the different modules of the system.

The whole project needed more several developers qualified in Web
development to be deployed quick enough to be considered viable.  Those
were the days when there was still a lot of Internet 'hype'.  Not only it
was very hard to find qualified Web developers, but those that you could
find were already working in very well paid jobs and it would not
financially viable to hire them.

I was so frustrated with these facts that I decided to invest on the
development of a new programming system that on one hand would require
code to execute typical programming tasks, and on the other hand it would
require less knowledgeable developers to program with it.

As a direct consequence of achieving these goals for this new programming
system I could also achieve other highly desirable goals of software

- Software that is written with less code is less likely to have
  implementation bugs.  This is has direct implications in the stability,
  maintainability and overall quality of the software.

- When a programming tool appeals to a wider audience of developers that
  may be less qualified, it may as well start appealing to professionals
  that may not be knowledgeable in software development but may be more
  skilled in the problems that the software product is meant to solve.

  For instance, an economist may be more skilled than a software engineer
  at defining the business rules that a software product should implement.
  A programming tool that is directed to solve domain specific problems is
  often more adequate because it is more accessible to domain

As shown, there is plenty of motivation to move on to a development system
that helps developers to bring up software applications in less time,
requiring less skilled programmers while promoting the overall quality of
the project.

o How MetaL works

- Meta-Programming

Developing a new language that would satisfy immediately the needs
presented above would be of great risk because it would take a lot of time
to develop.

At the same time giving up on the existing programming languages does not
a good idea because most of those languages have many years of development
and maturity that makes them more adequate to solve many real world
problems for which they have been tailored and polished.

A compromise between developing a new programming language that would
satisfy the presented needs and not imply giving up on the existing
languages is to write a Meta-programming compiler.  This compiler would be
able to interpret a new language and generate output source code in one
existing language that may be selected from a list of available target

- XML based programming language

Writing a new language compiler is not a trivial programming matter.  It
requires knowledge on designing compilers that are able to parse source
code written in a given syntax and then process it to generate output in a
target format.

A solution that greatly simplifies this problem is to require that all
source code be defined in a XML format.  XML is a markup language that
requires strict syntax rules.  This characteristic simplifies the parsing
process because there are plenty software components for generic XML
parsing that are ready to use at no cost.

- Programming as simple as cooking

It is a known fact that people tend to learn more easily abstract concepts
such as those of programming when these concepts are presented using
analogies with concepts that they are already used to deal in their daily

One of those concept that can be presented as analogous to programming is
cooking.  Everybody must eat.  Not that everybody eats cooked food or
how to cook, but is fairly reasonable to assume that almost everybody is
familiar with the concept of cooking.

In every cooking process there must be ingredients that have to be
prepared.  Then there are the recipe steps that have to be followed to
the food.

MetaL programming is like cooking.  The developers must first define the
ingredients that are known as 'input'.  Then the developers must define
recipe steps known as 'output'.  In MetaL, the 'input' ingredients are the
just definitions that the name of the known XML tags that will be used in
the 'output' recipe.

- Compiling MetaL programs

To build MetaL program the compiler takes a 'input' file and 'output'.
After examining the 'input' file the compiler traverses the 'output' file
interpreting the XML tags in it by invoking a compiler module that is
responsible for the implementation of the respective function.  The
definitions also specify which module of the compiler is associated with
each function XML tag.

When the compiler executes a MetaL XML tag, it invokes the module that is
assigned to implement the associated function actions.  The function
actions may be some immediate action, like creating a file, or may be
generating some output, like generating the lines of code of a program in
target language to which the input MetaL source code is being translated

- Generating output source code in a target language

MetaL modules may be used to execute other actions besides generating
source code in a target language but this is their most outstanding

Most modules that generate output source code just send to an output
the lines of code that translate the functions specified as XML tags in
'output' definition to the commands in the target language.

A module may be able to generate code for the same function for multiple
target languages.  The definition of which module implements the
translation of functions for each target language is done in a special
'bindings' definition file that is also defined in XML with a specific tag
structure and syntax.

The generation of output source files is usually done by a special module
that knows how to generate files in the target language with the correct
syntax eventually with appropriate indentation rules to make those source
files readable enough to look like as if they were hand written by real

o State of development of MetaL

- Current implementation

The current implementation of MetaL compiler engine and all the available
modules was written in PHP.  It may sound a bit odd that a scripting
language like PHP, that is mostly meant for Web programming, be used for a
usually heavy task such as compiling interpreting source files.

Thanks mostly to the latest Zend compiler and optimizer engine, it turned
out that PHP is not such a slow option as scripting language.  There is
also a lot of XML file caching that accelerates the parsing of previously
interpreted MetaL source files.

- Available modules

The available modules are mostly meant to generate source code in PHP to
develop Web applications, but any of them could generate code in other
target languages.  More modules can also be easily developed other

Here follows a list of the most important modules available at the time of
this writting:

* compiler - MetaL compiler engine.

* base - base module to inherit other module definition classes.

* base_bindings - base module to inherit other definition classes to
  implement target language bindings.

* php_bindings - language bindings for PHP.

* program - Access to context values passed to the MetaL compiler.

* build - Makefile like build control.

* distribution - Creation of archives for distributing MetaL applications.

* documentation - Generation of documentation from a device independent
  document definition format.

* expressions - General purpose data type manipulation functions and

* flow - Logic execution flow control constructs.

* class - Creating and invocation of OOP classes.

* page - Generation of output source code as Web page scripts.

* template - Generation of output from text based template files.

* options - Access to application wide global option values.

* cgi - Access to data values passed to Web scripts via CGI.

* crypt - Cryptographic functions.

* time - Date and time access and manipulation functions.

* xml - XML parsing functions.

* metabase - Database independent access functions using Metabase

* locale - Localization of application texts.

* file - File and directory access functions.

* system - External programs invocation functions.

* menu, image, link, form, email - Interface with existing native PHP

o Examples of existing applications

At the time of this writting there is already a number of existing
applications, some of which are publically available:

- Integral - Modular integrated system of Web based applications.  This is
  the base of the system of modules for business management that
  motivated the development of MetaL.

- Multi-page forms class

- Table wrapper base class

- Calendar generation class

- Query result table display class

- Web based ezmlm mailing list creation and configuration tool

- I-Know class - multi-word key expression indexing and searching
  technology for building knowledge bases.
  Not yet published.

- XML Writer class

- SOAP server class

o Future work

- Planned work

As most of what has already been developed for MetaL, the priority of
future work will be defined according to the current needs.  The original
motivation was to develop a integrated system of modular Web based

Currently I am no longer actively working on that project because I am now
working on a Internet portal company, so my work on MetaL is more
to assist my current job.  Given this, here follows my current list of
priorities for future development:

* Improve the build module to automatically figure if previously generated
  target files are still upto date by verifying all dependencies listed in
  outputted files list.

* Drop support for XML tag attributes to promote SML (Simplified XML)
  code because it is more readable and extensible.

* Add support for context specific functions to be added and removed
  dynamically by function modules and simplify functions of the class
  module that access object own variables and call its functions.

* Add support for literate programming in the class module to be able to
  naturally embed documentation for classes, variables, functions and

* Develop a module for creating and managing GUI now that PHP has GTK

* Develop a module for writing compiler modules in MetaL itself.

* Develop bindings for Perl and Java.

* Develop special bindings for C language to develop Web applications that
  run within Web servers as built-in modules, thus achiving raw execution
  speed.  The sub-project to develop these special bindings is named

- Opportunities to other Open Source developers

At the time of this writing MetaL is being opened to a restricted group of
developers that have been invited to be peer reviewers.  For a relatively
short period these developers will have access to the whole MetaL
technology and development materials.

The goal is to let them evaluate the technology so they can help to figure
if it is ready for public release.  After a public release no major design
changes will be done to not compromise the compatibility of the work of
other developers that will use MetaL for their own purposes.

After this peer reviewing period, that is expected to no last more than a
few weeks, MetaL will finally be released to the general public as an Open
Source project.  The Open Source license to be adopted is not yet decided
but will be most likely LGPL.

When MetaL will become a full fledged Open Source project, I expect that
will implicitly create a number of interesting opportunities to other Open
Source developers.

It is not possible for me to antecipate all sorts of applications that
MetaL may be used in the future, but I may suggest a few types of
applications that other developers may be working on in the future:

* Bindings to make existing modules generate code in other popular target
  languages: Java, Python, TCL, Delphi, Visual Basic, you name it, etc...

* Modules for new applications or to implement new domain languages.

* Rewrite the compiler in MetaL itself so that it can be built on lower
  level language that is much faster to execute.

* Graphical Integrated Development Environment

* Etc...

Author name: Manuel Lemos

Sun, 07 Dec 2003 22:00:18 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Announcing the world's 1st XML-based programming language

2. Transition from Clipper DOS based to Windows based Programming language

3. Announcing: New C like syntax for x++ (OO XML-based language)

4. Creating XML docs using PHP

5. Using PHP to validate XML

6. Xcerpt, a pattern-based, deductive query language for XML (and SSD)

7. Developing Executable Specifications Using Functional Languages

8. Using CLOCC xml.lisp to print XML in XML format

9. FW: Programming language vote - results

10. FW: Programming language vote - results

11. "Developing Visual Programming Applications Using Smalltalk"

12. Paper on using VW's XML and XSL classes


Powered by phpBB® Forum Software