Hacker News new | ask | show | jobs
by kevingadd 4798 days ago
Most people never complain about Java or C++ not having REPLs, but somehow C# is expected to have Python/Ruby features even though it's a static language.

For reference, 7 years ago would have been around when C# first introduced generics... well before it ever grew lambdas, LINQ, local variable type inference, or other more expressive features. Which makes the idea that it should have had a REPL then pretty silly.

5 comments

Not sure what being a static language has to do with having a REPL. Haskell and OCaml are static languages, and they both have REPLs. Scala too.

Also, if Java had just gotten a REPL, I can see someone saying "If this would have come 15 years ago then maybe I would have been excited."

I can't speak for dev360, but the way I read his comment makes me think that what he meant is that he's moved on to other languages at this point, so C# finally getting a REPL isn't really that interesting anymore.

What I'm saying is, try writing some valid, compilable C#2-era code in a REPL and see what a good experience it is.

Saying 'haskell and ocaml are static and they have REPLs' is totally missing the point; the way you write code and express types in those languages is different. C# is one of those 'fully formed type with methods' languages, where you have to define an entire type and its members up front. Not particularly REPL-friendly, especially in 2.0.

Now, with the newer features added in C#4 and later versions of the language, it's possible to actually use it in a REPL because you can create instances of anonymous types and write lambdas with result/argument type inference and variables with inferred types, and you can define classes in multiple stages ('partial' classes).

A Java REPL would have all these same problems, even now. (Or did lambdas ship?)

Have you tried writing Haskell in the repl? I would argue that just omitting the types (essentially var:ing everything) would still make a repl very valuable for trying stuff out while you write your code. When I worked at citrix I would debug constantly in ironpython and I would find and fix bugs 5 times faster than my coworkers that would write clunky command line programs.. A repl is a very powerful tool that any nimble dev should take seriously.
I personally think its typical Microsoft stuff. Too little too late. C# is/was a delight to work with but Microsoft has built themselves into a corner with their platform. They are always 6-7 years behind and misjudge. We had to wait how long to get a decent shell?? Why couldn't they make the damn thing posix compatible?? Or how long we had to wait for a package manager???? I will admit though that if I was still stuck in miserable ms land I would program in f# exclusively. The way it does oop feels like an improvement over traditional languages which is paradoxically bizarre and fascinating at the same time. I don't know but in retrospect leaving .net was the best thing that ever happened to me personally. It broadens your perspective on software dev when you don't constantly constrain yourself to viewing your world through entity framework or nuget or whatever other precious few technologies that run well on windows. That's all.
I learned on C/C++, followed by Java, then PHP... I didn't even know what a REPL was until I started working with Python. Now it's just painful not to have one.

Which is not to say that every language can or should have one, but it's not hard to see how people who come from a background where that's normal could look at this and say "good holy mother of spaghetti, how on earth do these savages operate?"

This is what Smalltalk and Lisp developers are saying since the early 80's.
That's a rather low bar, don't you think? Haskell/ML family languages had all that and more.
Haskell/ML families bear only the slightest similarity to C#. Saying 'Haskell has a REPL, so why doesn't C#' is like saying 'C and GLSL both have structs, so why doesn't C run on my GPU?'*

Furthermore, like I said in another comment, a C# REPL in that era would have been nearly unusable. The language is not designed for incremental authoring or compilation.

* CUDA notwithstanding

It is a matter of implementation, it has nothing to do with the language per se.
> Which makes the idea that it should have had a REPL then pretty silly.

Why? it is just a matter of providing the right implementation.

There have been many, many, many Java REPLs over the years. I have a feeling that you didn't do a search before writing your reply.