Super Computer.

Functional Programming and Ruby

<<<<<<< HEAD

> Functional Ruby


Functional Ruby


Functional Programming (“FP”) wasn’t on my radar until I started hacking at The Flatiron School two weeks ago (and by hacking I mean as in a hacking cough :).

Since my ego is super attracted to highbrow challenges and feeling intellectually superior, when I heard that FP was baller status because it’s both exceedingly powerful and exceedingly difficult to master, my interest was piqued. When I saw this speakerdeck presentation from Pat Shaughnessy ((“Get yo ass down to O’Shag Hennessy!” “Who?” “O’Shag Hennessy!!” “Principal O’Shaughnessy???”)) analyzing Ruby’s relationship to FP I was like, “challah!”

And here it is:

<<<<<<< HEAD

Say, what is functional programming anyway?

  • Higher order functions, bro.

  • LAZY evaluation (definition: Lazy evaluation delays the evaluation of an expression until its value is needed (non-strict evaluation) and which also avoids repeated evaluations. )

  • Memoization (definition: Memoization is an optimization technique used primarily to speed up computer programs by having function calls avoid repeating the calculation of results for previously processed inputs.)

An email from Matz! =>

  • Check out this screenshot of an old-school email from Matz.
  • Why aren’t we calling Ruby “MatzLisp”?!

Screenshot of email from Matz explaining how he invented Ruby

Ruby, and in particular Ruby 2.0, has a lot of functional features. However…

  • Ruby and Haskell can resemble each other, but only on the surface.

Screenshot comparing Haskell and Ruby functions

  • Under the hood, Ruby’s support of functional features is limited.

Slide comparing Ruby and Haskell code

  • Close, but no cigar!

Next slide showing the Ruby code resulting in NoMethodError

In Conclusion

  • Learning a truly functional programming language won’t be trivial.

======= You probably read the deck, but if you didn’t, here are a few takeaways from it.

Amaaazing :-D !

But I’m still confused :–/ ?

One of the coolest factoids is a screenshot of an old-school email from Matz to another developer explaining that Ruby might best be thought of MatzLisp.