Phillip Trelford's Array

POKE 36879,255

Progressive F# Tutorials London 2013

Last week’s Progressive F# tutorials conference seems to have struck a note:

Progressive F# 2013 best conference ever. Fact. #progfsharp

A big thanks to Skills Matter for organizing this 2-day hands on community event:

progfsharp-2013-800x300px1

You can see pictures from the event on Skills Matter’s Facebook photo stream:

Progressive F# Tutorials 2013 - Jon, Zach, Martin and Gustavo Progressive F# Tutorials 2013 - Coding in The Crypt
Progressive F# Tutorials 2013 - Coding Progressive F# Tutorials 2013 - Practising the Koans

 

Following on from events in 2011 and 2012 this year we welcomed 79 F#ers:

#progFsharp seems to grow in size every year :)

If you’d like to join us next year there’s currently an early bird discount:

If you enjoyed #progfsharp this year, why not get in early & get your ticket for next year? Tickets just £95 http://ow.ly/qoV5Y

This year’s F# Tutorials ran over 2 days with 2 tracks of hands on sessions.

Day 1

Jon Harrop kicked off proceedings with a talk on using F# to change the way we work:

Progressive FSharp Tutorials - Using F# to change the way we work

Followed by an F# Koans session with Rachel Reese, Dan Mohl and Robert Pickering. The F# Koans are a great way to get started with F#.

At the same time we ran a Programming with the Stars session with Rich Minerich and volunteer Michael Newton. This year‘s task was the Bank OCR Kata:

 1: let zeroToNineText = """
 2:  _     _  _     _  _  _  _  _ 
 3: | |  | _| _||_||_ |_   ||_||_|
 4: |_|  ||_  _|  | _||_|  ||_| _|                          
 5: """
 6: 
 7: let getDigits (source:string) len =
 8:     let lines = source.Split([|'\n'|]).[1..3]
 9:     [for digit in 0..len-1 ->
10:         let index = digit*3
11:         [for line in lines -> line.[index..index+2]]
12:     ]
13: 
14: let zeroToNine = getDigits zeroToNineText 10
15: 
16: let toNumber text =
17:     getDigits text 9
18:     |> List.fold (fun acc digit ->
19:         let n = zeroToNine |> List.findIndex ((=) digit)
20:         acc * 10 + n
21:     ) 0
22:         
23: let accountText = """
24:     _  _  _  _  _  _     _ 
25: |_||_|| || ||_   |  |  ||_ 
26:   | _||_||_||_|  |  |  | _| 
27: """
28: 
29: let n = toNumber accountText
val zeroToNineText : 'a

Full name: Snippet.zeroToNineText
Multiple items
val string : 'T -> string

Full name: Microsoft.FSharp.Core.Operators.string

--------------------
type string = System.String

Full name: Microsoft.FSharp.Core.string

  type: string
  implements: System.IComparable
  implements: System.ICloneable
  implements: System.IConvertible
  implements: System.IComparable<string>
  implements: seq<char>
  implements: System.Collections.IEnumerable
  implements: System.IEquatable<string>
Multiple items
module List

from Microsoft.FSharp.Collections

--------------------
type List<'T> =
  | ( [] )
  | ( :: ) of 'T * 'T list
  with
    interface System.Collections.IEnumerable
    interface System.Collections.Generic.IEnumerable<'T>
    member Head : 'T
    member IsEmpty : bool
    member Item : index:int -> 'T with get
    member Length : int
    member Tail : 'T list
    static member Cons : head:'T * tail:'T list -> 'T list
    static member Empty : 'T list
  end

Full name: Microsoft.FSharp.Collections.List<_>

  type: List<'T>
  implements: System.Collections.IStructuralEquatable
  implements: System.IComparable<List<'T>>
  implements: System.IComparable
  implements: System.Collections.IStructuralComparable
  implements: System.Collections.Generic.IEnumerable<'T>
  implements: System.Collections.IEnumerable
