Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
1  
Try writing something nontrivial in Haskell. If you can figure your way out, you're there. –  Federico Culloca Jul 24 '11 at 17:33
    
Excellent question! voting up. –  Chiron Jul 24 '11 at 19:57
    
Federico, must it be Haskell, what's an example of nontrival? –  Scott Weinstein Jul 24 '11 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? –  Thomas Owens Jul 25 '11 at 0:46
    
@Federico: your comment would make a very good answer if more detail was added. –  Larry Coleman Jul 25 '11 at 9:47
show 1 more comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
add comment

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!?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.