HackerTube.dev

Optional - The Mother of All Bikesheds by Stuart Marks

Devoxx · 63.4K views · 2016-11-11 · 58:43

Open on YouTube ↗

If playback is restricted in your region, try opening the original video. Use Mark watched to add it to your marked videos.

Overview

Stuart Marks explains the intended purpose and proper use of Java 8's Optional class and why it caused so much controversy. He gives guidelines for using its small API correctly.

On Hacker News

Cited as the authoritative explanation, from the person who added it to OpenJDK, of Optional's narrow intended purpose.

Discussed on HN; no positive recommendation is recorded in this export · HN mentions 2019–2022

Topics

Search by tags

What people said

cratermoon · 2022-07 · Reference

See also the discussion for a similar feature in Java, from "Optional: The Mother of all Bikesheds", where the use and misuse of get() has a central role. video: [VIDEO] slides: [LINK]

Read the original HN comment ↗
emccue · 2022-06 · Reference

These are pretty weak arguments For the first point - val/var "More importantly, it doesn’t offer its immutable counterpart, val. You still need to add the final keyword, which nearly nobody uses." This super undermines the criticism. "It has the feature but people don't use it" isn't exactly much to write home about. Just use `final var` if you want. Make "final var over var" the same force culturally as JS's const over let" "However, the developers of Optional designed it for return values only. Nothing is available in the language syntax for methods parameters and return values. To cope with this, a bunch of libraries provides compile-time annotations:" This flow of causality here is slightly incoherent. The phrasing implies that if there was a version of optional that was designed for method parameters that would be better and there would be less of a need for compile-time annotations. Here it is sealed interface Option<T> { record Some<T>(T value) implements Option<T> {} record None<T>() implements Option<T> {} } This has "better" semantics than Optional for storing in fields and for using as method parameters. The existence of this does not obviate the desire to have null static analysis, so Optional really isn't that related. [VIDEO] It is true though that Kotlin has a more consistent story here, but there are active efforts to improve it for Java. Also, the discussion of extension functions points out that static methods cannot be chained like instance methods - corre

Read the original HN comment ↗
kjeetgill · 2019-06 · Reference

That's not really "why" it was introduced. Optional is used as a null wrapper in other JVM languages so that idiom bled over pretty naturally. Here's a talk "Optional - Mother of all Bikesheds" by Stuart Marks, the guy who added it to OpenJDK: [VIDEO] It was mostly just meant to cover the zero or one case on fluent-style interfaces like the Streams API, so check as getFirst() or getAny(). In hindsight, the name Optional was a poor choice if they didn't want the idiom coming over.

Read the original HN comment ↗

Sources

Video by Devoxx, played through YouTube.

Data and selection notes

HN summaries and labels may contain AI errors. HN dates refer to discussions, not video publication.

HN Library: HackerTube export (2026-10-31) and open-index/hacker-news. Upstream summaries and classifications may contain AI errors.

Views, duration and playback status refresh separately from the published catalog. When an update fails, existing data remains visible.

Selection checks
  • SaaS & AI candidates: Topic keywords do not match
  • Editor-approved picks: Editorial review is required

Rule matches identify candidates. They do not guarantee video quality or financial results.

About the library and its sources