C# vs. VB
Rowan posted about C# vs. VB:
> None, if challenged, would be able to build anything using
> C# that Phil couldn’t build just as well in VB.
This isn’t the point. Different languages have different levels of expressiveness and also different aesthetics. A program written in Haskell may be 10 times shorter than the same program written in C++ for example [1].
Personally, I have two favourite languages: Ruby and Haskell :-)
In Ruby I can write this:
10.times { |i| puts i }
But in C# I have to write this:
for (int i = 0; i < 10; i++) { Console.Write(i); }
Which do you find more beautiful? :-)
BackgroundMotion Code Sample
The BackgroundMotion community site and ASP.NET code sample that we worked with Microsoft to develop has gone live. w00t!
If you’re interested in ASP.NET you definitely want to check out the sample as it illustrates one approach to architecting .NET web apps. The architecture was really designed to facilitate rapid development so emphasizes things like testability etc. My personal highlights of the sample are:
- Use of a domain-driven design techniques. Repository and Unit of Work abstractions over LINQ to SQL
- Model-level validation using the Validation Block
- Dependency injection using Composite Web Block
- Using Lucene.NET to index a domain model
- Using MVP with declarative data-binding in the presentation layer
Let us know what you think.
Eager Loading
Alex has been thinking a bit about object eager-loading (prefetch) retrieval strategies recently.
The LINQ to SQL approach of using a Lambda is interesting and was the approach we used on BackgroundMotion:
Contribution contribution = Repository<Contribution>
.Find(1)
.Including(c => c.ContributionTags);What’s more interesting to me however is that now we have a way to refer to symbols in a type safe way. Useful for things like data binding etc. where we want to specify a property and where currently we have to use a string. That’s not to say that this Lambda syntax is optimal for this but what can you do? :-)
With respect to eager load strategies our new domain model/persistence framework LightSpeed has the notion of a “named aggregate” - aggregate being a term taken from Domain-driven design. Basically we use an attribute called EagerLoad at the association level in the model:
[EagerLoad(AggregateName="ContributionDetail")] public readonly EntityCollection<ContributionTag> _contributionTags = new EntityCollection<ContributionTag>();
Then we can specify an aggregate name as part of our query.
Query query = new Query(Entity.Attribute("Title").Like("A%")); query.AggregateName = "ContributionDetail"; IList<Contribution> contributions = Repository.Find<Contribution>(query);
The key point is that we are being explicit about naming the aggregates.
Gardens Point Ruby.NET Compiler
This seems to have gone under the radar a little bit, what with all the recent Microsoft DLR/IronRuby news, but the QUT guys released 0.7 of their Ruby .NET compiler this month too - and it sounds like they are making good progress!
Since the last release we have added support for debugging (by generating pdb files) and have created a Visual Studio integration package allowing users to edit, build, execute and debug Ruby programs within Visual Studio 2005. This includes syntax colouring, error highlighting, brace matching, hidden regions, Ruby.NET projects, project properties, project templates and project item templates. Ruby.NET projects (.rbproj) enable multiple Ruby source files to be compiled into a single .NET assembly.
I wonder where we will see Rails.NET running first? :-)


