Friday, January 09, 2026

Binary Math–Subtracting by Adding

Some of my readers who have been teaching Advanced Placement Computer Science (APCS) will remember the BigInt case study. It was a case study involving mathematics using large (very large) integers. As released by the College Board it supported adding, subtracting, and multiplying large integers. You will notice that division was not included. In fact, asking students to implement division was part of the exam.

BigInt introduced the idea that multiplication was actually multiple addition. By extension, students were to figure out that division is multiple subtraction.

Computer science really requires understanding how mathematics works at a deep level. It becomes obvious (one would hope) when trying to understand how Binary, Octal, and Hexadecimal work. We don’t often spend much if any time trying to understand subtraction though.

Recently, on BlueSky I can across a message by Andrew Virnuls linking to a blog post titled Two's Complement and Negative Binary Numbers that explains subtracting by adding negative numbers.

Let me draw the two previous notes in this post together with some history of mine. Back in my university days I worked on a course connecting some test hardware to a computer. The computer was a Digital Equipment PDP-8. Now the 8 was an interesting machine. It didn’t have a hard drive and it was programmed in assembly language entered in Binary. Where as most computers we use today use hexadecimal representation (base 16) the PDP-8 used Octal (base 8). The word size was 12 bits. Not 64, 32, or even 16 – 12.

This word size places some limits and one of those limits was the number of machine language/ Assembly language instructions. There was no multiply, divide or even subtraction instruction. We had to write code to do those things similar to how code was written in BigInt for those operations. We also had to write code to do subtraction. There was an instruction to create the two’s compliment of a number though. That was handy. So we wrote code to find and use the two’s compliment of a number in order to do subtraction.

We used the subtraction routine to implement division. Though to be honest, we tried to avoid having to do multiplication or division in our project to keep performance reasonable.

I think we’re all glad that today’s computers have a lot more layers of abstraction than the PDP-8 had! Of course, and a lot of students do not realize this, most powerful assembly language instructions are actually the result of what is called microcode that works transparently behind the scenes.

We keep moving up the path of abstraction. Hal Berenson addressed this recently in a post called 98% of Developers can’t program a computer which is actually a bit of a success story including how artificial intelligence is helping with higher levels of abstraction.

Saturday, December 27, 2025

AI Written Code and Making Assumptions

I’ve been writing some code for my own amusement the last few days. I have happily using Microsoft CoPilot to help me out. One really has to be careful with prompts though. CoPilot loves to make assumptions about what the developer desires. Often, it assumes correctly. Often enough, it assumes incorrectly.

I spent a good bit of time trying to figure how where it was doing some things I didn’t want done at all and other places where it got my intentions backwards. For example, we both had different ideas about what a variable called _defaultColor should refer to. That took me a bit.

I could have tried to ask CoPilot to fix the problem for me but if I had a better idea of how to express what I wanted it would probably have gotten things right, for my definition of right, the first time. So I fixed it myself.

I also made some assumptions about what certain methods were doing. I mostly assumed correctly but mostly is not really good enough when dealing with code. I really should have spent more time reading the code and making sure I understood it before trying to modify it. Yes, I said it before knowing how to read code is more important than ever.

Reading code on a screen can be painful though. One tends to get a sort of tunnel vision looking at little bits of code at a time. Many years ago I worked with a developer who had a terminal that was originally developed to typesetting at newspapers. It was tall and could hold a lot of lines of code. It was great for reading code. I don’t have anything like that. For me, the answer is printing listings out on paper. Maybe its just me but that is what has worked well for me for over 50 years of writing code.

I have more modifications I want to make to my program. I’ll spend some serious time reviewing the generated code before I try to make those modifications.

Related read: "Source code is the literature of computer scientists." https://www.cs.uni.edu/~wallingf/blog/archives/monthly/2025-12.html#e2025-12-26T18_28_37.htm A post by Eugene Wallingford

One other note, CoPilot added a lot of helpful error handling code to what I asked. That’s awesome in a lot of ways. I think that spotting a lot of error handling code may be something that tips off an educator that a student used artificial intelligence to write their code. Keep a look out and be sure to ask the student to explain it all.

Thursday, December 11, 2025

Computer Science Education Week Greeting Cards

Seems like several years now I have joked or perhaps half joked that there are no Computer Science Education Week greeting cards. Have any of my readers seen any? It turns out that someone on Etsy offers some. I wasn’t impressed but at least someone else was thinking about it. Having students create cards might be a fun project.

What would they look like? What sort of message might they have? The most obvious might be some sort of thankyou to CS educators. That’s what the Etsy ones look like. It’s not a bad idea really.

Perhaps some sort of message encouraging students to try An Hour of Code (or An Hour of AI) might be a good idea.

Perhaps something related to Grace Hopper as the week her birthday falls in is the week selected for CS Education Week.

I have to give this some more though. I am looking for suggestions. I will have to remember to bring this idea up earlier next year.

Monday, December 08, 2025

