> You have to be pretty hard-core nix-pilled to understand what that one is doing just reading it straight-on [..]
There is little practical difference between that example and:
Object.keys(licenses).filter(name => licenses[name]?.spdxId?.startsWith("GPL"))
The main difference is the syntax regarding attribute set operator (`attset ? key`), the rest is easily understandable by anyone that knows at least one or two programming languages that have closures (including Javascript).
> On the other hand, the TypeScript code the author provides is reasonably straight-forward [..]
Readability-wise, the Nix code from the article wins - the TS version has annotations that make it unnecessarily verbose, like `nix.lambda`, `nix.app`, `nix.sel`; to name a few.
From the article:
> Nix is lazy, so the emitted code wraps an expression in nix.thunk(() => ...) wherever Nix would allocate a thunk. (throw-up emoji)
I concur with the feeling.
There is little practical difference between that example and:
The main difference is the syntax regarding attribute set operator (`attset ? key`), the rest is easily understandable by anyone that knows at least one or two programming languages that have closures (including Javascript).> On the other hand, the TypeScript code the author provides is reasonably straight-forward [..]
Readability-wise, the Nix code from the article wins - the TS version has annotations that make it unnecessarily verbose, like `nix.lambda`, `nix.app`, `nix.sel`; to name a few.
From the article:
> Nix is lazy, so the emitted code wraps an expression in nix.thunk(() => ...) wherever Nix would allocate a thunk. (throw-up emoji)
I concur with the feeling.