HackerTube
HomeLongsLikedHistoryWatch laterCategoriesPlaylistsSettings

Optional - The Mother of All Bikesheds by Stuart Marks

DevoxxCited 3× on HN, 2019-2022
YouTube
63K views · 10 years ago · talk · evergreen

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.

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

Python, Ruby & scripting languagesSoftware architecture & design#java#optional#apidesign#nullhandling#devoxx

3 comments from Hacker News

@cratermoon2022 · in “Rust should not have provided `unwrap`”

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: ▶ this video slides: link

CitesView on HN
@emccue2022 · in “What I miss in Java, the perspective of a Kotlin developer”

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. ▶ this 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

CitesView on HN
@kjeetgill2019 · in “Takes: Java web framework without static methods or annotations”

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: ▶ this 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.

CitesView on HN
Constraints Liberate, Liberties Constrain — Runar Bjarnason51:40

Constraints Liberate, Liberties Constrain — Runar Bjarnason

Scala World
44K views • 10 years ago
Simplicity Ain't Easy - Stuart Halloway50:01

Simplicity Ain't Easy - Stuart Halloway

ClojureTV
24K views • 13 years ago
Stuart Sierra - Components Just Enough Structure41:19

Stuart Sierra - Components Just Enough Structure

ClojureTV
36K views • 12 years ago
Brian Goetz - Stewardship: the Sobering Parts1:03:31

Brian Goetz - Stewardship: the Sobering Parts

ClojureTV
39K views • 11 years ago
Edward Kmett - Type Classes vs. the World1:42:53

Edward Kmett - Type Classes vs. the World

Boston Haskell
36K views • 11 years ago
How To Design A Good API and Why it Matters1:00:19

How To Design A Good API and Why it Matters

Google TechTalks
453K views • 19 years ago
Intentional Programming demo (Part 1) - Editor9:59

Intentional Programming demo (Part 1) - Editor

dftube
14K views • 20 years ago
Coroutines and Loom behind the scenes by Roman Elizarov45:22

Coroutines and Loom behind the scenes by Roman Elizarov

Kotlin by JetBrains
41K views • 3 years ago
RailsConf 2015 - Nothing is Something35:53

RailsConf 2015 - Nothing is Something

Confreaks
84K views • 11 years ago
Sebastian Markbage: Minimal API Surface Area | JSConf EU 201424:28

Sebastian Markbage: Minimal API Surface Area | JSConf EU 2014

JSConf
71K views • 12 years ago
The Clean Architecture in Python49:54

The Clean Architecture in Python

Next Day Video
114K views • 12 years ago
Object-Oriented Programming is Bad44:35

Object-Oriented Programming is Bad

Brian Will
2.6M views • 10 years ago
Ruby Manor 3 - Programming with Nothing by Tom Stuart40:50

Ruby Manor 3 - Programming with Nothing by Tom Stuart

Confreaks
13K views • 14 years ago
Data-Oriented Demo: SOA, composition1:32:47

Data-Oriented Demo: SOA, composition

Jonathan Blow
201K views • 11 years ago
MountainWest RubyConf 2014 - But Really, You Should Learn Smalltalk28:06

MountainWest RubyConf 2014 - But Really, You Should Learn Smalltalk

Confreaks
27K views • 12 years ago
Alan Kay - Programming and Scaling56:39

Alan Kay - Programming and Scaling

Colin McDonnell
36K views • 11 years ago
"Programming Should Eat Itself" by Nada Amin47:41

"Programming Should Eat Itself" by Nada Amin

Strange Loop Conference
43K views • 12 years ago
Intentional Programming demo (Part 2) - Compiler10:01

Intentional Programming demo (Part 2) - Compiler

dftube
4K views • 20 years ago
Nordic.js 2014 • Douglas Crockford - The Better Parts33:52

Nordic.js 2014 • Douglas Crockford - The Better Parts

Nordic.js
73K views • 12 years ago
The Forgotten Art of Structured Programming - Kevlin Henney [C++ on Sea 2019]1:29:27

The Forgotten Art of Structured Programming - Kevlin Henney [C++ on Sea 2019]

cpponsea
245K views • 7 years ago