loading...

re: Is JavaScript truly a functional language? VIEW POST

FULL DISCUSSION
 

What is functional programming?

In Wikipedia, "In computer science, functional programming is a programming paradigm where programs are constructed by applying and composing functions."

With Js you have the option to construct your program by composing and applying functions but,
I don't really understand what truly functional language means. In my point of view, the functional programming is more on the programmer and less on the language.

 

Functional programming is sometimes treated as synonymous with purely functional programming, a subset of functional programming which treats all functions as deterministic mathematical functions, or pure functions.

When a pure function is called with some given arguments, it will always return the same result, and cannot be affected by any mutable state or other side effects. This is in contrast with impure procedures, common in imperative programming, which can have side effects (such as modifying the program's state or taking input from a user).

 

It's a combination of both.

Functional programming is a programming paradigm: it's a specific way of writing code, where you follow certain rules.

You can write functional programs in many object-oriented languages, such as JavaScript and Python, but these programs aren't truly functional since their constructs don't fully mesh with the framework and rules of functional programming.

That's where languages like Haskell and Clojure come in — these are purely functional programming languages that do not have the traditional OOP constructs, and force the functional programming paradigm's rules, such as never mutating state directly and always keeping functions pure.

But yes, functional programming is essentially the composition of pure functions. Rather than telling the computer how to do something, you define what the program is to do.

Code of Conduct Report abuse