Hacker News new | ask | show | jobs
by gherkinnn 2402 days ago
Interesting!

Closure don’t seem to be widely discussed outside of certain areas, so be it.

SOLID is rather surprising though. It seems to be quoted and (supposedly) adhered to religiously. Though I suspect it’s akin to people preaching TDD in public while we all know that’s rarely the case.

1 comments

I'd say closures are one of the fundamental concepts of computer science. They're described in the introduction to chapter 2 of SICP, "Building Abstractions with Data".

SOLID sounds nice but I don't think I've ever seen anyone adhere to it religiously. Easy exercise: take any Java program, and imagine the spec changed the width of integers it needs to support, from 32-bit to some other size. How many files would you need to touch to make this change? Clearly, no class in the program has the Single Responsibility of this. The first letter of SOLID is already violated.

From that chapter: "In general, a method for combining data values satisfies the closure property if the result of combination can itself be combined using the same method."

It sounds like they're just describing recursive data structures? When most people talk about closures, aren't they referring to this (from Wikipedia)?

"In programming languages, a closure, also lexical closure or function closure, is a technique for implementing lexically scoped name binding in a language with first-class functions. Operationally, a closure is a record storing a function[a] together with an environment."

EDIT: My SICP quote was actually from somebody's notes, not the book itself. But the point remains.