Skip to content
/ lost Public

A Blazingly Fast™ general-purpose programming language

License

Notifications You must be signed in to change notification settings

snprajwal/lost

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lost

A general-purpose interpreted programming language written in Rust. Guaranteed to be Blazingly Fast™ :P

Why the name?

This was inspired by the Lox programming language from Crafting Interpreters by Robert Nystrom.

For obvious reasons, I cannot name it Lust, hence Lox + Rust = Lost :)

Usage

To run the Lost REPL, simply execute cargo run.

To invoke the compiler on a .lost file, pass the file as an argument to the above command, i.e. cargo run file.lost.

Getting started

The syntax is fairly straightforward, and is mostly borrowed from existing languages. Reading the below snippet should suffice to start writing code in Lost.

fn foo(n) {
    if (n == 0) {
        print("Zero");
        while (n <= 1) {
            print(n);
            n = n + 1;
        }
        return true;
    } else {
        print("Not zero");
        for (let i = 0; i < n; ++i) {
            print(i);
        }
        return false;
    }
}

let n = 5; // All numbers are handled as floating point values
let isZero = foo(n);
print(isZero); // false
print(foo(0)); // true

let a; // Uninitialised variables are null by default
print(a); // null

// Classes are slightly different compared to other languages.
// There are no fields in the class declaration, only methods.
// Self-referencing works with the `this` keyword.
class Vehicle {
  fn countWheels() {
    print(this.wheels);
  }
}

let car = Vehicle();
car.wheels = 4;
car.countWheels(); // 4

About

A Blazingly Fast™ general-purpose programming language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published