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.

  • 5
    JavaScript is an object oriented language, so go on and use your OOP skills using Node.js
    – Jonas
    Commented Nov 26, 2011 at 15:10
  • 5
    try functions. Those will solve almost every problem.
    – tp1
    Commented Nov 26, 2011 at 17:00
  • 4
    Here's a great resource on keeping your node source code neat and tidy and therefore manageable: nodeguide.com/style.html Commented Nov 26, 2011 at 17:20
  • 2
    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. Commented Nov 26, 2011 at 20:01

3 Answers 3


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.


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.


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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