Hacker News new | ask | show | jobs
by klntsky 1287 days ago
> just to save a few characters and make everything more magic than it is

No, this is not the true motivation. Human attention spans on symbols, the more succinct the code is, the more meaning it can encompass in the same number of characters. Writing abstracted enough code often requires inventing new languages to hide the complexity behind abstractions.

Software development in Haskell is particularly focused on DSLs, lens language being one of them.

^.. is a relatively simple operator though, it just abstracts away traversals.

3 comments

> Writing abstracted enough code often requires inventing new languages to hide the complexity behind abstractions.

Human attention may pick out symbols more easily, but human comprehension benefits from things that actually have meaning. Otherwise you end up with a soup of ASCII symbols that very few can parse since every library in Haskell seems hellbent on inventing new and useless ascii combinations for function names and operators.

Even the article goes (emphasis mine):

--- start quote ---

The basic operators here are ^., .~, and %~. If you’re not a fan of funny-looking operators, Control.Lens provides more helpfully-named functions called view, set, and over (a.k.a. mapping)

--- end quote ---

And then proceeds to use the ASCII soup instead of the more helpful function names.

It doesn't help in the least that there are multiple get operations ^. ^? ^.. Or this idiocy: "Here, a single < before the operator signifies that it returns the updated value, while a double << signifies that it returns the old value. This gets a little weird with the monoidal operator; <<>~ returns the updated value, not the old one". Bonus points. What does this do: <<<>~

Because "why have useful names when you can pretend your fake intellectual superiority by using confusing ascii symbol combinations"

> Software development in Haskell is particularly focused on DSLs, lens language being one of them.

The domain specific language for lenses is view, set, traverse, update etc. Not whatever this is.

> The domain specific language for lenses is view, set, traverse, update etc. Not whatever this is.

The word you are looking for is "script"; though that is rather ambiguous in the context of programming. I suppose "writing system" is good enough.

And now we have entirely expressed the problem: someone tried to make their code more readable by adding a donation-specific writing system! Just break out your handy Rosetta stone, and you'll be fine, right?

Yes and you tend to use ^. in Haskell where you'd use . in python, say. And . is also an operator. Similarly, you'd likely be using = in python where you'd use .~ in python. As for ^.., I'm not sure there's an idiomatic python equivalent - certainly nothing as simple as adding an extra . to the operator.
They are in fact well structured and not random at all. Take a look at this:

https://github.com/ekmett/lens/wiki/Operators

> Human attention spans on symbols, the more succinct the code is, the more meaning it can encompass in the same number of characters.

I could make it even more succinct by LZW compressing it. That would not improve comprehension, though...