I thought it would be fun if I could write vb.net or c# code at runtime and the interpreter would automatically parse it like python does it, so I made a little program, which would do something similar. Basically it looks like this:
InputArgs = Console.ReadLine()
ParseInput(InputArgs.Split(" "))
Private Sub ParseInput(Args as List(Of String), Optional TempArgs as List(Of String))
Dim arg as string = Args(0)
If arg = ".." then
...
elseif arg = ".." then
...
end if
End Sub
I know it’s not a good system, but it show’s the basics. So my question is: Is it possible to make vb.net or c# like python – interpreted at runtime?
This already exists in a fair number of shapes and forms:
Mono.CSharp
Mono has the
Mono.CSharpassembly, which you can reference to do whatever CSharp.exe (A C# ‘interpreter’ or interactive shell, if you will) can do:Needless to say this works on MS.Net too (of course, that’s the point about portable .Net).
Full sources here on github – just as the rest of Mono, in fact.
DLR
Several DLR languages have been implemented, including but not limited to
It will allow you to evaluate python/ruby code on the fly in the .NET framework.
Roslyn
Microsoft has published Roslyn as a CTP (preview). It can basically do the same stuff as the Mono REPL (first item), and (much) more. But it is a preview still.