r/javascript • • Oct 11 '17

JavaScript's Promise is Memory Unsafe

https://alexn.org/blog/2017/10/11/javascript-promise-memory-unsafe.html
70 Upvotes

77 comments sorted by

View all comments

Show parent comments

7

u/bluebaron Oct 11 '17

What about this list makes it lazy or asynchronous? Or for that matter, referentially transparent? JavaScript is strictly evaluated, you can't even construct a value in that list unless you have the value to want to add to it already. I see no function signatures indicating callbacks for asynchronous operations either. There's nothing preventing one from mutating one of the references within the list, so I'm not sure where the referentially transparent claim is coming from.

1

u/alexelcu Oct 11 '17

What about this list makes it lazy

The fact that the rest of the stream is described with a parameter-less function, also called a thunk, which is how you turn strict things into lazy ones, obviously.

asynchronous

The fact that the rest of the stream can be processed with a Promise.

Or for that matter, referentially transparent?

The fact that side effects get suspended in that parameter-less function and there's no mutation involved for building it.

I see no function signatures indicating callbacks for asynchronous operations either

That's what the Promise is for. If it would work properly that is.

There's nothing preventing one from mutating one of the references within the list

I've modified the original definition to have readonly on those members, if that makes you happy :-)

6

u/bluebaron Oct 11 '17

I missed the Task<A> you had in the constructor signature the first time, my bad.

Also, I know what a thunk is, and your tone in these comments comes off as pretty condescending. I think you'd be better received here if you abstained from talking to people like they have no idea what they're talking about.

2

u/alexelcu Oct 11 '17

I apologize for sounding condescending or aggressive, I do try to explain things using less jargon (thunk is less understood jargon).

I'm also incredibly annoyed. Somebody here called me a scumbag for talking about a library I've been working on in my free time at personal sacrifice, so I don't necessarily know what I'm doing here, instead of going home to my wife and kid, but I guess I'll just pass by the bank first to retrieve my million dollars.

As you can see, my humor doesn't help much either.

Cheers,