All loops in functional programming are expressed as tail recursions, or as folds that are implemented with tail recursions, because otherwise there's no way to express them. And classic loops are inadequate for expressing algorithms involving asynchronous calls, being error prone.
This is not a narrow, edge case, having started with lambda calculus in 1930. It's only an edge case when your tool of choice doesn't support it.
Hence my Stockholm Syndrome joke is really only a half joke ;-)
It is an edge case to keep around a 2,000,000 promise long chain
The issue is that the implementation should not keep around 2,000,000 promises, being the problem we are talking about. Please re-read what I wrote, because I don't want to keep repeating the same words.
As for why this is an issue, I'm also a little out of breath explaining why, tried to do that in a comment here.
If this is a bug in the implementation ... you should just report it to the v8 team
This isn't an issue with V8, since Firefox has the same behavior, but an issue with the standard.
If it's an issue in the spec you should point out the flaw in the spec and start a discussion about how to fix it.
I was under the impression that I'm doing just that and I'm showing you the solution as well.
you write an article attacking what's become a fundamental part of JS for the purpose of promoting your own library
Well, those of us that are building libraries, we like talking about it. I'm sorry for contributing stuff, I really am, it's a reward-less activity.
It's toxic and my issue is that it does nothing to help anyone except you.
You're attacking me for no reason. My critique was for a piece of technology, yours is personal.
So I should just be an angry man that complains about what other people do, but that does nothing about it?
Personally I prefer to show and tell, to build and deliver alternatives and to talk about it. That's not a "scumbag thing to do" in my culture, even if I were to do this for money, which I don't, this being on my own free time and at personal sacrifice.
What about calling people scumbags? Is that appropriate for this or any other community?
We have nothing more to talk about. Have a great life.
Ah, so this whole contrived example is to push the funfix package you wrote.
Future isn't a promise. So of course you can write it however you want. You can leave spec behind so you can show you fixed this "terrible" Promise bug by not using Promises.
I guess that if you work on stuff and talk about it, you must be one.
No. That's not the case. It's how you're coming across in all of this.
You came up with a rather contrived, academic example to demonstrate a very specific problem. Instead of addressing how the specific implementation causes problems, you attempted to generalize it beyond the scope of the issue - including using a clickbait title like "Promises are Memory Unsafe".
No, Promises are NOT memory unsafe and that has been shown time and time again in this thread. In fact, your example isn't even memory unsafe - it's just a fucking infinite loop that causes the program to run out of memory. The exception is thrown because JS can't safely handle memory after it's out of usable memory space.
People are upset with you because they expected you to actually demonstrate how Promises as a whole suffer from a serious memory problem. You didn't and people called you out. You somehow decided that the best approach was to double down on your flawed argument and attack people for criticizing your approach.
I replied in kind to all technical arguments and added extra explanations where possible, given the limitations of a forum and the time available.
Your argument has a logical inconsistency ... either my linked Funfix is proof that the leak is real and that a fix is possible, or it is not. I also added the following links to that article, for completeness sake:
There is nothing in the Promise API that says references must be kept in such chains — it's quite interesting how people jump to conclusions on how the implementation should behave, when the API itself is free of such constraints.
In fact intermediate references can be dropped, implementations are known, TFA now includes mentions of such implementations, which are widely deployed and verifiable. TFA also includes acknowledgements from the authors of the Promise spec and others.
And I think I've been pretty clear on that. If not, then let me know how the explanation in TFA can be improved.
0
u/[deleted] Oct 11 '17
[deleted]