4 ms·
Optics, as the OP calls it, is definitely an underestimated problem of modern computing. So much work goes in most languages into processing nested data struct
by Daishiman 6y ago
Optics, as the OP calls it, is definitely an underestimated problem of modern computing.
So much work goes in most languages into processing nested data structures, especially in this day and age of heterogeneous APIs, and a lot of it is actually not that difficult to generalize conceptually into most languages. A few weeks ago I wrote a PoC in Python and it was remarkably easy to make a lens for traversing data structures.
Declarative optics and updates would make writing business logic a lot easier on so many domains.
- warkdarrior 6y agoI wonder how these "optics" compare to .NET's Language Integrated Queries (LINQ) (see https://en.wikipedia.org/wiki/Language_Integrated_Query https://en.wikipedia.org/wiki/Language_Integrated_Query )
- Daishiman 6y agoLINQ is definitely a precursor, and has tons of fantastic ideas. It's unfortunate that Microsoft didn't continue to invest heavily into this as it's rarely mentioned nowadays.
- platz 6y agoI'm not sure I'd call LINQ a precursor when LINQ itself was based on haskell's monadic list comprehensions. monadic list comprehensions aren't quite the same thing as optics, however.
- Daishiman 6y agoList comprehensions aren't quite the same thing; they are declarative but they describe an iterative method of creating lists through maps and filters, whereas optics are semantically oriented around traversals and projections.
- platz 6y agoisn't that what I said?
- 082349872349872 6y agoThe nice thing about comprehensions is that, depending upon how one looks at them, they can be declaratively defined yet iteratively implemented.
- warkdarrior 6y agoWikipedia claims there are LINQ implementations for Javascript/Typescript and for PHP (in addition to C#, of course).
- emteycz 6y agoThese are really just simplified versions, though.
- scns 6y agoYou are onto something, since LINQ was developed by Erik Meijer, one of the authors of the paper linked in the childcomment of the siblingcomment.
- mongol 6y agoIs using the word optics for other things than projecting light with glass a new thing? I do not recall seeing this word used for other purposes much say 10-15 years ago. Not a native English speaker but have read English for at least 30 years.
- 082349872349872 6y agoThe earliest Newton reference of which I am aware is Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire (1991), where iirc both the bananas and the lenses are (visually!) optical. https://research.utwente.nl/en/publications/functional-programming-with-bananas-lenses-envelopes-and-barbed-w https://research.utwente.nl/en/publications/functional-progr... In particular, the metaphor isn't used in Algorithmics: Towards Programming as a Mathematical Activity (1986). https://ir.cwi.nl/pub/2686 https://ir.cwi.nl/pub/2686
- rainsil 6y agoI believe the concepts in the first paper are unrelated to those of modern lenses (i.e. functional references). See: https://stackoverflow.com/questions/17198072/how-is-anamorphism-related-to-lens https://stackoverflow.com/questions/17198072/how-is-anamorph...