How Much Debugging Knowledge Do CS Teachers Need

Mark Guzdial's blog is number one on my “must read” blog list. If you are a computer science educator it should be on your list as well. Mark had another particularly interesting post recently.

Dr. Tamara Nelson-Fromm defends her dissertation: What Debugging Looks like in Alternative Endpoints | Computing Ed Research - Guzdial's Take

In it, Mark talks about some of the work by his student, Tamara Nelson-Fromm. interesting stuff and I hope to read her papers when they come out next year. One question from Mark’s post really hit me:

“[W]hat does a K-12 teacher need to know about debugging?”

A partial answer given is “maybe it’s enough to just have checklists.” of things to check. Now “maybe” is a big word. I wonder how far it goes? That is to say, how often is a checklist enough? What happens when it isn’t enough?

I’m reminded of Kernighan's Law:

Everyone knows that debugging is twice as hard as writing a program in the first place. So if you’re as clever as you can be when you write it, how will you ever debug it?

Students write code that is as clever as they know how. If a teacher is more experienced and more knowledgeable than their students they maybe able to handle any problems the students have. The word “maybe” comes to play again. Over the years I have had a number of teachers approach me with a student program they could not debug. I’ve had to get help myself from time to time. Debugging is hard.

[As an aside, I love debugging code. It may be more fun for me than writing original code. I may also be weird.]

