Thoughts on .NET

Earlier this week, Microsoft announced their long-awaited .NET Framework. A potential alternative to Java?

As a Java developer, and someone who occassionally has to build on MS platforms, here’s my early thoughts…

Things I like

Common Language Runtime

Common Language Runtime (CLR) looks very nice! The obvious critisism from sceptics is going to be something about performance, just like Java got when it was announced because of it’s VM. Give me a decent architecture that allows me write apps how I want to rather than by squeezing raw processing power out of them with silly optimisations, any day. The success to app development is time and cost to market, not speed. In most apps nowadays, the performance bottleneck is almost always network latency related anyway.

Anyway, most apps built around things like J2EE, COM, etc aren’t much slower than C++, because the developer can focus on optimizations that really matter through design refactorings adapting to how the app evolves - and development time is much smaller too.

Metadata Attributes for Components

A bit like Javadoc + XDoclet really, except simpler and a lot more powerful. Attributes are compiled into the code and can be accessed via reflection. Custom attributes can be created.

I see this as a powerful way to extend the language.

Integration Services

SOAP, WSDL, UDDI, WebDav… this is a simpler and more modern stack than what we get out-the-box with Java (CORBA, RMI, ughh).

Managed Code

Suddenly C++ is simpler - not that it will need to be used much, but useful to know anyway. For the love of… please use managed code!

Remote Objects

Like RMI, CORBA or DCOM only simpler. Remote objects are painless to use or develop. Different channels can be used (TCP, HTTP, custom) and serialization (binary, XML, SOAP, custom). Can’t go wrong really.

Comes with some nice tools (webserviceutil and soapusds) so components can automatically expose WSDL interfaces and generate code specific proxies (similar to one of my favorite Java webservice tools - Glue).

I like the way you can create web service by just throwing an ASP like page with some methods (in any language) marked with the webmethod attribute in any directory of your site.

MTS / COM+

Provides functionality very similiar to Session EJBs - of course, easier to use and deploy. Managed transactional endpoints.

Isolation

What I didn’t like about MS’s previous DNA architecture was that a COM component was deployed to the operating system. This is fine if you have one machine per app or can afford to spend long hours deploying to multiple machines, but for most scenarios this isn’t the case. In .NET all components can simply be placed in an application directory and that’s all that’s needed for deployment. No registry modifications or anything like that required. Nice and simple.

Native code

Using native APIs in DLL files is pretty easy. Just define a method with a DllImport metadata attribute. Makes JNI look complicated.

Winforms + GDI

GDI is like Java 2D. I’m not sure how good it is, but I’d imagine it has quite a lot of power behind it and is less of a nightmare to use than Direct-X was.

WinForms are a layer on top of GDI that provide a simple OO Java Swing like interface for quickly creating powerful interfaces. Unlike the previous C++ MFC API, it looks very easy to use.

I love working with Swing, but Java interfaces have always had this very clunky feel to them. Let’s be fair, the native windows toolkit looks and feels much sexier than Swing’s metal feel, or it’s attempt to look like native windows (although having recently used Mac OS-X, I’m having to redefine my minimum criteria for sexy interfaces). A contraversial topic among Java developers is the speed of Swing - apparently it’s very fast if you make lots of optimizations. Yeah, well MFC is fast without having to make optimizations. Swing is skinnable, so is Windows XP.

Custom designers can make your own components easier to use in development environments (so when someone drops your own component into their application, they can have custom menu options, wizards, etc). Actually, this can be any kind of component, not just a Winform.

I also have some sceptical issues about UI building with .NET (addressed below).

Things that I’m sceptical about

My-Services and Passport

Nice idea, but I think it’s worrying that a central third party can store users personal and financial details. Think what they could do with the data! Already there have been some exploits posted on the net to get access to other people’s passports - ouch.

Deployment

NT/2000 servers have caused me massive headaches in the passed, particularaly with IIS, and MTS/COM+, and the fact that they’re just so blimmin’ hard to administer remotely and bugs (often in MS’s code) are just so hard to track down. Please prove me wrong here. I just can’t imagine ever wanting to run Windows based servers. Compared to Linux, FreeBSD, OpenBSD, etc, this seems really complicated and burdonsome.

IDE

It seems to be that Visual Studio is going to be the .NET development environment that can be used to lever the full potential of .NET. In some ways this is good, because people will be familiar with a common toolset, but what if the toolset isn’t good enough?

People thought make would be the best build tool of all time, then came along ant and no Java developer would be seen dead using make, simply because ant is better suited for the task.

IDE’s all started to look the same; a code editor with code completion, syntax checking, debugging, drag’n’drop forms editor, wizards, blah blah (Visual Basic style) - there wasn’t that much that distinguished them from each other.

Then the unthinkable happened, a revolutionary IDE was developed (Together from Together-Soft) that allowed OO systems to be designed, modelled and coded all at the same time with round trip support. None of the other IDE’s did that!

Then more recently a new IDE was released, IntelliJ IDEA which at first glance looked like all the other IDE’s but actually supported the most intelligent code completion features found anywhere and fantastic refactoring support (for people who take code/design quality and speed seriously) - no other IDE does that.

I hope that a single IDE won’t bring a halt to this kind of innovation. I also allow it’s flexible enough for developers to write their own little innovative plugins.

Naming Conventions

One of the important factors of Java’s success was the fact that from day one there were very clear coding conventions created - most importantly that of naming and capitalization. Because of this, code using libraries/components from lots of different sources always looked elegant, and there was always this familiar feel about using someone else’s code.

I’m a little confused as to whether there is a .NET convention or not. I found this little excerpt:

The conventions for using upper- and lower-case in .NET programs might be different from other languages you’ve used. However, the rules for .NET are simple: For all identifiers other than parameter names and private field names, capitalize the first letter of every word, including the first. (Microsoft recommends that all fields be private; however, they may be exposed with a property.) For parameter names and private field names, capitalize the first letter of every word except the first. You really need to know these rules, because the .NET Framework names adhere to them and some languages, such as C#, are case-sensitive.

So, the name of the main output function is System.Console.WriteLine, with exactly that capitalization. The name of the format string parameter for System.Console.WriteLine might be formatString, but not FormatString. But the name of the length property of a string might be StrLen, not strLen.

I hope this is true and I hope that MS make this very clear to all developers. I’m still asking myself the question, why is string used instead of String if the above is true.