18: F# what is it good for? Absolutely everything!20 May 2022
Rowan likes (loves) F# - in fact he won’t stop going on about it! we should be using it for everything - Andy is trying to learn F# (not going that well - it won't stick) - we’re going to discuss why F# is a good thing to learn, it's benefits over C# and what you can do with it
There are more than 200 flavours of Kit Kat in Japan. You can find Japan exclusive flavoured Kit Kats such as Adzuki (Red bean), Tamaruya Honten Wasabi (Japanese horseradish), Shinshu Apple and more.
Why is it called F#?*
The sharp (#) was started by c#
The name "C sharp" was inspired from musical notation where a sharp indicates that the written note should be made a half-step higher in pitch.
This is similar to the language name of C++, where "++" indicates that a variable should be incremented by 1.
The sharp symbol also resembles a ligature of four "+" symbols (in a two-by-two grid), further implying that the language is an increment of C++
Why should I learn it?
- Safest way to build software
- Very powerful type system
- Incredibly easy to model domain logic
- Super pattern matching
- Discriminated union types
- type inference
- Immutable by default - safe by default
- Functional first - provides a new paradigm to solve problems
- Functions as first class citizens
- Pipeline operations
- Composition over inheritance - compose building blocks rather than tightly couple through inheritance
- Currying - helps with composition
- Paradigm - functions have an input and an output, ideally don't cause any side effects. Trick is to understand side effects and build them into the domain - eg nulls are represented by a specific type
- When there are no side effects, the whole system is easier to reason about / goes hand in hand with immutability.
Why is it so hard for me to learn it! 😑
- Have you tried yet?
- Its .Net! With a some differences
- FizzBuzz - good one to try and use to learn F#
- if, else, for loop, recursive, type, pattern matching
Can you build..
- Console apps
- Enterprise apps
- Forms apps
- Mobile apps
- Blazor in F#?
Anything you can build in C# you can build in F#
Can you mix C# and F# in the same project or use F# libraries in C# and vice versa?
- a note on f# functions - you can share functions with c# code. They are exposed as Static methods
- f# classes just appear as a normal class in c#
Why no jobs for it?
- Good question - everyone is scared to learn, vicious cycle companies are then afraid to commit because they wont be able to find talent
- Quite a young language (v1 2005, v2 2010)
Seems like it’s more hardcore so people stay away from it
- Functional is just a slightly different way of thinking. But you can do object oriented as well, so you can ease into it
Need libraries or can you do everything “out of the box”
- a lot out of the box
- Small libs for convenience funcs around Option types of Result types - see railway oriented programming on fsharpfunandprofit.org
- paket is favoured over nuget in f#
- very precise control over package versions
- still use nuget packages - still use things like dapper micro orms, json.net etc
- use packages from github repos
- use packages from http sources
Things you need to know before learning it? (for C# knowing things like OOP are considered pre-reqs)
99% of people come to f# from c# (or vb.net) just need to learn the syntax
Big projects using F#
- jet.com - US based competitor to Amazon
- Subscription fee - point of difference is cheaper everyday items
- Tech focused - fulfilment chain optimised so that if you order 10 different things throughout the day, you get delivery.
- Bulk stock buying etc
- All f#
Compositional IT - benefits of F# + cloud
- consultancy services
Good resources for learning F#
Get programming with F# - a guide for .net developers - https://www.manning.com/books/get-programming-with-f-sharp
How to go and get started?
Just start using it!
OS project/utility of the week
Canopy is a web testing framework with one goal in mind, make UI testing simple:
- Solid stabilization layer built on top of Selenium. Death to "brittle, quirky, UI tests".
- Quick to learn. Even if you've never done UI Automation, and don't know F#.
- Clean, concise API.
- .net Standard 2.0.
- MIT License.