Lola: a new, but powerful scripting language - tests and reviews are welcome


I know this code is bad, for many, many reasons. But it's working..:slight_smile:

Please report bad things on the following gitlab repos. Thanks!


I had a dream about adding meters with kilometers, or km/h with m/s...
Now I can, with my first Rust programming language, lol :slight_smile:

I named it "Lola", because it is "lol" => really bad implementation here, still learning...

However, it has many features:

  • high precision numbers, thanks to rug
  • handles something like 95% of the SI units
  • variables,
  • loops,
  • condition statements,
  • user-defined functions,
  • arrays,
  • exceptions,
  • scopes,
  • anonymous functions,
  • ... lol!

Lola code example

// Returns the given string, repeated n times.
fn repeat_str(s: string, n: int) {
    let output = "";
    for n { output += s }

// Returns an array, each value having been mapped by the given function.
fn map(a: array, mapper: function) {
    let output = [];
    for v in a {
        output += mapper(v)

input = [ "Hi", "!" ];
output = map(input, fn(s) repeat_str(s, 3));

input = [ 2.55 km, 50cm + 700mm ];
// Tip: the "~" operator converts a value to the given unit, if possible:
output = map(input, fn(v) v ~m);

Output of the above lola code example:

[ HiHiHi, !!! ]
[ 2550 m, 1.2 m ]

A working inline version

Be prepared for 500 or 404 responses, sorry!

The actual website frontend is written in french... But all the docs are written in english.


In order to make it usable, and to learn more about Rust, I built four different projects:

lola: the core lib

The most stable project, as far as I know, and the base of all the other projects;

lola-cli: interactive cli tool

An interactive cli tool which runs Lola code (wrapper over the core lib);

lola-server: API which runs Lola code and persist it into "sessions"

An API which can run Lola code, and persist it in a database while adding the concept of "session"
(thanks to and, and using the core lib);

lola-front: a web frontend

Powered by Symfony, which needs lola-server (just in case: if the lola API is down, get prepared
to 500s, lol!)...


Wow, this look nice. I think you're way past the so-called newbie state now :slight_smile:

Did you evaluate Rust libraries that lets you work with SI units? I found uom (short for "units of measurement"). How does your language compare to such a library?

The syntax of the language might be the biggest difference? If I'm guessing right, Lola lets you write

    let length = 5.0km;
    let time = 15.0s;
    let velocity = length / time;

vs real Rust:

    let length = Length::new::<kilometer>(5.0);
    let time = Time::new::<second>(15.0);
    let velocity = length / time;

Yes, uom seems to be a very nice crate; I didn't try it for this project, because it implements zero-cost types, which are fixed on compile time, and I wanted to be able to add custom types dynamically, on runtime. In terms of performance, the lola scripting language is far, far away from the gain of using zero-cost rust crates directly, but it's not the goal.


To give more precisions about this, giving the ability to add custom units is a latent feature in the code (thanks to not using compile-time structures), but it's not available for now...

When thinking about it and by considering the actual code, I can understand that it requires a parse in two passes : indeed the actual parser needs to be aware of all the existing units; if some custom unit definitions are allowed, then these definitions have to be processed before the main parse. It looks a bit like C preprocessor directives, in the way that they must be parsed before everything else.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.