-
-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elvish as an embedded scripting language? #812
Comments
In theory, Elvish is already embeddable by the virtue of having a modular design; in your Go code you can use Elvish functions and elvish values are Go functions and values of particular shapes. In fact, the line editor component ( The AST is probably serializable, but I have not checked. In principle, you should be able to just refer to the godoc for the Nonetheless, your request is a very reasonable one, and ensuring that Elvish is embeddable is beneficial for making sure that the internal architecture of Elvish is modular enough, with good internal APIs. Still, since the stability of internal API as well as the language will only become a goal after the 1.0 release, I encourage you to give it a try, but beware of all the caveats mentioned above. |
Perfect, from what I've read of the API from the godoc your answer is what I expected. One additional requirement I forgot to mention is that I would like to parse and compile the input code/script before sending and executing it on the client, but as you said that shouldn't be a problem. I totally understand that Elvish isn't stable, and can accept that for this project. Just out of curiosity though, do you have any idea/timeline when Elvish will hit v1.0? |
I have written my thoughts in #815. |
@capnspacehook Compiling the Elvish code and sending the compiled code over wire is much harder than sending the AST, as Elvish's compiler actually compiles the AST into Go closures, which are inherently unserializable. You can only use the compiler to do the checking, and re-compile it on the client though. |
Hmm ok, that's really good to know. I will have to that then, compile to check on the server, send, recompile and execute on the client. |
So it seems the result of |
So after taking a deep dive into the source of the That being said, I can't express enough just how well written and designed Elvish is, it's a pleasure to work with, and it's syntax is very intuitive and simple. Thanks again for such a great project. |
Hi - really glad that you like the design! I would love to learn from your changes. - I try to write the code in a general way, but since all of the packages are really only used in the Elvish program, it's almost unavoidable that some parts get unnecessarily specific. In general, I feel understanding more use cases can be quite helpful for improving the internal design. |
No problem, yeah the intuitive syntax and the ability to use lists and maps in a shell scripting context is great. Yeah there's a few things I know looking back that I changed that could benefit others:
There are more changes I made, but they were specific to my use case and would not be good changes to make to Elvish generally. |
I am considering using Elvish as an embedded scripting language in a project, and just wondered if you guys had any tips or thoughts on how you would do that, if it's feasible at all, etc.
I was originally going to use Bash, but due to the fact the internal modules I will be calling will return objects, not text, Bash will not work.
Then I thought about using Elvish. It has support for lists and maps, which I figure I can use to create arbitrary 'objects', and is a shell scripting language.
My questions/concerns are:
The text was updated successfully, but these errors were encountered: