Skip to content

Getting Started with Functional Programming in F#

Sponsor: Do you build complex software systems? See how NServiceBus makes it easier to design, build, and manage software systems that use message queues to achieve loose coupling. Get started for free.

Learn more about Software Architecture & Design.
Join thousands of developers getting weekly updates to increase your understanding of software architecture and design concepts.


Functional Programming in F#At last night’s Windsor-Essex .NET Developers Group, we had Reid Evans presenting a talk on Getting Started with Functional Programming in F#. I absolutely loved this talk and wanted to share it along with some of my thoughts and takeaways. I’ve been over the last year or two going back and forth with learning F# and understanding more functional programming concepts.  So I was really looking forward to this talk. If you have any questions, please follow me on Twitter.

Video

This is the live stream we had to our user group.  If you are interested in functional programming and F#, I highly recommend giving this a watch.

 

Takeaways

I thought Reid’s intended takeaways were all met.  I came out of that talk with exactly what he intended.  As a speaker, I think this is the ultimate goal.  What you are trying to convey is achieved. That’s not to say people can find other takeaways, but knowing what you are trying to present and is received is great.

Defaults matter & No more null!

I think the hardest idea to fully “get” is how defaults matter.  I think this is really expressed when you see the difference of not being able to have null. The alternative of using the Option Type (a Union Type) as an alternative way of thinking about the problem of something not existing.  In Reid’s example, a record not existing in the database. What I love about is how you handle the resulting Option Type with pattern matching.  What I take from this is forcing the caller to property handle either Some or None. I think Reid said it really well that if your language allows null, you must check for null everywhere.  If it does not allow null, and uses something like an Option type, then that is very explicit.

Type Providers == Awesome

They are truly awesome.  It was really interesting to see how a type from a column of a database could be then be used to infer the argument of a method.  This is kind of mind blowing. I can see the value this would provide a developer in terms of not making simple accidental mistakes.  Plus having a built in integration test at compile time is just fantastic.

Composing Small Functions

Although the idea of writing small classes and methods are familiar to you in C#, I think the concept of you use those functions in a functional language is what differs. I loved the example of how the validation was tied together as it gives a great real world example.  As with everything I still need more understanding on this and where this can take you.

Other Thoughts

What I loved about this talk is it used real world simple examples of things you would do building an app like data access and validation. It was very easy to transfer the content into something you could relate to.  I think the fact that Reid often went down the road of making the comparisons to something I was already familiar with was a great help. If you watched the video, I’d love to hear your comments.   Reid would probably love feedback as well.  Please post a comments or on Twitter.

Leave a Reply

Your email address will not be published. Required fields are marked *