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 -
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 -
The joke's on me: last() isn't part of Enumerable. Maybe you need to take a look at Array, too, I guess, but I wouldn't want anyone to blindly adopt that whole thing. https://ruby-doc.org/core-2.5.1/Array.html …
2 replies 1 retweet 4 likesShow this thread
That is incredibly confusing that it's not part of enumerable... We should fix that
-
-
Replying to @sgrif @garybernhardt
Even more so because first *is* part of Enumerable. Till this very moment I assumed that calling last on a Hash was possible.
2 replies 0 retweets 0 likes -
Replying to @thepawandubey @sgrif
Given that, I'd guess that they didn't do it because last would consume the whole enumerable? Maybe it's supposed to prevent you from building a large lazy enumerable, then accidentally evaluating 999 elements when you call `last` for the 1000th?
3 replies 0 retweets 0 likes - 1 more reply
New conversation -
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.