Phillip Trelford's Array

POKE 36879,255

C# 6 Cuts

In a recent thread on CodePlex Mads Torgeson, C# Language PM at Microsoft, announced 2 of the key features planned for C# 6 release have now been cut:

  • Primary constructors
  • Declaration expressions

According to Mads:

They are both characterized by having large amounts of downstream work still remaining.

primary constructors could grow up to become a full-blown record feature

Reading between the lines Mads seems to be saying the features weren’t finished and even if they were they seemed to conflict with a potential record feature currently being prototyped.

The full thread is here: Changes to the language feature set

Language Design

I think there’s two distinct options when adding new features to an existing language with a large user base:

  • upfront design
  • implement incrementally

Upfront design should mean that all cases are met but comes at a time-to-market cost, where as an incremental implementation means quick releases with the potential risk of either sub-optimal syntax or backward compatibility issues when applying more features.

It appeared at the high level that the C# team’s had initially opted for the incremental option. The feature cuts however suggest to me that there may have been a change in direction towards more upfront design.

Primary Constructors

The primary constructors feature was intended to reduce the verbosity of C#’s class declaration syntax. The new feature appeared to be inspired by F# ’s class syntax.

If you like the idea of a lighter syntax for class declarations then you may just want to try F# which already has a well thought out mature implementation, i.e.

type Person(name:string, age:int) =
    member this.Name = name
    member this.Age = age

Or for simple types use the even simpler record type:

type Person = { Name:string, Age:int }

Note: on top of lighter class syntax F# also packs a whole raft of cool features not available in C#, including powerful pattern matching and data access via Type Providers.

Declaration Expressions

Declaration expressions was again designed to reduce verbosity in C# providing a lighter syntax for handling out parameters. Out parameters are used in C# to allow a method to return multiple values:

int result;
bool success = Int32.TryParse("123", out result);

Again handling multiple return values is handled elegantly in F# which employs first-class tuples, i.e.

let success, value = Int32.TryParse("123")

As shown above, C# out parameters can be simply captured in F# as if the method were returning multiple values as a tuple.

Conclusion

The first time I saw Mads publicly announce the now cut primary constructor syntax and declaration expressions was nearly a year ago at NDC London. At the time the features were announced with a number of disclaimers that they may not actually ship. I think in future it may be better for everyone to take those disclaimers with more than just a pinch of salt.

One Week in F#

With Sergey Tihon on vacation this week, I’ve collated a one off alternative F# Weekly roundup, covering some of the highlights from another busy week in the F# community.

News in brief

FSharp Logo

Events

This week has seen meetups in Nashville, Raleigh, Portland, Washington DC, Stockholm and London:



Recordings

Upcoming meetups

Upcoming Conferences

Projects

Blogs

FsiBot



Have a great week!

F#unctional Londoners 2014

2014 has been another crazy year for the F#unctional Londoners meetup with over 20 sessions already. Thanks to our hosts Skills Matter we’ve been able to hold a meetup roughly once every 2 weeks.

Here’s a run down of the year so far and what’s coming up.

January

Ross kicked off the year with a deep dive to his LINQ enabled erasing SQL Type Provider.

Following on, in May, Ross left the sunny shores of Southend to tour the east coast with the talk covering NYC, Washington DC and Nashville along the way.

sql-provider

First seen at DunDDD in Dundee, Anthony’s excellent talk went on to be featured at CodeMesh London too.

With F# built-in to Xamarin Studio you can easily target iOS, Android and Mac.

February

Tomas returned to London to talk about his work on Deedle while at Blue Mountain Capital in New York.

As a follow on from the talk Tomas ran a hands on session using Deedle to explore world climate, the titanic, stock market trends and finally US debt.

March

There was a huge turnout for Scott’s hugely informative and at times somewhat amusing talk first seen at NDC London.

set phasers to null

Eirik Tsarpalis and Jan Dzik, from Nessos, presented their work on MBrace a programming model and cluster infrastructure for effectively defining and executing large scale computation in the cloud.

In this hands on treasure hunt session, Tomas presented a series of data extraction tasks using type providers to find words to build a sentence.

April

Rob Lyndon introduced Deep Belief Networks and his GPU based implementation in Vulpes. This talk was repeated last week at the prestigious Strangeloop conference in St Louis!

May

Michael travelled up from Brighton for a hands on session on building type providers. Type Providers are a hot topic in the London group with a number of popular type providers produced by members including FSharp.Data, SQLProvider and Azure Storage.

Mixing biology and physics to understand stem cells and cancer (video)

Ben Hall from Microsoft Research Cambridge gave a fascinating talk about his work with a hybrid simulator in F# to explore how stem cells grow (and some worms!).

Stephen Channell gave a repeat of his excellent talk featured at FP Days and the F# in Finance conference on liquidity risk.

Ian was in town to run a session at the Progressive .Net Tutorials and gave a repeat of his excellent talk from DDD North.

June

F#unctional Londoners regular Isaac, aka the Cockney Coder, talked about his professional work with Azure including his Azure Storage type provider.

In this hands on session we used the material from Mathias Brandewinder’s session in San Francisco to have some fun drawing fractal trees.

In this session Gabriele Cocco talked about his work on FSCL, an F# to OpenCL compiler.

July

Borrowing material from Mathias again, we built a 2048 bot using the open source web testing library Canopy.



Grant popped down from Leeds to run a fun code golf session where the aim was to complete a task with the least number of characters.

August

Phil Nash talked about how he was using F# scripting at work along side his some of his C++ projects.

In this hands on session we looked at the popular parser combinator library FParsec, building a mini-Logo parser and interpreter.

September

James popped down from Edinburgh to talk about his work with Philip Wadler on the open source project FSharp.Linq.ComposableQuery.

Goswin Rothenthal talked about his work using FSharp scripting in the design of the Abu Dhabi Louvre building:

Coming up this Wednesday we have Evelina talking about some of her data science work at Cambridge.

November

On November 6-7th the Progressive F# Tutorials make a return with expert speakers including Don Syme, Tomas Petricek, Mark Seemann, Andrea Magnorsky, Michael Newton, Jérémie Chassaing, Mathias Brandewinder, Scott Wlaschin and Robert Pickering.

ProgFSharp2014Don’t miss the special offer that runs up to the end of Evelina’s talk giving a 20% discount to members, brining the price down to a barmy 200GBP, use code F#UNCTIONAL-20.