Live data from Hacker News

Why I'm Not a React Native Developer

arielelkin.github.io

271–280 of 318 posts

Re: Why I'm Not a React Native Developer

#271

Please what kind of programmer would ever do this? if (weAreConnected === true) { this.setState({ isConnected: true }) } else { this.setState({ isConnected: false }) } That is just verbose unnecessarily: this.setState({ isConnected: weAreConnected }); And probably not so popular, but this: var color; if (this.state.isConnected) { color = 'green' } else { color = 'red' } Would be simplified often to: var color = this.…

> Please what kind of programmer would ever do this? Someone with an interesting development development history (maybe C?), with little grasp of the idioms of newer coding styles.

What?

Re: Why I'm Not a React Native Developer

#272

I believe in the end it all boils down to the fact that JavaScript is a language that wasn't made for the needs of modern day (web) applications, but since it is still a standard, we need to force it into a form where we can have best control over its shortcomings. That's why things like Typescript, Flow and React exist in the first place. I know this article is about mobile app development, but I think JavaScript wo…

What are the needs of modern day applications? How does (what it was designed for) differ from (what is desired of it)?

Re: Why I'm Not a React Native Developer

#273

Earlier quoted context omitted.

TypeScript is a JavaScript best practice at this point. It's a type safety net on top of dynamic types, so you get the best of both worlds. TypeScript has a flag that prohibits switch fallthrough, for instance, though that's an easy one to set up a linter to catch. One reason I prefer NativeScript to React Native; they are embracing TypeScript and Angular vs. React. I find Angular 2 to be more flexible, but that I fr…

If you are not building large applications then TS is counter productive. Just consider the extra compilation step, the dependencies and obfuscated source code. While it can be tremendous help, calling it a best practice misses the point.

The code output is really clean; I wouldn't call it obfuscated. Especially when source mapping works just about everywhere.

And having ES2015 features (+async/await) is very useful: var should be deprecated, arrow functions should be standard, etc.

Tiny projects? Sure, do whatever you want. But I've started switching even my one-file, 2-3 screens of code Node servers over to TypeScript, and it's not only useful, it accelerates development by 100% simply because you don't need to run your code to know that you've got the types correct.

I stand by "best practice."

Re: Why I'm Not a React Native Developer

#274

Earlier quoted context omitted.

TypeScript is a JavaScript best practice at this point. It's a type safety net on top of dynamic types, so you get the best of both worlds. TypeScript has a flag that prohibits switch fallthrough, for instance, though that's an easy one to set up a linter to catch. One reason I prefer NativeScript to React Native; they are embracing TypeScript and Angular vs. React. I find Angular 2 to be more flexible, but that I fr…

TS over JS isn't best practice yet: Some of us like dynamic typing.

TypeScript gives you the benefits of dynamic typing without the drawbacks of a C++/Java restrictive-typing system.

It just makes the dynamic typing safer. It absolutely should be considered a best practice; anything that can accelerate development by 100% or more should be.

Re: Why I'm Not a React Native Developer

#275
post #70

Earlier quoted context omitted.

For what purpose is dynamic typing ever useful except "it’s faster to develop"? With a proper type system (see: Haskell, Scala) and parametrized types, you can do everything that’s reasonable in a dynamically typed language, too.

Unless you are doing Java, I would even take issue with the argument that dynamic typing is faster to develop. It's taken as obvious fact but I don't think we should just take that as face value. Getting as-you-type feedback, intellisense, and simple documentation (methods, parameters, types) is hugely productive. As well as the ability to break things and know you've caught all the breaks. I would say that a very fa…

I agree, and I consider TypeScript to be twice as fast to develop in as plain JavaScript just because you don't need to:

* Look up member names

* Look up object hierarchy structures

* Run code (or tests) to verify that you've done the above correctly

When the compiler knows the types, it can bring your code up to 90% correct. Half the time you don't even need to specify types: TypeScript can guess them from context.

You need to specify parameter types and return types; if you're declaring a variable without initializing it, or assigning it an empty array or object, you need to specify its type. Other than that you generally get type inference from TypeScript (at least as of 2.0).

Re: Why I'm Not a React Native Developer

#276

Earlier quoted context omitted.

Using a branch when you can just do an assignment is objectively bad code.

Objectively eh? And bad code by what criteria? In this case, it's a little more verbose than it needs to be, but hurts nothing.

But violates DRY = bad code. Not incorrect because it does what it's suppose to, just in a bad way.

Re: Why I'm Not a React Native Developer

#277
post #204

var a = 0; var b = -0; console.log(a === b) // true console.log(1/a === 1/b) // false That's perfect math you mean, of course -Infinity != Infinity, what did you expect? I think you should rather think harder, learn math possibly, and your 'safety' problems with arrays are not problems at all, it's the opposite for other people

> I think you should rather think harder, learn math possibly Oh the irony, when stating that 1/0 = infinity. If you'd learn maths yourself, you'd know that 1/0 is undefined.

yea 1/x is not strictly defined for x=0, but you can extend it in ℜ ∪ {+∞,-∞}, I don't know your math background, but 1/-0 could make you think of limits:

1/0 is like 1/0⁺ (limit of 1/x in ]0,+∞[ when x->0) == Infinity.

1/-0 is like 1/0⁻ (limit of 1/x in ]-∞,0[ when x->0) == -Infinity.

1/Infinity is 0 ....

0/0 is however an indefinite form, so it's NaN

so the behavior of JS makes sense

And even if 1/0 and 1/-0 returned NaN, they wouldn't be equal to each other too

Re: Why I'm Not a React Native Developer

#278
post #260
post #233

Earlier quoted context omitted.

Or FB sues you over literally any patent you happen to be infringing. They're a big company, I'm sure their patent war chest has a few zingers for cases like these. Oh, and your scenario only works if you sue FB/Instagram over your patents first. They can't revoke the patent grant willy-nilly except in retaliation.

I should point out we don't even know whether Facebook even has any patents for anything React does. And even if they do we don't know whether there are other libraries that do the same things and therefore infringe on those patents, making you liable if you use them. It's software patents you should be worried about, not open source projects that try to offer you even the tiniest amount of protection from them.

Plus, any patents Facebook does have on React technologies are quite likely to cover whatever similar technology you use instead.

> It's software patents you should be worried about, not open source projects that try to offer you even the tiniest amount of protection from them.

Amen to that.

Re: Why I'm Not a React Native Developer

#279

Earlier quoted context omitted.

Besides, while JS's problems are very real, they're quite exaggerated. It's still a perfectly usable language, even without TS and whatnot. And unlike some languages used for app programming, an error doesn't have the potential to hand you a segfault.

> ...an error doesn't have the potential to hand you a segfault. And that is a good thing why? So you don't realise there was an error and your app runs on in a corrupted state?

For starters, a huge set of security vulnerabilities are not possible. Ex: buffer overflow, double free, reading uninitialized memory.

Re: Why I'm Not a React Native Developer

#280
post #53

Earlier quoted context omitted.

That alone makes it a non-starter

Why? (Honest question.)

Because many people don't feel comfortable with having a legal gun pointing to the neck of their frontend or mobile platform.
Post reply on HN