Small practical guide on statically-typed languages for developers who switching from dynamically-typed languages to statically-typed versions. For example from JavaScript to TypeScript or Flow.
This guide assumes at least some prior knowledge of dynamically-typed languages. The idea of this guide is to help make a mental shift from dynamic to static types.
Most of the time I will use JavaScript and TypeScript or Flow examples. Maybe this will be useful for other languages - I do not know yet, let's see.
If you have prior knowledge of statically typed languages, but Hindley-Milner doesn't ring a bell for you, this guide can be useful for you too.
This is my diary of personal discoveries. I find myself explaining those things again and again to different people. I decided to write it down once and for all.
- Exhaustive check and why it is useful for event processing, enums, unions or disjoint unions
- Opaque types and how they could have saved Mars Climate Orbiter
- IO validation or how to handle JSON-based APIs in statically typed language
- What are types?
- Dynamically-, statically-, gradually-, weakly-, strongly- and un-typed languages
- Is JavaScript an untyped language?
- Type system vs null
- Making Impossible States Impossible
- Immutability and type system
- Classes, types, sets, structural and nominal subtyping, Liskov substitution principle
- Redux and impossible states
- Redux and impossible state transitions or FSM
- Redux and side effects
- Types and proofs
- Why JavaScript Promise is unsound?
- Terminology: soundness, completeness, totality, decidability
- Rosetta stone, Curry–Howard correspondence
- To be continued...
- To type or not to type: quantifying detectable bugs in JavaScript Gao et al., ICSE 2017
- Type systems will make you a better JavaScript programmer by Jared Forsyth 2017
- Types, and Why You Should Care
- Lauren Tan Swipe Left, Uncaught TypeError Learning to Love Type Systems
Ideas, questions, and fixes are welcome. Sharing on social networks is also a big help. Thank you.