1

So in Python on a unix environment, for example, we can open up python from terminal, start writing code and immediately run it to test some python library functions. Is there a similar commandline/scripting environment for C# or Java (perhaps a plugin to the IDE?)? Such a tool would seem pretty useful for experimenting with something like the System library.

Relatedly, I read that some versions of Python are compiled into bytecode before being executed by a virtual environment, which sounds like Java and C#. But, the Python program I open up in terminal and start typing code into has to be interpreted, right? So based on principle, it seems like it is possible to write a C# or Java interpreter. So I'm not sure why I just haven't seen anyone interacting with C# or Java on the commandline the way they do with Python.

Thanks.

7
  • C# and java need to be compiled before being interpreted Commented Aug 13, 2012 at 17:56
  • F# repl is quite good for experimenting Commented Aug 13, 2012 at 17:57
  • 2
    @Anonymous Sure, but Python, Scala, Haskell, and many other languages too. They just hide it better. Commented Aug 13, 2012 at 17:59
  • @Anonymous: Neither C# nor Java are interpreted. They are compiled into byte code upon build time and from byte code into machine code at run time by the JIT compiler Commented Aug 13, 2012 at 18:02
  • @delnan You're getting to the question I'm trying to convey, which is since many so-called scripting languages are also compiled, why hasn't C# or Java added a similar option, which I believe would be pretty useful? Commented Aug 13, 2012 at 18:08

3 Answers 3

7

For .NET there is LINQPad. It supports C#, VB.NET and F#.

The name suggests that it is only for LINQ but you can execute any code in there. There is no need for a database.

Sign up to request clarification or add additional context in comments.

2 Comments

Can you to this through the command line, or does one need the GUI?
If you want to write LINQPad scripts, you can run them later from the command-line using LINQPadRunner (github.com/mcintyre321/LINQPadRunner). Otherwise, you have to use the GUI. I don't really see how that could be a downside, though...why would you ever want to write C# code using just the command prompt when a text editor is easily available?
2

For .NET, if LINQPad is overkill for you, try the RunNET command-line package. It requires that you load script files instead of interactive typing, but lets you leverage more languages.

Comments

1

The ability to explore .NET types was one of the reasons I originally started learning F#, since it has an Interactive environment (in Visual Studio, click on View > Other Windows > F# Interactive.) Upon digging deeper into F# I have found it to be one of my favorite programming languages.

Anyways, you may want to look at it. It won't take long to figure out the basic syntax, and once you've got it you can explore various .NET objects in the Interactive Environment, if you don't want to wait for Roslyn.

For a tutorial, check out this page: http://www.tryfsharp.org/Tutorials.aspx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.