4 ms·
The performance difference between (peek n) and (last n) for vector typed n strikes me as something that really ought to be handled by the implementation, not t
by Blackthorn 5y ago
The performance difference between (peek n) and (last n) for vector typed n strikes me as something that really ought to be handled by the implementation, not the programmer since the outputs are equivalent.
I really like clojure, like, a lot, but I might have taken an opposite than intended result from this blog post. It made me feel like the language has a number of performance footguns that don't necessarily need to exist.
- dgreensp 5y agoI agree. Also, avoiding Clojure’s collections entirely is a great way to get better performance, but it’s hard to argue that is idiomatic. This applies doubly to ClojureScript.
- geokon 5y agoIt seems like an intentional design choice. didibus sorta explained it to me: https://news.ycombinator.com/item?id=28406315 https://news.ycombinator.com/item?id=28406315 It does feel like a tradeoff that was a bit too harsh. As the post shows, you can work around it... but at the end of the day my code ends up with a ton of (nth 0) and very few (first) calls. It feels a bit ugly.. and it doesn't feel "idiomatic" as in how you learn Clojure from a textbook. Some more discussion of it here: https://clojureverse.org/t/what-do-beginners-struggle-with/5383/142 https://clojureverse.org/t/what-do-beginners-struggle-with/5... I find the threaded stuff much easier to follow. Maybe it's mostly visual and familiarity And as an interesting extra: https://clojureverse.org/t/x-x-auto-transducifying-thread-macros-now-with-parallelizing-and/8122/50 https://clojureverse.org/t/x-x-auto-transducifying-thread-ma...