7

I've been wondering how to determine if I know functional programming. By know I mean in a Journeyman sense, not a master, but competent enough to do the work.

I like languages w/ query/data shaping constructs built in, but is knowing the ins and outs of maps, filters, and aggregates in the form of Linq, Sql, and Reactive Extensions sufficient to claim that one knows functional programming? Or are additional specific concepts and skills required?

Edit: I've been working in OO and languages that identify primarily as OO langs for 15 years. As I'm not in an env that is self-identified as functional, there's little to measure against.

Is avoiding immutable state and knowing how to use fold all there is?

6
  • 1
    Try writing something nontrivial in Haskell. If you can figure your way out, you're there. Commented Jul 24, 2011 at 17:33
  • Excellent question! voting up. Commented Jul 24, 2011 at 19:57
  • Federico, must it be Haskell, what's an example of nontrival? Commented Jul 24, 2011 at 20:30
  • Is evaluating how well someone knows functional programming any different than evaluating how well someone knows object-oriented programming, procedural programming, or aspect-oriented programming? Commented Jul 25, 2011 at 0:46
  • @Federico: your comment would make a very good answer if more detail was added. Commented Jul 25, 2011 at 9:47

2 Answers 2

3

Dakotah's answer is important and I would like to add a couple of things:

  • Understanding Monads.
  • Understanding Tail call optimization (TCO) and why it does matter and how the language in question implements it.
  • Understanding persistent data structures and how to implement a one by hand.

I'm pretty sure there are a lot of things, please feel free to complete the list.

3

The first step to be able to recognize the difference between imperative and functional styles in code. For example, Odersky in Programming in Scala highlights that one telltale sign is

that if code contains any vars [variables in Scala that can be modified] is is probably imperative style. If the code contains no vars at all--i.e., it contains only vals--it is probably in a functional style. One way to move towards a functional style, therefore, i s to try to program without vars.

For example, consider this while loop:

var i = 0 while (i < args.length) { println(args(i)) i+=1 } 

The var is the sign it is imperative. This is Scala would become

def printargs(args: Array[String]): Unit = { args.foreach(println) } 

But this code isn't purely functional yet because it has side effects.

From a functional point of view this should be:

def formatArgs(args: Array[String]) = args.mkString("\n") 

So ... to determine if you know functional programming, are you writing code without the equivalent of vars and no local side effects!?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.