Re:Why I'm not a React Native developer
by azangru on Saturday August 19, 2017 @03:31PM
(#15055130)
The example with the Person class suggests that the author is unaware of JavaScript getters:
I mean, even plain untyped JavaScript can do that!
[ Parent
| on HN ]
Re:Why I'm not a React Native developer
by objectiveariel on Saturday August 19, 2017 @04:18PM
(#15055351)
You're missing the point. The fact that the language still allows you to write `p.isImmortal = true;` is the issue.
Re:Why I'm not a React Native developer
by oceanswave on Sunday August 20, 2017 @07:31PM
(#15060797)
And my linter, or flow, typescript will pick that up in the same way the compiler will. Just because tooling these days catches these things in 'type safe' languages doesn't mean it's not a pointer to a chunk of memory that's defined at runtime beneath it all.
Which won't do anything. p.isImmortal will still be the setter. So it's a non issue -- and the linter can catch the mistake anyway.
That was a bad example indeed. If isImmortal was accepting any params though, you wouldn't be able to make it a getter.
And sure, Object.freeze exists, but almost none of the JS code I've seen uses it. And what's the point really when assignments to frozen fields don't even throw an exception, just fail silently. Same for getters. None of those tricks are gonna make JS into a good language in the eyes of people who don't for whatever reason consider it good already.