Ξ  


AlBasmala Archive Tags RSS About

πŸ’ VSCode is itself a JavaScript REPL πŸ”

Article image
Abstract

A meta-extension for VSCode that makes VSCode into a living, breathing, JS interpreter: It can execute arbitrary JS that alters VSCode on-the-fly. A gateway into the world of Editor Crafting!

(Inspired by using Emacs and Lisp!)

1. How do people usually code?

Either you,

  1. Use a code editor and edit multiple lines, then jump into a console to try out what you wrote⏳, or
  2. You use an interactive command line, and work with one line at a time —continuously editing & evaluating πŸ”„

The first approach sucks cause your code and its resulting behaviour occur in different places 😒 The second is only realistic for small experimentation —after all, you're in a constrained environment and don't generally have the same features that your code editor provides πŸ§Ÿβ€β™‚οΈ

2. If only we could have our cake, and eat it too! 🍰

With the VSCode Easy-Extensibility extension, we get both approaches! No need to switch between the two any more! Just select some code and press Cmd+E ---E for Evaluate! πŸ˜‰

Why the strange name? Why isn't this extension called something more informative, such as JS-repl-to-the-moon? πŸ‘€ Take another look at the above gif πŸ”Ό Besides plain old JavaScript, this extension let's us alter VSCode itself!! (It's a meta-extension! 😲)


Intro to Easy-Extensibility

3. Technically speaking, how is VSCode itself the REPL?

Let's do what math-nerds call proof by definition-chasing:

  1. Definition: REPL, an alias for command line, stands for Read-Evaluate-Print-Loop
  2. Cmd+E will echo the results in the notification area, in the bottom right-corner of VSCode
  3. So it retains each of the read, eval, and print parts of the Read-Evaluate-Print-Loop
  4. Moreover, since the program doesn't terminate, you're still in the loop part until you close VSCode

Bye! πŸ‘‹ πŸ₯³




Generated by Emacs and Org-mode (‒̀ᴗ‒́)و
Creative Commons License
Life & Computing Science by Musa Al-hassy is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License