YML – Why a Markup Language?!

YML 2.5.3 of Fr Dec 30 2011 – Copyleft 2007-2011, Volker BirkDownload YML 2

Introduction

Modelling approaches like Microsoft Oslo or Eclipse Modeling Framework are trying to reach the situation, that a programmer can define what he wants to have, and not only how to implement it technically.

Both projects are doing this in a complex way. With the CodeGen project, I'm trying to provide a generation framework plain and simple.

Because one of the problems to solve is a possibility to quickly define Domain Specific Languages and to work with them, I created YML. YML is very easy to use – but it does not do the complete job itself. As a matter of fact, I'm leveraging most of the features from the XML toolchain.

XML has the possibilities to do the job of creating Domain Specific Languages already; so my approach is to make these features fit in a concept for Declarative Programming and Code Generation.

XML – a language to design languages already there

Any time a formal language is created for computing, a compromise has to be found: whether the language is perfect for the computer but terrible for the human or vice versa. XML is very good for the computer ;-)

Using XML for the reasons mentioned above, but for programming? “Why a Markup Language?!” was what I was shouting some time playing around with a code generator in XSLT. That gave the idea.

Motivation

Many people don't write XSLT directly, because they don't like writing programs in angle brackets. The result usually is, that people are writing Java programs, and are processing XML from Java, or are using XSLT features from Java programs.

But that is very inefficient – there are small and quick XSLT processors, and there are no advantages at all to implement that in Java or C++ usually.

So I wanted to have something like a Java or C like language, which can be easily translated into XSLT. Then a common XSLT processor can process the program, and XML can be processed very quickly (see also the YSLT sample program).

I started this, because I saw, that code generation for Automated Software Engineering can be implemented very easily in XSLT – but writing XSLT is annoying.

What can I do with YML?

With YML you can:

How it works: Replacing angle brackets with some Python

Just writing down what I wanted to have instead of XML for a sample:

<list name="List of goods">
    <head>
        <columTitle>
            Goods
        </columnTitle>
        <columnTitle>
            Price
        </columnTitle>
    </head>
    <row>
        <value>
            Beer
        </value>
        <value>
            20
        </value>
    </row>
    <row>
        <value>
            Wine
        </value>
        <value>
            30
        </value>
    </row>
</list>

Something like that should be more easy, say, like this:

list "List of goods" {
    head {
        title > Goods
        title > Price
    }
    row {
        value > Beer
        value > 20
    }
    row {
        value > Wine
        value > 30
    }
}

Y Languages

The latter is what I call an Y language – a language specified in YML. How could this be achieved? Well, what's to do? To have the required information, how to build XML from the script above, we need:

How to do that? Let's invent a simple definition language for that information:

decl list(name);
decl title alias columnTitle;

Here you can download the complete list sample.

^Top^ >> Using YML 2 (source)