Visual Studio 2017 (and 2015) now features a REPL for interactive C#, F#, R, Python and possibly others. View -> Other Windows -> and whatever is installed should be visible.
Suppose I wanted to integrate my own (existing domain-specific) language into Visual Studio such that its REPL would be started by clicking on a menu item in Other Windows. I am only interested in using Visual Studio's built-in REPL services to conduct a dialogue with an existing language - not to design a language nor to use any of the DSM facilities provided by .Net or Microsoft. At least today.
Where would I begin? Would the Interactive R implementation be a suitable starting point? (The R interpreter would resemble my DSM more closely than say C#)
The appeal here is Visual Studio integration and the ability to reuse existing components.
Based on limited information on your DSL it is necessary to make assumption which equally well may be treated as requirements:
There is a compiler for DSL which is capable to produce partial syntax trees and compiles them to partial binaries, 'method bodies' or there is a compiler based expression evaluator.
There is a runtime on which DSL can be executed even as partial binaries (if the result of a compilation is an intermediate language then you would need virtual machine otherwise system specific runtime library).
There is a lot of work to do the plumbing between input/output interactive window, runtime, compiler between themselves and Visual Studio.
There are several examples which can be analyzed for prior art:
Roslyn Compiler
Scripting https://github.com/dotnet/roslyn/tree/master/src/Scripting
Interactive Services https://github.com/dotnet/roslyn/tree/master/src/VisualStudio/InteractiveServices
One which could be of direct use in REPL project is:
ReplHTML project https://github.com/TiarkRompf/replhtml
There are many toolkits available for fast development of a DSL or in principle for development of any programming language. Check some papers by Tiark Rompf as he was and is working on cross language virtual machines and efficient DSL/programming language development based on Graal VM. He is currently at Purdue University but before that he was working with Martin Odersky at EPFL in Switzeralnd on Scala, programming language development frameworks and their integration with virtual machines.
I would discourage you in using anything R as this is one of the examples from which one should not learn how to work with or develop programming languages.
Final warning: this is a big project which may require much more than one engineer year to complete successfully.
Related
One of the possibilities demoed when the C# dev team was talking about porting the C# compiler to C# was the option to extend the compiler phase with custom plugins, written in C#.
Was that option included in the Visual Studio 2015 release, and if so, where can I find the MSDN page for it?
Is there a good working plugin for C# in Eclipse? I'm using a Linux machine so I do not have access to Visual Studio Express. I already have an Eclipse Environment working perfectly for my needs so I don't want to deal with multiple IDEs if at all possible. It doesn't need code complete but highlighting and compiling would be nice.
Emonic is an actual eclipse plugin for C#: http://emonic.sourceforge.net/.
Here's a handy guide for how to get it set up: http://www.ibm.com/developerworks/library/os-eclipse-migratenetvs/
Monodevelop is great, but won't meet your requirement not to have to work in multiple IDEs.
I'm not sure about eclipse, but MonoDevelop is cross platform.
http://monodevelop.com/
From:
http://www.mono-project.com/Mono_For_Linux_Developers#Eclipse_in_C.23_Mode
Black-Sun
Emonic
eSharp
I don't personally have any experience with the mentioned plugins. Any C# development I've done on Linux has been through MonoDevelop
From Eclipse marketplace:
aCute: C# edition in Eclipse IDE
aCute enables C# application development in the Eclipse IDE.
aCute provides a rich C# editor with error reporting, hover, content assist, jump to references... (using OmniSharp) and syntax highlighting (using TextMate grammar).
aCute also integrates various operations of the dotnet command-line (New, Run, Test, Publish) as typical Eclipse IDE wizards and workflows.
aCute provide supports debugging for .NET applications.
in visual studio we can develop applications using multiple programming languages such as C#, C++, Visual Basic. Is this due to CLR?
I believe it is.
The functionality of .Net Framework
supporting many programming languages
is due to the use of the powerful CLR
See this link:
http://www.dotnet-guide.com/
The above statement can be found in the 3rd paragraph beneath the "Click here for FREE subscription" button.
Mainly, but I guess it is also a trend for IDEs to support several languages (vs one IDE per language). Eclipse for example supports 20 languages.
The fact that multiple .NET languages share a runtime and BCL, and can talk to each-other very easily is due to the CLR/CLI, but ultimately the VS IDE doesn't just write CLI (unmanaged C++ being the obvious example). Simply, the IDE (like many others) is designed to be extensible.
If you wanted, I'm very sure it would be possible to write your own compiler plugin for VS, using a managed or unmanaged language.
I understand visual programming languages to be those languages that allow the programmer to to manipulate graphical--rather than textual--objects onscreen to build functionality.
The closest thing I see in C#, VB, etc. is RAD controls, but that is just composing UI and the very simplest functionality -- it has nothing to do with the language itself, even.
Why, then is C# called "Visual C#", Basic .NET called "Visual Basic .NET," etc.?
What is "visual," or what is the rationale or history behind the nomenclature?
I don't think it has to do with the languages themselves being "visual."
From the Wikipedia article:
The term Visual denotes a brand-name relationship with other Microsoft programming languages such as Visual Basic, Visual FoxPro, Visual J# and Visual C++. All of these products are packaged with a graphical IDE and support rapid application development of Windows-based applications.
The languages are not called "Visual". The products are "Visual".
This is from way back before .NET. "Visual" Basic was "Visual" because of the forms development GUI. "Visual" C++ was "Visual" because of MFC and the wizards for creating an MFC application.
I suspect it all dates back to the original Visual Basic. The "visual" part of this was the UI designer...
The Ruby interface generator provided the "visual" part of Visual Basic
The use of the work "Visual" started to get popular with the introduction of Visual C++ version 1.0; it was the first version that ran natively inside Windows, whereas other versions ran in DOS mode even though they were able to produce Windows-runnable code. It has nothing to do with the languages, rather with the environment where the IDE runs.
I guess this is mainly a marketing choice.
It could, however be related to the fact that "Visual Studio" is a GUI, thus a way to "visualize" your code.
I guess it's all going from some event or some product name choice. And now, it just about the brand.
I mean, like, nowadays you can't even think about some IDE called Studio and the same can be said about, for example, Visual Eclipse.
During the last 10 minutes of Ander's talk The Future of C# he demonstrates a really cool C# Read-Eval-Print loop which would be a tremendous help in learning the language.
Several .NET4 related downloads are already available: Visual Studio 2010 and .NET Framework 4.0 CTP, Visual Studio 2010 and .NET Framework 4 Training Kit. Do you know what happened to this REPL? Is it somewhere hidden among examples?
I know about mono repl. Please, no alternative solutions.
The REPL demo was part of "what might happen next", i.e. after 4.0; in .NET 5.0 or something similar.
This is not 4.0 functionality, and never has been.
It's probably worth mentioning that the Mono project already does have a C# REPL which i tend to use for those small checks you do now and then. Take a look. Also, if I'm testing an idea which I'm uncomfortable Mono is going to handle to well and it's not worth starting a new test project then Snippet Compiler always comes in handy.
The Immediate window (Debug>Windows>Immediate Ctrl+D, I ) is fairly good replacement that's built in. It does require you start the IDE and put a breakpoint on something.
It does give you the context of where you would like to do experimentation.
Marc's answer is entirely correct, the possibility of a repl or script like c# has been discussed by Eric Lippert in two blog posts:
Why doesn't c# implement top level methods
It already is a scripting language
I would add that, the 2010 CTP does contain an f# repl (not much use for c# but if you were interested in some aspect of the BCL or CLR then it might be sufficient for your needs)
I find that LINQPad makes up for the lack of a REPL in many cases. It would be nice to get it integrated into Visual studio so you could interact with your existing code base more easily though.
Take a look at this C# REPL Script Environment which is a great way to quickly run C# script (and learn how to code)
I just published a VisualStudio Extension that provides a REPL environment inside VisualStudio (namely a C# REPL Environment with a Fluent API for .NET and VisualStudio)
In addition to being able to write and execute quick C# snippets (in a REPL environment), you can program VisualStudio IDE in real time!
You can install it using VisualStudio's Extension Manager (search for C# REPL) or via the download link at the VisualStudio Gallery page: VisualStudio C# REPL
The VisualStudio C# REPL page also contains more details and code samples.
There is also an Reddit thread on this extension (which contains more code samples).
Let me know what you think of it
Command-line REPL
To play with the C# REPL outside of Visual Studio, open the Developer Command Prompt for VS2015 and type the command csi to begin your interactive session. Here is a list of arguments that can be passed to csi.
Note: csi stands for "CSharp Interactive"
You can also open an interactive window directly from Visual Studio by navigating to View > Other Windows > C# Interactive.
Check out the Roslyn Wiki on the C# Interactive Window.
I found http://kamimucode.com/Home.aspx/C-sharp-REPL/1 . Which seems to be pretty good and I believe also exposes an API to evaluate expressions dynamically
To update on this old question c# REPL is now available as part of Visual studio IDE (starting VS 2015 update 1).
Introducing the Visual Studio 'C# REPL'
From time to time I want to try out some .NET API instead of wondering about C# language syntax. (There are far more subtleties in API than in the language itself.) If you are only looking for REPL for .NET, good old PowerShell is always with you.
C#:
using System;
using System.Text;
Convert.ToBase64String(Encoding.UTF8.GetBytes("Overflow"));
PowerShell:
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("Overflow"))