Hacker News new | ask | show | jobs
by ngruhn 358 days ago
I don't know if you just counted the JavaScript operators but if you count all the instances where some random symbol is used then it's really a ton. There is

    yield*
    function*
    a?.b?.c
    function f(x = 3) {
    x ??= 3
    ...
TypeScript adds even more:

    a!.b
    Type<T>
    type A = B extends C ? D : E
    ...
    
and there are countless ECMA proposals and TypeScript feature request that want to pile on even more. People seem to have zero qualms about cryptic syntax. I think the difference is that this syntax is mostly very ad-hoc. If you know the language already, this just adds a liiiittle bit extra to solve some very specific problem. On the other hand, Haskell operators like <$>, <*>, >>= are extremely general. After years I still learn about new and unexpected ways that you can use them (e.g. what the hell is `fix <$> id`). But paradoxically, because they can be used in so many seemingly unrelated contexts, you have no idea what to use them for at all initially.