Friday, December 31, 2021

Looking Back on Computer Science Education in 2021

I’ve never felt less prepared to write a look back on CS education than I do today. I’ve been retired from most of the year and the world has been changed a bit because of COVID. I have noticed some things have clearly happened. One is the increase in online development tools which I talked about a year ago. The other is an apparent growth in cyber security education.

I’ve also noticed some increase in virtual reality programming courses as well. How that will go is anyone’s guess. There are two barriers. One is that VR hardware is still expensive. It’s not just devices like the Oculus but also computers capable enough to support VR and its development. A lack of training is also a barrier. Most teachers seem to be learning on their own with help from documentation and videos from companies. That and some support through social media from other teachers.

The Unity Teach Community has well over 2,000 members and is very active. I highly recommend it if you are looking to get involved in teaching VR.

Online teaching and programming tools have really taken off. The code.org courses support this sort of thing but they are far from the only option. CodeHS for example shows up a lot in social media discussions. As does Coding Rooms. And repl.it. I should probably collect a list of them for a future post. Perhaps you could add your favorites as comments and help me out?

Cyber security has also seen a lot of growth. Cyber.org has a lot of materials and provide cyber security professional development. Social media support for teachers coming from teachers has also been growing. I recommend the Cybersecurity Educators Facebook group. Over 1,000 members and active and growing. This field is going to boom as security gets more attention all the time.

Every year I expect  the Internet of Things to take off but it never really does. The pandemic has made doing any sort of physical computing more difficult. But I keep hoping.

Machine learning and artificial intelligence didn’t seem to pick up a great deal but it is growing. AI 4 K12 has a lot of useful resources from teachers and I recommend checking them out. Most of what I see in K-12 AI is units in existing courses and not specific full courses. That’s probably best at the K-12 level. The math and coding involved in creating AI from scratch is intense. Learning how to use existing tools is both useful and age appropriate.

So progress has been made and that’s a good thing. 2022 should be interesting. Hopefully, in a good way.

Monday, December 06, 2021

Computer Science Education Week 2021

Well, its CS Ed Week again. Still no cards in the Hallmark store for it. I’ll get back to that in a moment. CS Ed Week has long been a time to introduce more students to computer science. When it started there were only small percentage of schools that offered any computer science education at all. We’ve made a lot of progress. There is still a long way to go though as even though more schools offer CS the number of students taking it are still very low.

There is no shortage of ways to introduce students to computer science during CS Ed Week. Hour of Code is probably the best known and widest platform in use. And it is a great one.Miles Berry has several activates in his blog post Five (out of twenty) things to do with a computer with more information about using Turtles one another blog post - Make a Turtle!

I never made a big deal of CS Ed Week when I was teaching for the very simple reason that the school I was teaching at required a full year (or two semesters) of computer science as a graduation requirement. Getting students to take courses was not an issue. We spent more time trying to make the course interesting, relevant, and even fun while being rigorous.

In hind sight, perhaps I missed an opportunity to have students celebrate what they were doing though.  There are some activates not involving code that we could have done. Maybe you want to try them as well.

Grace Hopper – The timing of CS Ed Week is the week that includes Grace Hopper’s birthday – December 9th. So it is a good time to talk about her and other women in computing. Women have played a huge and often underrecognized role in computing. Maybe younger students would like to make Grace Hopper birthday cards?

CSTA ran a number of contests for student for CS Ed Week some years ago. They make good activities. For example, filming a PSA video to promote computer science in general or specific courses. Posters to promote taking a CS course might be fun. In fact, have students create posters for a specific course that might be over looked. That may help fill courses that students don’t understand from a course description in a program of studies.

Speaking of programs of studies, ask students to write their own description of the course they are or have taken. You may gain insights into how students view the course that help you make the course better.

About that greeting cards, what would a CS Ed Week greeting card look like? Ask students to create some. Let’s make is have a celebratory feel!

Friday, December 03, 2021

First - Understand the Problem

Things are different for me being retired. I don’t get the blogging inspiration the way I used to. Today a post by Mike Zamansky (Work through the example!!!!!) got me thinking. I used to talk to students about problem solving and one of the things I tried to highlight was the need to understand the problem as completely as possible.

All too often students read or listen to instructions lightly and make assumptions that are not really supported by what has been presented to them. It is often tempting to skim and assume with the idea that it will save time. It works often enough, for simple enough problems, to help people to fall into the trap of thinking they are smart enough to do this always. Until it doesn’t work.

It’s hard to get students to focus on understanding the problem completely. Honestly, it can be hard for more experienced people to do this as well. The urge to jump into the coding is strong. I have been known to start coding too early myself. The more important the project/problem the more important it is to make sure you really understand the problem.

