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:
- Any (auto import): moved generic functions from Std that apply to all types
- Assertions (auto import): Moved all assert* functions from Std, these will be used in a future version to support @test lifecycle functions
- Collections (auto import): Functions related to Maps or Lists, eventually there will be an Iterable module created for most of this so that custom types can use them as well
- Date: Currently only includes now or utc, but more will come in the future
- Number (auto import): Functions for numbers have been moved from Std
- Random: Create random ints, floats, and bools; more types will be supported in the future
- String (auto import): A string operations have been moved here
- UUID: v4 uuids can be created or converted from strings
- Std - functionality has been added to a module for it's type, or Any
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.
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.@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
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:
- A Math module to add remaining math functionality
- An HTTP module that can be used to interact with other services.
- An HTML module to interact with html strings, this may become more broadly available as a Query module
- An FFI Module to interact with dynamic libraries from Rigz
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!