7 ms·
This is simply a list of things the author doesn't like about JS, very much of which is practically solved by Flow/TS and ESLint. He also makes some of the Rea
by STRML 10y ago
This is simply a list of things the author doesn't like about JS, very much of which is practically solved by Flow/TS and ESLint.
He also makes some of the React examples quite a bit more complicated than they need to be. Declarative UI is very simple!
Here's the same code, using both class and functional styles (whichever you prefer), in a much more succinct style (11 LOC vs 49):
class Root extends Component {
render() {
var isConnected = Math.floor(Math.random() * 10) > 5;
return <ConnectivityIndicatorView isConnected={isConnected} />;
}
}
function ConnectivityIndicatorView(props: {isConnected: boolean}) {
const color = props.isConnected ? 'green' : 'red';
return <View style={{backgroundColor: color, width: 20, height: 20}} />;
}
The point is, much like many things in software, it's all about perceptions and familiarity. He's not familiar with JS, and I don't fault him for that - it's a quirky language. But for the many, many developers who have built up a tolerance to JS and built/use tools to tame it, moving to React Native is a breath of fresh air vs learning Android & iOS toolchains and idiosyncrasies.
- jontro 10y agoThe point of having isConnected in the state is that it will change depending on OS events. Random is just used as an example
- atoko 10y agoEven with state, his code is overly verbose and can be expressed in a much more idiomatic way. var weAreConnected = Math.floor(Math.random() * 10) > 5; if (weAreConnected === true) { this.setState({ isConnected: true }) } else { this.setState({ isConnected: false }) } } turns into var weAreConnected = Math.floor(Math.random() * 10) > 5; this.setState({ isConnected: weAreConnected }); It's almost like he wrote it in the most obtuse way possible to prove his point. Unless he writes like that normally; If so then I can see where he's getting all these errors from.
- jontro 10y agoAbsolutely, especially since he/she wrote it that way in the swift version let weAreConnected: Bool = arc4random()%10 > 4 self.isConnected = weAreConnected
- deleted 10y ago[deleted]
- catshirt 10y ago"overly verbose" might be giving too much credit... it's bad code
- macspoofing 10y agoNo. 'Verbose' is correct. It's not bad code. It's a simple control flow.
- andrepd 10y agoUsing a branch when you can just do an assignment is objectively bad code.
- deleted 10y ago[deleted]
- macspoofing 10y agoObjectively eh? And bad code by what criteria? In this case, it's a little more verbose than it needs to be, but hurts nothing.
- mirekrusin 10y agoBut violates DRY = bad code. Not incorrect because it does what it's suppose to, just in a bad way.
- faceyspacey 10y ago
- STRML 10y agoRight, but that would almost certainly be a root-level property in any real app. In any case, it's still awfully verbose and confounding for little reason.
- Pfhreak 10y ago> This is simply a list of things the author doesn't like about JS, very much of which is practically solved by Flow/TS and ESLint. That's definitely not a fair characterization of this article. Concerns about roadmap and patent usage show up before any concerns about JS. Edit: Though I agree, a strangely large amount of the article is dedicated to "Why I just don't like Javascript."
- pauljaworski 10y agoThat is a very fair characterization of the article - 70% of the article's content is about why JavaScript is bad.
- andrepd 10y agoWell, it is :)
- xpaqui 10y agoIt is but not due to `Type errors`, `Lack of function signature`, `Immutability`, `You can’t trust arrays`, `Unsafe initialisation`, `Optional curly braces after an if`.
- coldtea 10y ago70% of the content is not necessarily "the most important part of the content". 2 minutes in a 5 minute animation short are the credits.
- EdwardDiego 10y ago2 minutes isn't 70% of 5 minutes. It's only 40%. Yeah, nitpicking, I know.
- coldtea 10y agoGetting the exact percentage is not necessarily the most important part of an analogy.
- 10y ago
- skewart 10y ago> it's a quirky language From the blog post: > JavaScript’s deficiencies seem to impress everyone except JavaScript developers, for whom the aspects of JavaScript that I outlined above are not awful warts, they’re “quirks” or “gotchas” that you, not your language, have to be on the lookout for. I think his point is that calling JS "quirky" makes it sound benign, or even cute. However, JS's quirks are actually serious shortcomings compared to other languages. For native iOS and Android developers React Native has a huge intrinsic appeal, for all the reasons he outlined at the start of the post. It's really tempting. Plus, the enthusiasm and scale of the JS community can sometimes ovrshadow concerns non-JS devs have about the language. To me the post seems helpful. From my experience React Native will certainly not be all puppies and roses for people coming from Java, Swift or Obj-C.
- andrepd 10y ago"Javascript’s inadequacy" is but a section. The author addresses many other concerns in the text. Also, the Flow thing is specifically addressed.
- ffjffsfr 10y ago> This is simply a list of things the author doesn't like about JS, very much of which is practically solved by Flow/TS and ESLint. One of shortcomings of language listed by author is precisely this: shortcomings in language are not fixed by fixing the language but by adding new community-supported library.
- tracker1 10y agoIs that really worse than a language you can't change?
- caub 10y agowhat's the point of function ConnectivityIndicatorView(props: {isConnected: boolean}) {.. props.isConnected ..} vs function ConnectivityIndicatorView({isConnected}) {.. isConnected.. }?
- coldtea 10y ago>This is simply a list of things the author doesn't like about JS, very much of which is practically solved by Flow/TS and ESLint. This is a lot more than "simply a list of things the author doesn't like about JS". The first part of the post in fact is totally orthogonal to JS, and all about React Native as a platform/project.
- Tloewald 10y agoThe anti JavaScript ranting is tedious and redundant, however he points out that virtually no React Native code uses Flow, etc., so it's an unused solution. The point about React having hundreds of dependencies is also well taken. While I'm at it, I find the graphs towards the end claiming, for example, that using Xamarin (or Appcelerator) is more productive than React Native, or implying Swift is barely shy of perfectly safe to stretch credulity. Finally, Javascript's "slow" state of development is a feature as well as a weakness, just as Swift's rapid pace of development is both a weakness and a feature. React itself progresses at a breakneck pace.
- pluma 10y agoI actually find it ludicrous the author is complaining about JS's development as a language being too slow. Just the other day I presented ES2015/2016 and the upcoming changes scheduled for 2017 to a room full of JavaScript developers and the general feedback was that JS was changing too quickly. The reason ES2015 was so huge and so delayed was actually that ES5 was pretty much the lowest common denominator everyone was able to agree on after the proposals for ES4 went up in flames. ES5 is necessarily incremental and ES2015's delay was mostly caused by the repercussions of ES4's failure -- ES4 failed because it valued innovation over backwards compatibility. I mean TC39 has announced that they will make a new release every year, batching whatever proposals are stable at that point. How can anyone call that particularly "slow" with a straight face?
- rdiddly 10y agoI for one enjoyed spending 70% of the time reading about how JS sucks. It's good to be reminded now and then. If I'm chopping wood for years with a dull axe, I get really strong, and good at swinging a dull axe, and at performing superhuman feats of adaptation - adjusting myself and my attitude to using a shitty tool. Maybe even, like Stockholm Syndrome, I come to enjoy it. Do I resent the guy who comes by once a year and reminds me chainsaws exist? No I do not.
- tracker1 10y agoFair enough... I find it ironic I left the world of .Net and C# behind for node, and am MUCH more productive in node. And he's recommending the reverse. That said, some of the more recent changes from MS have me interested in .Net again... I've even played around with some of the core/mono onbuild docker containers, which wasn't a bad experience at all.