Reading 1: Static Checking
As a running example, we’re going to explore the hailstone sequence, which is defined as follows: Starting with a number n, the next number in the sequence is n/2 if n is even, or 3n+1 if n is odd. The sequence ends when it reaches 1. Here are some examples: 2, 1 3, 10, 5, 16, 8, 4, 2, 1 4, 2, 1 2n, 2n-1 , … , 4, 2, 1 5, 16, 8, 4, 2, 1 7, 22, 11, 34, 17, 52, 26, 13, 40, …? (where does this stop?) Because of the odd-number rule, the sequence may bounce up and down before decreasing to 1. It’s conjectured that all hailstones eventually fall to the ground – i.e., the hailstone sequence reaches 1 for all starting n – but that’s still an open question. Why is it called a hailstone sequence? Because hailstones form in clouds by bouncing up and down until they eventually build enough weight to fall to earth. Here’s some code for computing and printing the hailstone sequence for some starting n. We’ll write JavaScript and Python versions of the code side by side for comparison: The basic seman
Reading 1: Static Checking Reading 1: Static Checking Objectives Today’s class has two topics: static typing the big three properties of good software Hailstone sequence As a running example, we’re going to explore the hailstone sequence, which is defined as follows: Starting with a number n , the next number in the sequence is n/2 if n is even, or 3n+1 if n is odd. The sequence ends when it reaches 1. Here are some examples: 2, 1 3, 10, 5, 16, 8, 4, 2, 1 4, 2, 1 2 n , 2 n-1 , … , 4, 2, 1 5, 16, 8, 4, 2, 1 7, 22, 11, 34, 17, 52, 26, 13, 40, …? (where does this stop?) Because of the odd-number
Explore this link on the map →related reading
- Reading 1: Static Checkingweb.mit.edu
- TypeScript: Documentation - The Basicstypescriptlang.org
- TypeScript: Documentation - TypeScript for the New Programmertypescriptlang.org
- Reading 2: Basic TypeScriptweb.mit.edu
- Basic TypeScriptweb.mit.edu
- No, dynamic type systems are not inherently more openlexi-lambda.github.io
- "We're building a new static type checker for Python" | Hacker Newsnews.ycombinator.com
- TypeScript: Documentation - TypeScript 3.7typescriptlang.org
- Everything is Fertilenickcammarata.com
- Reading 9: Avoiding Debuggingweb.mit.edu
- TypeScript: Handbook - The TypeScript Handbooktypescriptlang.org
- Reading 4: Code Reviewweb.mit.edu