News for hackers. Stuff that matters.
Re:A philosophical difference between Haskell and Lisp (2015) by layoutIfNeeded on Sunday August 02, 2020 @04:50PM (#24031625)
For one Lisp is not lazy like Haskell.
Re:A philosophical difference between Haskell and Lisp (2015) by howling on Sunday August 02, 2020 @04:58PM (#24031691)
The article elaborates on this point a bit:

> Like pipes in UNIX, the functions are clever enough to be performant when composed together–we don’t traverse the whole list and generate a new list each time, each item is generated on demand. In fact, due to stream fusion, the code will be compiled into one fast loop.

I imagine it is hard to do the same optimization in a non-lazy language.

Re:A philosophical difference between Haskell and Lisp (2015) by klipt on Sunday August 02, 2020 @05:28PM (#24031921)
It's interesting that he says you also need purity to do the optimization, but Unix pipes are not necessarily pure.
Re:A philosophical difference between Haskell and Lisp (2015) by garethjrowlands on Sunday August 02, 2020 @05:36PM (#24031990)
Unix pipes don't do stream fusion, which is the optimisation to which he was referring.
Re:A philosophical difference between Haskell and Lisp (2015) by klipt on Sunday August 02, 2020 @05:57PM (#24032125)
So if I put (x1, x2...) through pipes f and g, instead of calculating all the f(x)s first followed by all the g(f(x))s, it calculates g(f(x1)), then g(f(x2)), etc.

How is that order of operations different to stream fusion? Why does stream fusion require more purity than Unix pipes?

Re:A philosophical difference between Haskell and Lisp (2015) by newen on Sunday August 02, 2020 @08:28PM (#24032979)
Let's say there's a global mutable variable M (doesn't have to global, can be x1.M = M, x2.M = M, for example, but easier to think with global) which is used by and modified when f(x) or g(y) runs. Then, the order of operations would matter and so you get different results with and without stream fusion.
Re:A philosophical difference between Haskell and Lisp (2015) by klipt on Sunday August 02, 2020 @11:34PM (#24033977)
Right, but couldn't the same thing happen with Unix pipes if the components write to a global file?

You can do the same optimization Unix pipes does without language enforced purity, just with a caveat that functions sharing state might behave weirdly when fused.

Re:A philosophical difference between Haskell and Lisp (2015) by newen on Sunday August 02, 2020 @11:53PM (#24034068)
You could... I guess language designers generally avoid those types of optimizations since it can bring about unexpected results. As in, if syntactically the code is using one order of operations and semantically the code is using another order of operations, even if it's documented, lots of programmers would stumble into difficult to find bugs and be surprised by this behavior. Or worse, just get wrong results and never even find out it's wrong.
Re:A philosophical difference between Haskell and Lisp (2015) by ssivark on Sunday August 02, 2020 @04:57PM (#24031683)
I don’t understand why the above got down-voted... Without fusing (lazy) loops, having a bunch of independent sequential transformations (each with its own loop) can make the same computation significantly slower!
Re:A philosophical difference between Haskell and Lisp (2015) by vc8f6vVV on Sunday August 02, 2020 @05:13PM (#24031797)
Ruby or Scala don't have lazy evaluation by default, yet there are views (Scala) or lazy (Ruby), so no, you don't necessary need compiler help.
Re:A philosophical difference between Haskell and Lisp (2015) by layoutIfNeeded on Sunday August 02, 2020 @05:30PM (#24031945)
Yeah, you can emulate laziness at the library level with iterators, coroutines and whatnot, but it always comes with a certain API friction (some readers might be familiar with the “colored functions” analogy [1]) compared to Haskell’s approach that takes laziness to the extreme.

[1] http://journal.stuffwithstuff.com/2015/02/01/what-color-is-y...

Re:A philosophical difference between Haskell and Lisp (2015) by anchpop on Sunday August 02, 2020 @06:47PM (#24032460)
I was really hoping that article was going to start talking about effect systems. They're so cool! They make it possible to have many different function colors without it being a huge chore. They can be thought of as a more-ergonomic generalization of monads.
Re:A philosophical difference between Haskell and Lisp (2015) by atroche on Sunday August 02, 2020 @10:23PM (#24033619)
I'm sure you (OP) are aware, but just in case others aren't: Clojure stands out as a Lisp that embraces laziness.
Re:A philosophical difference between Haskell and Lisp (2015) by kjeetgill on Sunday August 02, 2020 @04:58PM (#24031687)
Not super familiar either language, how does lazy evaluation promote the use of smaller functions?
Re:A philosophical difference between Haskell and Lisp (2015) by jokethrowaway on Sunday August 02, 2020 @05:02PM (#24031709)
In non-lazy languages you would need to implement laziness to manage composing functions and have good performance. An example being take 5 . filter ... If evaluation wasn't lazy you would run take 5, return the result to filter and so on.
Re:A philosophical difference between Haskell and Lisp (2015) by vc8f6vVV on Sunday August 02, 2020 @05:16PM (#24031841)
In the languages I use (Scala, Ruby) it's already done, Rust is using iterators which are lazy too. None of those languages are "lazy" in Haskell sense.
Re:A philosophical difference between Haskell and Lisp (2015) by layoutIfNeeded on Sunday August 02, 2020 @05:33PM (#24031964)