Threads REPL
cc @andrewxhill @eightysteele
I know you guys were chatting about the shell and what it might be able to do. @jsign and I also chatted about this during the heavy threads development. It would be so nice to have a real, mongo feeling REPL interface.
This means we'll need some kind of scripting language since we probably don't want to reinvent the wheel in terms of parsing the input. I wonder, could we use a JavaScript interpreter? Again, inspired my mongo.
Some possible ways forward:
A Go program with a JS interpreter (written in Go)
This would involve interpreting the user input as JS, which would somehow map to an input compatible with the threads Go client. mongo takes a similar approach, apparently using SpiderMonkey: https://stackoverflow.com/a/8331139/641834
Other interpreters:
- https://github.com/robertkrimen/otto (pure Go)
- https://github.com/dop251/goja (pure Go)
- https://godoc.org/github.com/augustoroman/v8 (I think required CGO, not ideal)
Pros: All the niceties that come with standalone binary
A NodeJS program
This would involve using the built in REPL (https://nodejs.org/api/repl.html) alongside the threads JS client. Everything should be available there, from creating stores to starting transactions.
Pros: Likely much faster development time, npm install-able
Thoughts?
I would vote for a nodejs program, which shouldn’t come as a surprise 😜. This is potentially much more hackable for outside devs, easy to install / setup, and the faster turnaround time might be worth it right there? It I also don’t really have a horse 🐎 in this race at the moment, so take my vote with a grain of salt 🧂.
@sanderpick @carsonfarmer +1 for a real-mongo-feeling REPL interface. bullish on the proposal here for a nodejs program (vs. standalone binary)—fast dev time with npm install is pretty great imo. pumped!
Sounds good to me! The NodeJS REPL looks really easy to use. You just export functions and they magically are available to the user by name: https://nodejs.org/en/knowledge/REPL/how-to-create-a-custom-repl/
sick! reading up on the custom repl stuff now.
here's a stab—probably a lot of things to change/evolve, but this at least gets something going: https://github.com/eightysteele/thread-shell