1 Introducing F#


This chapter covers

  • Learning what F# is and isn’t
  • Why you should be interested in using F#
  • When is a good time to use F#
  • Understanding what this book will and won’t teach you
  • Understanding the mental model behind F#

In this chapter, I’ll be taking you through the basics of F#, how it may differ from other languages you’re familiar with, and why you should learn it. We’ll explore some of its great features as well as its potential as a primary programming language in your toolbox. Let’s get started!

1.1 What is F#?

F# is a general-purpose programming language that’s designed to build systems that are robust, succinct, and performant across Windows, Mac, and Linux. It has a lightweight syntax, yet a powerful type system and compiler. This makes it a compelling choice for writing applications, as it enables developers to rapidly model real-world systems in a way that does what they intend.

F# is an opinionated language with a set of characteristics that it is optimized toward. What do I mean by this? F# encourages us to write applications using a consistent set of simple constructs such as functions, data, and types in a very low-ceremony fashion compared to many other languages that come from a more classical object-oriented background. Although some of those languages have added in some capabilities to hide some of that complexity, in F#, this has been a core part of its design from day one. As an example, here’s some basic F# code that defines a function:

1.2 Why F#?

1.3 When F#?

1.4 How will this book teach me F#?

1.5 How does F# work?

1.5.1 Collaborative exploration

1.5.2 Type-driven development

1.5.3 Trusting the compiler

1.5.4 An opinionated language

1.5.5 Data and functions

1.5.6 Separation of business logic and external systems

1.5.7 Varied targets