In what seems like a different life I was a developer in an operating system group. The sub team I was on was writing a new print/batch subsystem from scratch. The three of us spent weeks looking at what features should be there and how they should be set up. We spent more weeks designing the code. All before we wrote a line of code. Honestly, the groups leadership was on our case to start coding before we were done understanding and planning. Long story short, we finished on-time without having to work crazy overtime hours. Planning paid off.

It’s a story I told regularly to students over the years. It may or may not have helped but I tried.

Monday, November 08, 2021

Money is Hard in Programming

Last week I wrote about the making change for a dollar project. It got me thinking about how hard dealing with money in programming really is. The problem with money is that 1/10 is an infinitely repeating fraction in Binary.If one adds 1/10

Take the following C$ code.

double penny = 1.0 / 10.0;
double dime = 0.0;
Console.WriteLine(penny);  
for (int I = 0; I < 100; I++)
{
     dime += penny;
}
if (dime == 10.0) Console.WriteLine("Dime");
Console.WriteLine(dime);

One might expect that the word “dime” would be printed but it’s not. What this code actually prints is the following.

0.1
9.99999999999998

The 0.1 is expected but as you can see, adding the 0.1 100 times doesn’t give exactly 10.0. The problem often doesn’t show up right away. This sort of thing often confuses beginners because the programming language “helpfully” hides the issue. When I had the program display the value of “dime” after every addition the discrepancy don’t show up until around 6.0.

5.8
5.9
5.99999999999999

It’s not only beginners who struggle with this issue. It’s a pretty common issue and some languages support a currency data type for that reason. The currency data type adds some overhead to operations and not everyone is a fan of using it. A different alternative is to use integers and insert a decimal point on display.

One of the first programming languages I used for business related software, called DIBOL, didn’t support floating point numbers at all. It supported 18 digits of integer accuracy. It was an interesting language. Using it did make it easier for me to think about using integers for money later in my career though. Most beginners don’t have that sort of a helpful start. They are used to thinking in digital rather than binary. To my way of thinking this reinforces my thinking that learning binary is an important part of computer science education.

Thursday, November 04, 2021

How Many Ways to Make a Dollar

I ran into a reminder of an interesting programming problem the other day. One I meant to use with students but never did. Other teachers I know do use it. Simply pot, how many possible combinations of coins are there that add up to a dollar. It’s easily solved with a set of nested loops like the ones below.

int count = 0;

for (int halves = 0; halves <= 2; halves++)
{
     for (int quarter = 0; quarter <= 4; quarter++)
     {
         for (int dimes = 0; dimes <= 10; dimes++)
         {
             for (int nickels = 0; nickels <= 20; nickels++)
             {
                 for (int penny = 0; penny <= 100; penny++)
                 {
                     int value = halves * 50 + quarter * 25 + dimes * 10 + nickels * 5 + penny;
                     if (value == 100)
                     {
                         count++;
                     }
                 }
             }
         }
     }
}
Console.WriteLine(count);

It’s pretty straight forward. The key thing is understanding what coins there are and what their value it. The code above doesn’t include a dollar coin. Should it? Probably but it depends on the way the problem is specified. Also these are the coins currently being minted. Over the history of the country there have been a number of other coins in circulation

US TREASURY: What denominations of coins are no longer being produced?

There are quite a few denominations of coins that the United States Mint does not produce any longer for general circulation. They are the half-cent coin, the two-cent coin, the three-cent coin, the half-dime coin (although it was replaced by the five-cent coin), a twenty-cent coins, and the various denominations of gold coins. Although the Mint does produce a series of gold bullion coins, these are not intended for circulation.

The problem would be more interesting if some of these were allowed. I keep thinking that there must be another way to solve the problem though. I just can’t think of what it might be.

[Edit] Jeremiah Simmons shared information about solving this problem using Dynamic Programming. It's more complicated but scales better. Take a look. Understanding The Coin Change Problem With Dynamic Programming

It is so sawesome when educators share ideas with each other.

Thursday, September 30, 2021

Define Learn To Code

I saw an interesting question today on Twitter:

My first response is that there is no definitive answer to that question. I thought about it for a while. One can learn to program by hooking a Raspberry Pi to a monitor, keyboard, and mouse and firing up Thonny and learn Python. One can use any number of online IDEs and a Chrome book. The last classes I taught had a mix of students running Eclipse and Processing on Mac and PC laptops with no appreciable difference. In short, does the computer even matter?

Maybe there is a question that has to be asked and answered before discussing the right or best laptop to use. That question is “what does it mean to “learn how to code?” I suspect we could have quite a long discussion on that question alone.

