Making a .Net REPL

Mike Parsons
HackerNoon.com
4 min readDec 30, 2016

--

My first experience with computers happened at university while I was interning with a local government agency. It was on an old Compaq 386 and the “programming environment” was dBase III. The minute I typed in …

I was completely hooked. I was blown away by how easy and versatile it was to create, browse and manipulate data with just a handful of commands in a completely interactive environment. I like to think that I built a successful career on the foundations of dBase, and later FoxPro.

It’s been a long time since I used FoxPro but I never lost my love for REPl’s (read-eval-print-loop). Being able to drop into an interactive environment like SQL, the Linux command prompt or the browser JavaScript console makes me feel like I have computing super powers. For me, I’ve have yet to find a programming tool or development environment that allows me to express or demonstrate ideas in code like an interactive REPL.

With all the recent interest and advances in bots and “conversational computing”, I think we are about to enter a new golden age of REPL’s. With that said, I am going to write a series of articles that demonstrate how easy it is to create a useful REPL from scratch. This first example focuses on the Microsoft .Net programming environment. Before I start, I know that many readers will point out a ton of very fine and useful REPLs for .Net. I am aware of most of them and this example is not meant to suggest that any of these would not be better suited for your own tasks. The purpose of this article and subsequent ones is to take the “minimalist” approach so that you create something functional without relying on a bunch of external dependencies.

So lets get started … here’s the entire code:

Save this code in a text file … dotnetrepl.js, for example

To compile the code, we are going to take advantage of a little know feature of the .Net framework — the javascript compiler. This compiler (jsc.exe) resides in the .Net Framework directory. On my machine, this is

To compile your REPL, open a command prompt to the location of your dotnetrepl.js and type:

This will create a dotnetrepl.exe in your directory and you are good to go with your new REPL.

The REPL uses Javascript syntax but you can access any .Net Framework Class. Here are a few examples:

I have prepared a short video that illustrates a few other examples:

Hopefully you found this quick introduction useful. In subsequent articles, I will build a series of simple, yet useful REPL’s that you may use as starting point for your own computing discoveries.

Hacker Noon is how hackers start their afternoons. We’re a part of the @AMI family. We are now accepting submissions and happy to discuss advertising & sponsorship opportunities.

If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!

--

--