News for hackers. Stuff that matters.
Re:Koto Programming Language by chaosprint on Saturday March 29, 2025 @09:28AM (#43515372)
Should compare with Rhai (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

Re:Koto Programming Language by nine_k on Saturday March 29, 2025 @01:20PM (#43517014)
Rhai 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.)

Re:Koto Programming Language by spacechild1 on Saturday March 29, 2025 @07:45PM (#43519782)
Isn't Rhai extremely slow? The website itself says that it's roughly 2x slower than Python3: 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#s...

The question is rather how much you can do in a given audio callback.

---

All that being said, Glicol is very cool!

Re:Koto Programming Language by chaosprint on Sunday March 30, 2025 @01:51AM (#43521695)
You 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

So at least I can say Rhai has some advantages on syntax and compatibility with wasm

Re:Koto Programming Language by spacechild1 on Sunday March 30, 2025 @07:55AM (#43523407)
That'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...

Re:Koto Programming Language by thayne on Sunday March 30, 2025 @02:19AM (#43521804)
Is koto any faster?
Re:Koto Programming Language by irh on Sunday March 30, 2025 @04:28AM (#43522436)
In 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).
Re:Koto Programming Language by 0x3444ac53 on Sunday March 30, 2025 @11:17AM (#43524839)
I looked into Rhai but was disappointed that it doesn't have first class functions.
Re:Koto Programming Language by cp3io on Wednesday April 02, 2025 @04:01PM (#43560894)
I implemented a similar project using Koto https://github.com/cornedriesprong/ohm. Not nearly as full-featured as Glicol, but I guess it can serve as comparison.