Becoming a Better Writer Through Computer Programming
Dec 18, 2023Do you want your kids to become better writers? Give them the chance to learn how to program! At first glance, that might seem nonsensical. After all, computer programs are often terse, hard to read, and use weird punctuation. How is that a model you want your kids to emulate when they write?
The point is not that you want their writing to look like a computer program. That would be nonsensical! Instead, computer programming helps teach the importance of things like appropriate word choice, spelling and capitalization, correct use of punctuation, and other skills that transfer directly to various forms of written communication.
Grammar and syntax
In elementary school (or what some used to call "Grammar School"), students begin to learn to rules for both spoken and written language. Grammar is the set of rules that allow us to make sense of language. Syntax is a subset of the grammar rules that deals with how "words are put together to form phrases, clauses, and sentences."
Every computer language has its own rules for grammar and syntax, too. These rules are not the same ones we use to speak and write correctly - otherwise, we'd be able to write computer programs in plain English! By learning grammar and syntax of a specific programming language, we come to better appreciate the rules that govern our own language.
What's the right word?
Compared with written and spoken languages, computer programming languages tend to have smaller overall vocabularies. That means that there are fewer words to pick from. According to the Washington Post, the Inuit and Yupik peoples have at least 50 words for snow. Many of these share a common root with something like an adjective added as a prefix or suffix that further qualifies or describes the snow. However, most programming languages have only a single word for a particular task or purpose. There might be similar words, but they are not likely to be perfect synonyms -- they cannot simply be swapped with one another. Instead, each probably results in some subtle difference in behavior.
For example, the Java programming language has two statements that print text to the screen. One is named print
, and the other is named println
. While they both print to the screen, one moves the cursor to the next line and the other does not. If you use one when you mean to use the other, your program will not work properly. Just like knowing how one word for snow conveys a slightly different meaning than another, knowing the difference between these two print statements is important. Further, while words like "snow", "slush", "sleet", and "frozen precipitation" might conjure similar images for a person, trying to use something like "display" or "put" in programming won't work if the correct command is "print".
Does spelling count (and what about punctuation)?
When I was in school, it was common to ask "Does spelling count?" in classes like Social Studies and Science. Since these were not language classes, we shouldn't be expected to use skills and concepts from Language Arts, right? Well, regardless of your opinion on that subject, spelling always counts in programming. What's more, capitalization almost always counts, too! Most computer programming languages are case-sensitive. This means that the computer treats words that are spelled the same but which have different capitalization as unique. In a case-sensitive programming language, "SomeValue", "somevalue" and "someValue" are all different. This can lead to hard-to-find issues in the code, but it encourages the programmer to develop the ability to think carefully about what they are writing and then to read carefully when looking for mistakes.
In many programming languages, something as simple as a misplaced semicolon will either cause the program not to run at all or (worse!) run in a manner different from what is intended. For example, the following code is valid in languages like Java, JavaScript, C, and C++. However, it doesn't do what it appears was intended. In fact, it would most likely cause the program to hang!
while (theValue < theMaxValue);
theValue = theValue + 1;
The problem is the semicolon on the end of the line with the while
statement. The languages in which this code would be valid use the semicolon, not the way the code is indented, to determine where the end of the loop should be. Even though the line that should be executing each time through the loop to increment theValue
appears to belong inside the while
loop, the semicolon marks the actual end of the loop. Therefore, so long as theValue
is less than theMaxValue
, the computer will do nothing! The semicolon acts like an empty statement.
Programming languages tend to make use of a wider set of punctuation characters than we use in written language. How often in everyday writing do you use the curly brace characters ( { } )? Or the tilde ( ~ ) or the caret ( ^ )? Punctuation characters in programming also sometimes have meanings that are different from what we are used to. In most programming languages, the asterisk ( * ) is the symbol for multiply, slash ( / ) means to divide, and percent ( % ) is a little-know math function called modulo that returns the remainder of a division operation. Python even has a double slash ( // ) operator that performs integer division where any fractional part of the quotient is dropped and the result is always a whole number.
To further complicate matters, the same obscure punctuation mark might have different meanings in different contexts. For example, in some languages, the ampersand ( & ) means "memory address of" when used in front of a variable. When used between two variables, it is a mathematical operator that performs what's called a bit-wise and. Finally, when two are used together ( && ) between two variables, they serve as a boolean and to combine two conditions into a single compound condition as in, "If it is raining AND I plan to go outside, then I should take an umbrella." The point here is not to provide a deep explanation for the ways these punctuation characters are used in programming. Instead, it is to show that programming teaches one the value of using punctuation characters properly and in accordance with the grammar and syntax of the language.
Breaking the rules
Someone once told me that English is one of the easiest languages to speak poorly and still be understood. We can often make sense of a sentence where the subject and verb don't agree, when a missing comma technically results in a run-on sentence, or when we use the wrong preposition. In other words, breaking the rules often has little impact on the meaning. This is definitely not true in the world of computer programming. The computer that attempts to run your program will never overlook an error. It will be stricter than the strictest Language Arts teacher your children have had or ever will have! If the program violates the grammar and the syntax of the language, it simply won't work.
Programmers quickly learn that making mistakes that result in errors is part of the process. They realize that the computer is not passing judgment on their code or their abilities as a programmer. Instead, it is simply saying that the code is objectively wrong. Most modern development environments try to provide helpful error messages that attempt to identify the location and the nature of the problem. Sometimes, the error messages include hints or suggestions that might fix the problem. Finding and fixing errors in code helps one develop better skills in proofreading, and it teaches them to accept feedback and criticism without seeing those as personal attacks.
Summing Up
Outside of academic and professional settings, we can generally get away with breaking many of the grammar rules that define our language. As a result, we can develop bad habits that carry over into more formal speaking and writing. Over time, we might even begin to forget the rules we were taught through our many years of schooling. Programming a computer puts us into an environment where the rules matter. We have not yet developed a robust programming language capable or working with what's called natural language.
Being forced to follow the rules of a programming language makes us more sensitive to things like correct and appropriate word choice, spelling and capitalization, and proper use of punctuation. As we learn to pay attention to these things when programming, our brain naturally begins to think about them in other contexts where the rules are less important. This is called the Baader-Meinhof Phenomenon, and while you may never have heard that term, I suspect you've experienced it. Once you become aware of something, you begin to see and make connections to it in lots of situations. For example, you learn a new word and suddenly it seems like everyone is using it.
So why not give this a try? Give your kids the chance to learn a programming language (particularly in a text-based language where the grammar rules are an integral part of the process) and see whether their writing improves. We can actually help with that. The Excalibur Solutions STEM Academy offers subscriptions to self-paced video lessons designed by educators and grouped into projects that teach computer programming, electronics, 3D design, and other concepts from Technology and Engineering - the T & E in STEM!
Stay connected with news and updates!
Join our mailing list to receive the latest news and updates from our team.
Don't worry, your information will not be shared.
We hate SPAM. We will never sell your information, for any reason.