News for hackers. Stuff that matters.
Re:Interview with Douglas Crockford by peanut_worm on Tuesday July 19, 2022 @11:28AM (#32152933)
I am surprised he doesn’t like the more recent additions to JavaScript. I liked ES6 features quite a lot.
Re:Interview with Douglas Crockford by jillesvangurp on Tuesday July 19, 2022 @12:26PM (#32154077)
"The best thing we can do today to JavaScript is to retire it."

I think that's a pretty interesting statement from somebody like Douglas Crockford. Not disagreeing; but still ...

I think there are two ways of looking at recent changes in Javascript. Either it's progress or it's just not enough progress. I think what he is saying here is that there it has too much baggage and that there are newer and more interesting languages now. That's not such a strange thing to say for somebody that has been involved with trying to create new languages.

My personal view is that browser Javascript is mostly a compilation target these days, including for Javascript itself, and that we now have a better compilation target in the form of WASM that is less awkward to target for a lot of languages as well. The question is what languages people will be using in the next years that target that. I'd say there are some interesting alternatives to choose from already and there are likely to be more in the next few years.

Re:Interview with Douglas Crockford by tadfisher on Tuesday July 19, 2022 @12:51PM (#32154522)
Javascript has GC and tail calls, and I don't think WASM is getting either anytime soon.
Re:Interview with Douglas Crockford by jillesvangurp on Tuesday July 19, 2022 @01:35PM (#32155178)
The experimental Kotlin WASM uses some experimental GC related flags in chrome. That stuff is working right now and will no doubt stop being experimental at some point. Tail calls might take a bit longer but there are probably people working on that too. But there are probably ways around that. WASM is already useful today and will incrementally get more useful over the next few years.
Re:Interview with Douglas Crockford by johnfarrelldev on Tuesday July 19, 2022 @02:25PM (#32155897)
I'm not sure about other engines but V8 the most popular JS engine does not implement tail calls.
Re:Interview with Douglas Crockford by dragonwriter on Tuesday July 19, 2022 @02:27PM (#32155927)
Isn't not efficiently implementing tail calls a current JS standard (in that implementing them means your implementation is technically broken) specifically to prevent software from relying on that optimization?
Re:Interview with Douglas Crockford by tadfisher on Tuesday July 19, 2022 @08:32PM (#32159804)
Someone should tell Ecma then: https://tc39.es/ecma262/multipage/ecmascript-language-functi...

I was wrong, though, tail calls are in ES14, and eliminating them is probably not implemented anywhere yet.

Edit: Wrong again, tail-call optimizations are in WebKit; iOS has had them since iOS 12 according to this: https://kangax.github.io/compat-table/es6/#test-proper_tail_...

Re:Interview with Douglas Crockford by kwertyoowiyop on Tuesday July 19, 2022 @02:01PM (#32155574)
He has said that a good language avoids exposing the programmer to choices that they can make incorrectly. He probably sees some added features in Javascript as creating such choices.
Re:Interview with Douglas Crockford by koromak on Tuesday July 19, 2022 @11:31AM (#32152986)
ES6 is what makes JS bearable to write modern day. Totally don't understand his point here. Who wants endless nested promise chains?
Re:Interview with Douglas Crockford by tombert on Tuesday July 19, 2022 @11:45AM (#32153270)
I can't speak for Crockford obviously, but my guess is that all these extra features come at the cost of making the language "bigger". I think part of the reason people liked JS in the early days was (at least if you avoided the attempt at OOP) how simple it was. You basically only had a few core types that were flexible enough to do what you needed, you worked with simple functions that worked on those core types, and you built simple abstractions on top of that.

Obviously this can be a blessing or a curse depending on who's writing the code; it's not terribly hard to write yourself a spaghetti mess of chaos in JS. Callbacks lead to a mess of nested lambdas, promises are better but still a bit clunky, and trying to work within the "few core types" led to the famous "wat" video [1], so these things come in tradeoffs.

Still, I see where Crockford is coming from (at least if I understand his point correctly). My interview language of choice is JavaScript, and I rarely use anything introduced from 2015 or later (except the shorthand function syntax). I like that the core language has basically no bureaucracy, and you can focus on just writing code.

[1] https://www.destroyallsoftware.com/talks/wat

Re:Interview with Douglas Crockford by the_other on Tuesday July 19, 2022 @12:14PM (#32153863)
> Who wants endless nested promise chains?

One of the things Promises solves is nesting. If you're nesting them, you're doing it wrong.

(I don't mean "never nest them"... but if you find you're nesting them, see if you can refactor to "all()" them or similar)

Re:Interview with Douglas Crockford by WorldMaker on Tuesday July 19, 2022 @04:00PM (#32157152)
You "should" never nest them, if you create a new Promise inside a .then() callback, immediately return it and move to a new .then() callback in the chain. Promises were built to flatten.

The hard part, of course, is threading complex flows of variables through your .then() callbacks where later Promise calls need a previous variable or three, and that's when a lot of people give up and just resort to deeper nesting. That's what async/await does the best at solving: capturing variables automatically in a simple state machine written like classic imperative code versus manually trying to thread state through callback closures and complex return types.

Re:Interview with Douglas Crockford by capableweb on Tuesday July 19, 2022 @11:55AM (#32153485)
> Who wants endless nested promise chains?

Believe it or not, you can actually structure things so it's "flat" looking without async/await (or even without Promises for that matter, but Promises solve other problems too).

Just because someone argues against something like async/await, doesn't mean they want the thing async/await is supposed to address.

Re:Interview with Douglas Crockford by saiojd on Tuesday July 19, 2022 @11:47AM (#32153307)
I've always felt there's a disconnect between two groups of people, those who use a language in their day-to-day work and those who approach it more as an object of study (i.e. academics or hobbyists). The latter view bloat as a bad thing, while it's not the biggest concern for the former (who have more pressing problems!). So for Crockford an expanding language definition is catastrophic, but for people writing web apps, if 1 new feature out of 10 very useful then it's still a huge win.
Re:Interview with Douglas Crockford by capableweb on Tuesday July 19, 2022 @11:53AM (#32153459)
I'm not a academic nor hobbyist but work professionally with JavaScript for more than 10 years.

I'm also "against" the constant syntactic sugar that gets added with little to no benefits, just leading to JavaScript having a large syntax.

Why introduce "classes" which are just sugar on top of existing syntax? Many examples just like this, where sometimes it feels like JavaScript has changes just to have changes.

Although I'm not gonna complain too much, many of the new features are more than just syntactic sugar and makes my life a lot easier. I just wish they were slightly more conservative I guess.

Re:Interview with Douglas Crockford by LordN00b on Tuesday July 19, 2022 @12:41PM (#32154345)
To take your argument to the extreme, why have for loops, when then are syntatic sugar over while loops? I'm generally a fan of syntatic sugar in a language if it's purpose is to simplify what's already there; but it is a balance between developer productivity and ease-of-use. I once saw javscript described as 'pithy', becuase of it's small syntatical footprint, that's probably not true so much now.
Re:Interview with Douglas Crockford by ptx on Tuesday July 19, 2022 @01:52PM (#32155434)
I believe Crockford said in a talk [1] that he was going to stop writing loops when tail-call elimination is supported everywhere.

Also, avoiding the for loop in JS might be a good idea because of how easy it is to shoot yourself in the foot with "for (x in stuff) ..." creating a global variable (when you accidentally leave out "var").

[1] Probably this one? https://www.youtube.com/watch?v=XFTOG895C7c

Re:Interview with Douglas Crockford by kwertyoowiyop on Tuesday July 19, 2022 @02:02PM (#32155592)
Indeed. Just as with real sugar, a little syntactic sugar is great, but too much is icky.
Re:Interview with Douglas Crockford by saiojd on Tuesday July 19, 2022 @06:23PM (#32158771)
I agree with you, but you also agree with me, I think.

You said that, despite the bloat, you won't complain too much because some features make your life easier. That's precisely what I was saying!

Re:Interview with Douglas Crockford by tomgp on Tuesday July 19, 2022 @12:18PM (#32153932)
my feeling was that Crockford’s ‘…good parts’ was intensely pragmatic. About as far away from the academic approach you’re describing as i can imagine. A bigger, multi paradigm language makes it harder to read other peoples code as the chances are higher that they’re employing a different paradigm or alter a different idiom, a clear maintenance burden.
Re:Interview with Douglas Crockford by saiojd on Tuesday July 19, 2022 @06:28PM (#32158814)
Pragmistism literally means utility for problem solving. Who do you know solves problems using a Crockford-style subset of language features?

Note that, no where did I argue that bloat is good. I only said that it was tolerable given that some new features are useful. Maintenance burden is a real problem, but is still tolerated in practice.

I don't agree that subsetting a language is far from an academic approach. In fact this is what pretty much every PLT class does in order to make reasoning about language definitions easier.

Re:Interview with Douglas Crockford by tomgp on Wednesday July 20, 2022 @11:05AM (#32166800)
Identifying that subset of the language was paradigm shift in JS development. around 2008 when the good parts came out i don’t know any serious JS developers who didn’t take on board many of its lessons. examples: avoiding ‘this’, understanding the value of functions as first class citizens, understanding closures. these weren’t unique to crockford but by presenting them in an accesible plain spoken way he moved the state of the language forward.

i do agree that there’s a need to weigh the value of new features vs bloat but id say 1 good feature in ten is pretty poor odds.

another example of crockfords pragmatism is JSON which for all its flaws has been a real boon.

edit: un-auto correcting “crockpot” :D

Re:Interview with Douglas Crockford by saiojd on Wednesday July 20, 2022 @05:34PM (#32172685)
Interesting points, thank you! JSON is a great example, I understand what you meant now.

That being said, I really wish JSON had comments :P

Re:Interview with Douglas Crockford by irrational on Tuesday July 19, 2022 @01:58PM (#32155532)
And those new features are usually new/different/“better” ways of doing what you could already do in the language. You can totally use JS without using any of the ES6+ syntax.
Re:Interview with Douglas Crockford by saiojd on Tuesday July 19, 2022 @06:24PM (#32158785)
Do you do this personally, or do you use ES6+?
Re:Interview with Douglas Crockford by nicoburns on Tuesday July 19, 2022 @12:43PM (#32154385)
The ES6 additions were great. It's the ones post ES6 (like private fields) which are becoming increasingly questionable.