3 ms·
One place you can see this in action is that [ ] are lists and [| |] are arrays. JS favors arrays, OCaml lists, so you either write dsls with [| |] (ugly), or
by aaron-lebo 9y ago
One place you can see this in action is that [ ] are lists and [| |] are arrays.
JS favors arrays, OCaml lists, so you either write dsls with [| |] (ugly), or you import a module and convert from lists to arrays and your bundle size goes up 80 KB (don't recall if minified or not).
I was surprised to see Reason continue with this syntax. The idiomatic approach for either side is suboptimal unless I'm missing something.
- bsansouci 9y agoWhat DSLs are you referring to here? One reason to favor lists over arrays has been that they are immutable. Most of my personal JS array usages have been as dynamically sized arrays, because I’ll use .push all over the place. That usecase is the primary reason to use lists instead: it’s much faster to prepend and destructure on lists.
- aaron-lebo 9y agoSomething like Elm's Html module: div [ id "test" ] [ text "stuff" ] vs div [| id "test" |] [| text "stuff" |] If the JS library expects an array (not uncommon), that gets ugly quickly.
- yawaramin 9y agoHi, I'm pretty sure a tree-shaking bundler like Rollup can wipe out most of that bundle size by using only the list functions you need. Then again, if you need to use arrays, use arrays, [|1, 2, 3|] is not actually that bad–you get used to it pretty quickly.