Lucia

Lucia

WASM Playground

About Lucia

Lucia

Lucia-... by SirPigari

Lucia is a lightweight, expressive scripting language with Python inspired syntax, implemented in Rust for performance and safety. It includes static typing, an integrated package manager (Lym), and is released under GPLv3. This playground runs a smaller version built using wasm-bindgen for in-browser experimentation - some native features are omitted.


Status

CIWASM Build

Lucia Playground

Loading...

Running WASM warmup

For loops are declared with the "for" keyword. Each block in lucia ends with the "end" keyword. The "[x..y]" syntax is used to create a range of values. It returns a generator. The range is always inclusive and you can specify the step by "[y, step..x]". Try changing the code a bit to see how it behaves.

Output

You can declare variables two different ways. One way, the most often used, is with the ":=" syntax. This is used for auto type inference. The other way is with the "x: T" syntax. This is used for explicit variable types. Some of the types are: int, str, float, bool, void, any... When the value is missing (so no "=") it assign to the default value of the type or null if no default was found.

Output

You can assign values to variables like in any other language. Just use the "=". Try commenting out the first line to see what happens.

Output

Functions are declared with the "fun" keyword. Each function has a name, a list of parameters, return type, and a body. Return type can be omitted, in which case it defaults to "any".

Output

Conditional statements are declared with the "if" keyword. You can have multiple "else if" branches and an optional "else" branch.

Output

While loops are declared with the "while" keyword.

Output

Lists are ordered collections of values. They can contain values of different types. Lists are mutable, but append/extend return new list instead of mutating (bug).

Output

Maps are collections of key-value pairs. Keys are unique and can be of any type. Values can be of any type as well.

Output

Errors can be handled with the "try" keyword. The code inside the "try" block is executed, and if an error occurs, the code inside the "catch" block is executed. The error tuple is available as "e" inside the catch block.

Output

You can import standard library modules with the "import" keyword. Some of the available modules are: random, math, time, os, regex, json... You can also import specific functions or variables from a module with the "from" keyword. Sleeping is simulated in WASM because js is single threaded.

Output

Macros are a way to define reusable code snippets. They are declared with the "#macro" directive. Macros can take parameters and can be called like functions, but they are expanded at preprocessor time. This example defines a simple logging macro that prints a message with a timestamp.

Output

Lucia (repo)

Docs

Lym

Lucia Playground