tag:blogger.com,1999:blog-30596097.post3296908143328198113..comments2018-09-20T16:00:29.765-07:00Comments on null is null or not an object: Fibonacciφhttp://www.blogger.com/profile/09634660954553065936noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-30596097.post-36694392094062363012011-07-30T03:00:46.054-07:002011-07-30T03:00:46.054-07:00It recursively calls itself while trying to avoid...It recursively calls itself while trying to avoid recursion of the Fibonacci function. For instance, non recursive example would be: <br /><br />var Y = function(f) {<br /> return function(g){<br /> return g(g);<br /> }(function(h) {<br /> return function() {<br /> return f(h(h)).apply(null, arguments);<br /> };<br /> });<br />};Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-30596097.post-12048361962248017792011-07-29T16:23:19.072-07:002011-07-29T16:23:19.072-07:00@Anonymous, could you explain a bit the issue with...@Anonymous, could you explain a bit the issue with "closed form"?φhttps://www.blogger.com/profile/09634660954553065936noreply@blogger.comtag:blogger.com,1999:blog-30596097.post-80031894730856010562011-07-29T16:18:50.246-07:002011-07-29T16:18:50.246-07:00The implementation of Y-Combinator in your post is...The implementation of Y-Combinator in your post is not in "closed form" because it remains recursive itself.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-30596097.post-27172193936051697692010-09-26T11:53:17.474-07:002010-09-26T11:53:17.474-07:00Well, function calls are just way more expensive i...Well, function calls are just way more expensive in JS with current JITs, so it might not be the stack per se, but the correlation between large stacks and recursive calls. Actually, TraceMonkey probably could handle this case the best if it traced recurisve calls (I'd guess it doesn't for now).<br /><br />I don't really do much in JS-land anymore, so I don't really have any ideas for such aync frameworks. Actually, I don't think I really like much of either async or frameworks since I dislike the hollywood protocol (don't call us, we'll call you). I know I'm in the minority in the JS world, especially with JS-based server frameworks gaining some popularity.<br /><br />I wonder what could be done with WebWorkers, as an alternative.won3dhttps://www.blogger.com/profile/09787472194187459747noreply@blogger.comtag:blogger.com,1999:blog-30596097.post-36868316648735174732010-09-25T11:49:32.079-07:002010-09-25T11:49:32.079-07:00Ah yes, I did forget Crockford's Little Javasc...Ah yes, I did forget Crockford's Little Javascripter.<br /><br />In an attempt to answer your iterative vs. recursive question, I found <a href="http://www.ics.uci.edu/~eppstein/161/960109.html" rel="nofollow">this page</a><br /><br />Indeed, iteratively is much, much faster than recursively. What you mention about stack space is also what I suspect the reason for why Yfib is much faster.<br /><br />Given that browsers are implementing optimization on their side, it's a bit more difficult to analyze the algorithms on javascript. For example, Chrome would handle n=8000 if I first run n=6000 on a cold start, non-memoized run<br /><br />You guess correctly, I am working on an application for combinators, as part of a tiny, asynchronous framework. <br /><br />Do you have any applications in mind?φhttps://www.blogger.com/profile/09634660954553065936noreply@blogger.comtag:blogger.com,1999:blog-30596097.post-15812993517074611712010-09-24T19:46:11.172-07:002010-09-24T19:46:11.172-07:00To Mock a Mockingbird is awesome, but you can'...To Mock a Mockingbird is awesome, but you can't mention Javascript Y-combinators without mentioning Crock's Little Javascripter:<br /><br />http://www.crockford.com/javascript/little.html<br /><br />How does iterative compare with recursive? Also, how does the "miss" case for memoization compare to the recursive? I would guess that it would still be faster, since it converts double recursion to single recursion. You would save stack space to do it iteratively.<br /><br />My guess is that you'll have a non-toy example for combinators, though, which is exciting.won3dhttps://www.blogger.com/profile/09787472194187459747noreply@blogger.com