Experience helps of course. I have debugged student code without looking at the code. Lots of teachers have done the same. We do see a lot of students making the same errors year after year. Students are good at coming up with unique bugs though. They’re clever that way. (See Kernighan's Law) That’s where checklists are likely to come up short.

Why is this a problem? After all, students do, generally, fix the problem. Sometimes on their own and sometimes with help. For different definitions of “fix the problem” of course. There are always workarounds. That is especially true of the type of projects assigned to beginners.

My concerns start frustration levels. The cognitive load of learning to program is high already. Spending a lot of time on a bug can be very frustrating and that can be a turnoff for students. A demotivator. Worse, if the teacher can’t solve the problem what chance does the student have? Maybe programming is too hard!

Circling back to the teacher, if they don’t have a good plan for debugging than they are not likely to be able to teach students how to debug. Sure they can share checklists and that’s not a bad thing. Like most things, students will learn more by watching a teacher model debugging than from reading about it.

Now when we are teaching, most of us try to avoid making mistakes or creating code with bugs. Generally, we practice demos multiple times to make sure we can demo the code error free. Yay us, looking like we are amazing. The occasional error, planned or otherwise, is a teaching opportunity that should be welcomed however!

Circling back to the question asked earlier, how much should a k-12 CS teacher know about debugging? It’s hard to come up with a definitive answer. Probably more than is covered in most professional development though. Arguably, it should start with technical knowledge a good bit beyond staying a chapter ahead of the students. So more than a lot of teachers who have been voluntold to teach computer science have.

They should also have some solid experience reading code. Now a few years of teaching will give you some good experience reading code. It will give one a lot of experience seeing errors as well. That’s not much help for a beginner teacher though.

I’m not sure what the answer is and finding time in the already far to limited time for training that new teachers have now is a struggle as well. I am uncomfortable with the idea that “it’s enough to just have checklists.” though.

Wednesday, December 03, 2025

Are We Really Teaching Artificial Intelligence

According to Code.ORG

The Hour of Code is now the Hour of AI

The Hour of AI makes teaching AI literacy easy, engaging, and fun. Empower your students to become the next generation of innovators with AI.

Of course the web site has a lot of activities that are still labeled “Hour of Code” but it raises the question: What does it mean to teach artificial intelligence?

In a conversation, a very smart friend talked about how there was a time when we taught Office applications (Word processing, spreadsheets, and the like) and called those classes computer science classes. That’s not real computer science and the CS education community has fought that characterization for years. With some success!

My friend made the comment that much of what is called teaching AI today is the AI equivalent of teaching the Office application of AI and not the science of AI. For example, is teaching AI teaching how to use an existing AI tool and having students train it to recognize some type of object. Is that the same as teaching how the AI works or what sorts of algorithms are behind the training? Of course not.

Likewise, teaching students how to write good prompts to a LLM is not the same as teaching how a LLM works. In fact, I would argue, its not any different from teaching students to write good instructions to another person.

Now I am not saying that learning how to write a prompt or train a machine learning tool is not valuable. Clearly it is. Arguably it is even necessary. But is that really teaching Artificial Intelligence in the same way that a course like AP CS is teaching computer science? Or is it more like teaching applications without teaching how it works?

I have heard the argument that students are not ready to learn how AI works or that the algorithms are too complicated. I would agree that students may not be ready to create an AI at the level of ChatGPT but that doesn’t mean they cannot handle the concepts behind that sort of software.

The truth is that a lot of what AI, especially machine learning and Large Language Models are doing is not really that new. What is new is that we have lots more data for AI to work with and we have processing speed that is a lot faster than what we used to have. Machine learning is heuristics on steroids. LLMs are data analysis with lots more data and faster CPUs.

We had software learning by asking questions and trying different options 50 years ago. Now we have the software asking itself the questions and finding new paths based on data. We had rule based software for decades but now we have better algorithms to evaluate data against rules. We’ve been studying text looking for hidden meanings throughout history. Now we have more text for algorithms to analyze and the ability to analyze in more ways in less time. We can start with simple data sets and basic concepts that teach the roots of AI. Students can deal with it. They do that sort of thing with human intelligence all the time.

If we are serious about preparing students for the future of AI we really need to get serious about teaching some depth of concepts. Let’s not stick with the Office applications equivalent and lets move on to the real science.

Saturday, November 29, 2025

Teaching Reading Code–More Important Than Ever

Thanks to Facebook memories and a link that was almost a dead link I reread a post on my old blog – How To Read Code. It got me thinking about Artificial intelligence writing code. What? Let me explain.

If students are going to use AI to write code they are going to have to know how to read and understand it. There are several reasons for this. One is that AI almost never write 100% of the code necessary for a project. Without being able to read and understand the generated code students will be unlikely to be able to take the project to the finish.

Reading code for understanding can also be helpful to learning more about computer science. Not just coding but computer science. Code is the language of CS but there is a lot more to understanding computer science than just writing code.

AI systems have been trained on a wide variety of code samples from a wide variety of developers with a wide variety of coding styles. That means that students reading AI generated code, potentially, have exposure to more styles and techniques than their instructors are likely to show them.

Having students read explain the code they read can be a powerful tool for their learning and for teachers to use for evaluation. Keeping students from asking the AI to write the explanation is probably a good idea though.

All of this makes me think about code reviews (Archived blog post on that - The Art of the Code Review)  Organizing code reviews may also be a good teaching tool. Reviewing student code, AI generated code, or perhaps publicly available code examples on the internet. If AI can train on other people’s code why not students?

I am wondering what having an AI explain student code would look like. Would it help students understand their own code better? It might. I have seen a lot of students tossing different code snippets into a project hoping it would work but not really understanding what the code was doing. Would it also help them understand the process of reading code? Interesting idea I think.

Wednesday, November 26, 2025

Monty Hall Problem and the Problem of Artificial Intelligence

I’m always looking for interesting projects. The other day I ran into the story of the Monty Hall Problem. The brief version of this logic/probability problem is based on a famous game show. In the hypothetical, a player is trying to win a car. Behind two doors are goats with a car behind the third. The player picks one of the doors. Before opening the door the show host opens a door, a different door, and shows that there is a goat behind it.

The player is then given a choice – stay with their first guess or switch to the different door. What’s the best option? The answer from Marilyn vos Savant who has the highest recorded IQ was that the player should change their guess.

This answer was highly controversial with many experts in probability and math saying she was wrong. Computer simulations showed that she was right though. There is an explanation for this in the Wikipedia article linked to at the top of this post.

If you know me at all, you can probably guess that I had to write a simulation myself. Trust but verify! I think it makes a good project to assign students as well.

There is a little fly in the ointment for me though. I crated a project with the name “Monty Hall” and with almost no other hint than that and Copilot in Visual Studio started writing code for the simulation!  Well, that was a surprise.  I have mixed feelings about the help. It made writing the simulation easier for me but it kind of took some of the fun away from it as well.

Copilot’s code assumed form objects that I had not created as well. It didn’t create those objects automatically. Fortunately for me, I know enough about Visual Studio and Windows Forms that I could add them easily enough. I am also experienced enough that I added other code and objects to make the project more me.

Also, as an experienced programmer, I was able to easily understand the generated code. The code generated is a little different than what I would have generated. Better? Worse? Really, just different. No big deal for an experienced programmer.

What about students? As teachers, we probably don’t want students having AI write 90% of their code for them. Copilot can be turned off and doing so is a very good idea in classroom and school lab situations.

Will students understand the generated code? In many cases, probably not. In this case, the generated code used the the ternary conditional operator. This is a perfectly valid operator in C#, Java, C++, and several other languages. It’s not often taught to beginners however. It also used a break statement which a lot of software purists do not approve of and strongly teach against.

So determining if a student used AI to write their code may, in some cases, be easy to determine. Not something you want to bet on though.

Circling back to the assumptions that Copilot makes – like objects and variables not defined automatically – students may struggle with adding the missing pieces. I would expect that in some cases trying to add what AI leaves out may be more problematic than writing code on ones own. Frustration is a common problem for students already. Artificial Intelligence may, in some cases, exacerbate the problem.

As I have noted in several blog posts, AI often creates solutions different from how I would code them. That has been a learning experience for me. I love seeing different solutions, different language features, or features used differently.

It is potentially a learning experience for students as well. My concern is that without a solid knowledge base will students be able to really understand and learn from AI generated code? Some will. Many will not.

We’re all trying to figure out what artificial intelligence means for software development and especially for teaching software development. It’s going to be a wild ride for a while.