To me it boils down to:

  • What problem are you trying to solve – how do you define “learning to code”
  • What software helps you best learn to code by your definition
  • What hardware runs the software you want to run

Picking the hardware should almost always be the last thing one picks. Now I have to go think about what it means to “learn how to code.”

Sunday, September 26, 2021

Phun With Phone Numbers

Among the programming projects I ran into recently was one to calculate all of the combinations of letters one could make from a phone number. Companies do this sort of thing all the time. They generate the combinations and then look for words related to their business so they can use it as a mnemonic and help people remember their phone number. Probably a bigger deal before domain names than now but still useful.

How many possible combinations are there? Well, that depends. It can be a low or 2187 (3 to the 7th power) and a high of 16384 (4 to the 7th power). The highest number is for phone numbers with all 7s and/or 9s.

I’m trying to write small bits of code to keep my mind active and solving interesting (to me) little programs. Initially I didn’t care to write this program (though eventually I did) so was thinking around the problem from other directions. What if I took a word and had a program generate a phone number? That was fun. And pretty easy. So I thought about the logical (to me anyway) next step. What if I had a list of 7 letter words and generated a file with the phone numbers that matched each word?

It turns out I have a small word list with just under 114,000 words in it. Step one was building a new file with only the seven letter words in it. A nice little project that is simple even for beginners.

I borrowed the code from the earlier program that turned a word into a number. A handy thing that shows the value of methods and reusable code. I used that to create the file with a list of seven letter words and phone numbers. A list of just over 22,000 for what its worth.

When I did write the program to create all the possible combinations of characters for a phone number I had a nice data file to use to check my work. That was surprisingly helpful.

Anyone out there assigning the program to create all the combinations of letters for a phone number? What interesting solutions are students coming up with?

Friday, September 24, 2021

An AI Tutor for CS Education

Recently I came across a Microsoft Research project called AI for Programming Education. The project “goal is to build a personalized and autonomous intelligent teaching assistant (an AI Tutor) for programming education, enabling on-demand education.”

It’s an intriguing and I think ambiguous idea. I tend to be skeptical of AI tutors as a general idea. A half dozen years or so ago I attended a workshop at Microsoft Research dealing with hinting systems. In other words, how can the computer give hints to beginners. I wrote about hinting systems and the workshop here.

The tl;dr is that it is a hard problem. No surprise to teachers of course. Knowing when to hint and how much to hint is a tough problem for human teachers. For a computer AI it is going to be harder still. That’s just one part of what an AI tutor would have to be able to do.

I don’t know any more about the project than what I read on the web page (link above) and that they are looking for a CS Education researcher to help with pedagogy. CS Education/Pedagogy Research Internship Opportunity at Microsoft (AI-driven Program Synthesis in the PROSE team) That is an encouraging move.

With more and more of education moving to the cloud, more and more online curriculum being developed, and systems that are getting smarter about helping programmers to write code (IntelliCode Completion In Visual Studio (Preview) 2022), creating an AI tutor seems like a logical project to take on. I assume papers will be published. I look forward to reading more about this project over time.

Monday, September 20, 2021

Book Review–System Error: Where Big Tech Went Wrong and How We Can Reboot

System Error: Where Big Tech Went Wrong and How We Can Reboot is what you get when a top philosopher, a top political scientist, and a top computer scientist get together to think deeply about technology and society and write a book.  It’s not a book for just one group. It’s not a dry textbook or academic paper but a clearly written explanation of the issues. It’s a book for everyone.

The book talks a lot about both artificial intelligence and social computing which are more connected to each other than may be obvious at times. The social and political impacts of these topics and others are covered in a clear and understandable way without hyperbola, scaremongering, or blatant cheerleading. This is one more thing that makes it stand out from many other books on these topics.

Yes, there are parts that are scary. Yes, there are parts that are optimistic. All in all though it is as fair and open minded a book as one can get. The book askes questions that have to be asked. There is enough data and sets of facts to give one a lot to think about. In fact, I found several times that I had to put the book down to think about what I had read. It’s that sort of book.

Were I teaching Advanced Placement Computer Science today, especially Principles but also APCS A, I would assign reading from it and have class discussions. If I could not get a class set I would at least have some copies in the library put on reserve. But I’d really like my students to read it all.

This is a book that should be on some required reading lists. Computer scientists really do need to think about the “should we do this” question as much as the “can we do this” question. This is the book to start thinking that way. But policymakers need this books as well. So do business people. So give it to the polysci and business majors you know.  A lot of social scientists should read it as well – sociology, psychology, social work. Probably more. It will help one understand what people are dealing with in today’s world.

