Live data from Hacker News

Functional data structures in JavaScript with Mori

sitr.us

11–20 of 21 posts

Re: Functional data structures in JavaScript with Mori

#11
post #4

I like that the article calls then "functional data structures". Every time I call them by their real name (persistent data structures), _at least_ one person will get confused and think I'm talking about serialization to disk.

I consistently see the same problem. That is exactly why I use the word "functional".

what's wrong with "immutable" ?

Re: Functional data structures in JavaScript with Mori

#12

Earlier quoted context omitted.

I consistently see the same problem. That is exactly why I use the word "functional".

what's wrong with "immutable" ?

Immutable does not imply persistence/structural sharing, a key aspect of these data structures.

Re: Functional data structures in JavaScript with Mori

#13
post #2

This is great. I never understood why underscore/lo-dash doesn't have a `conj` or a `concat`. JavaScript's `push` mutates data which you'd think you'd want to avoid if you're using a functional library like underscore/lo-dash. `concat` makes sense to leave out when you consider that arrays already have a `concat` function. But if that's the reasoning, why did underscore/lo-dash include `size` and `max` and all those…

One thing I never understood about - awful generalization - "real" functional languages is their fascination with terrible naming. What I mean is things like `car`, `cdr`, `conj` - words that are impossible to understand if you don't already know what they mean.

Re: Functional data structures in JavaScript with Mori

#14
post #13
post #2

This is great. I never understood why underscore/lo-dash doesn't have a `conj` or a `concat`. JavaScript's `push` mutates data which you'd think you'd want to avoid if you're using a functional library like underscore/lo-dash. `concat` makes sense to leave out when you consider that arrays already have a `concat` function. But if that's the reasoning, why did underscore/lo-dash include `size` and `max` and all those…

One thing I never understood about - awful generalization - "real" functional languages is their fascination with terrible naming. What I mean is things like `car`, `cdr`, `conj` - words that are impossible to understand if you don't already know what they mean.

It's the same with C-like syntaxes, or OOP, or *nix stream commands, or the English language, or the phonetic alphabet. It's all a thick pile of history that has been agreed upon piece by piece.

Re: Functional data structures in JavaScript with Mori

#15
post #13
post #2

This is great. I never understood why underscore/lo-dash doesn't have a `conj` or a `concat`. JavaScript's `push` mutates data which you'd think you'd want to avoid if you're using a functional library like underscore/lo-dash. `concat` makes sense to leave out when you consider that arrays already have a `concat` function. But if that's the reasoning, why did underscore/lo-dash include `size` and `max` and all those…

One thing I never understood about - awful generalization - "real" functional languages is their fascination with terrible naming. What I mean is things like `car`, `cdr`, `conj` - words that are impossible to understand if you don't already know what they mean.

I guess there was a time where one had to care about the length of the source code.

that's why some came up with these abbreviations.

Re: Functional data structures in JavaScript with Mori

#16
post #13
post #2

This is great. I never understood why underscore/lo-dash doesn't have a `conj` or a `concat`. JavaScript's `push` mutates data which you'd think you'd want to avoid if you're using a functional library like underscore/lo-dash. `concat` makes sense to leave out when you consider that arrays already have a `concat` function. But if that's the reasoning, why did underscore/lo-dash include `size` and `max` and all those…

One thing I never understood about - awful generalization - "real" functional languages is their fascination with terrible naming. What I mean is things like `car`, `cdr`, `conj` - words that are impossible to understand if you don't already know what they mean.

That's only lisp and particularly faithful derivatives (unfortunately including clojure). Haskell uses more natural names - head, tail, last.

Re: Functional data structures in JavaScript with Mori

#18
post #13
post #2

This is great. I never understood why underscore/lo-dash doesn't have a `conj` or a `concat`. JavaScript's `push` mutates data which you'd think you'd want to avoid if you're using a functional library like underscore/lo-dash. `concat` makes sense to leave out when you consider that arrays already have a `concat` function. But if that's the reasoning, why did underscore/lo-dash include `size` and `max` and all those…

One thing I never understood about - awful generalization - "real" functional languages is their fascination with terrible naming. What I mean is things like `car`, `cdr`, `conj` - words that are impossible to understand if you don't already know what they mean.

That might just be an age thing: older languages seem particularly bad at this. Lisp has its cars and its cdrs, but C is even worse with ioctl, atoi, fputc, strxfrm and so on.

Assembly is worse yet, and mixing C with assembly is basically a path to Lovecraftian madness: I really hate the way intrinsics look. Here's a real snippet from StackOverflow:

    a_i = __mm_load_ps(&A[n*i+k]);
    b_i = __mm_load_ps(&B[n*k+j]);
    c_i = __mm_load_ps(&C[n*i+j]);

    __m128d tmp1 = __mm_mul_ps(a_i,b_i);
    __m128d tmp2 = __mm_hadd_ps(tmp1,tmp1);
    __m128d tmp3 = __mm_add_ps(tmp2,tmp3);
    __mm_store_ps(&C[n*i+j], tmp3)
You can also go too far in the other direction: see Java and especially Objective C.

Re: Functional data structures in JavaScript with Mori

#19
post #16
post #13

Earlier quoted context omitted.

One thing I never understood about - awful generalization - "real" functional languages is their fascination with terrible naming. What I mean is things like `car`, `cdr`, `conj` - words that are impossible to understand if you don't already know what they mean.

That's only lisp and particularly faithful derivatives (unfortunately including clojure). Haskell uses more natural names - head, tail, last.

Even most Lisps have first/rest as synonyms of car/cdr (dating back to some very old Lisps, and mandated by the Common Lisp standard). They just don't seem to have culturally caught on as idiomatic.
Post reply on HN