Dedicated to Finn (2018-2026) 🕊️
FinnLang is a simple, scripting language designed for learning interpreters and compiler basics. It supports basic variable declarations, expressions, control flow, and woofing. Also check out the gallery of dog pics.
I made a web sandbox where you can play with FinnLang.
Here are the installation steps, enjoy!
Note: Make sure you have the latest versions of Cargo, and npm
- Clone the Repository
git clone https://github.com/yourusername/finnlang.git
cd finnlang- Start the Backend Server Navigate to the backend directory and run the Rust server:
cd backend
cargo run --bin serverThis'll start the FinnLang backend on localhost. Default is port 3000, but you can change it in server.rs.
- Set Up and Run the Frontend In a new terminal window, go to the frontend sandbox directory:
cd ../finnlang-sandboxInstall the dependencies:
npm installThen, start the development server:
npm run devThis should open the web sandbox in your browser at http://localhost:5173 (or whatever Vite uses by default).
- Write your finnlang code in a
.finnfile, for example:
let x = 0;
while (x < 5) {
woof(x);
x = x + 1;
}
woof("Hello world");
Save this as file_name.finn in the ./backend folder.
- Build and run the interpreter using Cargo:
cargo run -- file_name.finnReplace file_name.finn with the path to your own .finn file if needed. (Or you can use your own file path)
- Output will be printed to the terminal as your program executes.
- int — 64-bit signed integers
- bool — Boolean values: true or false
- string — Double-quoted strings "hello"
- double — Floating point numbers
Supports:
- Arithmetic: + for numbers and string concatenation
- Boolean logic: && (and), || (or), ! (not)
- Comparison: ==, !=, < (less than)
let a = 5 + 3;
let b = "Hello, " + "world!";
let c = (a == 8);
Use woof to output values:
woof("Hello, world!");
let a = "HI";
woof(a);
Use if, elif, and else to declate conditionals. elif and else are entirely optional.
if (x < 0){
woof("x is less than 0");
}elif (x == 5){
woof("x is equal to 5");
}else{
woof("x is something else");
}
Repeat code with initialization, condition, and update:
for (let i = 0; i < 5; i = i + 1) {
woof(i);
}
Define and call custom functions with the funct keyword:
// Function without parameters
funct sayHello() {
woof("Hello, world!");
}
// Function with parameters
funct greet(name: string, age: int) {
woof("Hello " + name + ", you are " + age + " years old!");
}
// Call functions
sayHello();
greet("Alice", 25);
Support for single-line and multi-line comments:
// This is a single-line comment
/*
This is a multi-line comment
that can span multiple lines
*/
let x = 5; // End-of-line comment
Repeat code while a condition is true:
let x = 0;
while (x < 5) {
woof(x);
x = x + 1;
}
You can declare arrays of data
let nums = [0, 1, 2, 3, 4, 5];
let names = ["Alice", "Bob", "Charlie"];
Assign new values to existing variables:
let count = 10;
woof(count);
count = count + 1;
woof(count);
Declare variables with let. (Type annotation is optional)
let x = 10;
let name: string = "Charlie";
let name2 = "Charlie";
let flag: bool = true;