3 ms·
Seems like TCO is is hard to do in browser JS, that's surprising. It's kind of a deal killer for basing a functional language on. JVM too for that matter.
by imglorp 3y ago
Seems like TCO is is hard to do in browser JS, that's surprising. It's kind of a deal killer for basing a functional language on. JVM too for that matter.
- gleenn 3y agoI'm sorry you are so attached to implementation details but that hardly detracts from the general usability of a language. Clojure is hosted both on the JVM and JavaScript and is, all things considered, both usable and popular enough of a Lisp and it definitely doesn't have TCO. You can bail out to using "loop" if you're that perf sensitive.
- imglorp 3y agoIt's not an implementation detail if you can't do recursion in constant stack space. The underlying VM should allow all CS primitives, and the guest can add constraints as it wants.
- gleenn 3y agoHow is that not an implementation detail? You can't really inspect the stack at runtime in a useful way. It's literally just performance and yeah you might run out of memory somewhere but that's true of every language detail, some languages are more efficient than others. I'm getting downvoted but I think my comment stands. Clojure is a perfectly useful example of a language without TCO. It's not necessary, it's a detail. And as a long time developer, there hasn't been a single time where I cared if my stack took constant space or not. It has never mattered.
- lispm 3y agoIn full TCO, any tail call is a jump in constant stack space. What Clojure provides is a "loop" construct, which kind of looks like a limited form of self recursion.
- hajile 3y agoNot hard at all. Chrome had it implemented, removed it, then added it back, but only for WASM. They disliked that it didn't leave stack frames in some cases. Apple refused to break the JS backward-compatibility guarantee and implemented as-per the spec and Chrome refused to turn on their implementation for users unless it added a special keyword to identify it as a tail call. Chrome dev's emotional investment and resulting stubbornness has split the JS community and made their implementation incompatible with the spec. They are 100% in the wrong here.
- baq 3y agoIn the meantime on the backend we’re looking at stack traces cut apart with trampolines and living with it…
- robocat 3y ago> Chrome dev's emotional investment and resulting stubbornness ... You really undermine your position when you start fabricating bullshit like that. The chromium team had good reasons to not implement it (including clusterfuzz security issues). Apparently it was actually the Microsoft and Mozilla teams that blocked the feature: https://stackoverflow.com/questions/54719548/tail-call-optimization-implementation-in-javascript-engines#54721813 https://stackoverflow.com/questions/54719548/tail-call-optim...
- hajile 3y agoFF objected because they didn't want to do the work, but they're now doing that work making proper tail calls work in WASM, so their objection is irrelevant now. MS objected that Windows APIs made PTC slow, but they now use Chrome, so they don't have an excuse today either. There's nothing inherently insecure about proper tail calls and that is pure FUD. That just leaves Google. They chose to die on the hill of syntactic tail calls and are still refusing to implement the spec. The only reason left is their pride and emotional investment in STC. Even back then, Safari was implementing and had more marketshare than Edge and FF combined (now 2.5x their combined market share with FF only having around 3% share today). I'm tired of bad excuses and want them to actually implement the now 8 year old spec properly.
- pjmlp 3y agoImplementation language doesn't have necessarily to do with language being implemented, unless one does the easy way to translate one into the other.