5 ms·
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
by tieTYT 13y ago
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 other things that already exist?
- jkrems 13y agoOne 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.
- zachrose 13y agoIt'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.
- camus2 13y agoI 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.
- lmm 13y agoThat's only lisp and particularly faithful derivatives (unfortunately including clojure). Haskell uses more natural names - head, tail, last.
- mjn 13y agoEven 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.
- tikhonj 13y agoThat 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.