4 ms·
Should compare with Rhai (https://rhai.rs/ https://rhai.rs/) I found rhai's syntax very straightforward, and I could almost accomplish my needs just by looking
by chaosprint 2y ago
Should compare with Rhai (https://rhai.rs/ https://rhai.rs/)
I found rhai's syntax very straightforward, and I could almost accomplish my needs just by looking at some basic examples.
I use Rhai in wasm, and it can handle real-time audio blocks, which is really impressive:
https://glicol.org/tour#meta2 https://glicol.org/tour#meta2
- nine_k 2y agoRhai looks somehow more OO, and is somehow conceptually bigger, with function overloading, operator overloading, currying, etc. Koto looks more like FP an stream processing, with pervasive anonymous functions, very simple data structures, and an emphasis on iterators. Rhai also offers some safety guarantees: no panics, no stack overflows, etc. Rhai seemingly requires slightly less ceremony when interfacing with Rust: direct use of many things, as opposed to implementing a trait to interact with Koto. (Disclaimer: I spent 5 minutes skimming the docs of each.)
- spacechild1 2y agoIsn't Rhai extremely slow? The website itself says that it's roughly 2x slower than Python3: https://rhai.rs/book/about/benchmarks.html https://rhai.rs/book/about/benchmarks.html. Apparently, Rhai doesn't even compile to bytecode and instead walks the AST! This doesn't sound like a language I would pick as for DSP... On the other hand, you can always write your own Rhai interpreter if necessary. And if you restrict the language to a limited set of features, which you need to do anyway to keep it realtime-safe, you could even compile it to native code. > and it can handle real-time audio blocks, which is really impressive: Any scripting language can do this as long as you stick to operations that don't cause memory allocations, system calls or other non-realtime-safe operations. For example, you can use Lua to write process functions for Pd objects: https://agraef.github.io/pd-lua/tutorial/pd-lua-intro.html#signals https://agraef.github.io/pd-lua/tutorial/pd-lua-intro.html#s... The question is rather how much you can do in a given audio callback. --- All that being said, Glicol is very cool!
- chaosprint 2y agoYou are absolutely right. Thanks for the correction and info! I gave Lua a shot, but getting the toolchain set up in wasm was a hassle: https://bytedream.github.io/litbwraw/introduction.html https://bytedream.github.io/litbwraw/introduction.html So at least I can say Rhai has some advantages on syntax and compatibility with wasm
- spacechild1 2y agoThat's a valid point. Being native to the host language (Rust) is generally a big advantage. I just don't really understand why Rhai uses an AST walking interpreter, that's basically the least efficient way of implement a scripting language. Once you have an AST, a byte code compiler/interpreter is not really hard to implement, so I'm wondering why they knowingly leave so much performance on the table...
- thayne 2y agoIs koto any faster?
- irh 2y agoIn my tests it's been ~1.5-2x faster than Rhai, but Koto's still some way behind Lua in benchmarks so I'm not trying to make a big claim here (although that said one of the reasons I started work on Koto was to avoid the runtime overhead of Lua <-> Rust conversions, e.g. Koto shares the same string representation as Rust, Koto lists are just wrapped `Vec`s, etc).
- 0x3444ac53 2y agoI looked into Rhai but was disappointed that it doesn't have first class functions.
- cp3io 2y agoI implemented a similar project using Koto https://github.com/cornedriesprong/ohm https://github.com/cornedriesprong/ohm. Not nearly as full-featured as Glicol, but I guess it can serve as comparison.