⬅ 🏠 Home
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:
foreach, if we iterate over a collection of tuples, we can omit the brackets (just as in Python).
/=, instead of having to negate the entire equality using
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:
alice.is_online and bob.is_onlineinstead of
alice.is_online && bob.is_online. We can even write
alice is_online and bob is_online.
foo() or bar()instead of
foo() || bar().
!, which can easily be missed when read. So we write
if not productive then drink_coffee()instead of
if !productive then drink_coffee().
}, just as in Python.
Mamba also uses arrow notation to more clearly denote the flow of data:
<-is used to assign to variables. It denotes data flowing from the expression on the right to the identifier on the left.
->is used within type definitions of functions and methods.
=>is used to denote the control flow of the application. This is used for two reasons:
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:
]to insert variables into strings.
elseare used for program flow, and