dwyl / comments-you-will-regret-blocker-chrome-extension

:speak_no_evil: [WiP] A Chrome Extension that monitors comments typed into a textarea and blocks you from posting silly things you will regret!
GNU General Public License v2.0
9 stars 1 forks source link

Use Flow? #12

Open ryanpcmcquen opened 7 years ago

ryanpcmcquen commented 7 years ago

Should we use Facebook's Flow project for this extension?

As @Charlotteis mentioned if we decide to go with Flow, we should add something about it to the README!

https://github.com/dwyl/comments-you-will-regret-blocker-chrome-extension/pull/3#discussion_r93768677

nelsonic commented 7 years ago

@ryanpcmcquen I don't think we have anything against using Flow besides the "one more thing to learn" ... also would using Flow not require "transpilation" https://flowtype.org/docs/running.html (recommends using "Babel"...)❓ which kinda defeats the objective of using "Vanilla JS" ...

Flowtype might appear to add the benefits of static type checking to JS just as Typescript promises to do so, but they can both lead us into a false sense of security because they do not detect run-time errors... “Uncaught ReferenceError: foo is undefined”

if you need to add Type definitions to your JS why not just use a Typed Immutable language like Elm which gives you a lot of useful things out of the box and compiles to ultra-efficient JS. The maintainability and debug-ability of Elm is what attracted us to it.

Totally agree with @Charlotteis's point that Elm-lang does not look beginner-friendly on the surface: https://github.com/dwyl/comments-you-will-regret-blocker-chrome-extension/issues/8#issuecomment-268995380 but that is something we are about to test with the current cohort of @foundersandcoders in the first week of January... (wish us luck!) So we will know pretty soon if Elm is beginner-friendly or not... And if you have the patience/time to try it out, I suspect you might like it. 😉

To @andrewMacmurray's point in https://github.com/dwyl/comments-you-will-regret-blocker-chrome-extension/issues/8#issuecomment-268773358 yes, we would need to write a "port" to "interop" with the JS on the page (i.e. read the contents of the <textarea>) but I think this is a good thing as we can clearly separate the concerns.

image from @rtfeldman's talk on "Elm in Production": https://youtu.be/R2FtMbb-nLs

Please go with what you are comfortable with. 👍 I'm just making a suggestion based on the hope that this extension might become something useful that other people could want to extend and if you're inviting random people on the internet to extend your code you'll want them to follow a rigorous approach to ensure all the code in the project co-exists well. (i.e. "no side-effects" of adding new functionality)

Before you decide, read: https://mixandgo.com/blog/writing-a-chrome-extension-with-elm

ryanpcmcquen commented 7 years ago

@nelsonic if flow required transpiling I would not want to use it. They really need to do a better job of promoting their commented vanilla JS version:

// @flow
const api = (request /*:Object*/ , response /*:Object*/ ) => {

https://flowtype.org/blog/2015/02/20/Flow-Comments.html

Note that not all items need a type specified. flow is pretty good about inferring types in lots of places.

nelsonic commented 7 years ago

Oh, wow. Ok. yeah, Fb obviously want people to use Babel... Sure, if you are prepared to use the comments version of Flow.... (why not?)