Wednesday, July 7, 2010

C# 4.0: The industrial response to Lisp?

I just skimmed the C# 4.0 specification, and I'm quite fascinated by it. The spec itself is extremely well-written and readable, as far as language specs go. Anyone who's ever tried to read ECMA-262 or the JLS will agree.

But more importantly, the features of the language really raise the bar for all dynlangs out there. With dynamic, C# effectively usurps untyped programming, while maintaining static types elsewhere. With LINQ's expression trees, they seem to tackle the same problem as Lisp does with S-expressions. And MSR's work on evolving generics, a lot of which seems to finds its way into C#, is highly interesting.

That C# qua language is way ahead of Java is clear. What's more worrying is that all dynlangs, including the few acceptable ones, like Common Lisp and Factor, are starting to look horribly dated against C#. Seriously.

Note the following quote by grandmaster Tim Sweeney:
In Bracha's work here, and in Microsoft's work on C# 3.0, I sense an undercurrent dragging the language model toward the LISP/Smalltalk "ideal" of metadata-intensive, introspective, dynamic, loosely-typeable programming programming. ... If you go this route, one day you'll realize you evolved the ultimate hacker language, and it became a godawful mess for writing real programs. (My emphasis)
Evolving the ultimate hacker language, and making it a godawful mess for writing real programs, is of course the topic of this blog. Note also the following quote on C#'s type system, again by Sweeney:
These [Variance and Generalized Constraints for C# Generics] extensions stretch the C language family to an impressive new local optima
Now, I must say that I haven't ever used C#, so I don't know how it stacks up ITRW. I'm assuming, based on long observation, that Microsoft with high likelihood fucked up the pragmatics completely, and that programming in C#, as opposed to reading about it, is deeply depressing.

But what I'm saying is that the Perl-Python-Ruby-PHP-Tcl-Lisp-language has to catch up, maybe for the first time since 1959!

12 comments:

Paul N. said...

Fortunately, programming in C# isn't terrible either. Microsoft have done a good job in making sure the language appears consistent when reading it; there aren't too many large nitpicks out there with regards to the reading and writing of C#.

Bryan said...

C# was designed by Anders of Turbo Pascal/Dephi fame. Visual Studio as a whole has also been very influenced by him for the past 10 years.

Having used C# extensively, I can say with full confidence that your assumption about the pragmatics is completely wrong.

Unknown said...

I find C# to be easy to read - of course I've been working with it for 10 years now so I'm a bit biased. It's easy to underestimate how productive some of the new C# features (3.0+) are in real usage - automatic properties and LINQ immediately come to mind. I briefly hopped over to Java to do some Android development and immediately missed the little niceties like events.

Jeremy Beckham said...

I have to second what Bryan said. C# is actually pretty nice to program in.

Download LinqPad and then you can try it out without having to install the full SDK or Visual Studio. I'd recommend paying for the intellisense license though.

Also, Visual Studio Express is a really good IDE even though it is free.

Felipe D. said...

The question is not whether you've used C# extensively and think it is pragmatic, but whether you have used anything better (e.g. Common Lisp) and _still_ think it's as pragmatic you once thought it was. If you say that C# is more pragmatic than, say, using COBOL for an web application, then sure. But the author of this post is correct insofar as new C# features sound a lot better on paper than how they really stack up when wanting to express yourself in code.

Not to even mention that if you go outside of the OOP/procedural paradigm in C# and start coding using functional-style language constructs, C# gets pretty ugly pretty fast.

Todd Lucas said...

You really should give it a try. You can download the free version and give it a run on Windows. On Linux/Mac, you can run Mono (which is only a little behind).

I've been programming C/C++ and dynamic languages for many years. I like the low level control of the C family but I also like the speed and flexibility of dynamic languages. C# gives you both. I've been using C# for a couple of years now and I have to say, I find the thought of using most other languages depressing. I am so much more productive in it. The C# team keeps adding such great features that there's always something interesting to learn and leverage. The fact that it's an open standard and we have Miguel and team keeping pace with Mono assuaged any doubts I had. I hate to say it, but I've become a C# fan boy.

Barry Kelly said...

Programming in C# is far from depressing. It's a very well put together language. The staging from anonymous methods to lambdas to LINQ in particular was very well done, and dragged a huge number of procedural neanderthals to usable functional programming.

Vladimir Sedach said...

ECMA-262 is "weird" because it is actually an informal operational semantics for JavaScript. Which is great if you're implementing it, not so good if you need to understand how to program in it. It's also written so that a lot more of the implementation mechanisms are mandated by the spec and even exposed to programmers, which is great for metaprogramming but makes efficient implementation tricky.

Anonymous said...

I haven't read many language specifications, so could someone tell me how ECMA-262 is "weird"? I find it a readable and concise description, step by step, of how the language works. The only comprehensive reference out there, as far I have seen.

It cannot compare to the HyperSpec of course, but I could imagine it being much less readable. And much longer.

Anonymous said...

I've been programming in C# for about 6 years and I do find it enjoyable to program in, despite using other languages like lisp.

I would agree with Felipe D. however, that programming in a non-OO style gets unsightly pretty quickly. What it *is* good for, though, if using ideas from other paradigms inside of OO.

Manuel Simoni said...

@clacke: Well, in ECMA-262, I can't see the forest for the trees. It focuses so much on lowlevel detail – not declaratively, but as Vladimir said, operationally. I find that very hard to digest.

As to the ANSI CL spec, it has the interesting property that you can only read it when you already understand what it's saying. Same for the RnRS.

Adrian said...

I've had to go from 0 to hero on C# quite quickly in having to program my own FTP authentication/directory provider interface. The only other programming experience that I have had was with PHP and Classic ASP. C# was easy to learn. The basis for my interface was a template from a Microsoft Technet posting, I did have to add our own logic to work with our user databases.