News for hackers. Stuff that matters.
Re:Bun, JavaScript, and TCO by runarberg on Sunday December 31, 2023 @02:46PM (#38826919)
I think the most cited reason they give is diminished developer experience. That is when developers write a recursive function without intending it to be tail call optimized, they loose their call stack. In theory this makes debugging harder. However I don’t—and others interested in JavaScript design—don’t buy this reasoning. There is little—if any—data showing this happens to developers in real life.

I also believe that Google’s representatives at TC-39 (and Mozilla’s to a lesser extent) knows this. Meaning they have other reasons for not implementing TCO. My personal theory is that they are very much against expending the functional paradigm in JavaScript. TC-39 has been very hostile towards any proposals which would expand the functional paradigm in JavaScript. The decision to advance the hack style pipeline operator (which uses a placeholder) over the F# (functional/tacit) operator is a prime example of this.

This, I believe, is purely political.

Re:Bun, JavaScript, and TCO by odyssey7 on Sunday December 31, 2023 @03:49PM (#38827408)
Sadly I sense something amuck against the functional paradigm as well.

Paul Graham wrote back in 2001 that Lisp was a secret weapon for building a startup due to the developer productivity gains. https://paulgraham.com/avg.html

As a corollary, the more lisp-like JavaScript is, the more it reduces barriers to entry for launching a tech company, promoting more software engineers into potential new competitors.

Could it be that Java and Python are taught in universities because some members of the industry prefer making it more cumbersome for new grads to launch a company? Having significant barriers to entry is business strategy 101.

Re:Bun, JavaScript, and TCO by jart on Sunday December 31, 2023 @04:34PM (#38827699)
Are you saying that knowing LISP makes you like an instant Paul Graham? If only.
Re:Bun, JavaScript, and TCO by klyrs on Sunday December 31, 2023 @07:14PM (#38828616)
Ew, I hope not. I know lisp, I do not want to be Paul Graham.
Re:Bun, JavaScript, and TCO by odyssey7 on Sunday December 31, 2023 @04:42PM (#38827756)
Nice try
Re:Bun, JavaScript, and TCO by sroussey on Sunday December 31, 2023 @06:34PM (#38828429)
Having worked on debuggers in JS land I can tell you that it would generate lots of bug reports.

Does the developer expect a call stack?

Does the developer NOT expect a call stack? Maybe they want to see if the optimization was activated.

Bug reports either way.

That said, all sorts of weird changes happen when a debugger is enabled.

The jit will eliminate various pieces of code and remove variables from scopes, but you better put them back if the debugger stops! This one I remember in Firebug. Oops!

¯\_(ツ)_/¯

Re:Bun, JavaScript, and TCO by hajile on Monday January 01, 2024 @12:09PM (#38833322)
Safari has enabled proper tail calls for 8-9 years now and they haven’t caused issues despite Safari having 20% of the worldwide browser market.
Re:Bun, JavaScript, and TCO by runarberg on Monday January 01, 2024 @07:30PM (#38836675)
I guess Safari doesn’t have this large a share of developers, who are the main concern here. But I guess we will truly see if this is an issue as Bun increases in popularity.
Re:Bun, JavaScript, and TCO by hajile on Tuesday January 02, 2024 @10:39AM (#38842691)
The major Google "objection" was automated trace loggers. When something goes wrong, they grab the stack trace and ship it off to the developers.

In this particular case, devs definitely see the Safari traces when bugs pop up.

Re:Bun, JavaScript, and TCO by sroussey on Wednesday January 03, 2024 @10:24PM (#38862598)
I feel like it could be represented in the trace or the debugger or both and eliminate everyone issues.

Devs definitely don’t like surprises, but also absolutely hate their tools not telling the truth.