Fork me on GitHub
#off-topic
<
2017-06-01
>
captainlexington15:06:00

I can't even figure out what's going on here

dpsutton15:06:27

i think its trying to say look down on others based on what language they use

roberto15:06:41

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.

fellshard18:06:45

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 😛

john15:06:31

With some typically self deprecating british humor on top

seancorfield16:06:37

I love Verity Stob… so funny!

dpsutton16:06:56

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

seancorfield16:06:04

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:

fellshard16:06:44

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. ¯\(ツ)

fellshard16:06:04

Aphyr's - while a bit more whimsical and filled with technical witchery - felt much sharper for that kind of satire.

seancorfield16:06:38

To me, Aphyr’s is too bogged down with technical cleverness to be effective. Humor is cultural/subjective tho’…

roberto16:06:50

hmm, yeah, I don’t find british humor funny. 😕

fellshard17:06:35

Imbibe deeply of Pratchett, and you might find your preferences shifting 🙂

dominicm17:06:19

I thought it quite funny. I liked the twist at the end. Went from futuristic to Me in Exeter a couple years ago 😛

jmacneal19:06:29

It's definitely inspired by the opening chapter of Brave New World

john21:06:37

@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.

mobileink21:06:16

hmm. i'm not convinced we need to introduce threads. any computation has an evaluation strategy.

mobileink21:06:45

to me strict eval means "reduce to normal form".

john21:06:46

I just mean the base event loop. Which is eager. LazySeqs create sub event loops.

mobileink21:06:30

what events? assume we are in a single-threaded env.

john21:06:57

Right, CLJS, for instance.

john21:06:22

JS has an event loop.

mobileink21:06:07

yeah, but that's orthogonal to strict/lazy.

john21:06:10

Well, lazy evaluation in CLJS is a looping construct that repeatedly calls one function on a data structure.

ghadi21:06:46

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.

john21:06:33

just in time evaluation

ghadi21:06:39

more terminology isn't helping... =(

mobileink21:06:59

on-demand = just in time.

john21:06:21

Right. eval in CLJ/CLJS is not JIT/On demand

mobileink21:06:03

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.

dpsutton21:06:15

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

mobileink21:06:48

@john huh? taking from an inifinite list?

john21:06:58

But in clojure, only specific functions will actually do the necessary iteration on the structure in order to realize each next.

john21:06:11

like into

mobileink21:06:37

right. but that's a language feature: lazy eval.

john21:06:06

It's more of a feature of into and LazySeq, together, but not necessarily other things.

mobileink21:06:04

ok. the lazy eval feature of certain forms is defined by the language.

mobileink21:06:35

laziness need not be all or nothing.

mobileink21:06:07

it is a feature of clojure that some evals, but not all, are lazy.

john21:06:31

You could implement it in mostly languages though, probably.

john21:06:06

If you go read the LazySeq code, you'll see how it realizes the sequence. It's pretty simple.

mobileink21:06:19

indeed, presumably in any kanguage.

john21:06:44

But in a "lazy language," like haskell, internal forms aren't realized unless they are needed. Whereas in clojure, they are realized immediately.

john21:06:42

(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.

mobileink21:06:25

right. with strict eval, the arg will be fully reduced to 3. you can't do that with (repeat 5) etc.

mobileink21:06:47

i don't see the logic of saying that things like (repeat 5) are strictly evaluated in clojure.

mobileink21:06:04

it makes no sense to me.

ghadi21:06:13

Repeat immediately returns you a data structure

mobileink21:06:46

sure. on that can later be evaled.

john21:06:58

returns a cljs.core/LazySeq in the repl

ghadi21:06:48

No, it's already evaluated. The fact that it is a sequence that hasn't been fully realized yet is besides the point

mobileink22:06:28

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.

ghadi22:06:46

You're thinking in terms of Haskell again

ghadi22:06:10

Which is fine, but it's not helping understand

ghadi22:06:38

There's no reduction phase here

john22:06:45

It might be better to think of lazy structures as just functions that close over state and call themselves.

mobileink22:06:49

no, i'm thinking of evaluation strategies. after all, haskell is exactly like clojure in this respect, afaics.

ghadi22:06:08

You call a function and it immediately returns a structure

mobileink22:06:16

no reduction = lazy eval.

ghadi22:06:30

If you look up Clojure and Haskell in Wikipedia, they use different evaluation strategies. I'm trying to illustrate why

mobileink22:06:55

in the end the whole point is reduction to normal form.

ghadi22:06:05

Clojure is exactly like Java and Python in this respect

mobileink22:06:38

java has language-level infinite lists?

ghadi22:06:07

What does language level mean

ghadi22:06:43

Clojure's are in a library, not the language

mobileink22:06:56

the language supports it out of the box, you don't have to implement it yourself.

ghadi22:06:00

It happens to be the core library, but it's a lib nonethelrss

dpsutton22:06:09

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;
}

