Appendix G. Functional Languages for the .NET Framework


Nigel Perry

Appendix G credit: Nigel Perry, Department of Computer Science, University of Canterbury, Christchurch, New Zealand, nigel@cosc.canterbury.ac.nz. This work was started while the author was on sabbatical at Utrecht University. Many thanks go to Erik Meijer, the original team leader, and Arjan van IJzendoorn team researcher at Utrecht. The work was supported with grants from the Dutch Government and Microsoft Corporation.

Hosting functional languages in object-oriented environments, such as the .NET Framework, so that they interoperate well with other languages presents a number of problems. In this appendix, we describe methods to address these problems and introduce Mondrian, a new functional language specifically designed for such environments. The appendix concentrates on the programmer's view of Mondrian's types, functions, and interlanguage calling mechanisms. We compare these to traditional functional languages and describe how they appear to other languages on .NET. Mondrian implementation issues are not dealt with in depth.

Although this appendix is not a tutorial on functional programming, it is intended to be accessible to nonfunctional programmers. In doing this, we aim to introduce to those readers who are unfamiliar with functional languages to some of the benefits of using the .NET Framework and CLR to write parts of their code in Mondrian.

The advantages of hosting functional languages on the .NET Framework are many. For existing functional-language programmers, they include access to large libraries and interlanguage working opportunities. Other-language programmers gain access to the expressive power of functional languages without needing to convert whole projects to the paradigm.

There are also benefits for language implementers; including "free" garbage collection and access to the .NET Framework to provide language support services. Interested readers are referred to [1].

Unfortunately, using the Common Language Runtime (CLR) raises problems for functional languages. The type systems of the two paradigms are quite different. The CLR provides a system based on subtyping (inheritance), overriding ("polymorphism"), and immediate ("strict," "applicative order") evaluation. Functional languages are typically based on parametric polymorphism and just-in-time ("nonstrict," "normal order") evaluation. These two are rather different, especially from a programmer's standpoint.

Mondrian has been designed to bridge this divide. In this appendix, we show how traditional functional language constructs map to those in Mondrian, using Haskell [2] as our reference, and how Mondrian constructs appear to other CLR-hosted languages. Mondrian itself is still in development, and its final syntax and semantics may change. We restrict ourselves primarily to types, functions, and interlanguage calling issues.

We do not argue the relative merits of functional and object-oriented languages ”there is plenty already written on that subject ”but rather work from the basis that both have their merits. We also do not consider multi-paradigm languages, such as O'CAML [3]; rather, we see the benefit of targeting the CLR as allowing multi-paradigm programming without the need to design multi-paradigm languages. Each may have its place, but we leave that for others.



Programming in the .NET Environment
Programming in the .NET Environment
ISBN: 0201770180
EAN: 2147483647
Year: 2002
Pages: 146

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net