Site icon [<Developer>]

Why I like F# over C# – Less Noise


Oh, jingle bells, jingle bells
Jingle all the way
Oh, what fun it is to ride
Oh shit a blog deadline ♫

Introduction

I did my first ever session a few months ago, I did a session called “Why you should learn F#”. I spent 30 minutes sweating and stuttering about pipelines and discriminated unions, people reactions were “Ok nice, but why is it better than C#, why do I need this, show some more code comparisons”. At first, this is what I NOT wanted to do, go the F# is better then C# blablabla way. I don’t hate C#. But I would like F# to be the language I use for projects at work, so if this is the way to convince people/companies to use F#, so be it.

I’m not a playa I just F# a lot – Big Pun

Succint Code

So in this blog I’ll start with a simple example why I like F# over C#. It’s how small and clean the code looks, because there’s less ceremony. This is because of:

To show the difference I simplified the code from a tool I wrote in F# and translated that to C#. I kept the C# in the same file, that removed some more code you normally had to add if you follow the C# code guidelines. The screenshot says it all I think, you can see how many, unneccesary, noise is added to the C# code.

Code from FolderTimeLine.fs to make sense of the code in screenshot 😉

That’s all for now, this is just one argument of the F# over C# story. Sorry I had to squeeze this one out a little, last year when I saw the fsadvent and I was like “Next year, I’m going to write an awesome blog about how I learned F# by blogging this year”. Well I learned some F# and did some blogging, but waaaayyy less then I hoped. So next year, I will again try to make the world safe for fsharpocracy.

Exit mobile version