Rigz Blog

Your source for the latest updates, tutorials, and insights about Rigz.

Rigz 0.5.0

Author: Mitch

Date: January 10, 2025

Updated: January 17, 2025

The biggest release of Rigz so far!

Rewrites

The biggest changes to Rigz were due to two minor rewrites. The first is that Rigz VM is now stack based for simplicity while the language is ironed out. The second rewrite was related to the switch to a stack based VM, values are now fully pass by reference. This change was made to reduce unintended copies from being made.

        
        mut a = 1;
        mut b = a;
        b += 1;
        assert_eq a, b
        
      
If you want them to be separate values simply call `.clone`.
        
        mut a = 1;
        mut b = a.clone;
        b += 1;
        assert_neq a, b
        
      

List & Map Comprehensions

This syntax is heavily inspired by terraform and values will be converted to a list when calling it. Values (or keys in maps) that return none will be filtered out.

[for v in [1, 2, 3, 'a', 'b']: v if v.is_num] # [1, 2, 3]

A single value is now supported for maps, the key and value will be the same.

{for k, v in {1, 2, 3}: k, v if k % 2 == 0} # {2 = 2}

Lambda Support

Rigz now supports lambdas or passing functions as a reference

        
          [1, 37, '4', 'a'].filter { |v| 
            v.is_num 
          }.map { |v|
            v.to_i
          }.reduce(0, |res, next| res + next)
        
      

More Modules

The following modules have been added:

The following modules have been removed: The VM module has been updated to reflect this is now a stack based VM.

Memoization

The @memo lifecycle can be used to add memoization to a function, similar to Python's [@cache](https://docs.python.org/3/library/functools.html) Currently largely recursive functions may run into a stackoverflow in the Rust code, this will be addressed. Once lifecycle functions are supported you'll be able to customize how this works.

Processes

Processes can now be created with the @on lifecycle or by using `spawn`, there's still a lot of work to do here but simple use cases will work.

        
          @on("message")
          fn foo(a) = a * 2

          pid = send 'message', 21
          receive pid
        
        
          @on("message")
          fn foo(a, b) = a * b

          @on("message")
          fn bar(a, b) = a - b

          pids = broadcast 'message', 21, 12
          receive pids
        
        
          pid = spawn do
            42
          end

          receive pid
        
      
This adds a `threaded` feature to Rigz, when using `js` it will create single threaded processes. However this functionality is not fully supported. Future versions of Rigz will likely switch to tokio instead of a thread per process.

Dedicated WASM Support

Previously there was one feature `log_std_out` to make this usable in a browser setting, that feature has been removed in favor of a JS feature. With this JS feature all stdout/stderr will now use console.log/err instead. The test suite now runs verifying wasm functionality.

Plans for v0.6

More Modules in the Std Library

There are four modules planned next:

I'm also debating a JVM module that can interact with Jars or running java processes but that may have to wait until 0.7.

LSP

A basic LSP will be created for Rigz and support Goto definition & Formatting. We'll see how much else I'm able to add, ideally parts of this are available in 0.5.x releases.

Pattern Matching

Currently the only option available is a series of if/else blocks, Rigz will support elixir style function pattern matching. I'm still debating a match expression, but functions will be supported.

More Lifecycles & Meta-programming

With @memo, @on, and @test being stabilized, the next focus is @after to support terraform style plan & apply runs. The ability to create and manage your own lifecycles will be added. Part of this should include metaprogramming support.

Custom Types

Currently custom types are stored as maps, I'd like to have a dedicated object type that can be used and better support custom traits/impls.

Install rigz with cargo install rigz or check it out online!

Back to Blog