Showing posts with label Functional Programming. Show all posts
Showing posts with label Functional Programming. Show all posts

Sunday, 21 July 2013

Skimmer's Guide - Functional Programming for Java Developers

“Multithread programming requiring synchronised access to shared mutable state is the assembly language of concurrency.”

WHAT IS THE ABOUT? 

Dean Wapler brings to us "Functional Programming for Java Developers". Although two years old now, the book touches on concepts that are still highly relevant both today and upon the introduction of Lambdas to Java.

We begin with why functional programming is so important and look at actual techniques we can utilise. Immediately after we are encouraged to apply our learning in handy and thought provoking exercises. This format is followed in each of the following chapters and really helps to reinforce learning!

How we model our data and operate with it is the next focus, introducing the "functional power tools" that are filter, map and fold. Along with the following section on functional concurrency, these two form an incredible bounty of invaluable information.

Recapping on everything we have learnt, we look at how to improve our object orientated programming and where to go from here.

WHAT STOOD OUT? 

Declarative vs Imperative Programming (p. 7) 
Highlighting the key difference between functional and object-orientated programming using a well thought out factorial example.

The Actor Model (p. 41) 
Fantastic coverage of this concurrency tool which is short and sharp, very useful for beginners.


IIF YOU READ NOTHING ELSE... 

Why Functional Programming? (p. 1 - 5) 
Concise chapter on why Functional Programming actually matters.

Combinator Functions: The Collections Power Tools (p. 29) 
A brilliant section on tools that are crucial in any functional language: filter, map and fold. Covers both what these tools do and learning more through actually implementing them for a custom List data structure.

CONCLUSION 

Whilst this book is a great introduction to the basics, it lacks any great depth. Published in 2011, the available functional programming tools of the time (such as GS Collections and Google Guava) are surprisingly absent.

In my view, what is lacking in depth is made up for by having such a broad coverage in only 72 pages. This book forms a good bridge for those starting with functional programming to take toward exploring specific topics/tools in greater depth.

Saturday, 6 April 2013

Functional Programming for the Object Orientated Programmer


Having finished our first book (The Well-Grounded Java Developer), the LJC Book Club has now started our new book: Functional Programming for the Object Orientated Programmer.

To keep things consistent, Ged and I will be keeping all the Skimmer's Guides on the LJC Blog from now on. I've drafted the first one and hopefully it will be available soon.

So far I have found the book a little slow, I'm dying to learn it all already! The functional style of coding combined with the old school command line style coding is bringing back strong memories of when I first started coding with Haskell xD

During the course of this book, we will be doing a load of exercises and I will be sharing all my code on GitHub (https://github.com/arkangelofkaos/fp-oo). Hopefully over the course of reading this book the quality of the code I produce will increase as well ;) However I am in dire need of a fully functioning IDE! My goal for next week is to try to get my old ultimate version of IntelliJ 11 fully set up and ready, I need my autocomplete and formatting back :P

In any case, so far the book is great aside from the slow start. I got so sucked into it that I've accidentally read ahead already. My immediate goals are to learn how to do recursion and pattern matching properly in Clojure, can't wait!

Sunday, 10 March 2013

Skimmer's Guide - "Chapter 10: Clojure: Safer Programming" of "Well-Grounded Java Developer"

Foreword

Recently I set-up the LJC Book Club (blog here) with Ged Byrne and the first book we chose was "The Well-Grounded Java Developer" by Benjamin Evan and Martijn Verburg.

As a part of the reading schedule, Ged and I are hoping to produce a weekly "Skimmer's Guide". 

This is my first such attempt and hopefully there will be many more to come!




“..Lisp is an acronym for Lots of Irritating Silly Parentheses...”

What did we read about?

Week 6 has brought us to the Clojure chapter which focuses on introducing the functional language to Java developers. The topics range from your simple 'Hello World' program all the way to Clojure style concurrency being used to steal all the money from Ben's account!


What stood out?

Arithmetic, equality and other operators (p. 287)
Simple explanation of the Clojure mathematical operators and introduces variadic functions. In-short using a variable number of function parameters - e.g. (+ 1 2 3) // returns 6

Schwartzian transform (p. 290)
Great example which allows you to learn how to read Clojure "inside-out" and really get to grips with core concepts of functional programming.

Multi-thread ATM (starting p. 308)
Fantastic example of whole concise Clojure can be over Java, as well as explaining how to do concurrency in Clojure.


If you read nothing else this week...

Getting started with the REPL (p. 281)
Get started hacking on the "Clojure console" and learn about mutable/immuntable state in Clojure.
Interoperating between Clojure and Java (p. 299)
Learn how to call Java from the "Clojure console" and get under the covers of Clojure on the JVM.