Introduction
The C# 3.0 currently available in preliminary version is part of the LINQ project [1]. The aim of this project is to integrate better support for working data into mainstream general-purpose programming languages developed at Microsoft. It particularly targets the .NET platform, i.e. C# and VB.NET. Most of the ideas that are implemented in C# 3.0 are already available in mostly research and experimental languages that were previously developed at Microsoft Research. Among the most interesting and influential of these languages developed are Cω [2] and F# [3].
Contribution of F#
F# is a language based on ML, which is an impure functional language. In fact, it is based on a language called OCaml that adds several features to the standard ML. Functional languages are very different from imperative languages, with most of the widely used languages like C++, Java, and C# being imperative. The biggest contribution of F# is that it shows how functional languages can be compiled for the .NET Runtime (CLR) because the .NET CLR was initially designed for executing code written in imperative languages. Another aim of F# is the interoperability with other languages targeting the .NET platform. Part of the F# related research is also the ILX [6] project that shows how the .NET runtime could be extended to provide better support for functional languages, like first-class functions.
Functional programming, in general, was a big inspiration for some of the C# 3.0 features. The F# research language already showed how these features could be implemented for the .NET platform. C# 3.0 includes constructs that were inspired by:
- Type inference: ability to deduce the type of expression
- Tuples data types: types that represent a pair of values
- First class functions: ability to take a function as a parameter and return it as a result
- Lazy evaluation: ability to evaluate expressions only when it is needed later
- Meta-programming: ability to manipulate with program source code
Most of these features that were added to C# 3.0 are very limited when compared with their implementation in F# and other functional languages. However, it is very interesting to see how functional concepts are becoming more and more important and can benefit the non-functional languages.
No comments:
Post a Comment