I decided at the start that the hunt is open for all language features with Rye, but until above Rye 1.0, I won't be touching modules in any way. In Rebol they called it programming in the small vs. programming in the large. You want your language to function well in both.
If possible modules should come from the basic features of the language itself, so until those are in place it makes no sense to build on top of them. It's like making an elaborate plan on how to cross the river, when you have not seen the river yet. And the path to the river is as or even more challenging and important than the river crossing itself.
Currently, Rye has a very basic way of adding builtin functions / bindings / integrations to it. You compile them into a single binary. I think I saw something like that in Lua years ago.
This is not as bad as it seems. We use Go build's flags, so you can define, at compile time, what functionalities you want your Rye binary to have.
go build -flags "sqlite,httpd"
Example above builds a Rye interpreter with addition of sqlite and http server functionality. Compiling Rye with Go is quick and simple. There are no Makefiles or special scripts needed.
Still, this is much more cumbersome than for example Python's import statements. But it has some benefits too. Single binary is a simple, portable and non-conflicting concept. Python's default causes conflicts with conflicting versions of interpreters or python libraries. They had to invent virtualenv, venv, pyvenv and similar tools, to separate python environments. Our more primitive way enables us to simply do:
go build -flags "sqlite,httpd" -o ~/projects/A/ryel
go build -flags "psql,httpd2,crypto" -o ~/projects/B/ryel
rye .needs
We don't have modules, just compiled in bindings, but it's still beneficial to clearly declare the bindings that a script needs. And get alerted immediately when bindings aren't there, not fail at some later point of execution.
That's why I added a function, that returns a Rye interpreter object. And this object has some generic methods. Method needs lets you declare what binding script needs. includes? and can-include? are more useful for exploration, in Rye shell for example.
I also played with a more declarative way of producing local (per project) Rye interpreters. More about this in the future.
Follow Rye development on Github.
Komentarji
Objavite komentar