hell (read: write programs dynamically), I learned that life can be easier when you write programs statically: 1. Bug’s Life 2. Type Checking and Lessons Learned 3. Flow: JavaScript Static Type Checker 4. Practical Flow
programs due to the complexity of the programs and/or the incorrect way of solving problem. Bug Report Channel Reported by everyone except the creator himself. Debug Debugging is twice as hard as writing the code in the first place.
JavaScript code without running the actual code. 2. Static Type Checker Since debugging is twice as hard as writing code, we need to code smarter. Static type checking allows you to confidently write code faster, bigger, smarter. Unlike tests, it covers rarely-used code path better. 3. Tests Tests are slower and more expensive than static type checking but offers you higher guarantee of your program’s stability and consistency.
to reduce possibilities for bugs in computer programs by defining interfaces between different parts of a computer program, and then checking that the parts have been connected in a consistent way.
Properties: • Able to perform features that difficult/impossible to verify statically: dynamic dispatch, downcasting, etc • Runtime overhead causes programs to run slower, bigger in size. Static 2 Perform type checking at compile-time Properties: • Compiled program runs faster, no runtime overhead. • Intuitive, don’t need to run the code path to verify the correctness.
to catch every single error that might happen at runtime. This comes at the cost of sometimes catching errors that will not actually happen at runtime. Completeness The ability for a type checker to only ever catch errors that would happen at runtime. This comes at the cost of sometimes missing errors that will happen at runtime. Both It’s like telling everyone to shut up, quietly. Flow sometimes has to make a tradeoff: being as sound and complete as possible; but tend to favor soundness over completeness, ensuring that code doesn’t have any bugs.
have your popular dependencies typed even though they were not written in Flow. 1. Install flow-typed globally $ yarn global add flow-typed ; 2. Pull libdefs (based on package.json) $ flow-typed install ; 3. You can use those types now
is statically typed. 2. Refactor won’t be scary anymore if the code is statically typed. 3. It is harder to make a mistake (read: bug) than it is to make a program; when the code is statically typed. 4. Writing code is faster when the codebase is statically typed.
code is statically typed. 2. Refactor won’t be scary anymore if the code is statically typed. 3. It is harder to make a mistake (read: bug) than it is to make a program; when the code is statically typed. 4. Writing code is faster when the codebase is statically typed.
code is statically typed. 2. Refactor won’t be scary anymore if the code is statically typed. 3. It is harder to make a mistake (read: bug) than it is to make a program; when the code is statically typed. 4. Writing code is faster when the codebase is statically typed.