val fold : ('State -> 'T -> 'State) -> 'State -> 'T list -> 'State

Full name: Microsoft.FSharp.Collections.List.fold
val findIndex : ('T -> bool) -> 'T list -> int

Full name: Microsoft.FSharp.Collections.List.findIndex

The code above was my attempt, check out more solutions on F# Snippets:

In the afternoon Rachel Reese ran a hands on session on Try F# from Zero to Data Science:

Looks like we broke http://tryfsharp.org during @rachelreese great workshop session ;) #progfsharp

Thought - @rachelreese should rename her session to DOSing around on TryFSharp ;) #progfsharp :D

Meanwhile Robert Pickering’s tutorial was on programmatically generating sounds and music with Undertone.

Playing with Undertone with @alanmgreen and @DaveHoganIW at #progfsharp... did I mention I know nothing about music! :> /cc: @robertpi

After some pizza and drinks, the coding spilt over to the local pub:

Progressive FSharp Tutorials - Don and Dan

And by all accounts the fun continued on through the night:

Progressive F# Tutorials 2013 - Halloween Fun

Day 2

In the morning there was a choice between Machine Learning for Fun and Profit with Matt Moloney and Time for Functions in the Enterprise with Simon Cousins (which was my 11yo son’s favourite session!).

In the Machine Learning session we used Deep Belief Networks to categorize digits and to predict fluctuations on the Bitcoin/USD exchange rate.

The code sample and tasks are here: http://trelford.com/ProgFSharpML.zip

Simon’s slides and samples are here: https://github.com/simontcousins/pft2013

In the afternoon Dan Mohl and Zach Bray led a tutorial on Web Programming while Rich Minerich ran a Pacman AI competition.

Dan and Zach’s slides and tasks: https://github.com/dmohl/FsOnTheWeb-Workshop

Here’s a screenshot from the Pacman session:

MattDrivenDev Pacman

Ben Lynch won the competition with a really strong AI:

Probably the best #fsharp conference in the world #progfsharp - and not just 'cos I won the graphman contest! (which I did, by the by ...)

If you fancy having a go at writing your own Pacman AI, pop down to the F#unctional Londoners meetup on November 14th.

I’m already looking forward to next year, if you can’t wait that long for some more conference action with F# check out:

The Promise of Polygot Programming on .Net

.Net was Microsoft’s answer to Java. Java promised a single language that could target multiple platforms. .Net offered multiple languages that targeted Windows. Back then that meant C#, VB.Net and C++/CLI,

Virtual Machines

Things have moved on for both VMs, the JVM now has a plethora of languages like Groovy, Clojure and Scala. Meanwhile .Net code has become cross platform via Mono, in fact C# and F# now have arguably offer a better story for iOS than Java. For iOS, Xamarin compiles C# and F# code to native ARM binaries.

Both VMs have been hugely successful and have seen a wealth of libraries and frameworks built on them, allowing them to interoperate with a vast array of software and devices. This makes languages built on these VMs compelling as you don’t need throw away existing enterprise investments and build everything again from scratch.

Enterprise Java

Java 8

Progress on the Java programming language has been slow, which has in part helped accelerate the adoption of new functional-first languages like Clojure and Scala. Java will be the last mainstream programming language to add lambdas when Java 8 is released potentially in March 2014.

Question marks have also been hanging over Java’s open source credentials since Oracle’s acquisition of Sun. Back in March 2012, Thoughtworks put the Future of Java in the Assess ring of their Technology Radar.

That said in London at least the Java community seems to be strong in numbers with over 3,500 members in the LJC meetup compared to just over 400 for the London .Net meetup.

C# Convergence

C#, VB.Net and C++/CLI all share similar features and so the vast majority of developers have converged over time on the C# programming language.

The dynamic CLR languages IronPython and IronRuby have lost much of their momentum and Nemerle seems to have been subsumed by JetBrains for N2.

That really just leaves F# under active development, built-in to both Visual Studio and Xamarin Studio, it uses the same compiler as F# is open source under Apache 2.0.

C# 5

On .Net, the C# programming language has seen a little more innovation than Java, adding rudimentary functional programming constructs in C# 3 for LINQ like lambdas and extension methods for expressing higher-order functions.

Progress in C# 4 and 5 has been lacklustre since Microsoft departed on a rewrite of the compiler in C#, a closed source project called Rosyln, which is yet to surface.

In C# 4 the focus was on dynamic support, where the main new feature in C# 5 was async, a feature introduced in F# in 2007.

Linux

In the enterprise one of the biggest threats to .Net code bases is migration to Linux, for which outside of Mono there is no .Net story. Xamarin, key contributors to Mono, are overwhelmingly focused on mobile. Recent improvements in Mono, particularly in garbage collection, I feel make it a viable server-side platform, but it currently lacks the support and investment seen on the JVM.

As large enterprises continue to look for cost savings, I suspect more .Net share could be lost to switches to Linux. Lower operating costs combined with the promise of higher productivity with powerful functional-first languages like Clojure and Scala, are hard for IT managers to ignore. Nowadays many finance companies use the JVM on the server-side and reserve .Net, specifically WPF, solely for their front-end applications.

I’d like to see Microsoft join forces with Xamarin to deliver a well supported server-side platform with Mono for C# and F# on Linux, to compete directly with Clojure and Scala. That also means .Net open source authors should be supporting Mono deployments too.

Polyglot Programming

The promise of polyglot programming on .Net, where you pick appropriate languages for specific tasks, now rests primarily with familiar C# and functional-first F#.

As C# and F# are statically typed languages on .Net, interop between them is seamless. Both languages also offer bridges to external libraries via C APIs with P/Invoke. F# also offers rich interop to data sources and programming languages on other platforms via Type Providers.

With F# Type Providers you can interact with languages like R, MATLAB and TypeScript and their rich libraries with intellisense support in your editor. Type Providers are a real enabler for true polyglot programming.

Edge.js also bridges the gap between the .Net and JavaScript worlds with Node.js interop.

The combination of C# with it’s familiar syntax and object-oriented constructs with F# and it’s functional-first constructs and type providers, in my opinion, offers arguably the most powerful and productive programming environment currently available.

In the same Thoughtworks Technlogy Radar that questions the Future of Java, they had this to say on F# and C#:

F# is excellent at concisely expressing business and domain logic. Developers trying to achieve explicit business logic within an application
may opt to express their domain in F# with the majority of plumbing code in C#.

I’m seeing more and more .Net shops adopt F# alongside C#, take for example Kaggle a data science consultancy based in San Francisco:

At Kaggle we initially chose F# for our core data analysis algorithms because of its expressiveness. We’ve been so happy with the choice that we’ve found ourselves moving more and more of our application out of C# and into F#. The F# code is consistently shorter, easier to read, easier to refactor, and, because of the strong typing, contains far fewer bugs.

As our data analysis tools have developed, we’ve seen domain-specific constructs emerge very naturally; as our codebase gets larger, we become more productive.

The fact that F# targets the CLR was also critical - even though we have a large existing code base in C#, getting started with F# was an easy decision because we knew we could use new modules right away.

The point here is not to throw the baby out with the bath water and rewrite your entire solution in a new language, instead leverage your existing investments and use the right tool for the job on new features.

Functional Programming

Functional programming has permeated the majority of mainstream programming languages, and is gaining increasing mind share. Here’s a nice slide from Grant Crafton’s recent session on functional programming at DDD North:

Who likes FP

It’s clear to me that many of the original protagonists of object-oriented programming are migrating towards functional. Recently I met Eric Evans, author of Domain Driven Design, in New York who spoke at length on how he’d gone all-in on functional.

At conferences like Strangeloop, I’d go as far as saying this is a done deal, very few people are talking about OOP anymore.

Functional Learning

There’s been quite a lot of FUD around functional programming being hard to learn. In general people encounter two initial speed bumps:

  • Unfamiliar syntax
  • Unlearning 

Neither of these speed bumps are insurmountable, otherwise there wouldn’t be such a large number of developers turning to functional languages.

Lack of familiarity with syntax can be overcome with just a few hours of immersion. For F# I’d recommend the F# Koans to guide you through the language syntax step-by-step and a Cheat Sheet to lookup common operations as you code. F#’s syntax is based on the ML programming language, once you’ve got the hang of it you’ll be able to read a host of other ML based languages like Erlang and Haskell.

Unlearning tends to take longer than learning, so unfortunately if you’ve been programming in an imperative or object-oriented style for a long time, it will be slightly harder to pick up functional programming. That it to say learning functional programming is not inherently hard, just that thinking differently can take some time. I’d recommend tackling short programming exercises like Code Katas or Project Euler problems to break the back of it.

Be patient, once you’re over the hump you could find the experience fun and rewarding:

Happy learning!

Software Developer in Test Role at Trayport

At Trayport we’re serious about quality, and are now hiring for a software developer in test.

You…

  • Are enthusiastic about building automated tests that help continuous delivery of exceptional quality software.
  • Are skilled with .NET and have strong development and debugging abilities, with knowledge of test frameworks and design patterns.
  • Love to work in lean and agile environments, delivering software through TDD, ATDD and BDD.
  • Want to work in a team of talented technologists who will challenge and inspire you.

We…

  • Have a track record of delivering high quality software the energy trading industry depends on.
  • Have a Joel Test score of 11 of 12.
  • Offer a great benefits package including healthcare, gym membership, bonus scheme and a well-stocked kitchen.
  • Hold regular social events for the whole company, including an annual weekend away.

What can we offer you?

  • Good spec hardware, access to a decent library and an office with top facilities.
  • A relaxed environment which includes a casual dress code, regular tech talks, hackathons and opportunities to attend top conferences.
  • Flexible working hours and paid-for home PC and broadband.
  • An induction period to get you up to speed with our business and a buddy to make sure your questions are answered.

What will you be doing?

  • As part of one of the three software teams at Trayport, you’ll automate the testing of top-of-class trading software – both front ends and servers.
  • Have the responsibility and flexibility to choose and develop tools and technology required to enable the team to continuously deliver high quality software.
  • Contributing to the whole spectrum of automated testing from end-to-end UI tests to improving and refactoring unit tests along with promoting good practice to the rest of the team.
  • Experience work on a range of features and products, helping the team produce top quality tested code and have a say in all areas across the business.

Trayport was founded in 1993 and now has around 200 employees, we’re proud of our small company feel but boast a global vision. Our range of clients spans household energy companies, banks, hedge-funds and regulation bodies – providing Windows-based front-ends and servers to facilitate all aspects of trading. We’ve recently moved to top-class offices in a great City location – if you’re interested in what you’ve read, apply today by letting us know how you can help shape our future.

Email me: phillipt@trayport.com with your CV (no recruiters please).