This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-01
Channels
- # beginners (133)
- # boot (59)
- # cider (5)
- # cljs-dev (30)
- # cljsrn (23)
- # clojure (212)
- # clojure-austin (3)
- # clojure-brasil (1)
- # clojure-chicago (5)
- # clojure-italy (10)
- # clojure-russia (5)
- # clojure-serbia (1)
- # clojure-spec (34)
- # clojure-turkiye (2)
- # clojure-uk (132)
- # clojurescript (163)
- # clojutre (1)
- # cursive (5)
- # datomic (58)
- # emacs (42)
- # events (1)
- # graphql (26)
- # hoplon (16)
- # jobs (1)
- # lumo (27)
- # numerical-computing (3)
- # off-topic (127)
- # om (9)
- # onyx (24)
- # re-frame (20)
- # reagent (20)
- # ring-swagger (14)
- # sql (19)
- # unrepl (28)
- # untangled (3)
- # vim (8)
- # yada (17)
Ah, the lament of the functional ascetic lol https://www.theregister.co.uk/2017/05/31/at_the_feet_of_the_great_monad/
I can't even figure out what's going on here
yeah, it isn’t reserved only for FPers, unfortunately. You see the same attitude when people look down on php devs. Or ruby ppl looking down on everyone else, etc.
It's one thing to think you're superior at the top, it's another to be critical of languages that are objectively at the bottom 😛
I love Verity Stob… so funny!
never read this author before. clicking on the name to get a list of other articles. This one didn't seem to hit the mark with me but I'd like to read some others
If you didn’t find this hilarious, you might not be moved by other Stob pieces either… It’s a somewhat peculiarly British style of humor :uk:
It's amusing, but the effectiveness of the caricature is a bit dampened by how token some of the descriptive parts are, instead of feeling naturally woven in. ¯\(ツ)/¯
Aphyr's - while a bit more whimsical and filled with technical witchery - felt much sharper for that kind of satire.
To me, Aphyr’s is too bogged down with technical cleverness to be effective. Humor is cultural/subjective tho’…
I thought it quite funny. I liked the twist at the end. Went from futuristic to Me in Exeter a couple years ago 😛
@mobileink Lazy eval is like a synthetic thread, on top of real threads, that only loops on one function, which is the realization of next element. So perhaps it's about distinguishing between regular eval on (inc 1)
, which will eval eagerly, and the looping eval that runs on a LazySeq.
hmm. i'm not convinced we need to introduce threads. any computation has an evaluation strategy.
Well, lazy evaluation in CLJS is a looping construct that repeatedly calls one function on a data structure.
In Haskell, evaluation is demand-based. When an answer is demanded, a function gets called. In Clojure when you call a function it happens immediately, regardless of demand.
to me it's more about how far rather than when. with strict eval you get reduction to normal form. with lazy you might get bo reduction or partial deduction, to be completed later.
i think the JIT vs just in time evaluation is confusing and that's why ghadi said more terminology is not required. at this point its not clear if you mean the fact that jvm code is interpreted or the delayed evaluation of the thunks in a seq
But in clojure, only specific functions will actually do the necessary iteration on the structure in order to realize each next.
If you go read the LazySeq code, you'll see how it realizes the sequence. It's pretty simple.
But in a "lazy language," like haskell, internal forms aren't realized unless they are needed. Whereas in clojure, they are realized immediately.
(def a (+ 1 2))
my understanding is that in Haskell, a
wouldn't not become 3
until a
was called in some other eager context.
right. with strict eval, the arg will be fully reduced to 3. you can't do that with (repeat 5) etc.
i don't see the logic of saying that things like (repeat 5) are strictly evaluated in clojure.
No, it's already evaluated. The fact that it is a sequence that hasn't been fully realized yet is besides the point
but you cannot reduce (repeat 5) to a normal form. all you can do is translate it into a fn the will return the right vals when called later. to me that is what counts as lazy eval.
It might be better to think of lazy structures as just functions that close over state and call themselves.
no, i'm thinking of evaluation strategies. after all, haskell is exactly like clojure in this respect, afaics.
If you look up Clojure and Haskell in Wikipedia, they use different evaluation strategies. I'm trying to illustrate why
here's the java implementation:
final synchronized public ISeq seq(){
sval();
if(sv != null)
{
Object ls = sv;
sv = null;
while(ls instanceof LazySeq)
{
ls = ((LazySeq)ls).sval();
}
s = RT.seq(ls);
}
return s;
}
final synchronized Object sval(){
if(fn != null)
{
sv = fn.invoke();
fn = null;
}
if(sv != null)
return sv;
return s;
}
that's not close to what any common usage of a "lazy language" adjective could mean then
the original question is whether clojure has lazy eval, as a feature of the language.
LazySeqs and a collection of associated functions have lazy eval. And that part of clojure is "lazy"
@ghadi: aha. is that why you say clojure eval is always strict? that would make sense, if you mean that the lazy stuff is a kind of add on. but i'm inclined to treat it as in practuce a part of the language defn.
still, that would be a good topic for some doc. my guess is pretty much everybody thinks lazy seqs involve lazy evaluation.
From the perspective of both a Clojurian and a Haskeller, I think you all have some good points. The confusion seems to stem from the fact that the distinction between compiler-level and userland is a bit blurred in Clojure
i think the idea that the core language uses strict eval, while the "std lib" implements restricted forms of lazy eval, is pretty interesting. and show off the power and flexibity of clojure.
@ghadi thanks so much for engaging. i think i have an idea of what you mean now, and my grasp of the language has expanded.
worth looking into the sources. lazy-seq
is defined as
(defmacro lazy-seq
[& body]
(list 'new 'clojure.lang.LazySeq (list* '^{:once true} fn* [] body)))
just going to your power of Clojure comment. The power of clojure is in its interop with java in this case 🙂It's harder to explain stuff when someone has an advanced knowledge of things sometimes. @mobileink
When you call a function, it gives you flesh. In Haskell when you call a function it gives you a thought about flesh
omg! the metaphysical cafe! it's in an early mamet play. the menu includes things like "idea of lamb, soupcon of asparagus, notion of beef stroganoff". 😂
there's also call-by-need, which gives you either a thought of flesh or thaws out a steak from the freezer if available 😄
Do you think that if I write a spec that requires that the value is a vector and it is sorted, and I use clojure.test.check.generators/generate with that spec, it will be able to generate sorted vectors in a Bogosort fashion?
100% serious about this.
This could be used as a sorting function by requiring that every element of the vector is an element of an input vector, or something