Staying local

Sometimes I don’t feel like going all around the world on the Internet to accomplish something I can do on my local laptop. Somehow it can feel… slow, or wasteful (although it’s rarely either) to send my bits out into the great pandemonium of planetary data centres, only to have them come right back to where they started – while equivalent functionality sits unused on my rarely-breaks-a-sweat computer.

I’ve been playing with Dart and Flutter lately, and wanted a simple way to evaluate basic Dart code – so I recently made a little REPL that’s available in my tmux environment. The left pane is a Vim window with a main() entry point open, which is evaluated in the right pane whenever the file is saved. That’s it!

Uh, wait, you say – couldn’t you just use DartPad?.. Yes! Absolutely. Or repl.it for that matter, which is pretty great too. And neither of those options requires any setup or mucking with config files.

But sometimes I’d rather keep it local.

Published by

Kirk Wight

I am a Code Wrangler at Automattic, helping make WordPress.com the best it can be. Pender Island, British Columbia, Canada is where I call home. Lover, not a fighter.

3 thoughts on “Staying local”

  1. Nice! I love this sort of stuff.

    I don’t know if you know, but nowadays (since Vim 8, I believe?) you have native terminal functionality right inside the editor. So suddenly a lot of things that previously required tmux or GNU screen can be done natively.

    Here is the equivalent functionality using just `:term`:

    And here is a different take on REPL — more in the Lisp sense — where you have a VM running alongside an editor, and you can press Enter on a block of text to “send” it to the VM. For instance, define a function in the source file and press Enter to load it in the VM:

    The latter works thanks to a tiny script that I just forced myself to put on GitHub: https://github.com/mcsf/vim-repl. I don’t know if it’s your jam, but I hope this proves useful! 🙂

    1. And yes, my use of the term REPL is quite loose – what you’ve shown is more accurate I think, like the PHP interactive shell (`php -a`), which Dart doesn’t seem to have.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s