Technology is impacting society, and our democracy, in many ways. Some are obvious and some are not. If we want to have a civil society we need to think deeply about the impact of technology on individuals and organizations This book is a great way to start.

Friday, September 17, 2021

Debugging–Slow is Smooth and Smooth is Fast

Mike Zamansky had an interesting post called  What They Used To Know that got me thinking about the old days. Now Mike is a youngster and didn’t really start in computers until the 1980s.  I started in the 1970s with punch cards and batch processing. That meant that there was no instant gratification seeing your program run.

With batch, one handed their cards to an operator and some time later, hours or maybe a day, one got their cards back with a listing that showed the results. Results usually meaning a list of errors that kept the program from running.

Desk checking, studying the listing and trying to fix as many errors as possible before trying again was a bit of an art form. To this day I will often print out a program to look at the big picture in a way that still doesn’t feel effective on a screen. It’s tempting to see that as a way to go – limited opportunities to have the computer check ones code.

There are downsides to this sort of thing though. Specifically, having limited runs or at least long waits between runs encourages writing large amounts of code at a time and discourages writing and testing small pieces of code regularly.

Being able to hit “compile” every other minute though tends to encourage, or at least support, the beginner tendency to “throw some code in and see what happens.” This wastes time in the long run and often leads to ugly, hard to maintain, and inefficient code.

The military has a saying that “slow is smooth and smooth is fast” that some what applies. Slowing down to really analyze code, think smoothly, generally leads to a faster result. Tossing code in on a wing and a prayer is not smooth but chaotic. Slowing down to really look at what is happening is smooth and looks slow to the casual viewer but leads to faster results.

As I was thinking tonight and asking, “what if we limited people to some limited number of compiles a day?” It seemed like a good idea until I thought of the possible problems. That’s when I realized that external controls on speed are not the answer. Rather the answer is for developers to regulate themselves. To slow down and focus in ordered to make faster progress.

Tuesday, September 07, 2021

Some Simple Early Programming Projects

If you are not on Twitter you may be missing a lot of good things. For example, the other day Kelly Lougheed (@kellylougheed ) tweeted out a bunch of simple labs that only require user input and mathematical operations. I have copied them below because I want to be able to find them again later.

I’ve used unit conversion for years but it gets old. Fahrenheit to Celsius, miles to kilometers, grams to tons, you get the idea. It gets boring. Kelly has some great ideas. There is an idea from Neil Plotnick (@NeilPlotnick)  below Kelly’s ideas.

Have any more? Add them to the comments for future readers! And be sure to follow @kellylougheed and @NeilPlotnick on Twitter.


Kelly Lougheed (@kellylougheed )

Programming activities that involve ONLY user input and mathematical operations:

  • Program to calculate the tip
  • Program to calculate cost per person when dining out
  • Program to convert units (made-up units like Harry Potter currency okay) What else?

Also just wrote this silly lab where the user can input their age and be told their future in 10/20/30 years ("When you are X years old, you will retire to a desert island", etc.)

0.3 Fortune Teller Lab

Fortune Teller Lab Directions: Where do you see yourself in 10 years? Have the user type in their age, and tell them their future at various ages (which you calculate by adding years to their current…

docs.google.com

And for extensions, I love little math challenges that involve Ss printing out the result of mathematical expressions (getting practice with operators!). For example, there is the Four 4's Challenge, and also this 1996 Challenge:

0.3 1996 Lab

1996 Lab Directions: Use the numerals 1, 9, 9 and 6 exactly in that order to make a mathematical expression that prints the following numbers: 28, 32, 35, 38, 72, 73, 76, 77, 100 and 1000. You can…

docs.google.com


Neil Plotnick replying to @kellylougheed

I have my students code algebra equations like the distance formula. Also stuff for geometry such as area and volume measurements. Ohms law for physics. Ideal gas laws in chemistry.

Saturday, September 04, 2021

Are You Assigning Projects or Recipes?

Chris Lehmann, the amazing principal of Science Leadership Academy in Philadelphia,  says “If you assign a project and get back 30 of the same thing, that’s not a project, that is a recipe.”  Now recipes have their place for sure.  They often make a good start. I see programming as a creative thing (art/craft/skill/science/what ever) and I want to see creativity from my students.

For me this starts with day one. In my introduction to my classes I tell students that I want to see creativity. I want them to make projects their own. This can be a difficult thing for some students. There are teachers out there who do want to see the same thing from every student. It makes things easy to grade I guess. Or something.

Very often in early projects is is hard to be creative. There are only so many ways to calculate degrees Fahrenheit to Celsius. On the other hand you can ask students to find two measurements they like and convert one of them to the other. You’ll be amazed at the combinations students come up with. Sure you’ll get the simple conversion using degrees Kelvin but someone will do miles to furlongs.

Even simple programs can get creative with tools that make graphics easy. C# and Visual Basic both have the Windows Forms libraries to use but Processing can make using Java or Python colorful and graphic as well. To say nothing of a lot of block programming systems.

Of course, students getting bogged down in how a program looks can be an issue at times but that can be dealt with though conversation.

An even better way is often letting students choose their own projects. I always finish up a semester with a larger project that students select themselves. Student get very creative with those projects. The Advanced Placement Computer Science Principles course requires a Create project which serves a similar purpose.

For smaller projects it can take a bit more to encourage creativity. After all if there is known input and expected output that’s going to be the same. Here is where you want students to be creative in their code. Let students decide if they want to use a for loop, a while loop, or even a foreach loop. Decision structures can also be done in different ways. Having students turn in code that looks different is a great learning/teaching opportunity. I love showing students the different solutions that students turn in. This both encourages them to try to be different and lets them see different solutions. The idea is to open their minds to looking at problems in different ways.

The most important thing is to encourage creativity. Celebrate it!

Thursday, August 26, 2021

IntelliCode Completion In Visual Studio (Preview) 2022

There is a preview out for Visual Studio 2022 available and since I a) love to try new things and b) am not limited to by what is on the student computers I have been trying it out. Normally, I don’t see a lot in new versions of Visual Studio that impact me personally or me as a teacher. That is not the case with this new version of VS. The new feature is called IntelliCode Completion. (you can read more about it here)

