Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just started with functional programming (with JavaScript and Node.js) and from the look of things it looks as if the code I am writing would grow to be one hell of a code base to manage, when compared to programming languages that have a sort of object oriented paradigm.

With OOP I am familiar with practices that would ensure your code is easily managed and extensible. But am nore sure of similar convention with functional programming.

share|improve this question
JavaScript is an object oriented language, so go on and use your OOP skills using Node.js – Jonas Nov 26 '11 at 15:10
try functions. Those will solve almost every problem. – tp1 Nov 26 '11 at 17:00
Here's a great resource on keeping your node source code neat and tidy and therefore manageable: – danielrbradley Nov 26 '11 at 17:20
As far as I know, the only functional programming feature JavaScript has is lambdas (more accurately, nameless functions) and function passing. If you want to learn functional programming, you should probably look into something like Haskell or F#/OCaml or Scala or Lisp. – Rei Miyasaka Nov 26 '11 at 20:01
up vote 6 down vote accepted

In practice, a large functional codebase will still need to be divvied up in some sort of structural system. If you are comfortable in OOP, classes remain the natural structuring element. You strive for "functional objects": conceptually related functions are placed together in a class. Of course, you avoid non-conversational state and reliance on instance variables.

Going beyond structure, there are certain techniques, such as partial function application, that are preferred in the functional world for extension, maintainability, and generalization. Learning to recognize these opportunities can be difficult when working in a hybrid functional/object mode, though. Personally, I think it is a good idea to work in a hybrid mode but to study and play in a more pure environment, such as that provided by Haskell.

share|improve this answer

Functional programming languages enjoy a lot of powerful concepts to build high quality code, for example: Partial applied functions, functions compositions (this one is really powerful and my favorite), macros, higher order functions. And not to forget immutable data structures.

share|improve this answer

Rather than abandoning OOP for FP, try augmenting it with some FP patterns. Any time you need to process a collection is a good candidate and points to a common set of FP methods like map, fold and reduce. Take a look at underscore.js and backbone, an MVC framework that makes extensive use of the former.

share|improve this answer

Your Answer


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.