aardappel / lobster

The Lobster Programming Language
http://strlen.com/lobster
2.27k stars 120 forks source link

Feature: Implementation of Lobster as a scripting language embedded in rust. #297

Open gustavomh opened 8 months ago

gustavomh commented 8 months ago

I would love the ability to use Lobster as a scripting language built into Rust. something similar to what you have with Lua (rlua crate) or python (PyO3 crate).

aardappel commented 8 months ago

I'm sure that could be done.. but I doubt that is something this project would provide directly. Likely a separate repo that could implement that.

In fact, as you can read about in the "extending Lobster" section in https://aardappel.github.io/lobster/implementation.html, what would likely be much more interesting is having a way to use Rust to take the role of C++ in providing built-in functionality to Lobster, i.e. not "Lobster embedded in Rust", but "Rust embedded in Lobster".

A language like Lobster is much better at being the main program, and providing all the plumbing/glue.. you want Rust for speed, not for plumbing :) Imagine the velocity of development if most non-speed sensitive changes in a combined Lobster-Rust program can be done instantly, without a Rust build.

istathar commented 6 months ago

i.e. not "Lobster embedded in Rust", but "Rust embedded in Lobster".

I realize that you explicitly differentiate what you're after away from their pattern, but perhaps the vocabulary being looked for here is "host language" in the sense of Lua and Wren.

Lua is implemented in C, yes, but it's more that you can communicate between Lua and the language that's hosted in (via C via FFI to anywhere). At that point yes the scripting language is calling the shots, but the heavily lifting of the implementation (not to mention the compiler/interpreter) is available in the host language that is the actual runtime/ecosystem/whatever at play.

So here's the question, restated: would you countenance having the implementation language of Lobster change away from C++?

aardappel commented 6 months ago

If I could snap my fingers and change all the C++ involved in the project into Rust overnight, I probably would.

But the reality is that rewriting it all in Rust would be a crazy amount of work. And a mixed project (both C++ and Rust) would be worse than just one of them.. at least with just C++ I get nice tooling and debugging.

There's also a lot of low level stuff going on in the VM that Rust likely wouldn't be able to do as well as C++.

The project also uses a lot of C/C++ libraries that would need replacing and wrapping.