Tuesday, May 31, 2005
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius, and a lot of courage, to move in the opposite direction.
---Albert Einstein
Wednesday, May 25, 2005
Fundamental types in C#
Something I miss in C# is the ability to tell if an object is of "fundamental type". I often need to check whether a object is "primitive" (obj.GetType().IsPrimaitive), or System.Decimal, or System.DateTime, or System.String for that matter.
On a similar theme, why is there no C# type alias for System.DateTime, it seems like a obvious omission...
Inline IL in C#
Here is a blog post about a tool that allows inline IL in C#/VB.Net. I could be useful for implementing feature that are not natively supported by C#. I can't think of anything I can use it for at the moment....
SOAP is wrong, have a REST
There is nothing simple about SOAP anymore. The "simple" part of the SOAP acronym is just a joke. I find the REST idea very appealing. It's very simple, if you want to:
- get information about something you do a HTTP GET to a object-specific URL, which returns XML;
- create or update something you do a HTTP POST with the new information in XML;
- delete something you do a HTTP DELETE.
ASP.NET on Linux
There is a new Visual Studio .NET plug-in you can use to develop ASP.NET applications for Linux and any Java-enabled platform. It's free, and called Grasshopper. It apparently converts MSIL to Java byte code, so your app can run in Tomcat.
Better URLs for ASP.NET applications
I just came across this, better URL's for ASP.NET. I makes development easier, but also provides an API for pages. And there's and add-in for Visual Studio 2003. Add it's free...
Visual Studio 2010 Concept IDE
I came across this today, a concept for a future Visual Studio IDE. Interesting stuff, check it out...
Synonyms
In Ruby, providing synonyms for operations is good practice, but .NET has an almost complete lack of them. For example, in .NET arrays have a "Length" property, and the ICollection interface has a "Count" property. These are synonymous, but cannot be used interchangeably, i.e. you can't get the "Length" of a IList, only the "Count". Why not allow both names for a property?
If you allowed synonyms for keywords, you could write poetic programs. In English, it is considered bad writing to repeat the same word over and over again, so why not in programming languages....
Tuesday, May 24, 2005
Serialization performance
I've been writing a YAML serializer for .NET, and in doing some performance tests, was surprised to see the XMLSerializer is faster then the BinaryFormatter! The follow table shows the results of serializing 1000 people objects:
| Serializer | Serialized Size (K) | Run 1 (MS) | Run 2 (MS) | Run 3 (MS) | Run 4 (MS) | Run 5 (MS) | Average (MS) |
|---|---|---|---|---|---|---|---|
| yaml | 482 | 78 | 62 | 78 | 63 | 62 | 68 |
| xml | 1380 | 109 | 78 | 94 | 78 | 78 | 87 |
| binary | 278 | 125 | 125 | 141 | 140 | 141 | 134 |
| soap | 2261 | 562 | 516 | 484 | 500 | 500 | 512 |
If you use remoting, you have a choice between the SOAP and Binary formatters, you cannot use the XML one. As I understand it, ASP.NET web services use the XMLSerializer, hence ASP.NET being faster than remoting.
I like YAML. I first came across it when learning Ruby, and trying out Ruby on Rails, for some example YAML click here. YAML is a simple, compact, human readable text format. I hope it stays simple, unlike SOAP...
Systems and sub-systems
I've worked on numerous systems, but none with sub-system packaging, why not? I must have worked for the wrong companies....
I've worked on projects that package layers into DLLs, e.g. there was a "data access" DLL, a "business layer" DLL, and usually the UI is a single EXE. This type of system is easy to develop, but any change (e.g. adding a feature that spans UI, business and data layers) requires you to re-test and re-release the whole system.
I recently worked on a large finance system that had gone too far the other way. Each UI feature was packaged into it's own DLL, with it's own business layer, and data layer. Sounds ideal, right? Wrong. I was working with two Visual Studio solutions, one for the back-end services, one for the UI, with each solution having over 100 projects in. It took up to ten minutes to load the solution, and ten minutes to run-it-up in Visual Studio.
You might ask if I needed all the 200 projects - I didn't - but someone had created nasty inter-project dependencies. For example, all error messages were stored in a single file which all projects depended on. So adding an error message caused all project to require re-compilation. There was also some "common" UI elements that had been grouped into a project, but this common project referenced (directly and indirectly) over 30 other projects.
So what ever happened to sub-systems? Grouping related things into sub-systems (projects), that have limited external interfaces, is the best of both worlds. You can change a part of the system without having to re-test and re-deploy the whole thing, and you don't end up with spaghetti projects that are slow to work with.
Monday, May 23, 2005
Device Drivers
I've been playing around on Zeta (the latest version of BeOS), I love it. What I don't love is :
- my video chipset is not supported (only works in VESA mode),
- my sound card does not work (AC97 driver does work with my laptop),
- my wireless networking does not work (Intel Centrino).
Things I like
I'm not just a moaner you know, I do like stuff as well. ClocX is a lovely clock for XP, with a large choice of clock faces, transparency, and many other options. I use the "ModanieSmall" clock face.
I love ObjectDock for it's OSX-like interface. I don't use it now, as it crashes too regularly on my machine.
I'm loving FireFox, especially with the add blocking script installed. (Small moan - why do I have to reinstall the whole of FireFox when they fix bugs, why not supply a patch?)
Spybot Search&Destroy is another favorite, a free spyware and adware remover.
Sysinternals should be mandatory for all developers, I'm using Process Explorer as a replacement for Task Manager.
Things that annoy me about C# - interfaces
Interfaces are great, I love 'em. What I don't like is C#'s restriction on the implementation of interfaces. Implementations must be either public (okay), or private using the "interface.method" syntax (okay), but what about protected? I want to be able to do the following, but I can't:
public interface IMyInterface
{
void SomeMethod();
}
public class Class1 : IMyInterface
{
// This causes a compile error
// saying class does not implement interface!!!
protected virtual void SomeMethod()
{
// do stuff
}
}
public class Class2 : Class1
{
protected override void SomeMethod()
{
// do other stuff
}
}
You can do this in VB.NET, why not C#?
Things that annoy me about C# - delegates
Me and a colleague have been discussing things wrong with C#. Delegates somehow seem like a broken design. For instance, when I start a new thread, why do I need to pass an instance of the ThreadStart delegate? Why not just pass the method?
For instance, instead of:
Thread t = new Thread(new ThreadStart(SomeMethod)); t.Start();How about:
Thread t = new Thread(SomeMethod); t.Start();Much cleaner. On a similar theme, why not allow a method to implicitly declare a delegate, so instead of:
SomeDelegate dele = new SomeDelegate(this.SomeMethod); dele.BeginInvoke(null, null);How about:
this.SomeMethod.BeginInvoke(null, null);Also, delegates are not interchangeable. If you declare two delegates with the same signature, they cannot be used interchangeably, why not? Delegates and System.Reflection.MethodInfo seem very similar, they "smell" in refactoring terms, begging to be combined in some way...
Sunday, May 22, 2005
Managed OS written in C#
I work in C# on a day-to-day basis, so was interested to hear about a Managed operating system, mostly written in C#, coming out of Microsoft Research. It's called Singularity, and you can see an interview with some of the developers over on Channel 9. If they would make it open source, I bet many people would start actively contributing to it, never mind...
