4 ms·
> Not every day or even once in an average week, unless you're doing something wrong. Do you have to understand it or not? There is a ton of information on the
by sergeykish 6y ago
> Not every day or even once in an average week, unless you're doing something wrong.
Do you have to understand it or not? There is a ton of information on the web (viewed 191k times) [1], [2], etc. Acting like it is intuitive is disingenuous.
No, that's you who don't understand. I've shown particular code that is error prone in JS but is ok in other languages. That is the issue. It is not solved. Every novice gets it. It is simple to solve. Instead you claim "you should not need this", tell it 191k viewers. Yes, you know what's going on, still you claim "you don't need this".
class Foo
end
foo = Foo.new
foo.class == Foo // metaprogramming! *You shouldn't even be futzing with these things in _any_ file*
Sure I know about method definition in class. Extend it (same class). It is useful technique.
And please don't post twice same if you can't read response.
[1] https://stackoverflow.com/questions/9959727/proto-vs-prototype-in-javascript https://stackoverflow.com/questions/9959727/proto-vs-prototy...
[2] https://javascript.info/class-inheritance https://javascript.info/class-inheritance
- pwdisswordfish4 6y ago> that's you who don't understand Because your comments are incomprehensible. > I've shown particular code that is error prone in JS but is ok in other languages. It's not OK in Java. It's not OK in C. It's not OK in C++. Because you can't even do that in any of those languages. > still you claim "you don't need this" Look at the languages I listed above. Think about the program you're trying to write. Do you think it's impossible to write the program you want to write in those languages, where you are not even allowed to to do your clever tricks? Look at the underscores in the name __proto__. That's a huge, massive sign in your face that means, "If you find yourself touching this a lot, it's because you're doing something wrong." How could it be clearer? Imagine it were called __proto$do_not_use$__ instead. But you use it anyway. And then you ask, "why is this so difficult?". Where's the surprise? Think about this whole thread. You're doing something, experiencing pain, and then complaining about the pain that you feel. Yes, of course you feel the pain. Every time you mention the pain, you are actually giving an argument against yourself: it's not the right thing. So stop doing it. The fact that you got instanceof wrong is further evidence that you're not the best person to tell us which road to take to get to the party--you don't know the city. (As for the code snippet you wrote in this comment, it's not clear at all what you're even trying to say. Once again: incomprehensible.)
- sergeykish 6y agoI've mentioned prominent example, there is underlying problem class Foo {} typeof Foo //"function" Foo instanceof Function //true Is there underscore here? How about typeof Object //"function" typeof Function //"function" Object instanceof Function Object instanceof Object Function instanceof Function Function instanceof Object How many underscores there? And looks like you don't know about Object.getPrototypeOf Object.setPrototypeOf Reflect.getPrototypeOf Reflect.setPrototypeOf without underscore and you blame I don't know this land. You've got burned by Java and C++, bad for you. There are other languages — Python and Ruby (last example). JS [[Prototype]] is equivalent of class hierarchy. You shown many times that you can't comprehend, normal reaction should be investigate and understand first, not your case. It shows you in a bad light.
- pwdisswordfish4 6y ago> there is underlying problem No, you haven't ever defined _any_ problem, only abstract things that bother you. There is only one problem that matters: writing a (correct) program. If you can do it without meta-programming, then you should. If you start meta-programming when you don't have to, then you have already lost. If you are doing this when you shouldn't, and then you experience pain and say, "This system needs to be fixed", then make sure you fix the correct part of the system: yourself. > JS [[Prototype]] is equivalent of class hierarchy. Which nobody is futzing around with (because they can't, and they shouldn't futz with it anyway) on the level that you're insisting we do, in the ordinary course of writing programs. (The level where you are seeing "problems".) Once again: keep that stuff in your REPL. If you are editing a regular source file that will be committed to the repo and you are typing out "prototype" or "__proto__" or "setPrototypeOf" more than once or twice every 10k lines, then you're almost definitely doing something wrong. > You've got burned by Java and C++, bad for you. No, it's that the world is burning because of thousands of programmers who can't behave responsibly because they pick up a dynamic language and say, "There are no adults around to discipline me, so now is the time to go nuts." (And the irony is that this thread exists because of your complaints about JS and how it burns you, where I started out arguing that JS is fine at the beginning. But now you're the champion for JS?)