Yeah this is very much a current issue for me. I want Pyret to be a lot more
pleasant and the command line, and a REPL is just one part of that.
The short answer for the REPL is that it's not on the main branch – there was a
lot of code churn around when it was written and reviving that version is now
pretty nontrivial.
That said, I'm going to use this as an opportunity to talk about some of the
things we've made a bunch of progress on in the last 9 months or so, because
they are related to getting a good CLI repl going.
The main reason Pyret is a nuisance to use at the CLI is that it has all kinds
of startup time issues. In CPO this is paid once each time the editor loads,
and lots of intelligent in-memory caching of modules happens to give a snappy
experience after that. We don't have the same abstractions available at the
command line where the in-memory state of the compiler is constructed at
each startup.
This is mostly because Pyret causes some significant code blowup to get those
good error messages, and because of the stack management story. The upshot is
that it takes a few _seconds_ for the compiler to start up, and hundreds of
milliseconds to a second for the simplest compiled files to run.
This isn't a new problem, just an engineering problem, and we're attacking this
from a few angles:
- Many languages support _compile servers_ or _language servers_ (see the Flow
type checker and the Scala compile server for good examples) that cache lots
of useful information. These typically start up semi-transparently in the
background, and client executables connect to them for much snappier
performance. There's an experimental compile server in the master branch,
with a test repo for it at
https://github.com/jpolitz/pyret-starter-repo,
which will let you install Pyret via `npm install`
- Much of the fancy compilation Pyret does for the browser is simply irrelevant
at the command line, because the fancy compilation is all about managing
control flow by simulating pre-emptive concurrency atop a single
JavaScript thread. For lots of reasons, we've historically just had one
version of the compiler that generates this code, but we're working on
compile options to turn off a lot of this support, which significantly speeds
up a lot of operations at the command line. (See
https://github.com/brownplt/pyret-lang/pull/1054)
- Since the Pyret compiler has historically relied on a lot of npm packages,
and we can customize the build process for
code.pyret.org as much as we
wanted, command-line Pyret had lots of bad assumptions about the existence of
`node_modules/` and other implicit node dependencies. This made using the
compiler, and the files it generated, overly frustrating outside of contexts
that we set up in the pyret-lang and
code.pyret.org repos. We're working to
fix that with a combination of `browserify` and more information about raw JS
dependencies. (See
https://github.com/brownplt/pyret-lang/pull/1053)
(I note the irony that a tool called `browserify` helps the offline
experience.)
The overall goal here is to give Pyret a command-line experience where users
get snappy feedback, can run Pyret code without the overhead of CPO, and don't
need to think too hard about installation or nonsense about tracking lots of
relative paths. This is "just" engineering that we need to get through, and
we'll be sure to let folks know when we have things worth trying out.
All of these things are aligned with getting the CLI _REPL_ to work well, too,
because it faces a lot of the same startup and dependency issues as general
standalone Pyret files.
I also want to make a note that a huge amount of this progress is thanks to Ian
Boros, a terrific student from Brown we were lucky enough to work with this
past academic year and some of this summer (the two pull requests above were
created by my account, but mostly consist of Ian's commits). You can see his
Github commits as the user puppyofkosh.