Saturday, October 09, 2004

I love .NET, but it sucks

And here's another thing. I really like coding with .NET, but the thing I like most about it is its promise of multi-language development. Unfortunately, it doesn't deliver! Now I'm not talking about little qualms like the fact that you can't put C# code and VB code in the same project. I'm talking about the incorrect assumptions and lack of vision in the design of the CLR and CTS.

  • They assume you'll only ever want single inheritance.
  • They assume you'll only ever want stack-based control flow, not continuations or coroutines or microthreads or fibers. You can use fibers (cooperatively scheduled threads), but it is not part of .NET; you have to use the Win32 API for threads, but this is not portable to Mono or DotGNU and, I would guess, the Compact Framework; and can't be used in a web browser.
  • They assume you'll only ever want a static type system
  • They didn't give much/any consideration to functional programming methodologies

However, they are improving things somewhat. They have added a useful and efficient system of genericity in .NET 2.0, for example. Dino Viehland of Microsoft told me

“we're certainly aware of coroutines and other forms of non-stack based control”

BUT....

“we have no specific plans to support fibers as a managed API”

BUT STILL...

“This is one area that seems to be a bit of a hot topic, so hopefully we'll do something here”

I have written an article extolling the virtues of coroutines (here) and others have written of the advantages of microthreads. I encourage you to learn how these concepts could be useful in your software development, if only it was actually possible to use them!

The trouble with Python

I like Python, really. And I regret that I don't have much time to learn it, and I regret that I've never actually written a program in it. But it's too slow.

I don't mind if a language is slow, really I don't. Not per se. There's lots of computing power in every computer today so it usually doesn't matter. The key word, though, is “usually”. Usually it doesn't matter, but sometimes it does. The trouble with Python is not that it's slow, but that it can't not be slow. It is always interpreted, and it always uses a dynamic type system. Even if you could compile it, the type system would always slow you down. Which is too bad because it has a nice syntax and many people say it's fun to use.

You can interface with C, of course (there may be problems with Stackless I hear, but they're being ironed out). And personally I've got lots of experience in C, but that's beside the point. I think a truly general-purpose language should be good for virtually any task, even those tasks that require really fast code. I don't want to switch to another language in the middle of development when I already like the one I'm using. Anyway, one place where speed still matters is small devices like PocketPCs and Palms and cell phones. And since these devices are becoming more and more important, it's important once again to have a language that can run code fast.

Still, Python might be the best general purpose language out there that is also well-known and popular. I hope I get a good excuse to use it someday.