Functional-Programming

4 posts in this section

Java 8 Overview: The Release That Changed Everything

Before We Start — Feel the Difference You’re about to learn Java 8. Before diving into history and theory, let’s just feel what changed. Here’s the same task written in Java 7 and Java 8: Task: Find all names that start with “A”, uppercase them, sort them, and collect into a list. // Java 7 — 10 lines, two passes, one temporary variable, zero joy List<String> result = new ArrayList<>(); for (String name : names) { if (name.

Continue reading »

Lambda Expressions (JEP 126): Syntax, Closures, and Target Typing

The Problem Lambdas Solve Every Java 7 developer has written the same five lines of boilerplate to sort a list or run a background task. Lambda expressions eliminate that ceremony entirely — and once you understand target typing, closures, and composition, you will find yourself reaching for them in every layer of a codebase: validation pipelines, event systems, retry logic, and beyond. Before Java 8, passing behaviour as a value required an anonymous inner class:

Continue reading »

Method References: Four Kinds and When to Use Each

What Are Method References? Method references are a signal to the reader: “this lambda does exactly one thing — it calls this existing method.” When the entire body of a lambda is a single method call, replacing it with a method reference removes noise without losing information. Knowing which of the four kinds to apply in each context is what separates fluent Java 8 code from code that merely uses the syntax.

Continue reading »

Streams API: Lazy Pipelines and the Functional Data Model

The Problem Streams Solve Java loops are not wrong — they are often the right tool. But when a computation is a multi-step pipeline of filter → transform → aggregate, a loop hides the structure of the computation in a tangle of temporary variables and mutated collections. The Streams API makes the structure explicit, lets the JVM optimise it, and composes naturally with lambdas and method references. Consider filtering a list of orders to find the names of active premium customers who spent over $500, sorted alphabetically:

Continue reading »