Mamba

Logo

Documentation of the Mamba Language

View the Project on GitHub JSAbrahams/mamba_doc

🏠 Home

1 💭 Philsophy of the Language

1.2 Readability

Syntax and Syntax Sugar

One thing that can significantly hinder the readability of source code is syntax noise. Therefore, I tried to limit the amount of symbols and keywords in the language. I believe that when reading a piece of code, one should be able to understand what is happening without being hindered by excessive syntax.

One way to make code “look” more elegant, and ideally more readable, is through use of syntax sugar. This allows developers to, ideally, express their ideas in a more elegant manner. Syntax sugar however comes with its own set of problems, one of which is that it can introduce a new way of solving the same problem. We therefore aim to use syntax sugar sparingly, but still often enough so the language does not become overly verbose. A few examples are shown below:

As stated before, we also decrease the reliance on symbols, which may be another source of syntax noise. This should make the language more closely map to the english language, but not so close as to introduce ambiguity into the language. A few examples are given below:

Mamba also uses arrow notation to more clearly denote the flow of data:

This, combined with (sparing) use of syntax sugar, should ideally make the language easier to read. Take for instance the following piece of code:

foreach composer in composers do
    if composer.death is undefined then
        print "[composer] has not died."
    else 
        def years_ago <- today - composer.death
        print "[composer] died [years_ago] years ago."

Without any knowledge of Mamba, the reader should ideally, when reading above, be able to deduce that:

Notice how little program specific syntax there is: