Programming Languages for Teaching
Note that following article is dated and my opinions changed significantly since then
While reading Structure and Interpretation of Computer Programs book (sicp for short), I was amazed by how well the topics are explained. At first glance, the book looks like it's about programming, but it's actually more than that. Even though I'm still at chapter 3, I'm already in love with the book. Among other things it truly changes the way of thinking in general. All these things got me into thinking what made sicp so special? Why not all other topics are explained in such a manner in general teaching? I think among other things it's the explaining things with a mixture of natural language and a formal language. switching between them whenever necessary. Natural language for explaining common topics and formal languages for explaining "definite" topics. The formal language I mean programming language. As I'm interested in linguistics, I have been thinking why not use this innate ability of programming languages to teach other topics as well and get the same benefit?. I firmly believe this is to be true. That's a bold claim! Let's see a few points which I think backs up this claim. This idea may not be something new. My main intention in writing this to get a clear picture for me and have a discussion with others to improve my understanding.
Premises
The key difference between natural language and formal language is ambiguity or inexactness. Its surprising to see how we even make sense of any natural language sentence. The framing of words, sentences, sounds(phonetics) everything is full of special cases. There is no single generic rule (or grammar) for these things. The natural language I mean the language we all learn, the one we speak. Not the one taught in school, which is more of standardized language. See constructed language.
Ambiguity in natural languages mainly due to its reliance on context to make sense. When someone says "Write your name", it's grammatically correct but it's unclear whether he is asking to write the name of the person or to write "your name". Though we make sense of sentences like this daily. Formal languages are exactly opposite in this regard. By definition they are unambiguous. A formal language sentence can't have two different meanings. That's why we have a special formal language for mathematics.
Programming language
Programming language a formal language. When we think of programming language we usually think of "telling" computer what to do. Programming languages are now separated enough from the computer that we can now write programs without actually understanding how the computer works.
So what?
Just as natural language serves as a tool for thinking, we can use a the programming language to understand things better or easier; as a tool for education. We can use a programming language to understand topics which are 'exact' in nature. We have mathematics for the exact same reason but I think a programming language huge benefit over it. not only that mathematics have various confusing different notations (does <code>d(x+1)/dx</code> means division or differentiation) it also unifies all different notation for describing things which are 'exact'.
How?
For understanding.
DSL (Domain Specific Language) with and REPL kind of environment is the best tool to just try out different possibilities. Take the example of understanding kinetics. In the current model of teaching students are taught some rules and formulas and some cliché examples and expected to understand and get intuition. Instead, if you provide an environment with proper DSL for the topic (maybe be some fancy animation), students can explore possibilities to get the intuition of the topic. One might ask "why bother with a programming language? a simple UI with GUI elements such as seek-bar and an input box to change parameter is more than enough!". but only so much you can do with the limited combination, instead if we provide the ability to combine different things (such as ability to try different formula itself), students can try different combinations of the rules and figure out why things are the way they are. What we are essentially giving here is the ability to "change" and "define" the rules itself. Unlike playing along with the already defined rules, which traditional teaching promotes. This ability to combine and define different things cannot be fully realized without a language, language's recursive nature is very essential in combination.
For experimenting
To understand a topic, experimenting with it is essential, current model of teaching provides very less importance to experimenting. Programming languages might fill that gap and give easy means to 'experiment' and pattern match the results. Seeing the changes immediately makes the learning more interesting and more involved. Bret Victor talk on "Inventing on Principle" may be relevant here.
For expressing
I often find myself struggling to explain topics which are "mathsy" or related to logic. Almost always I end up mixing words from the programming language and natural language. Having common languages explain these sort of things might solve this problem. Maths fill this void but partially because of lack of uniformity. A common programming language might fill this gap. It can act like a natural language for explaining topic leaned towards logic.
As a tool to hide the complexity
All high-level programming language has a weapon called "Abstraction" to fight complexity. Abstraction is a tool to hide complexity by separating problem into layers. This aspect can be utilized to make teaching focused on one topic or layer. Like having a DSL and explaining the topics incrementally make the topic at hand simple and focused. Sicp has a various example illustrating this. Especially picture language, explaining the combination of drawing first and then explaining the drawing primitive. This aspect forces us to think why we have to define primitives in the first place. Another example of finding square root is the best to showcase how things can be explained incrementally. Gradually explaining the fixed point formula is arguably the best way to explain some topic. Though abstraction is not unique to a programming language, programming language forces us to think in a certain way and draws the clear line between layers of abstraction. From my personal experience understanding and implementing church numerals was a insightful experience. I think It is possible because of clear abstraction.
For evaluation
With the current model students are evaluated based on their "explanation" of the topic or asking for things they "remember". I don't think explanation actually reveal much about understanding. Sometimes they can't explain the intuition they have. Ability to explain is definitely a good thing to have but that should not be a measure to evaluate understanding. Evaluating practical activity which utilizes their understanding might be better. For example, to evaluate students understanding of kinetics, we can provide a physics environment with slightly different DSL to the student. And can ask them to show or create something in that environment based on the understanding.
Just as a language, for its own sake!
Same as natural languages, we can explore programming language to create/express art. There are already various examples, which use programming language as a tool to create something. To name few sonic pi for sound processing and processing for generative art and all other kinds of visual art.
What languages should we use?
All this fine and dandy only if we have a simple language. If teaching language itself is a big hurdle then there is no point in doing so. Current programming languages are more focused on "programming" aspect, we need something more 'simple'(no pointer etc). As this is a tool for explaining general topics. I think something like Lisp fits perfectly. Its simple enough that basic syntax can be explained in 4-5 hours and its homoiconic nature blurs the line between code and data distinction which is essential 1. obviously, I'm biased because of sicp.2 The point is it's not about the language's syntax but the properties of all high-level language.
Final thoughts
There is no doubt that we understand some topic better with a different approach or explained using a different medium (for example, Explaining calculus visually). The languages we use might actually affect our thinking. We just have to try. Using programming language for teaching is partially explored. For example scratch (But the goal is different though). Maybe using formal language is not that effective in practice or maybe teaching the language itself is a big problem. But It's worth exploring