So in every *other* programming language, we can add a simple function like Ruby's Hash#merge, and it's fine, and no one bats an eye. But in JavaScript, everyone gets ten times as excited, produces 100 times as much writing and discussion... and support for it is unpredictable.
-
Show this thread
-
Because Twitter tends to read criticism of anything JS-related as a moral condemnation: this has nothing to do with the people involved. We locked ourselves into a monoculture built on top of a language that wasn't designed. This is about the best we could've expected given that.
4 replies 2 retweets 53 likesShow this thread -
It's strange that the accepted solution is "throw another compiler in front of the compiler" in the form of Babel... which itself is a monoculture. Solve the monoculture by layering another monoculture over it. Doesn't seem right.
4 replies 2 retweets 38 likesShow this thread -
Another similar example. How do you spell "get the last element of an array"? Python (as of 1990): xs[-1] Ruby (as of 1995): xs[-1] JS (also as of 1995): xs[xs.length - 1] JS (as of 1999, probably an uncommon idiom): xs.slice(-1)[0] JS (as of 2015): var [x] = xs.slice(-1)
3 replies 2 retweets 6 likesShow this thread -
Every JavaScript version, past and current, is obviously worse than negative indexing, which existed before JavaScript was rushed out the door. (It was rushed out by Netscape as a play to slow the adoption of Sun's Java applets.) Why don't we adopt the 28-year-old simple thing?
3 replies 1 retweet 6 likesShow this thread -
This doesn't look like a huge issue when considering single values. But what happens in real life? Python or Ruby: g(f()[-1]) JavaScript, 1995: var xs = f() var x = xs[xs.length - 1] g(x) JavaScript, 1999: g(f().slice(-1)[0]) JavaScript, 2015: var [x] = f().slice(-1) g(x)
2 replies 0 retweets 11 likesShow this thread -
I'm reminded by
@sgrif that `xs.last` is more idiomatic Ruby than `xs[-1]`. That just raises the further question: why on earth don't JavaScript's arrays have `last()`? You don't even have to invent this stuff, committee folks! Just copy Enumerable! https://ruby-doc.org/core-2.5.1/Enumerable.html …6 replies 1 retweet 18 likesShow this thread -
Replying to @garybernhardt
All methods on Enumerable are non-destructive. ;)
1 reply 0 retweets 0 likes -
Replying to @sgrif
Oof... of course they are; they'd have to be. I was thinking of array methods like delete.
1 reply 0 retweets 0 likes
Yup, not the first time I've seen someone assume `delete` etc was on `Enumerable` :)
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.