|CSharpRepl Brings REPL Superpowers To C#|
|Written by Nikos Vaggalis|
|Monday, 21 November 2022|
REPL, once an inherent property of the interpreted languages, has now found its way into compiled languages too. Tools like CSharpRepl for C# and Jshell for Java make it happen.
A REPL is an interactive programming environment that takes single user inputs, executes them, and returns the result to the user; input (Read), execute the input (Evaluate), return the result to the user (Print), wait for the next input (Loop).
So what's the deal with REPL? It's all about the immediate feedback loop you get; you can enter program elements one at a time, immediately see the result, and make adjustments as needed. You can evaluate anything;variables, code blocks, functions, even define full-fledged classes and use them in the REPL console, always getting instant feedback, or even use C#/Java as a scripting language for testing purposes and running short lived utility scripts.
This comes in stark contrast with the typical workflow of working with a compiled language:
A REPL gives you the option to try out code without that hassle. You can test individual statements, try out different variations of a method, and experiment with unfamiliar APIs. Which makes it great for quick tutorials and prototypes.
Furthermore modern IDE's like VSCode can do REPL without leaving the IDE for the shell which as an extra gives you color themes, autocomplete and syntax highlighting. However the CSharpRepl tool gives you these goodies out of the box in supporting intellisense, installing NuGet packages, and referencing local . NET projects and assemblies, making the need for an IDE totally optional.
As such CSharpRepl provides the following features:
It also has the advantage of running multiplatform on Windows 10, Mac OS, and Linux.
You install it as a dotnet tool by running:
then running csharprepl once the installation completes.
Type some C# into the prompt and press Enter to run it. The result, if any, will be printed:
The new major release of CSharpRepl 0. 4. 0 brings:
Find it in its GitHub repo
New major release of CSharpRepl 0.4.0
Fable - Write Front-End Apps For The Web In F#
Python and .NET - An Ongoing Saga
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
or email your comment to: email@example.com
|Last Updated ( Monday, 21 November 2022 )|