|Functional thinking: Functional features in Groovy, Part 1
Over time, languages and runtimes have handled more and more mundane details for us. Functional languages exemplify this trend, but modern dynamic languages have also incorporated many functional features to make developers' lives easier. This installment investigates some of the functional features already lurking in Groovy, showing how recursion hides state and how to build lazy lists.
|Articles||22 Nov 2011|
|Functional thinking: Why functional programming is on the rise
Java developers should learn functional paradigms now, even if they have no immediate plans to move to a functional language such as Scala or Clojure. Over time, all mainstream languages will become more functional; Neal Ford explores the reasons why in this installment.
|Articles||29 Jan 2013|
|Functional thinking: Transformations and optimizations
Various functional languages and frameworks feature many of the same abstractions and behaviors but name them differently. In this Functional thinking article, series author Neal Ford optimizes the solution from the preceding installment by improving the algorithm and adding caching, illustrating how each language or framework accommodates the required changes.
|Articles||16 Oct 2012|
|Functional thinking: Rethinking dispatch
Next-generation languages for the Java platform have more-flexible method-dispatch mechanisms than the Java language. In this Functional thinking installment, Neal Ford explores dispatch mechanisms in functional languages like Scala and Clojure, showing new ways to think about executing code.
|Articles||21 Aug 2012|
|Functional thinking: Either trees and pattern matching
Scala's ability to perform dispatch based on pattern matching is a feature much envied by Java developers. This installment shows how a combination of standard data structures and generics provides a pattern-matching-like syntax in pure Java.
|Articles||10 Jul 2012|
|Functional thinking: Functional error handling with Either and Option
Java developers are accustomed to handling errors by throwing and catching exceptions, which doesn't match the functional paradigm. This Functional thinking installment investigates ways to indicate Java errors functionally while still preserving type safety, shows how to wrap checked exceptions with functional returns, and introduces a handy abstraction named Either.
|Articles||12 Jun 2012|
|Functional thinking: Functional design patterns, Part 3
The Gang of Four's Interpreter design pattern encourages extending a language by building a new language from it. Most functional languages let you extend the language in a variety of ways, such as operator overloading and pattern matching. Although Java doesn't permit any of these techniques, next-generation JVM languages do, with varying implementation details. In this article, Neal Ford investigates how Groovy, Scala, and Clojure realize the intent of the Interpreter design pattern by allowing functional extensions in ways that Java does not.
|Articles||15 May 2012|
|Functional thinking: Functional design patterns, Part 2
Design patterns represent just one way to solve problems, but if you primarily use object-oriented languages, you may come to think in design patterns. In this installment of Functional thinking, Neal Ford illustrates solutions to a common problem -- incompatible interfaces -- using traditional design patterns, metaprogramming, and functional composition. Each approach has pros and cons, but thinking about the design of the solutions helps you see problems in new ways.
|Articles||03 Apr 2012|
|Functional thinking: Coupling and composition, Part 2
Programmers accustomed to using the building blocks of object orientation (inheritance, polymorphism, and so on) can become blind both to its shortcomings and to alternatives. Functional programming uses different building blocks to achieve reuse, based on more general-purpose concepts like list transformations and portable code. This installment of Functional thinking compares coupling via inheritance with composition as reuse mechanisms, and pinpoints one of the key differences between imperative and functional programming.
|Articles||04 Oct 2011|
|Functional thinking: Functional design patterns, Part 1
Contrary to popular belief, design patterns exist in functional programming -- but they sometimes differ from their object-oriented counterparts in appearance and behavior. In this installment of Functional thinking, Neal Ford looks at ways in which patterns manifest in the functional paradigm, illustrating how the solutions differ.
|Articles||06 Mar 2012|
|Functional thinking: Functional features in Groovy, Part 3
Modern dynamic languages have incorporated many functional features to take mundane tasks off developers' hands. This article explores the benefits of caching at the function level with Groovy, contrasting it with an imperative approach. It illustrates two types of caching -- intramethod and external -- and discusses the advantages and disadvantages of the imperative and functional versions.
|Articles||31 Jan 2012|
|Functional thinking: Immutability
Immutability is one of the building blocks of functional programming. This Functional thinking installment discusses the many aspects of immutability in the Java language and shows how to create immutable Java classes in both traditional and newer styles. It also shows two ways to create immutable classes in Groovy, removing much of the pain of the Java implementation. Finally, you'll learn when this abstraction is appropriate.
|Articles||26 Jul 2011|
|Functional thinking: Thinking functionally, Part 3
Functional thinking series author Neal Ford continues his guided tour of functional programming constructs and paradigms. You'll look at number-classification code in Scala and take a glance at unit testing in the functional world. Then you'll learn about partial application and currying -- two functional approaches that facilitate code reuse -- and see how recursion fits into the functional way of thinking.
|Articles||28 Jun 2011|
|Functional thinking: Thinking functionally, Part 1
Functional programming has generated a recent surge of interest with claims of fewer bugs and greater productivity. But many developers have tried and failed to understand what makes functional languages compelling for some types of jobs. Learning the syntax of a new language is easy, but learning to think in a different way is hard. In the first installment of his Functional thinking column series, Neal Ford introduces some functional programming concepts and discusses how to use them in both Java and Groovy.
|Articles||03 May 2011|
|Functional thinking: Laziness, Part 2
Implementing lazy evaluation is easy in a language that supports closures. This Functional thinking installment shows how to derive a lazy list using Groovy's closures as building blocks. Then it explores some of the performance and conceptual benefits of lazy evaluation, including the ability to initialize fields lazily in some languages.
|Articles||19 Dec 2012|
|Functional thinking: Laziness, Part 1
A common feature of many functional programming languages is lazy evaluation, whereby expressions are evaluated only when necessary rather than upon declaration. Java doesn't support this style of laziness, but several frameworks and related languages do. This article shows how to build laziness into your Java applications, using pure Java and functional frameworks.
|Articles||20 Nov 2012|
|Functional thinking: Functional features in Groovy, Part 2
With Groovy, metaprogramming and functional programming form a potent combination. See how metaprogramming enables you to add methods to the Integer data type that take advantage of Groovy's built-in functional capabilities. And learn how to use metaprogramming to incorporate the Functional Java framework's rich set of functional features seamlessly into Groovy.
|Articles||20 Dec 2011|
|Functional thinking: Coupling and composition, Part 1
Working every day in a particular abstraction (such as object orientation) makes it hard to see when that abstraction is leading you to a solution that isn't the best alternative. This article is the first of two that explores some implications of object-oriented thinking for code reuse, comparing them to more-functional alternatives such as composition.
|Articles||30 Aug 2011|
|Functional thinking: Tons of transformations
Functional programming constructs are appearing in all major languages now, but they can be hard to spot because they're identified by a wide variety of common names. This installment of Functional thinking shows the same example written using seven different functional frameworks and languages, investigating similarities and differences.
|Articles||25 Sep 2012|
|Functional thinking: Thinking functionally, Part 2
Functional languages and frameworks let the runtime control mundane coding details such as iteration, concurrency, and state. But that doesn't mean you can't take back control when you need to. One important aspect of thinking functionally is knowing how much control you want to give up, and when.
|Articles||31 May 2011|