Week 14 · 14.4 · Fri, Nov 6 · The Bigger Picture: ACT-style reading
One Wrong Character: From Mariner 1 to Java's Symbols
1 This section explains why a single character can matter so much in a program, from a rocket launched in 1962 to the symbols that every Java program uses.
A Mark Too Small to See
2 On July 22, 1962, NASA launched a spacecraft called Mariner 1 from Cape Canaveral, Florida. It was meant to fly past Venus. Within minutes, the rocket carrying it veered off course. For safety, a Range Safety Officer sent a command that destroyed the rocket and the spacecraft. NASA's records put that moment at 293 or 294.5 seconds after launch, a little less than five minutes.
3 Investigators found two causes working together. The first was a fault in the rocket's beacon equipment, which at times lost a signal that the guidance system needed. The second was a single missing mark. The rocket's guidance equations had first been written by hand, and one of them had a short bar, called an overbar, drawn above the symbol R for radius. When the handwritten equations were turned into coded instructions for the computer, that overbar was left out. Without the bar, the coded equation meant something different, and the guidance program sent the rocket incorrect steering commands.
4 The mistake is sometimes reported as a missing hyphen. NASA says that account is wrong: the missing mark was an overbar, not a hyphen. Engineers fixed the problems quickly. Mariner 2 was launched on August 27, 1962, about five weeks later, and on December 14, 1962, it gave scientists their first close-up look at another planet.
Rules a Compiler Checks
5 A Java program has to be checked before it can run. A program called a compiler reads the code and turns it into a file that the computer can run. Every programming language has rules about which symbols may appear and how they fit together, and those rules are called its syntax. When code breaks a rule, for example by leaving out a semicolon, the compiler reports a syntax error. Oracle's Java tutorial says the message usually gives the type of error, the line number and the place on that line where the error was found. While any error remains, the compiler does not create the file that runs, so the program does not run at all, not even the lines that are correct.
6 The compiler is also exact about letters. Java is case-sensitive, which means that it treats a capital letter and a small letter as different characters. For that reason, System and system are two different names in Java. A person reading a line might guess that the two were meant to be the same word, but the compiler does not guess. It checks the code against its rules and reports anything that does not fit. Figure 1 sets Mariner 1's missing mark beside a compiler's message about a missing semicolon.
Symbols With Jobs
7 Each symbol in a line of Java has a job. A semicolon ends a statement, which is one complete instruction. A pair of braces, { and }, marks a block, a group of statements that belong together. Double quotation marks surround a string literal, which is text that prints exactly as it is written.
8 Two symbols that look almost alike have different jobs. The single equals sign, =, stores the value on its right in the box on its left. The double equals sign, ==, asks whether two values are equal, and its answer is true or false. The steps language used earlier in this unit stored values with ← and asked questions with =. Java stores with = and asks with ==.
9 Even one symbol can change its job. When + stands between two numbers, it adds them. When it stands between two pieces of text, it joins them into one string, a step called concatenation. The two lines below differ only in their quotation marks.
1System.out.println(2 + 3); 2System.out.println("2" + "3");
5 23
10 Today's question asks why Java stops a whole program over one missing semicolon. The compiler checks every symbol against Java's rules and does not guess what a missing one was meant to be, in the same way that Mariner 1's guidance program followed the equation it was given rather than the one its writers intended. On today's bench, each symbol is typed exactly, matched to its job and read the way the compiler reads it.
Summary
11 In 1962, one missing overbar helped send Mariner 1 off course. A compiler checks code against the language's syntax and reports a syntax error instead of guessing, so a program with one wrong character does not run. Java is case-sensitive, and each symbol has a job: ; ends a statement, braces mark a block, quotation marks surround text, = stores, == asks and + adds numbers or joins text.
Sources: NASA Space Science Data Coordinated Archive, Mariner 1; NASA Science, Mariner 1 and Mariner 2; Oracle, The Java Tutorials: Common Problems (and Their Solutions), Expressions, Statements, and Blocks, Equality, Relational, and Conditional Operators, Assignment, Arithmetic, and Unary Operators, Variables and Strings; Oracle, The Java Language Specification, Java SE 21 Edition, Chapter 3.
Read the passage on the left. Answer each question by clicking a choice: the right answer turns green, and a wrong one tells you why. Questions point to paragraph numbers, as on the ACT.
1. Main idea
The main purpose of the passage is to:
2. Detail
According to paragraph 3, what was left out when the handwritten equations were turned into coded instructions?
3. Words in context
As it is used in paragraph 2 ("the rocket carrying it veered off course"), the word veered most nearly means:
4. Purpose
The author includes the sentence "The mistake is sometimes reported as a missing hyphen" (paragraph 4) mainly to:
5. Inference
Based on paragraph 5, a Java program has ten correct lines and one line with a missing semicolon. What happens?
6. Detail
According to paragraph 6, why are System and system two different names in Java?
7. Compare
According to paragraph 8, how does Java's use of = differ from the steps language used earlier in the unit?
8. Cause and effect
According to paragraph 9, the two lines of Java print 5 and 23 because:
9. Author's claim
Which sentence from the passage best answers why Java stops a whole program over one missing semicolon?
10. Figure
In the third panel of Figure 1, which symbol in System.out.println("Hi"); is labeled as the end of a statement?