dpsutton22:06:38

final synchronized Object sval(){
	if(fn != null)
		{
                sv = fn.invoke();
                fn = null;
		}
	if(sv != null)
		return sv;
	return s;
}

dpsutton22:06:42

infinite sequences in java

mobileink22:06:20

@ghadi wait, you're saying lazy stuff is not part of the definition of clojure?

dpsutton22:06:52

here's one in C#: Enumerable.Range(0);

john22:06:57

It's defined on the clojure side, per say.

ghadi22:06:07

Yeah it's not baked into the compiler, it's in userspace

mobileink22:06:12

@dpsutton yes, of course, you can implement it in any language.

dpsutton22:06:18

so all languages are lazy?

dpsutton22:06:36

that's not close to what any common usage of a "lazy language" adjective could mean then

dpsutton22:06:54

i think we have an ill-defined concept then

mobileink22:06:26

you can write a lazy lib (infinite seqs etc.) in any language.. that's different.

dpsutton22:06:39

i think we all agree with that

dpsutton22:06:53

and the fact that rich hickey did it doesn't change the semantics of clojure

mobileink22:06:41

ok. who said it did? semantics is a separate issue.

mobileink22:06:37

the original question is whether clojure has lazy eval, as a feature of the language.

john22:06:26

LazySeqs and a collection of associated functions have lazy eval. And that part of clojure is "lazy"

john22:06:50

Unlike Haskell, right?

mobileink22:06:23

@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.

john22:06:28

In Haskell, it's more like there are a handful of functions for doing eager eval

mobileink22:06:43

still, that would be a good topic for some doc. my guess is pretty much everybody thinks lazy seqs involve lazy evaluation.

mobileink22:06:25

which they do, but whether that is a language feature is a separate question.

john22:06:38

Perhaps a better word would be lazy iteration

john22:06:04

Eval is eager, while iteration is optionally lazy, where many core abstractions opt in.

john22:06:27

But usually also support eager.

ghadi22:06:33

Well said

sophiago22:06:08

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

mobileink22:06:46

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.

mobileink22:06:48

compare the definition of C. it defines the language, but also the std libs.

mobileink22:06:31

but the lib features do not really define the language.

mobileink22:06:05

@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.

ghadi22:06:28

:thumbsup: awesome

dpsutton22:06:34

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 🙂

ghadi22:06:50

It's harder to explain stuff when someone has an advanced knowledge of things sometimes. @mobileink

ghadi22:06:10

Clojure's​ evaluation is pretty ordinary

ghadi22:06:26

When you call a function, it gives you flesh. In Haskell when you call a function it gives you a thought about flesh

john22:06:55

Reminds me of a chain of promises.

sophiago22:06:44

more likely futures, but that is exactly what's going on

mobileink22:06:08

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". 😂

mobileink22:06:42

the play is "squirrels". very funny.

sophiago22:06:56

there's also call-by-need, which gives you either a thought of flesh or thaws out a steak from the freezer if available 😄

mobileink22:06:52

i'm looking for the eval strategy that will do my laundry.

mobileink22:06:25

i'll take that.

joelsanchez23:06:56

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?

joelsanchez23:06:18

100% serious about this.

joelsanchez23:06:56

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