When you're learning a computer language, don't even try to learn what everything means.
Learn what everything does.
Discussing books that teach coding, a reader laments:
Without clear definitions of words, the new learner spends most of his time defining them….
He’s right. Many definitions are mind-boggling.
Here are three prominent authors trying to define a basic programming term.
Definition 1
To catch and hold values, JavaScript provides a thing called a binding, or variable.
Definition 2
JavaScript variables derive their types based on the values they are assigned at run-time….
Definition 3
A variable is a named reference to a value. That way an unpredictable value can be accessed through a predetermined name.
If you understand these definitions, it can only be because you wrote them.
How about this one?—
What is a closure?
A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment).
I teach programming languages, and I can’t follow that.
To avoid confusion, I teach variables to beginners this way.
Let’s take JavaScript as an example.
First, I show how to code an alert…
alert("Hello, World!");
…and then what happens when the code runs…
Then I replace the text with a variable in the alert statement…
let greeting = "Hello, World!";
alert(greeting);
…and then what happens when that code runs—the same thing.
So the beginner intuitively grasps the essence of variables—without needing a definition.
Of course, there’s more to know about variables than that. But I teach those things the same way—by demonstrating, not defininig.
And I follow the same practice all the way through the book, always showing concrete examples, so the learner can see the thing in action without worrying about confusing abstractions.
How to do it without buying my books—or any books.
One of the most generous, most helpful sites you’ll find on the Web is W3 Schools. Their tutorials teach with examples—and minimal flights of pedantry.
Most important, their Try It Yourself feature lets you practice live coding.
And it’s all free.
Here’s their Try It Yourself page that teaches the alert statement. I’ve edited the image to squeeze it into this post and to show the alert statement highlighted.
The tool isn’t perfect. For example, the JavaScript shown in the lefthand panel contains four pieces of code that the learner hasn’t studied yet, a no-no, in my opinion.
Frankly, I often take exception to W3’s lesson structure. For example, the first ten lessons are shown below.
I believe coding knowledge should be built like a pyramid, with each lesson resting on a foundation of prior knowledge.
That is: First, you learn to code an alert. Then you learn to do it with a variable. Then you learn to do something else with the variable.
W3 doesn’t adhere to that notion. The order of lessons is pretty random.
Still, those Try It Yourself exercises are invaluable. And if you’re learning from a book, close it every five minutes, so you can visit W3 Schools to search for the same topic and its Try It Yourself practice.
More free exercises
If you’re learning JavaScript or Python, you’re welcome to create your own study plan by borrowing the outline of my free online exercises. The exercises are keyed to the chapters of my books, which use the pyramid-building structure. It isn’t necessary to buy the books (but isn’t prohibited, either).
You may even want to use my exercises to practice with someone else’s book that you did buy. After reading about a topic, look it up on my index of exercises, like the one shown above.
Anything to make your learning journey less of a death march.