Question

I'm a .Net and Angular developer who's been working with OO languages throughout my education and work history. Lately I've been thinking about spending some time with one of the functional programming languages, namely Haskell, to try and get a feel for what functional programming is all about.

My main reservations are on whether Haskell is a good language to start with and whether it is actually used anywhere in the industry. I guess the industry use question is more broad to target all functional languages. I have never personally met anyone who worked with functional programming language in their day today job. I'm basically trying to justify learning a functional programming language instead of another OO library or framework, relevant to my field.

Was it helpful?

Solution

Since you write that you're a .NET developer and you don't even mention F#, odds are that you're a C# developer. In that case, I'd strongly suggest that you learn F# first. It's another .NET language, and it's a great stepping stone for anyone coming from C#.

In itself, it's a great FP language, but it also offers full interoperability with the existing .NET ecosystem. Besides its FP features, it also offers a full set of OOP features. This enables you to learn gradually.

  1. Learn the F# syntax, but keep on writing object-oriented code. You can do this in a week or two.
  2. Start learning functional concepts. For instance, once you understand maps and folds, replace your for loops with those.
  3. Learn more abstract functional ways of thinking. Repeat from here.

You can take each of these steps in small increments, all the time staying productive.

Once you have a good grasp of the functional parts of F#, Haskell can be a good next step. I've met many people who tried to learn Haskell 'from scratch'. Most people report that they give up because the learning curve is too steep.

I came to Haskell via some years of F# and found it a natural next step.

There's lots of free learning resources for F#, the most famous of which is probably F# for fun and profit. If you come from C#, another great introduction to F# is Real-World Functional Programming. It juxtaposes examples in C# and F# so that you can compare.

As far as I can tell, there aren't a lot of jobs where you get to program exclusively in F# or Haskell, but learning either will likely still make you a better programmer, so I'd highly recommend it.

I've written F# professionally, but never Haskell. I've written a lot of Haskell semi-professionally; I'm self-employed and invest significant time in doing so, but no-one has ever paid me to program in it. Still, I consider it highly worthwhile.

OTHER TIPS

I have never personally met anyone who working with functional programming language in their day today job.

I am paid to write OCaml, AMA!

My main reservations are on whether Haskell is a good language to start with and whether it is actually used anywhere in the industry.

Haskell isn't a great language for your first language, but it is a very solid language for your fourth language or so. It has a fair number of guides (such as the very nice learnyouahaskell), a stable compiler, and is very representative of a functional programming language.

That said, it is used by almost nobody (relatively speaking) in the industry.

I'm basically trying to justify learning a functional programming language instead of another OO library or framework, relevant to my field.

Functional programming techniques are commonly used these days in most languages. Learning a language more devoted to functional programming will help you better understand those techniques - how to use them, as well as where their strengths and weaknesses lie compared to object-oriented or procedural programming. It's another tool for your box, and will help you program better even if you never ship a line of code in the language itself.

I could also suggest you to look at Scala, which, on its front page, literally says:

"Scala combines object-oriented and functional programming in one concise, high-level language."

Arguably, if you come from an OO background, like most of us, I'd dare say, then using Scala makes sense, if anything for the sake of experimentation. Also, the main reason is that in all their docs, references, even papers by Odersky, they do put emphasis on using functional constructs and on thinking functionally, which might be all you really need so you can do a smooth transition to start writing .NET in a more functional style.

Moving to Java, looking at how the Streams API is implemented as well how annotations like @FunctionalInterface enable you to write functional code, and, if interested reading through the Java Enhancement Proposals regarding functional features can give you a great feel how things work under the hood which can definitely help you in shifting your mind.

  • If your main interest is in broadening your programming mind and skill set, more academic languages like Haskell, ML or Clean are probably for you.
  • Haskell is actually used in industry, but not on a very broad range (e.g. Facebook has a group doing Haskell, Standard Chartered maintains an own Haskell dialect, etc.).
  • If you are more interested in practical languages that you can use in day jobs, object-functional languages Scala, OCaml and F# are probably at par language-wise, so you rather pick one depending on the platform, F# for .NET, Scala for the JVM, and OCaml for Unix/compiled. Even C# allows a fair amount of functional programming.
  • Scala jobs are fairly wide-spread, job market growing from what I see, OCaml is very limited (e.g. Jane Street Capital), F# is used far less than it deserves.
  • If the JVM is a serious option there is also Clojure as a modern, object-functional Lisp, which gained a lot of traction in the job market, part. in the US (I held a full-time Clojure job for one year).
  • If you are more inclined towards UI development you may abandon Angular and try Elm, or even PureScript which is Haskell for JavaScript runtimes (browsers/Node.js).
  • Having mentioned UIs, don't underestimate the potential to introduce functional languages through specific applications that use them as their "DSL", e.g. build tool Fake (using F#), or load testing tool Gatling (using Scala).
Licensed under: CC-BY-SA with attribution
scroll top