One example of many. In Ruby, you can merge hashes (JavaScript "objects") by doing `x.merge(y)`. That's been in forever. It's a simple thing. You call merge; done.
-
Show this thread
-
The JS standards body standardized their equivalent syntax (`{...x, ...y}`). It's a nice syntax! Great! But the JavaScript ecosystem is so labyrinthian that tool support, docs, blog posts, are all inconsistent. And all three change monthly, but the old ones remain available.
6 replies 0 retweets 16 likesShow this thread -
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.
4 replies 0 retweets 25 likesShow 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 -
Replying to @garybernhardt
FWIW I think most folks would consider `g(f.last)` more idiomatic in Ruby (not sure about Python). I've personally never found `-1` meaning end of the array particularly obvious or intuitive
2 replies 0 retweets 0 likes -
Replying to @sgrif
That's definitely true. But that just raises an even more obvious question: why doesn't JavaScript just have last()?!
1 reply 0 retweets 0 likes
100% agree that lacking`.last()` makes no sense
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.