DEV Community

Anton
Anton

Posted on

The road to functional programming as a newbie.

So I started reading "Functional Programming. Practice and Theory" by Bruce J. MacLennan. I went to the library with a friend of mine to learn German. I live in Yoshkar-Ola. A city in the middle of Russia. I was'n expecting to find a book like that at a library in my city. The book was an accident to be honest. I wasn't looking for it.

I'd like to quote some stuff from the book. Also the book is confusing because the author uses unfamiliar jargon to me like gotos and structural programming and applicative programming. Well applicative programming was explained as another name for functional programming. But what is gotos?

Here is the quote that I like:

Why is the notation of arithmetic expressions of such benefit to the mathematician? The reason seems to be quite subtle and fundamental. It embodies the principles of structuring, which underlie all our attempts to master a complex problem or control a complex situation by analyzing it into simpler subproblems, with clean and narrow interfaces between them.

C.A.R. Hoarse (1973, 15)


Update 17th December:

I went on and read about the six reasons author gives to use the functional programming and that is:

1) Functional programming dispenses with the ubiquitous assignment operation. As structured programming is often called "goto-less programming", so functional programming can be called "assignment-less programming". Assignments are still there but they are hidden from the programmer.

I have no idea what is assignment operation and goto-less programming. So let's head over the google and find out.

dive_deeper_when_I_have_the_time_to_kill_or_the_context_requires_me_to_know_that_stuff

PC mag encyclopedia says this:

goto-less programming

Writing a program without using goto instructions, an important rule in structured programming. A goto instruction points to a different part of the program without a guarantee of returning. Instead of using goto's, structures called "subroutines" or "functions" are used, which automatically return to the next instruction after the calling instruction when completed.

That is not enough for me to understand.

Here's the definition by thefreedictionary:

structured programming (redirected from Goto-less programming)

the design and coding of computer programs using a top-down methodology.

And of course wikipedia https://en.wikipedia.org/wiki/Goto

Oh, and there is a whole article on structured programming https://en.wikipedia.org/wiki/Structured_programming

While I was reading the goto article on wiki I had the urge to go the bathroom. While I was there I had a great idea (do you have great ideas there?) to make a notice that when I go unnecessarily deep like I'm doing with goto I will make a hashtag like #dive_deeper_when_I_have_the_time_to_kill_or_the_context_requires_me_to_know_that_stuff

In my situation it would be better to dive deeper in understanding what it means to program without assignments:

I've tried to read those two article, I'm still not getting it. I hope I'll get it later.

2) Functional programming encourages thinking in higher levels of abstraction by providing mechanisms (higher-order functions) for modifying the behaviors of existing programs and combining existing programs.

3) Functional programming provides a paradigm for programming massively parallel computers. The absence of assignments, independence of evaluation order, and ability to operate on entire data structures provide paradigms for programming these machines.

4) FP has its application in AI.

5) FP is valuable in executable specifications and prototype implementations. The simple underlying semantics and rigorous mathematical foundations of FP, along with its high expressive ability, make it an ideal vehicle for specifying the intended behavior of programs.

6) I don't understand the sixth reason at all. So maybe I will understand it later.


I will update the post while reading the book. I hope to understand the underlying principles because author said even though you may not use functional programming but knowing such principles will improve your style.

Top comments (0)