The Safe Language

Write Code That
Just Works.

F# is a tool for talking to computers. It is built to be simple, correct, and short. It stops you from making mistakes before they even happen.

What is F# exactly?

Normally, writing code is like giving a computer a recipe: "Take a bowl. Put flour in it. Add water. Mix it." This is a step-by-step list.

F# is different. It is a Functional Language. This means instead of long lists of steps, you build small, smart tools (called functions) and plug them into each other. You focus on the final result, not the boring steps to get there.

THE F# PROMISE
  • Less Typing
  • Fewer Bugs
  • Easy to Read

The "Sealed Box" Rule

Normal Code (Boxes that stay open)

In most languages, you put data in a box. Later, someone else can open that box and change the data without telling you. This causes huge problems when programs get big.

F# Code (Sealed Boxes)

In F#, once you put data in a box, you seal it shut. It can never change. If you want a different number, you must make a brand new box. This means you always know your data is safe.

The Assembly Line (The |> Arrow)

F# has a magic symbol that looks like this: |>. We call it the pipeline. It takes data and pushes it forward to the next step, exactly like a factory assembly line.

Raw List of Names
Filter Out Blanks
Sort A to Z
Print to Screen

The Smart Guesser

Computers are usually not very smart. You have to tell them exactly what kind of thing you are typing. If you type a "5", you have to yell, "HEY COMPUTER, THIS IS A NUMBER!"

F# has Type Inference. This means it looks at your code and guesses correctly. It sees a "5" and knows it is a number. It sees "Hello" and knows it is text. This means you type much less, and the code looks much cleaner.

The Shape Sorter (Pattern Matching)

Imagine a baby's toy box where you put the square block in the square hole, and the round block in the round hole. F# has a tool just like this for data. It looks at the shape of your data and decides what to do with it. It is much cleaner than using endless "If this, then that" rules.

If it's a Circle...
Find the radius
If it's a Square...
Find the width
If it's a Triangle...
Find the height

The .NET Superpower

F# does not work alone. It lives on a massive foundation called .NET (made by Microsoft). This is a huge library of tools.

Because F# lives here, it can talk to anything else built on .NET. It can easily share work with its older, more common brother, the C# language. You get the math powers of F# with the giant tool belt of .NET.

Where do people use F#?

Finance & Money

Banks and trading companies love F#. When you are moving millions of dollars around, you cannot afford a single mistake. Because F# uses "sealed boxes" (immutability), it is almost impossible to accidentally change a money value in the wrong place.

Data & Science

Scientists who look at weather, medicine, or space use massive lists of numbers. F# is built specifically to process giant chunks of data quickly and smoothly using its simple math-like functions.

The "Empty Box" Problem

In old programming languages, if you asked for a user's name, the computer might give you a box. Sometimes the box has a name inside. Sometimes the box is secretly empty (called "Null"). If your code tries to read an empty box, the whole program crashes.

Old Way (Dangerous)

You never know if the box is empty until it blows up your code.

F# Way (Safe)

F# forces you to check the box first. It makes you write rules for "If it has something" AND "If it is empty". No crashes allowed.

The Label Maker

Imagine building a rocket. One engineer uses "miles", and another uses "kilometers". If they add 10 miles to 10 kilometers, the rocket crashes. F# has a built-in label maker to prevent this.

10 + 10 = 20 (Wait, 20 what?)
10<miles> + 10<km> = ERROR

F# stops the program before it even runs if your labels don't match!

Tools Holding Tools

In F#, functions (the tools that do work) are just like regular items. You can put them in a list, save them for later, or hand them to another tool. Imagine a robot that can hold other smaller robots to do its job.

The Fact Sheet

Other languages use "Classes" to store data. Classes are like complicated machines with hidden buttons and secret levers. F# uses "Records" instead.

A Record is just a plain, simple fact sheet. It holds data and nothing else. No hidden tricks, just pure information.

ID Card
  • Name: "Alice"
  • Age: 30
  • Role: "Engineer"

The Strict Choice Menu

Sometimes a thing can only be exactly one of a few options. A payment is either "Cash", "Card", or "Check". F# lets you create a menu that strictly forces you to pick one of these choices. The computer will never let you pick a secret fourth option.

Choice A
Choice B
Choice C

The Magic Translator

Reading data from the internet or a database is usually a painful guessing game. F# has a superpower called Type Providers.

You just point F# at a spreadsheet or an internet file, and it magically reads it. It instantly creates all the correct labels for your code before you even hit the run button.

Database File
Translating
.CustomerID
.OrderTotal
.DateBought

The Scratchpad

Don't want to build a giant factory just to test a small math problem? Use the F# Scratchpad. You write one line, hit enter, and it gives you the answer instantly.

F# Interactive

> let score = 10 + 5;;

val score : int = 15

> printfn "Hello!";;

Hello!

val it : unit = ()

The Busy Chef

If a chef waits for the water to boil before chopping the carrots, dinner will take hours. F# makes it incredibly easy to say, "Start boiling the water, and while you wait, chop the carrots." This makes programs blindingly fast because they never sit around doing nothing.

Task 1: Downloading File
Task 2: Reading Database (Happening at the same time)
Task 3: Updating Screen
F#
C#

The Friendly Neighbor

Most programming languages live on their own private islands. F# shares a house with C# (one of the most popular languages in the world).

This means if someone already built a cool tool in C#, you can use it in your F# code instantly without changing anything. They share all their toys.

Built by Everyone

F# was started by a smart group of researchers, but today it is an Open Source language. This means thousands of programmers from all over the world help improve it every single day. It is free forever, and anyone can look inside to see exactly how it works.

What does the code look like?

Notice how clean it is. There are very few brackets or confusing symbols. It almost reads like English.

// 1. We make a list of names
let names = ["John"; ""; "Sarah"; "Mike"; ""]

// 2. We build an assembly line to clean it up
let cleanNames =
    names
    |> List.filter (fun name -> name <> "") // Remove blanks
    |> List.sort                            // Sort A to Z
    |> List.map (fun name -> name.ToUpper()) // Make ALL CAPS

// 3. Print the final result
printfn "%A" cleanNames

Ready to try it?

F# is free and works on Windows, Mac, and Linux. All you need to do is download the .NET tool from Microsoft, open your computer's terminal, and type this exact command:

dotnet new console -lang "F#"