BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Don Syme Presents F# Design Principles at .Net Fringe

Don Syme Presents F# Design Principles at .Net Fringe

This item in japanese

Bookmarks

Don Syme, creator of F#,  presented at .Net Fringe 2016 an assessment of the current status of F#. He also commented on the duality that exists in F#, a functional language created on a runtime built for object oriented languages.

F# was released under an open source license in 2010. F# walked the .Net path early, as C# and .Net are open source since 2015. Putting F# open source was mainly to increase its credibility. Back at the time, a language had to be open source in order to be taken seriously by developers and companies.

There was a long standing initiative to bring new languages to .Net. Functional programming languages were isolated, running in their own VM. Interops standards (C-calls, COM, CORBA, XML) made language integration difficult.

The F# approach is to use an already well adopted runtime and to compromise where needed. The language is designed with end-to-end interop in mind. This approach is often used for newer languages such as Scala and Swift.

The F# approach is to embrace objects, make them fit with the expression-oriented typed functional programming. While being a functional language, F# also supports classes, abstract classes and interfaces.

// Class definition
type Vector2D (dx:double, dy:double) =
    let d2 = dx*dx + dy*dy // object internals
    // Exported properties
    member v.DX = dx 
    member v.DY = dy
    member v.Lenght = sqrt d2
    member v.Scale(k) = Vector2D (dx * k, dy * k) // Exported method

Classes are supported along with interfaces and abstract classes. One notable addition is the ability to define them anonymously, a feature called object expressions.

type IMathExample =
    // abstract method
    abstract member Add: int -> int -> int

    // abstract immutable property
    abstract member Pi : float

// Interface implementation with object expressions
let obj = 
  { new IMathExample with
    member this.Add x y = x + y
    member this.Pi = 3.14 }

As the F# language is evolving in several ways, Syme gave an overview of its current status:

  • Open, cross-platform, neutral, independent
  • The F# language accepts contributions.
  • Non-profit organization overseeing it, the F# Software Foundation
  • Mobile support and tooling through Xamarin
  • The Visual F# tools from Microsoft provide support for Windows and Azure.
  • The F# compiler services powers many F# tools projects.
  • F# 4.1 is underway.

Syme coined a new term while talking about language independence. He defines mimetic independence as the ability to define a technology as an idea independently from another technology, association or vested-interest. F# achieves mimetic independence, while the significant contribution of Microsoft must still be acknowledged. As a counter example, Visual Basic wouldn't qualify as it is completely dependent on Microsoft.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT