Is functional programming so related to mathematics because much of the functional programming is depicted with mathematical notions? Is it a MUST to have a strong base of maths to learn & understand functional programming for a programmer with a imperative background?
All programming is related to mathematics. Indeed many universities still place their computer science programs under the purview of the mathematics department.
As for learning functional programming, you do not need to have a strong base in mathematics to learn it. I've learnt three different functional languages now to reasonable proficiency (Haskell, Erlang, Clojure) and my own maths skills are extremely weak. Haskell's community can, indeed, get a little bit annoying in its maths-focused way of speaking about things, but Erlang and Clojure both are very pragmatic functional programming languages that are not that hard to pick up because the tutorial information is written, seemingly, for programmers, not hard-core maths geeks. That being said, despite my handicap in maths I did pick up Haskell, so it's not impossible.
The real difficulty I've found in picking up declarative programming languages in general (of which functional is a subset) is giving up that urge to be in control; to tell the computer what to do. It takes some getting used to.
Yes. Essentially, a functional program is a bunch of statements like that:
// 1_ and 2_ are "dummy arguments" f(1_) := sin(1_) g(1_,2_) := 1_ + 2_ etc...
x = f()
y = g(x)
z = h(x, h2(y))
You are writing what the program is supposed to do in a form of equations defining new values (note: not variables) as functions of previously defined values. You also define the functions as relations. It is really quite similar to the way mathematical theorems are written.
IMO Mathematica, as an example of a language in which you can use functional programming, does not require a strong background in math. In fact, I don't think I encountered anything like functional programming during my basic math education. I started Mathematica programming doing C-style, and discovered functional programming only years later. I don't think the basic functional programming constructs like
NestList, etc require any math background at all.
not really. functional programming is just a methodology, but it had its base in lambda calculus and stuff like that.
Closures are a (small) attempt to introduce functional programming concepts into procedural languages. instead of
for(int i =0 ; i < num; i++) doStuff(arr[i]);, you can instead assume that the elements of the array inherently can have "stuff done to them" so
arr.each do |el| doStuff(el) end
The short answer is: Yes, because everything with a certain degree of formalization (such as programming languages) is strongly related to mathematics, for varying degrees of mathematics.
But, using a programming language does not strictly require familiarity with mathematics, for example theroetical foundations of languages. You don't have to know what a context free language is and what laws and property such a language has in order to use one. Likewise, you don't have to be a Germanist or Romanist to speak german or french.
The "mathematical" notation is not a common property of functional languages. Scala and all Lisp based languages have very different syntaxes compared to Haskell.