Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29152 > unrolled thread

Functional programming - Professor Frisby's Mostly Adequate Guide

Started bybeegee <bgulian@gmail.com>
First post2016-01-06 07:35 -0800
Last post2016-01-18 12:10 -0800
Articles 4 — 4 participants

Back to article view | Back to comp.lang.javascript


Contents

  Functional programming - Professor Frisby's Mostly Adequate Guide beegee <bgulian@gmail.com> - 2016-01-06 07:35 -0800
    Re: Functional programming - Professor Frisby's Mostly Adequate Guide "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-01-07 08:44 -0800
      Re: Functional programming - Professor Frisby's Mostly Adequate Guide Stefan Weiss <krewecherl@gmail.com> - 2016-01-07 19:05 +0100
        Re: Functional programming - Professor Frisby's Mostly Adequate Guide Scott Sauyet <scott.sauyet@gmail.com> - 2016-01-18 12:10 -0800

#29152 — Functional programming - Professor Frisby's Mostly Adequate Guide

Frombeegee <bgulian@gmail.com>
Date2016-01-06 07:35 -0800
SubjectFunctional programming - Professor Frisby's Mostly Adequate Guide
Message-ID<28cf4382-ffa5-4935-8d6b-cbb07284cf13@googlegroups.com>
I haven't visited this group in years but I credit it with really teaching me JavaScript (the good and bad parts).  So it popped up today in my mail and I revisited.  What has excited me lately is a way of developing programs in JavaScript that 

a.) moves away from OOP
b.) moves away from JQuery
c.) moves towards planning architectures that are directional and have few side effects.

I am not going to advocate any frameworks.  I am going to recommend a book:  Professor Frisby's Mostly Adequate Guide to Functional Programming.

https://drboolean.gitbooks.io/mostly-adequate-guide/content/

The books examples are all JavaScript and subjects range from pure functions, currying, composing and functors among others. It's a short, dense book.  The practical benefit of the book I have found is in finding new ways to think rather than new ways to program. 

I'd be interested to know other's thoughts on functional programming now that there is at least one serious framework that encourages big app development in JavaScript using its principles.


Bob

[toc] | [next] | [standalone]


#29164

From"Michael Haufe (TNO)" <tno@thenewobjective.com>
Date2016-01-07 08:44 -0800
Message-ID<893daf06-da3e-4da8-b25e-7479d93cb95c@googlegroups.com>
In reply to#29152
On Wednesday, January 6, 2016 at 9:35:14 AM UTC-6, beegee wrote:
> I haven't visited this group in years but I credit it with really teaching me JavaScript (the good and bad parts).  So it popped up today in my mail and I revisited.  What has excited me lately is a way of developing programs in JavaScript that 
> 
> a.) moves away from OOP
> b.) moves away from JQuery
> c.) moves towards planning architectures that are directional and have few side effects.
> 
> I am not going to advocate any frameworks.  I am going to recommend a book:  Professor Frisby's Mostly Adequate Guide to Functional Programming.
> 
> https://drboolean.gitbooks.io/mostly-adequate-guide/content/
> 
> The books examples are all JavaScript and subjects range from pure functions, currying, composing and functors among others. It's a short, dense book.  The practical benefit of the book I have found is in finding new ways to think rather than new ways to program. 
> 
> I'd be interested to know other's thoughts on functional programming now that there is at least one serious framework that encourages big app development in JavaScript using its principles.

Scott Sauyet was walking down the same path. We discussed this some time ago:

https://groups.google.com/forum/#!topic/jsmentors/0Cj7AEH5Oic/discussion
https://groups.google.com/forum/#!topic/jsmentors/wH6X8SDPnbw/discussion
https://groups.google.com/forum/#!searchin/comp.lang.javascript/ANN$3A$20RAMDA/comp.lang.javascript/kajDUzrsHkQ/UVQkmnwpMCwJ
http://ramdajs.com/0.19.0/index.html

In regards to the referenced book, I'm not certain I'm a fan of its approach. It assumes far too much of the reader. 

For example: under "Chapter 2: First Class Functions" it talks about Node "modules", MVC, and AJAX. That is only the beginning. It seems quite scatter brained.

[toc] | [prev] | [next] | [standalone]


#29166

FromStefan Weiss <krewecherl@gmail.com>
Date2016-01-07 19:05 +0100
Message-ID<n6m9ce$5he$1@news.albasani.net>
In reply to#29164
On 01/07/2016 17:44, Michael Haufe (TNO) wrote:

> Scott Sauyet was walking down the same path.

And now he's part of the book :)

| Exercises
|
| A quick word before we start. We'll use a library called ramda which
| curries every function by default.

<https://drboolean.gitbooks.io/mostly-adequate-guide/content/ch4.html>

See https://www.npmjs.com/~crosseye

> In regards to the referenced book, I'm not certain I'm a fan of its
> approach. It assumes far too much of the reader.

Yeah, it could definitely use some editing. For example, a function
named "reduce" is used without introduction or explanation in an example
that looks rather hard to figure out for beginners:

  var head = function(x) { return x[0]; };
  var reverse = reduce(function(acc, x){ return [x].concat(acc); }, []);
  var last = compose(head, reverse);

  last(['jumpkick', 'roundhouse', 'uppercut']);
  //=> 'uppercut'

