📎 Webclip
Porting from C# to F#: Introduction
The post introduces a series on porting C# code to F# and says the goal is to compare approaches, not to assume a direct translation is the best result. It frames porting as a way to see the differences between imperative and functional code, then organizes the work into three levels of sophistication.
Reading notes#
- A direct port keeps the original shape where possible, using classes and methods and often mutating values.
- The functional level replaces classes and methods with modules and functions, favors immutability, uses higher-order functions, pattern matching, and list functions or recursion.
- One path to functional code is to port first and refactor later; another is to make the C# code functional before moving it to F#.
- The advanced level changes the design to use algebraic data types, especially union types, so the domain is encoded in types and illegal states are not representable.
- The series will apply these levels to a bowling game, a shopping cart, and a subway turnstile example.