Basically what it does is try to help you write code faster and with less typing.

IntelliCode now predicts the next chunk of code based on your current context, and presents it as an inline suggestion to the right of your cursor. If you like it, just hit tab-tab to accept it; otherwise simply keep on typing to adjust the completion further.

Take the following code for example. I have a string array declared. In my btnGet_Click method I typed “foreach (“ and Visual Studio showed my the code in gray as a guess of what I wanted to write. In this case, it was right and by hitting the tab key the code was in place. Continuing to type would have replaces the suggestion.

For me this has been awesome. It's helped me start all sorts of loops and even helped build Boolean expressions. What does it mean for the classroom and beginners? That is the big question for teachers.

I know that teachers are divided on Intellisence which helps with understanding and suggestions with variables and methods. I suspect that if you don’t want your students using that sort of predictive information you’re going to really hate IntelliCode. Even if you like Intellisence, as I do, you may have concerns about IntelliCode. I admit to having some concern myself.

My first impression was that it could prevent a lot of typos and badly formed code. It does have that potential. On the other hand, will students put too much faith in the AI and assume code it suggests is correct for their particular program? That could be a big problem. I have had students blame to tools for their own mistakes for years.

Teachers can use this for a good discussion of artificial intelligence. What do you think of the information was used to train the AI? (Spoiler – lots of code in GitHub) How well does the AI really understand the context of a specific student project?

Clearly, students need to be prepared for using this feature. Students need to know that it is not prefect and that they need to be careful what suggestions they accept.

It does look like this feature can be turned off by specific area of help. Maybe there will be a way to turn it completely off easily on release. It’s on by default right now. So what do you think? A helpful feature for beginners or more potential for harm than help?

Monday, August 23, 2021

Hexapawn–An Interesting Programming Project

I'm cleaning up and finding interesting things. Well, actually, interesting books. One find is called "A Collection of Programming Problems and Techniques." Copyright 1972  So obviously, continued cleaning up is on pause while I code up solutions to some of the problems.

One of the problems in the book is Hexapawn (Hexapawn on Wikipedia) I remember this being a sort of challenge program when I was an undergraduate student. I didn’t take it on back then and forgot about it until running into it the other day.

I decided to take this on. I think it will be a good project for students. As did my old professor.

Hexapawn is played on a grid, often a 3 by 3 grid, with “pawns” on the top and bottom rows. Pawns, as in Chess, can move one square forward or diagonally right or diagonally left to capture pieces belonging to the other player.

 

A player wins by advancing their pawn to the opposite side of the grid or by preventing the other team from making a legal move.

It’s a simple game to play but takes some work to program.

One of the issues is that there are some tricky edge cases to be aware of. While pawns in the center column need to check for three possible moves, pawns in the left and right columns only have two possible moves. That can be a lot of special casing. It gets even worse if one uses larger boards. Trying to check for a move to the left for the left most pawn will create an error in many cases.

Years ago I ran into a boundary condition like this and a member of my team made a suggestion that I have used many times since. She suggested boxes outside the visible grid that, along with not showing, were marked as illegal moves. This means that one can check for straight, left, and right moves for all pawns without getting a subscript out of range error.

An other project I have used this technique is with the lights out game. In that game there are four squares that have to be checked in interior squares, three for edge squares, and only two for corner squares.

Using an outline of invisible squares outside the main set of squares allows the same code to be used for all squares.

I wrote a bit about the Lights Out project some years ago at The Complex Question of Complexity in Programming by the way.

I’m not quite done with my Hexapawn project but I am really understanding how it makes for a good programming project. One can set student requirements low or high. One can assign a two player game or ask students to write an artificial intelligence to play against a computer. It’s a game that lends itself to creating a heuristic program (think machine learning) for more advanced students. Low floor, high ceiling.

Friday, August 20, 2021

Playing With Code–Recursion

Recursion was never a big part of my toolbox but I am starting to appreciate it more recently. Regular readers know that I have been writing about and writing code for some older, simpler cryptography systems. For one of them I needed a list of letter in the alphabet without duplicating previous letters.

I needed to take a letter from the alphabet (I had a string of it) and see if it was in a list of used letters. If the letter was used already I wanted to check the next letter. It’s pretty straight forward if you can assume that not two letters in a row are used in the previous string. There is probably a decent iterative way to do this but I was coming up blank. Until it occurred to me that a recursive solution might be just what I needed.

I came up with the following code. It checks of the letter at location k in the alphabet list is in the string to check. If it has not been used it returns the index of the letter to use. If it has been use the same function is called again looking at the next letter index. This continues until we find an unused letter.

private int getNext(int k, string check)
{
     if (check.IndexOf(alpha.Substring(k, 1)) < 0)
         return k;
     else
         return getNext(k + 1, check);
}

I really like this solution because it emulates the way I think about the task. It’s also easy to understand. Recursion is not always hard and confusing. Sometimes it really makes things easier.

Program note: The nice people at Feedspot have compiled a Top 20 Computer Science Blogs list. Yes, I made the list but there are a lot of very good blogs on that list. They cover computer science more broadly and many will be worth a follow.

In cryptography news, the NSA Codebreaker Challenge 2021 is now open.

While you are here, I have been regularly updating my Tiny Book of Simple Cryptography. The current list includes:

Caesar Cipher
Vigenère cipher
One Time Pad
Polybius Square
PigPen Cipher
Columnar Transposition Cipher
Keyword Columnar Transposition Cipher
Random Block Transposition Cipher
Steganography
Bacon’s Cipher

Monday, August 02, 2021

IoT, Python, and Raspberry Pi–Oh My

Trying learn too many things can be a risky proposition. But sometimes it feels like the way to go. Regular readers of this blog know that I have been trying to learn Python and that I have been experimenting with the Internet of Things with Phidget devices. Mixing the two is a pretty obvious step but since I really want to set up some autonomous systems without tying down my laptop, it seems like the Raspberry Pis I have accumulated would be the way to go. So mixing a new programming language (Python), with a new development domain (IoT) with a new operating system (the Raspberry Pi OS is built on Linux) seemed like something I should give a try.

Fortunately for me, the Raspberry Pi OS installation comes with the Thonny, Python IDE for beginners and the Phidgets software has downloads and installation instructions for the Pi and Thonny. I had a little trouble getting the Phidgets library to install at first but the Thonny IDE had the ability to get the library and install it for me which was a big help.

Thonny feels like a very nice IDE for beginners BTW. I am surprised I hadn’t already known about it. It installs in Windows, Mac OS, and Linux. And it is free which is also nice. Visual Studio Code also installs on Raspberry Pi so if you are using that on other platforms it could be an easy move on the Pi.

My experiment involved using the Phidget Plant Kit because water and electronics go so well together. Seriously though I like the idea of having a computer controlled watering system for plants. That’s something I have wanted to do for a while. Plus it is something that lends itself to cross curricula work in schools.

Initially I plugged in a monitor, mouse, and keyboard. Not a bad desktop if a little slower than I am used to but fine for what I am needing. Next step was connecting over the network with VNC (Virtual Network Computing). This is the step I need for setting the Pi up without tying up my monitor, keyboard, and mouse.

Well, I have some more experimenting to do. More posts when I have some projects fully completed.  I’d love to hear what other people are doing with Raspberry Pi and IoT as well as where you like to go for connectable hardware.

Thursday, July 29, 2021

Playing with Bacon's Cipher

Bacon's cipher is a fairly well-known and simple cipher. Its considered a form of steganography. Unlike most steganography, the code is hidden in the text and not an image. The format is a 5-bit binary encoding where each letter of the plaintext is replaced by a group of five of the letters 'A' or 'B'. This binary code has A as 00000 or "aaaaa" and Z is 11010 or "bbaba". There are variations and the original version used the same codes for the letters "I" and "J" and for "U" and "V". The usual implementation is to use one type face for "a" and a different type face for "b".

Often this is done with a serif and a sans serif font. Other options, and the first one I use below, uses italics and non-italics.

thequickbrownfoxesjumpedoverthelazy

One other option I have used is mixing upper and lower case letters.

The QUicK brOwn FoXes JUmPed ovER tHe lAZy

The big disadvantage of using mixed case letters is that it is not very subtle. It’s almost obvious that there is something special going on. Italics is less noticeable. Serif and Sans Serif are even more subtle.

One semi-famous example of the use of serif and Sans Serif fonts is the Cipher on the William and Elizebeth Friedman tombstone. The biography of Elizebeth Friedman,The Woman Who Smashed Codes: A True Story of Love, Spies, and the Unlikely Heroine Who Outwitted America's Enemies,is a seriously recommended read BTW.

I’ve been experimenting with coding and decoding using this method using a computer program. The upper/lower case combination is pretty easy both to encode and decode. C# has a nice Char.IsUpper method that was very handy for decoding. Encoding with different font faces was trickier for me. I finally used HTML for output.

Parsing an HTML file is not to bad, though I haven’t coded that at this time. The obviousness of this method still rules this out as a serious method for me. If fact just making a raw HTML file available, no matter what sort of type facing one uses, just feels to obvious for me. I suppose that getting an image of the message and posting that would work pretty well. It doesn’t lend itself to computerized decoding however. Maybe some AI pattern recognition would work well?

Speaking of images, there are examples of using this encoding in pictures of groups of people. Some people facing straight ahead and some turned to the side. Just about any possibility of two different options would work. Its a pretty flexible system.

This is not the sort of encryption that holds up to serious attack but I had some fun playing with it.

I have updated my Tiny Book of Simple Cryptography with a chapter on Bacon's Cipher. This is the seventh chapter with a simple cryptography technique.

Monday, July 19, 2021

Pluses and Minuses of the Unary increment Operator

There has been a conversation on Twitter about the unary increment operator (++) and related (+=, –, etc.). I tend to gloss over these when teaching beginners. Especially those in a first programming course. A friend of mine disagrees. It started with:

Would you ever write, or teach a beginner, a = a + 1 if your language supports a += 1 If so, why?

Now obviously professional programming and beginner programming are not exactly apples and apples but we should probably be teaching best practices. Right? On the other hand, there is thing called cognitive load. There are really  at least four ways (in most C-style languages) to ad one to a variable.

  1. a = a + 1
  2. a += 1
  3. a++
  4. ++a

I generally teach options 1 and 3. I mention the others but don’t really expect students in a first class to use them all. Cognitive load. It’s enough for students to remember two ways to do something and they don’t need all four.

The first one has an advantage that it follows a general form. A value is added to a variable and saved in the original variable. This works for a lot more than adding one. Now arguably a += 1  does the same thing but the other format is a building block for more complicated  assignments with out the complexity of figuring out where += fits into the order of operations.

Now the pre and post increment (and decrement) operators are sort of special. It makes a difference which one you use;

foo = bar[I++] and foo = bar[++I] give very different results.

Personally I don’t want beginners using either except as a standalone statement. So I teach it for incrementing loop control values but don’t talk much about using it other places. Now obviously there are cases when using these operators in other places is a good idea. But I think beginners have enough trouble as it is without adding some unneeded complexity.

As time goes on and students become more comfortable with the language and the art of programming, by all means, show them the cool stuff. But remember that code should be readable by people as well as computers. When I was doing code reviews as a professional developer I always looked to readable and easy to maintain code. That’s how I want my students thinking as well.

Agree? Disagree? Jump in in the comments below.

Friday, July 16, 2021

Observations on #CSTA2021 Virtual Conference

The CSTA 2021 Virtual Conference is in the books. I really did enjoy it and I learned a lot. Virtual conferences are different from in-person conferences and I plan a post on that. But for now I want to talk about this year.

First off, the conference program was pretty awesome if I can say that as part of the conference committee that selected them. Not only was content good but the presentations were very well done. At  least the ones I sat in on were. I wonder if the experience of teaching online as so many have had to do played a role in preparing teachers to present at a virtual conference. Thoughts on that?

Secondly, the chat feature in Hopin got a lot of use. As one person pointed out, yelling things out in a live presentation is rude but adding questions, comments, or additional resources in a chat windows is not. More than that it adds to the value of the presentation.

Sessions for grades younger than high school are growing in number. This is hugely important in my opinion. This year, Nifty Lessons had a lesson for the very young grades. There were not many teachers of those grades to hear it though. I would love to see more nifty lessons for younger grades. Elementary school and middle school teachers are doing amazing things and we need to share them.

I ran two monitors during the conference. One monitor was on the conference itself while the second was split screen between the Slack channel the conference staff and committee used to handle things behinds the scenes. The other window was following the #CSTA2021 Twitter hashtag. I don’t have data but it felt like the Twitter stream was less busy than most years. I suspect two causes. One the aforementioned chat activity in Hopin and the other the fact that computers and phones were occupied with attending the conference rather than social media. Is this god, bad, indifferent? I don’t know. Being virtual we had many more people AT THE CONFERENCE so maybe we don’t need as many Tweeting for the people not there?

There was a clear theme of equity in CS education in this year’s conference. Given the last few years, equity is and will continue to be an awfully important topic. The keynotes were all on that topic and at the risk of taking criticism, was that necessary? I love people talking about how they bring equity into the teaching. I will listen to Amy Ko again in a heartbeat for example. The last keynote at CSTA 2021 had some inspiring stories. It was great to hear the success of students from students. We can probably all do even more to bring equity to teaching CS. I would just have liked a little more variety in the keynotes.

I have been thinking about what else I would like to see in keynotes for next year.

One is talk about the need for ethics in CS education. I am not sure what form this keynote should be given or who should give it but ethics in computing is a critical topic in my eyes.  We’re seeing ransomware and cracking into systems all the time. We need to make sure we are bringing ethical thinking into our teaching. Students need to ask “should I?” as often as they ask “can I?”

The second thing I would like to see is pure inspiration. At this point in the year teachers are tired, drained  and most of us could use some excitement. The future of technology is amazing and hearing about the possibilities and ideas that we can share with students to encourage them would be a great thing. Again, I am not sure who is the person to bring it but I want to hear a positive and exciting message about the future. I want energy!

So what do you think? How was the conference for you? What was great or not so great? What do you want to see next year?


BTW, my daily notes on the conference are at:

Notes on Day Three of #CSTA2021

No morning help desk duty for me today so I watches the whole “Morning Java” session. For those of you not at CSTA, Moring Java was an introduction to the day with our conference chairs and guests. Today.Michelle Lippoli, Senior Operations Manager (Events and Membership) for CSTA, talked about all the work that goes into running a conference like this one. And it is a lot of work! Next year CSTA will be in-person in Chicago. There is a lot of excitement about being able to meet in-person but I hope we have the virtual option as it makes the conference possible for so many more people.

First session of the day for me was Nifty Assignments. Though I was tempted by Python and Micro:bit…on a Calculator? and I will look for the video in the future. Nifty is a conference favorite. The idea started at SIGCSE (See more on that here) and I have used projects from previous sessions at CSTA and SIGCSE.

Michele Lombardi - Unplug the Internet!  9-12
Review internet vocabulary, how messages are sent, and introduce potential cyber attacks using this unplugged internet simulation.

I’ve done something similar but I love the forms she uses and the other information about things to do.

Cindy Gonzalez - Bring your 3D world to life!  K-5
Design a 3D design in Tinkercad, upload your design to Cospace, code your design & enter your 3D world using the DoInk Green Screen app

Talk about making students creators and not just consumers. I love the cross curriculum opportunities.

Roger Jaffe - RSA Encryption Without the Math  9-12
How to teach RSA encryption without having to teach the math

I struggle with teaching public key encryption so this set of resources looks very exciting to me. I can see using this lesson in Advanced Placement Computer Science Principles.

Learn more about CSTA Nifty Assignments at: https://sites.google.com/site/cstaniftyassignments/

After Nifty Assignments, I attended Teach Cybersecurity. Change the Future/ (Slide deck here) Did you know that there are guidelines for what to teach about cyber security? There was a lot of discussion about teaching cyber security in the chat. A lot of teachers are, not unreasonably I think, worried about students misusing the knowledge. The Teach Cyber program, and every other program I have looked at, included ethical thinking integrated into the curriculum. This is a curriculum worth looking into if you are thinking about adding a cyber security course.

Last mini session of the day for me was My CSP Experiment – teaching Advanced Placement CS Principles with two different programming languages at the same time (JavaScript/AppLab and Python) This teacher developed a detailed scope and sequence with dates and time and then mapped the concepts to unites from different curriculum programs (code.org, CodeHS and others) Concepts were taught largely with pseudo code and unplugged activities. That was a lot of work. I really admire her skills. (Slides are here)

Well, that’s a wrap for me. It’s been a great conference and I learned a lot. I’m glad I don’t have to travel for hours to get home.