4 ms·
Like the strict MLs (ocaml, Standard ML, F#, ...), while Lisp and Scheme can express the Haskell idioms it lacks the pervasive laziness that makes them (somewha
by discarded1023 4y ago
Like the strict MLs (ocaml, Standard ML, F#, ...), while Lisp and Scheme can express the Haskell idioms it lacks the pervasive laziness that makes them (somewhat) efficient. For instance one might write `zip [0..] xs` to number the list `xs` in a single pass. This lack of laziness (even on code that does notionally work without it) manifests in blowing stacks, in Scala at least. Also the lack of types (type classes) precludes at least some things such as the `deriving` mechanism.
For all that you're dead right about Python.
- still_grokking 4y ago> This lack of laziness (even on code that does notionally work without it) manifests in blowing stacks, in Scala at least. Please don't spread FUD. The std. lib functions in Scala are stack safe. (Simple, fast while loops under the hood when it comes to collections). To pick up the `zip` example: val r = (1 to 100_000_000).zip(1 to 100_000_000) won't blow up with a stack overflow. https://scastie.scala-lang.org/a4v5w1bKTeadQaPtK9CC5A https://scastie.scala-lang.org/a4v5w1bKTeadQaPtK9CC5A Also custom recursive functions can be made safe (for example by using trampolining). You blow stack in Scala only when you explicitly ask for it by writing unsafe code. (Which is BTW something that applies to more or less all languages as almost nobody ever repeated the mistake to build a lazy by default language). https://news.ycombinator.com/item?id=1924061 https://news.ycombinator.com/item?id=1924061
- rekado 4y agoWith SRFI 41 (streams) this can be expressed lazily in Scheme, but it is more verbose than Haskell: (import (srfi srfi-41)) (define xs '(a b c)) (stream-zip (stream-from 0) (list->stream xs)) This returns a lazy stream whose values can be evaluated later.
- _glass 4y agoSounds irrational, but it looks much more beautiful for me. My brain says, you should like Haskell, mirroring my experience that static languages with a strong type system are much better for big projects. But my heart knows, I would always prefer Lisp.
- substation13 4y agoThe strict MLs often have a `lazy` keyword, but it's definitely not as tidy as Haskell for this use-case. I'm sure a clever Clojure macro could be devised for the same!
- Reefersleep 4y agoFunctions like map and range return lazy lists in Clojure. This is how I'd implement zip: (def zip (partial map vector)) ;;Usage: (zip (range) [:a :b :c]) ;;=> ([0 :a] [1 :b] [2 :c])