gluon-lang / gluon

A static, type inferred and embeddable language written in Rust.
https://gluon-lang.org
MIT License
3.2k stars 145 forks source link

Gluon as a standalone language? #818

Open Escapingbug opened 4 years ago

Escapingbug commented 4 years ago

I know that Gluon is intended to be a embeddable language, but to me, I think it is also a good choice to become a standalone language as well. So, what is the attitude on this?

And to be able to integrate Rust extension, we might ensure Rust extension in some specific format, so that when "install" a Rust extension, we actually compile a new Gluon binary with extensions added as modules. In this way we have full Rust power, and a standalone language is quite possible?

Marwes commented 4 years ago

It is interesting to some extent, for instance shebangs (#! gluon) works as a way to run standalone scripts from the command line but that does not allow for a way to load and run rust code as you suggest.

Since the embedding use case does not have this issue I haven't prioritized it but it is something I would like to support in some way as it would be a path for the language server to provide completion for the rust code that is loaded. So even the embedding use case could stand to benefit from running the code as Rust -> Gluon -> Rust module instead of just Rust -> Gluon

Escapingbug commented 4 years ago

Sorry I haven't fully got this, what do you mean by running the code as Rust -> Gluon -> Rust module?

And to load and run Rust code, my suggestion is that we can have something like a "Package Manager", when it "loads" (or actually installs) Rust code, it compiles Rust module to get a new gluon binary with that module. This is what I currently have in mind.

Marwes commented 4 years ago

Sorry I haven't fully got this, what do you mean by running the code as Rust -> Gluon -> Rust module?

Probably should just say Gluon -> Rust that is, the gluon code alone decides how and what rust code to load in, without any Rust layer above it to control it. This would be useful for the language server since it only sees Gluon code atm, but if Gluon code alone could load Rust then the language server would also be able to see any custom rust modules that users create.

And to load and run Rust code, my suggestion is that we can have something like a "Package Manager", when it "loads" (or actually installs) Rust code, it compiles Rust module to get a new gluon binary with that module. This is what I currently have in mind.

That could work but I think it may be even easier (for users, not to implement) if gluon could load dynamic libraries like lua does. (There is some inherent unsafety in this, but I think that is acceptable)