There is also pseudocode that looks like JavaScript, but isn't. At least
not with the results it claims:

  // associativity
  var associative = compose(f, compose(g, h)) ==
    compose(compose(f, g), h);
  // true

The two resulting functions will be equivalent, but they're not the same
function, so `==` will result in `false` instead.

Then again, this is the first book I've seen that tries to teach FP
using only JavaScript. It looks interesting enough that I'll probably
read the rest of it when I can find the time. I don't mind reading
between the lines a little or looking up features I'm not familiar with.

- stefan

[toc] | [prev] | [next] | [standalone]


#29327

FromScott Sauyet <scott.sauyet@gmail.com>
Date2016-01-18 12:10 -0800
Message-ID<e4eb03d3-b354-4690-bb29-0a07ff5b3447@googlegroups.com>
In reply to#29166
Stefan Weiss wrote:
> Michael Haufe (TNO) wrote:
> 
>> Scott Sauyet was walking down the same path.
> 
> And now he's part of the book :)
> 
> | Exercises
> |
> | A quick word before we start. We'll use a library called ramda which
> | curries every function by default.
> 
> <https://drboolean.gitbooks.io/mostly-adequate-guide/content/ch4.html>


Strands of influence are getting a bit tangled. Reg Braithwaite's 
_Javascript Allongé_ [1] was a major inspiration for the creation of 
Ramda's predecessor. Since then he's talked of using Ramda for future 
editions of the book. (He hasn't as of yet, which I think is a good 
idea.) Brian Lonsdorf, aka Dr. Boolean taught a course [2] which the 
other founder of Ramda and I attended. He was using our barely-known 
library for his course, which made us feel it was was ready for wider 
distribution. Now his book uses Ramda for many of its examples. Just 
today he became a core member of the Ramda team, and added a new side 
project to Ramda to expand our nascent Lenses implementation to deal 
with things like Prisms and Isos. 

I agree that this book still needs work. This has become a common 
publishing model: create the book in the open, accepting feedback all 
the while. I believe there is discussion of making a printed book from 
this material, but perhaps more errors will be caught up front than is 
typical with a few technical reviewers. 

On the other hand, my feeling is that this is an excellent book. I had 
been approached about writing a book about functional programming in 
Javascript, and I thought that, while _Allongé_ was excellent, and 
Michael Fogus' book [3] was reasonable, the only other book out on the 
topic (Dan Mantyla's _Functional Programming in Javascript_ [4]) was 
execrable, and so was really considering it. When the _Mostly Adequate 
Guide_ came out, I realized that I didn't need to. It was doing 
exactly what I wanted to do. So, yes, I'm mostly impressed. 


>> In regards to the referenced book, I'm not certain I'm a fan of its
>> approach. It assumes far too much of the reader.

I'm curious as to how you'd like to see it changed. I'm so buried in 
the same world he's promoting that I have a hard time seeing such 
instances. 



> Yeah, it could definitely use some editing. For example, a function
> named "reduce" is used without introduction or explanation in an example
> that looks rather hard to figure out for beginners:
> 
>   var head = function(x) { return x[0]; };
>   var reverse = reduce(function(acc, x){ return [x].concat(acc); }, []);
>   var last = compose(head, reverse);
> 
>   last(['jumpkick', 'roundhouse', 'uppercut']);
>   //=> 'uppercut'

Absolutely. I'm sure he would appreciate an issue or pull request at 
the Github repostitory for the book [5]. 



> There is also pseudocode that looks like JavaScript, but isn't. At least
> not with the results it claims:
> 
>   // associativity
>   var associative = compose(f, compose(g, h)) ==
>     compose(compose(f, g), h);
>   // true
> 
> The two resulting functions will be equivalent, but they're not the same
> function, so `==` will result in `false` instead.

Yes, he should have some better way to distinguish pseudo-code from 
actual code, and again an issue or pull request would probably be 
appreciated. 

But there is something fundamental here too. Functional programming 
will make little distinction between these two notions. Two functions 
which always have the same results for the same inputs, really ARE the 
same function from an FP point of view. So, while this is an incorrect 
use of syntax, the underlying point is still important. 


> Then again, this is the first book I've seen that tries to teach FP
> using only JavaScript. It looks interesting enough that I'll probably
> read the rest of it when I can find the time. I don't mind reading
> between the lines a little or looking up features I'm not familiar with.


What I appreciate about it is perhaps exactly what some don't like. It 
doesn't try to build everything in excruciating detail with 
mind-numbing definitions. It strikes a reasonable balance between 
_how_ and _why_. 


  -- Scott


  [1]: <https://leanpub.com/javascript-allonge>
  [2]: <https://frontendmasters.com/courses/functional-javascript/>
  [3]: <http://shop.oreilly.com/product/0636920028857.do>
  [4]: <https://www.packtpub.com/web-development/functional-programming-javascript>
  [5]: <https://github.com/MostlyAdequate/mostly-adequate-guide>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web