5 ms·
Isn't this whole issue just a minor version of the problem Ruby has with monkeypatching? The fact that a Ruby guy can define `method_missing` to allow for bare
by benaiah 13y ago
Isn't this whole issue just a minor version of the problem Ruby has with monkeypatching? The fact that a Ruby guy can define `method_missing` to allow for bare strings shows how Ruby is cool (though you should never do that), but the fact that you can redefine `undefined` in JS shows how JS is stupid (despite the fact that you should never do that). I don't understand the dichotomy.
- chrisrhoden 13y agoPeople don't typically inject frequently changing, unvetted advertising code into their ruby runtimes. Generally, the most frequently that the ruby code in your runtime changes is each deploy.
- benaiah 13y agoGranted, but that's an incidental problem, not one arising from JS being a bad language. Also, I highly doubt there is much advertising code that changes the value of "undefined" - certainly not any I've encountered. This really boils down to "my code won't act the same way if I give unfettered access to my environment to unvetted code" which is true in almost any situation. If you're having problems because "undefined" is being redefined, you have bigger and more fundamental problems. There are a lot of bad things about JS, but this is not one of them - its overly nitpicky and completely unfair. This same capability (of being able to redefine almost anything) is lauded as part of Ruby, but when it could theoretically cause any easy-to-avoid problem in JS, it's just more proof that JS is a shitty language. Sorry if I'm coming across as combative - I don't mean to. I just think this whole snide criticism of JS for every little thing is silly and unhelpful, and has more to do with a superiority complex than actual technical issues.
- gwright 13y agoIn general you are correct, redefinition in Ruby can be abused, but it isn't so easy to abuse 'nil' in Ruby as it is to abuse 'undefined' in Javascript. In Ruby, nil, is a keyword so you can't assign to it nor can you use it as a method parameter.