6 ms·
I hope this feeling passes, but I get nervous when code example syntax starts looking really foreign to me. Whether accurate or not, my brain is kind of in a p
by Waterluvian 9y ago
I hope this feeling passes, but I get nervous when code example syntax starts looking really foreign to me. Whether accurate or not, my brain is kind of in a place of, "okay so ES6 cleaned up a lot, we're all kind of settling on Webpack, npm, certain various toolsets and best practices. I don't feel constantly overwhelmed anymore, can we not rush into another flurry of change?"
On the other hand, it looks like we're streamlining some verbosity. I just hope we can be okay with the right balance and we don't end up with a really terse looking language.
- timwis 9y agoIt looks strange to me, too. It looks like they using typescript in their examples, probably to be more descriptive.
- danabramov 9y agoIt is Flow. We were trying to be descriptive for folks who already use it (like we do at FB) so they know the intended type signatures, but the same changes apply if you skip the types. Sorry it came across as confusing.
- danabramov 9y agoI edited the post to hide the annotations behind a gist: https://github.com/reactjs/reactjs.org/pull/719 https://github.com/reactjs/reactjs.org/pull/719 Hope this is clearer now!
- Waterluvian 9y agoThanks, Dan. I can appreciate the value that Flow adds. But in my opinion, when it's default in the code examples of a top shelf library, it creates an implicit dependency to learning from the blog post, no matter how small or obvious it may be.
- losteric 9y agoFYI, the examples are partially written in Typescript not ES6... so they should look foreign.
- kevmo314 9y agoWhat parts are in Typescript? This looked like all ES6 to me.
- losteric 9y agoNever mind, they updated the post. As of my post the first few examples had some type annotations in the form `methodName(varName: type, ...)`, which I assumed was TS. All the examples are plain ES6 now.
- chrisweekly 9y agoflow, not ts, right?
- m0meni 9y agoFor the first two examples, there's some unfamiliar syntax because they added Flow[1] typings to the examples (not TypeScript as other comments are suggesting). What about the syntax do you find confusing? The rest is all just ES6 + class properties. [1]: https://github.com/facebook/flow https://github.com/facebook/flow
- bringtheaction 9y agoCan someone explain to me why they went for static getDerivedStateFromProps(nextProps, prevState) Instead of getDerivedStateFromProps(nextProps) Was it to prevent people from mutating the object perhaps?
- danabramov 9y agoYes, since that’s the most common issue with what people do in componentWillReceiveProps. It is invoked during the interruptible phase in async mode so mutations and side effects are unsafe there. Same as in the render method.
- deleted 9y ago[deleted]
- HumanDrivenDev 9y agoOh god, I really don't hope we're settling on webpack. Unless you just want to pull the ladder out from web devs with mediocre machines (we don't all have californian salaries).
- abritinthebay 9y agoExpand? Webpack isn’t the cause of bad bundle times: awful Dependancy Trees are. Even on an old machine I view bundle times of more than 30 seconds (without minification) as suspicious.
- HumanDrivenDev 9y agoYou actually think 30 seconds is OK for 'compiling' a dynamic language? We might as well start using C++ in the browser if that's the kind of feedback loop we have to deal with. Browserify does it much more quickly.
- joshribakoff 9y agoBundler != compiler. With caching my babel webpack setup has 30s cold startup and <1s compile and reload for a huge huge code base Edit: I should say bundler != tranpiler. A bundler may or may not be implemented as a compiler. In the end it's just fancy concatenation and code generation, whereas a transpiler (going from one language to another) requires parsing to an AST
- iovrthoughtthis 9y agoThis is an on going thing. Transpilers are just a word invented to mean compiling one high level language into another. The thing is, compilers already to that. The "level" of the language is irrelevant, the fundamental concepts are the same. So compiler works.
- abritinthebay 9y agoTranspilers are a specific type of compiler. They are source-to-source between the same approximate abstraction level. It's been used this way since at least 1980 (eg: in 86-DOS there was TRANS.COM)