Skip to content

Latest commit

 

History

137 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Helix

A small, fast scripting language, implemented from scratch in Rust. Helix compiles source to bytecode and runs it on its own stack machine — no tree-walking interpreter, no parser generator, no external runtime.

The aim is a language that stays out of the way: light enough to drop into a Rust program, quick enough not to think about, and predictable in the places scripting languages usually aren't.

Demo

                                                                                    
      ........................................................................      
......................................-======-......................................
:::::::::::::::::::::::::::::::::::+*######****+=:::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::--+###%%%%###****++-:::::::::::::::::::::::::::::::::
--::::::-----::-------::--------+*##%%%%%%##*****++=---:--------::-----::::::----:::
---------:----------:----------+***#%%%%%%#******++=------:---------::---------::---
:::---------::::--------------=*****#####********+==---++***+=------------::::------
--::::---------:::::--=====----++++*******++****+==---.*#%%#***======---------------
==----:-----======---------=====+++++++++++++++==----..+#%##***+=---------=====-----
=======----------======**++=----==============-------..=+++++++=----========--------
----==---------------#%%%##*+---------------------:....:=====--:::---==-------------
--==========--------*#%%##**+===---::::::::::::::....  ..:::::....:=====-----------=
===========---------+*****+==---::-=--.................--=-----===========-=======--
-------============--=====---.....====++=-::::::::::--===========-----------========
-----============------::::..---=+++++++++------------=++++++++====------------=====
==-=========================-=======================================-===============
=-------------=+++++++++++++--------------+++++++++++++=--------------++++++++++====
-------------++++++++++++++---------------++++++++++++++=--------------=++++++++++++
-----------=++++++++++++++=---------------+++++++++++++++=---------------=++++++++++
=========-================================================-===============+=========
+++++++=-----------------+++++++++++++++++-----------------++++++++++++++++=--------
++++++=-----------------=+++++++++++++++++------------------+++++++++++++++++=------
++++==-----------------=++++++++++++++++++------------------=+++++++++++++++++=-----

A raytracer — perspective camera, Blinn-Phong shading, hard shadows, a checkerboard plane and distance fog — written entirely in Helix. Source in examples/raytracer/.

The cast loop never asks what shape it is holding; every object just answers ray_intersection:

fn Scene:cast_ray(self, ray, t_min, t_max) {
    let closest = .none;

    for object in self:objects {
        match object:ray_intersection(ray, t_min, t_max) {
            case (.some, hit): {
                # shrink the window, so a later object only counts if it is nearer
                t_max = hit:t;
                closest = (.some, hit);
            },
            case _: {}
        };
    }

    closest
}

Running

Requires Rust and Cargo.

cargo run -- file.hx    # execute a script
cargo run               # start the REPL
cargo test              # run the test suite

Docs

  • overview.md — a tour of the language
  • grammar.md — the grammar, as the parser implements it
  • examples/ — game of life, tic-tac-toe, pathfinding, sorting, the raytracer
  • std/ — the standard library

Status

v1.0. Complete enough to write real programs in.

Embedding is the direction rather than the current state. The host API is still compile-and-run, and the interner and source map are process-global, so a host gets one engine and scripts leak their source. Values are reference-counted, so cycles leak. Hash maps aren't in yet.

License

MIT

About

A bytecode-interpreted, statically typed programming language.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages