# One Thing I Learned From F# (Nulls Are Bad)

DevFeed: [One Thing I Learned From F# (Nulls Are Bad)](<https://devfeed.tech/articles/one-thing-i-learned-from-f-nulls-are-bad-33390.md>)

Original publisher: [Read original article](<https://timkellogg.me/blog/2012/02/29/one-thing-i-learned-from-f-nulls-are>)

Published: 2012-02-29T00:00:00Z

Content type: opinion

Language: en

Sources: [Tim Kellogg](<https://devfeed.tech/sources/tim-kellogg.md>)

Topics: [F#](<https://devfeed.tech/topics/fsharp.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [C#](<https://devfeed.tech/topics/csharp.md>), [exceptions](<https://devfeed.tech/topics/exceptions.md>), [pattern matching](<https://devfeed.tech/topics/pattern-matching.md>), [Haskell](<https://devfeed.tech/topics/haskell.md>), [OCaml](<https://devfeed.tech/topics/ocaml.md>)

Tags: [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [exceptions](<https://devfeed.tech/tags/exceptions.md>), [f-sharp](<https://devfeed.tech/tags/f-sharp.md>), [functional](<https://devfeed.tech/tags/functional.md>), [pattern-matching](<https://devfeed.tech/tags/pattern-matching.md>), [programming](<https://devfeed.tech/tags/programming.md>)

## AI overview

The author reflects on learning F# while contributing to VsVim, highlighting pattern matching, discriminated unions, and F#'s option types. The article argues that using None and Some instead of null can make invalid states explicit and reduce null-related bugs.

## Source excerpt

Recently I started contributing to VsVim, a Visual Studio plugin that emulates Vim. When he was starting the project, Jared Parsons decided to write the bulk of it in F#. He did this mostly as a chance to learn a new language but also because it's a solid first class alternative to C#. For instance, F#'s features like pattern matching and discriminated unions are a natural fit for state machines like Vim.This is my first experience with a truly functional language. For those who aren't familiar with F#, it's essentially OCaml.NET (the F# book uses OCaml for it's markup syntax), but also draws roots from Haskell. It's a big mind shift from imperative and pure object oriented languages, but one I'd definitely recommend to any developer who wants to be better.Since I've been working on VsVim, I've been using F# in my spare time but C# in my regular day job. The longer I use F# the more I want C# to do what F# does. The biggest example is how F# handles nulls.In C# (and Ruby, Python, and any imperative language) most values can be null, and null is a natural state for a variable to be in. In fact (partly due to SQL), null is used whenever a value is empty or doesn't exist yet. In C# and Java, null is the default value for any member reference, you don't even need to explicitly initialize it. As a result, you often end up with a lot of null pointer exceptions due to sloppy programming. After all, it's kind of hard to remember to check for null every time you use a variable.In F#, nothing is null (that's not entirely true, but in it's natural state it's true enough). Typically you'll use options instead of null. For instance, if you have a function that fails to find or calculate something you might return null in imperative languages (and the actual value if successful). However, in F# you use an option type and return None on failure and Some value on success.Here, every time you call find(kittens) you get back an option type. This type isn't a string, so you can't just