amilajack / popcorn-time-desktop

🍿 🕐 🎞 A Modern Popcorn Time Client
MIT License
468 stars 109 forks source link

PR: Transition towards Flow #135

Closed amilajack closed 7 years ago

amilajack commented 8 years ago

Here are my reasons/thoughts on transitioning towards flow.

Pros:

  1. It embraces FP (functional programming): Functional languages require strong type systems. 'undefined' and 'null' do no exist in functional languages. Removing or at least avoiding these values can provide us with some guarantees that we won't get runtime errors. The unspoken direction of out development stack and environment is towards one that is similar to Elm, which is arguably the best front-end development experience available at the moment. Elm guarantees no runtime errors. One of the ways that Elm guarantees this is because it is a proper functional language that has a strong type system.
  2. Strong types will standardized in ES7/8: It is a widely accepted that future versions of Ecmascript will embrace static typing. Embracing static typing now will prepare us for what is already coming.
  3. Possible Performance optimizations: Javascript's dynamic nature comes at the cost of performance. VM's can significantly improve their optimization by using types as heuristics. Emscripten is a good example of this.

    Cons:

1. Learning Barrier: Ideally, people that know standard Javascript should be able to contribute. Flow isn't that hard to learn and its pretty easy to learn.

Note that adding Flow support is a lower priority than enabling all the FP eslint rules

Thoughts?

thangngoc89 commented 8 years ago

Well, flow is easy to learn and it can be adopted incrementall. If you have trouble when implementing, just ping me

amilajack commented 8 years ago

Personally, i find flow to be very intuitive. But for beginners who want to contribute, learning intersection types or disjoint unions might be more of a barrier.

Also flow support was added to the release branch yesterday.

amilajack commented 7 years ago

Couple useful links:

https://flowtype.org/docs/react.html#stateless-functional-components https://flowtype.org/docs/react.html#defining-components-as-reactcomponent-subclasses