Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

F# comes out of the box with an interactive REPL. C# has nothing of the sort and is in fact kinda difficult to play around without setting up a full project (though LINQpad works and its also possible to do via powershell).

Is there something fundamentally different about the languages that allows F# to have the interactive console but makes it difficult to implement it for C#?

Since many years later people are still coming to this question I should note that now there are many options. You can use powershell (pre-installed on every modern windows machine) to play with the .Net framework. Or you can use LINQpad to prototype arbitrary c# code. Or you can use ScriptCs or you can use an online jsfiddle-type environment like or Jsil. Lots of options.

share|improve this question
C# does have a REPL. It's called the Immediate Window and has been available for quite a while. It has certain limitations, some of which have become increasingly noticeable since C# 3.0, as new language features were not supported by it, but it nevertheless is a full-fledged REPL. – Allon Guralnek Jul 12 '12 at 19:35
I remember the project Roslyn demo release circa 2012 had a REPL in it for VS2010 – James Dec 15 '15 at 2:57
up vote 54 down vote accepted

Is there something fundamentally different about the languages that allows F# to have the interactive console but makes it difficult to implement it for C#?


F# is a descendant of the ML programming language, which in turn was heavily influenced by languages like Lisp and Scheme. Those languages were designed from day one to have three nice properties.

First, those languages do not really have statements the way you think of them in C#. Rather, almost everything is an expression that has a value, so an evaluate-and-then-print-the-value mechanism makes sense in almost every situation.

Second, those languages discourage programming with side effects, so you can make evaluations without worrying that you’re going to be messing up global state.

Third, most of the work you do in those languages is “at the top level”; there is typically no enclosing “class” or “namespace” or other context.

By contrast, C# emphasizes programming control flow with statements that produce side effects, and those statements are always in multiple nested containers -- a namespace, a class, a method, and so on.

So these are all things that make it harder for C# to have a REPL, but certainly not impossible. We’d just need to figure out what the semantics are for statements and expressions that appear outside of the usual context, and what the semantics are of mutations that change name bindings, and so on.

Why does F# have an interactive mode but not C#?

Because the F# team decided that having a REPL loop was a priority-one scenario for them. The C# team historically has not. Features do not get implemented unless they are the highest priority features that fit into the budget; until now, a C# REPL has not been at the top of our list.

The Roslyn project has a C# REPL (and will eventually have a VB REPL as well, but it is not ready yet.) You can download a preview release of it to see how you like it at

share|improve this answer
Python has a nice REPL, and it do have statements, side effects, and namespaces. And so do Javascript, Bash, etc. Many languages that violates your criterias have REPL just fine. – Lie Ryan Jul 11 '12 at 0:10
Welcome back Eric! I hope we will be seeing more answers from you. – SolutionYogi Jul 11 '12 at 1:15
@LieRyan I think you missed the entire point. The only "Criteria" for an interactive REPL loop is that someone sat down and wrote one; in F# it was high priority and relatively easy, in C# it was low priority and relatively hard, thus F# got one early on and C# didn't. – KutuluMike Jul 11 '12 at 2:58
Interesting. I would add that the experience gained building so many compilers for the .NET framework prior to the release of VS2010 (I count four C#, four VB.NET, two J# and two C++/CLI) must have affected how a brand new compiler for a brand new .NET language was built. I'm sure it was built in a Roslyn-esque style with lots of thought around how to enable the Compiler-as-a-Service scenario, which seems like the direction you'll be developing all future .NET compilers and compiler revisions. To me it seems the era in which F# was born inevitably played a role in how its compiler was written. – Allon Guralnek Jul 12 '12 at 19:48
Great answer. About Python vs C#: {} syntax languages do not bend nicely for REPLs, indentation based languages have a great advance here. Never thought I ever would think or say it: indentation syntax is better than {} syntax. For REPLs as well as for readability of code. So as long as there is no C# metasyntax that substitutes indentation with {}, REPL experience will never be as smooth as for instance in F# or Python. – citykid Jan 18 '14 at 11:19

Mono has a C# repl:

It even has a GUI version that allows you to directly manipulate graphics objects, or create Gtk# widgets:

enter image description here

share|improve this answer
Sure, and its definitely possible, but is there something about C# that makes it harder? – George Mauer Jul 10 '12 at 19:08

I believe it's mostly a historic thing. REPL environments have always been associated with functional languages, ML family languages included, and F# stays true to that tradition. Keep in mind that interactive environment is something that users coming from functional background take for granted, lack of such a feature would be put VS and - by extension - F#, at a disadvantage.

On the other hand, no such feature has been commonplace in the OOP community.

There are however REPLs available for many non-functional languages, including C, Java or C#. Also while it's a far cry from a full-fledged REPL, the Autos feature in VS shows that it's certainly doable with C#.

share|improve this answer
This is the most plausible explaination I've seen. In the beginning, there was Fortran and there was Lisp, and Lisps had repls. Lisp begat... well, you get the idea. Lisp lineage languages had repls, and Fortran lineage did not. – Aaron Jul 11 '12 at 15:40
@Aaron LISP is 1959 but REPL is attributed to LISP machines, 1973. By then, there were many, many languages already around. Notably PASCAL and Smalltalk. – Sprague Apr 13 at 12:46

I believe C# is primarily object-oriented. To write even simplest code, you should divide it into multiple classes. To use REPL, you would need to write lots of code.

F# being primarily functional doesn't have this problem and you can easily write even complex code in straightforward fasshion and convert it into object/s later.

It is easier to write a single line of function than to write class, that spans many lines.

share|improve this answer
There is nothing stopping you from using functions/classes defined in external files in REPL statements. The fact that OOP is more verbose doesn't hinder REPL functionality by itself. – scrwtp Jul 10 '12 at 20:39
Python, being quite object-oriented and featuring syntactically significant linebreaks, does have a decent REPL. Scala, being statically typed, compiled, and rather object-oriented, does have a REPL. REPL is most useful for short things like importing existing classes and calling some methods; verbosity of the language is not a concern. E.g. SQL is quite verbose but every SQL database comes with a REPL (a 'query tool'). – 9000 Jul 10 '12 at 20:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.