CLR 4.0: Managed Languages

Over the years.NET has been a great platform for multiple languages, and actually launched with support for 16 different languages. Up until recently, however, it has been difficult (but not impossible) to create functional and dynamic languages for.NET.

With the release of CLR 4.0, Microsoft is officially releasing IronPython, IronRuby, F#, and several other functional or dynamic languages. In order to do this, the CLR is gaining support for a few language features that are common in these types of languages, specifically support for:

  • Big Integers
  • Tuples
  • Tail Recursion

Big Integer support was a request from both the F# and Python languages and was co-implemented with the Microsoft Optima team. (This is the team that works on the Microsoft Solver Foundation, which is a brand new framework and managed code runtime for mathematical programming, modeling, and optimization.)

Tuples were also a request from both the F# and Python languages and provide the ability to create classes on the fly. The real benefit, especially to C# and VB developers is that now there is a built-in data type which will allow multiple return values.

public Tuple<Int32, Int32> DivAndRemainder(Int32 i, Int32 j) { return new Tuple.Create(i/j, i%j); }   // Accessing items in a tuple. for (Int16 i = 0; i <= 25; i++) { for (Int16 j = 1; j <= 5; j++) { var tuple = DivAndRemainder(i,j); Console.WriteLine("{0}\t{1}\t{2}\t{3}\n", i, j, tuple.item1, tuple.item2); } }

Tuples are implemented as a generic class, in a very similar fashion to the Func and Action classes. C# and VB.NET don’t get the same syntax support in the language (in F# or Python you create a tuple with syntax like (4, “Hello World”) which is very concise), but this is almost as easy (and there may possibly be some syntax support in C# 5.0).

Also requested by the F# team is support for tail recursion. Tail recursion is relatively rare in C# and other procedural languages so this is more important for the functional languages that will be supported.

](http://digg.com/submit?url=http%3a%2f%2fgeekswithblogs.net%2fsdorman%2farchive%2f2008%2f11%2f10%2fclr-4.0-managed-languages.aspx&title=CLR+4.0%3a+Managed+Languages)

This article is part of the GWB Archives. Original Author: Scott Dorman

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.