A question was raised on Facebook last week asking about teaching truth tables and logic gates in an intro class in programming Python. The teacher who posed the question certainly appreciates the value of these topics but was wondering both how best to motivate the topics and if they were really appropriate in an intro programming course as opposed to, say, and intro computer architecture or electronics course or even a more general intro CS survey course.
This came up for me when I started at Hunter. One of my classes was and is a CS0. It was mostly an intro to programming in Python with a touch of C++ at the end but it also included:
- an intro to assembly
- Truth tables and logic gates
These topics were put in the class to prepare students for Hunters Systems/Architecture classes in the CS sequence. Classes they wouldn't see for a year or more.
I worked the binary and hex into a small project and ASCII was already covered in CS1 and I had my CS0 kids in CS1 so I left it for then. Assembly? I also left that for CS1 and talked a bit about it when we looked at the debugger and C++. I felt that was a much more appropriate platform rather than a random couple of lessons out of nowhere on assembly. In CS1, we were able to look at the assembly code generated by a simple C++ program and it actually meant something.
Truth tables and logic? I just left them out.
I was in a similar situation as my friend who asked the question and even though I couldn't make an official change in the syllabus, I made the decision to leave things out anyway.
Why did I do this?
Because you have to pay attention to the entire sequence when deciding what topics to put in which course.
Let's talk about truth tables. Truth tables aren't really a topic but rather a table to keep track of truth values from boolean expressions. It's a useful tool and pretty much the same idea as charting variables for tracing code and charting values for graphs - something they've likely done in math, science, and even history classes in high school. They've also seen truth tables in high school. I can't speak for localities out side of New York State but basic logic and truth tables are covered and just about all my students went to high school in New York state.
My kids need basic logic -
not mostly for use in
conditionals. They already know it and we review as needed but truth
tables just aren't necessary for my kids. There's another argument
that I've been given by my department for teaching truth tables again
anyway but I'll get to that and refute it later.
Logic gates, the other topic I just blow off. Logic gates make sense to teach in a computer architecture course, a systems course, any couse where you're doing low level stuff and even a general CS course where you want to demystify what's going on under the hood. In those contexts you can do some interesting and I'd say exciting things. You can show a half adder or full adder circuit to show the basics of how computers can do math. You can also show a flip-flip - rudimentary memory and other rudimentary circuits. This can be great in a "demystify" course and certainly in a course that's going to do a deep dive into the low level but in an intro programming course? Not so much.
It's just something out of place. You cover it for a couple of lessons and then the kids forget it. One could make the case that early exposure, even if it's cursory, helps students understand harder things later on but I don't buy that in this case. I buy that in the case of recursion. There, I think early exposure is helpful. That's because recursion involves some deep thinking. In this case, the logic gates material covered isn't really deep. It's basically just present. It is what it is - there's nothing deep to think about, at least on in the intro class.
In a way, it reminded me of something I noticed years ago in Algebra 2 and Trigonometry. Towards the end, apropos of nothing, there's a unit on the circle. It doesn't really fit in the course and it doesn't really introduce anything new that's meaningful but it's there nonetheless. Kids have to know it because they have to know it. Most of the course, right or wrong you can reasonably justify - the identities and algebra will help in calculus, for instance, but the circle unit is just there.
The best I could figure is that it was placed in back in the day. Back then, Alg2/Trig was a terminal course - it was the last math class that most students would take. This was before the precalc let alone calculus craze. Someone or some people felt that since this was the last chance, students should at least see some circle stuff so it got added in. Then, it just stayed there. Later, when Alg2 was no longer the last math course, the topic made less sense. It also became more clear that the circle unit didn't really prepare students for anything to come yet it remained.
This is why you have to look at the big picture. Not just an individual class but what came before and what comes after.
Back to logic gates.
The big argument I heard from the CS department was that they needed that for the Systems/Architecture sequence which is a 2 class, 6 credit part of the CS major.
The conversation would go like this:
Me: Should we really be teaching logic gates in CS0?
Them: Yes, it's essential.
Them: They need to know it in CS160 (the first of the sys classes).
Me: So do they?
Them: No, we always have to reteach it.
Me: So if you're reteaching it anyway, what's the point?
I teach around 20 to 30 students each year in my CS0. Given that we have over 1,000 CS majors overall, I teach a tiny fraction. My class is also an honors section.
All the other CS0 students are taught logic gates and truth tables yet the CS160 professors still have to reteach the material in CS160. What's the point? Time could be much better spent in CS0 diving more deeply into material more relevant to the CS0 experience.
So, I just didn't teach those topics.
I felt this was the right move but it could also have been really bad so i tracked my students. Each year, I surveyed them as to their CS160 experience. How'd they do in the class? Were logic gates taught assuming zero background? Was it hard or harder for them? Etc.
Turns out, I made the right call. Every year my kids did fine (actually, much better than fine). Every year the teachers retaught logic gates in CS160 from scratch and every year my students felt they missed nothing by not covering it in CS0.
I started writing this post because a friend asked about motivating logic gates in an intro programming class. Sorry to say, I didn't answer that question at all but it got me further thinking about pipeline and sequence and how we frequently don't look at our students education as a whole. Neither as a whole in our subject area or, even more importantly as w real whole - a whole student and whole person.
We really should.