↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

Why is F# code so robust and reliable?

The post says Access Softek used F# for EasyCoin after years of bugs in C# and .NET work. It attributes the low bug count in production to language features that make state, errors, dependencies, and concurrency more explicit.

Reading notes
#

  • Values and records are immutable by default, which helps with code predictability and concurrency safety.
  • Discriminated unions with exhaustive match make the compiler warn when a case has not yet been handled.
  • The use of null is not the default; missing values are handled with Option<'T>, which forces explicit handling of Some and None.
  • Errors in business logic should be handled with Result<'T> or with specific DUs, instead of custom exceptions in the middle of the transaction.
  • In F#, variables, functions, types, and files can only depend on what was defined before, which avoids circular dependencies and makes clear what depends on what.
  • The compiler warns about unused expression results, which draws attention to cases that could go unnoticed.
  • Typed primitives with units of measure help distinguish similar types, such as different IDs, at no runtime cost.
  • Implicit conversions are not accepted; explicit conversions reduce type errors and problems in string interpolation.
  • Concurrency can be modeled with actors and messages, using MailboxProcessor<'Msg> or Channels.
  • Dependency injection is done through explicit arguments, which allows compile-time checking and makes testing easier.
  • The text also mentions SQL, HTML, IaC, and typed route parameters, as well as transpilers from the Fable project to JavaScript and Python.