News for hackers. Stuff that matters.
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:

  class Person {

    get isImmortal() {
      return false; // noone is immortal
    }

  }

  p = new Person();

  p.isImmortal

  // >>> false

  p.isImmortal = true;

  p.isImmortal
  // >>> false

I mean, even plain untyped JavaScript can do that!
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.
Re:Why I'm not a React Native developer by coldtea on Saturday August 19, 2017 @05:40PM (#15055779)
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.
Re:Why I'm not a React Native developer by raquo on Sunday August 20, 2017 @01:32AM (#15057085)
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.