Thursday, May 25, 2023

Coding With AIs Prompts Are Important

Last night, when I could not sleep, I got up and wrote some code. I added some features and data checking to my Wordle solver helper program. When I finished I felt good about my work and myself. I think that made it easier to get to sleep and I slept well.

It got me thinking this morning. When I was in university and still learning how to code I would occasionally get frustrated and feel less confident. So I would write some simple program to help me feel like I could actually code. I must have written code to display the multiplication table from 1 times 1 to 12 times 12 at least once a semester. It worked for me.

Now that is a trivial program but it involves nested loops (for me anyway) and I am not sure I would assign it to students today. It’s really a meaningless program in today’s world when everyone has a calculator app on the phone they don’t leave the house without.

I did wonder how an AI would write the code. So I opened the chat option in Bing and asked it “Write some C# code to display multiplication tables in a list box” It gave me some code that displayed this:






Not what I wanted at all. The problem is ambiguity! So I tried again with “Write some C# code to display the multiplication table from 1 times one to 12 times 12” and got this:

Not what I wanted either. So I specified at grid format “Write some C# code to display the multiplication table from 1 times one to 12 times 12 in a grid format”

This reply required a dataGridView object and the program did not work. Looks like I need to set up the dataGridView object in ways the AI did not explain. Now there is a problem worth thinking about. I asked Bing what settings I needed for the dataGridView and it gave me several. Program still did not work. At this point I gave up on the dataGridView option. It sort of feels like overkill anyway.

So I tried another prompt “Write some C# code to display the multiplication table from 1 times one to 12 times 12 in a grid format in a list box”

Finally I got what I wanted even though I am not thrilled with the formatting.

I’ve got a number of takeaways from this. Yes, students could use  these AI tools to get code for typical school assignments. On the  other hand, I think it would be fairly easy to tell when they do. The use of features that are not typically covered in class lectures or demos would be one clue.

It’s not always easy to provide the right prompts to the AI. Sometimes it takes some iteration. I think though, that teacher have to reduce ambiguity in assignment descriptions in many cases. Arguably some amount of ambiguity is helpful to allow for creativity. It can be a fine line,

As noted, I didn’t like to formatting so I did modify the code to get closer to what I wanted. I think programmers are going to be needed in a lot of cases to finish off what AIs generate. Both providing the right prompt and finishing off will be important skills for some time to come. Finishing off is going to require some serious skills in many cases BTW. Programming is not dead yet.

Saturday, March 18, 2023

Finding Words With All The Letters Programming project

Does anyone else lay in bed in the morning thinking about coding projects or is it just me? I’ve been playing around with a Wordle solver helper for a while now. It helps me find words based on what I know after each guess. One of the things I like to do is see how many possibilities there are based on different hints. Yesterday I had most of the letters but not in the right place. So this morning I was wondering about words that had the same letters but in different orders. Seemed like something I needed to write some code about.  

A key method is to compare all the letters in one string with the letters in a second string. At least the way I was thinking of handling it. It struck me that that is a great assignment for students. I don’t have any students handy so I asked ChatGPT to write that function. This is the prompt I gave it:

Write a C# function that accepts two strings and returns true if all of the letters in the first string are included, in any order, in the second string. Return false if any of the letters in the first string are not included in the second string.

That is a lot like what I would assign a student. ChatGPT gave me some very nice code. It wasn’t exactly like what I was writing in my head. It used foreach and ToCharArray which is probably the best and easiest way to do this. I was coding before either of those became common so my mind goes to for and while loops and the string SubString method. This was a good reminder for me.

I left the rest of the program, which wasn’t a lot of code, to myself.

Once written I had some fun with it. For example, the letters in Alfred also makeups the word flared. The letters in face are also used in café. Some groups of letters do not make up any words of course, This seems like it could be a fun project to give students. It was fun enough for me.

Tuesday, March 14, 2023

Book Recommendations for CS People

tl;dr Book recommendations:

Overnight Code was recommended to me after I recommended Code Girls on Facebook. Overnight Code is a truly inspiring story of a woman with two strikes against her (female and Black) whose hard work, determination, and talents helped her do some revolutionary work in naval engineering and integrating hardware/software systems.

Debugging code is arguably a lot harder than writing new code. Raye Montague was amazing at debugging code and integrating disparate systems. But also a good person who helped mentor and advance others. She was given tasks that others had said were impossible to complete. Talent and hard work (Raye had a lot of both) allowed her to accomplish beyond expectations.

There is a lot of good career and life advice woven into this story as well. Advice for everyone. I could have benefited from this book early in my career.

"Code Girls: The Untold Story of the American Women Code Breakers of World War II"  was recommended by several people in a Facebook group dealing with a Kindle Challenge that Amazon is running. The idea about code breaking sparked my interest right away. This book was more than just that though.

There were plenty of insights into code breaking but the look into the lives of these amazing women was the highlight. It was a different time and women would not as respected as they should have been. Yet, these women put their considerable talents into working for the war effort and their country.

Code breaking is a fascinating subject in itself of course. I enjoyed reading about the “bombe” machines, how they were created and used. I also found the difference that code breaking made in the conduct of the war (World War II) to be interesting. This is not the sort of thing many history courses cover.

It’s easy to label these books as books for Women’s History Month or the Raye Montague book as being for Black History Month but that would be a mistake. These are books for all year long. I recommend them to anyone interested in the progression of computing in society. Code Girls is a great read for cybersecurity or cryptography students. Overnight Code is a powerful read for anyone not just computer science people. It is just that inspiring.

Thursday, February 23, 2023

Does It Run in the IDE?

I was reading a tweet from a person saying they lost points a program written with pen and paper because the teacher thought the code would not run. When the student asked the teacher to write the code on the computer it ran.

The Twitter discussion was on the wrongness of code assignments on paper but I am not sure that paper coding assignments are necessarily wrong. I suspect that the problem in the Twitter user's case may have been a teacher who is experienced. I could be wrong of course.

The real problem is a teacher putting too much faith in their own mental execution of the code on the paper. I have found it a good practice to enter code I was the least unsure of into an IDE and run it on the computer. I’d almost always check code I thought did not work. Students can be very clever and write code that doesn’t look like it will work but does work. Or code that does look like it works but doesn’t.

This all points to problems with testing computer programming in general. Writing code for evaluations is problematic in a number of ways. Yes, I know the AP exams do it that way. I’ve only graded the AP A exam once but I can tell you it’s not that easy. Handwriting can be hard to read for starters. I’ve already mentioned how clever students can be. I loved the 10 line code answer for a guestion that was looking for a one line return statement. I could have saved myself a lot of time if I could have verified it by running it.

Asking students to write code in an IDE offers logistical issues for starters. There is also the issue of students being able to look at each other’s screens and sharing files. Some object to students using autocorrect, error checking, and help files. All the sorts of things professional developers use. Some teaches do prefer code turned in electronically because it allows for auto graders. I’ve discussed them here several times. Basically, mixed feelings.

Evaluating student knowledge is one of the more difficult tasks programming teachers. It’s a problem with no easy answers. For now, I think, the best policy is to use a variety of assessments.

Tuesday, February 14, 2023

People Are Bad At Giving Instructions

One of the things that make me sure that programming will be around for awhile even with better and better artificial intelligences is that people are bad at giving instructions. Well, that may be unfair. They are reasonably good at giving instruction to other people but that is not the same as being good at giving instruction to the literal minded.

The most famous instruction, I first heard it from Grace Hopper almost 50 years ago is the instruction for using shampoo “Lather, Rince, Repeat.” There is a lot left out there. Most obviously, repeat how many times? It also doesn’t say if one should wet their hair first. In computer terms, an infinite loop without setting initial conditions.

I recently bought a new cover for a light switch. The first instruction was to turn off the circuit breaker for the switch. Good advice. On the other hand, the instructions did not say to reset the circuit breaker when finished installing the cover. A literal minded installer would never have a working switch.

Of course, people figure these things out. We are aware of the larger context and are good at filling in missing pieces. Computers are not that good at any of this.

Part of what we teaching when teaching programming is how to give instructions. Not just how to translate those instructions into code but to fully understand and describe the steps needed to complete at task. I believe these are necessary skills. I think they will translate to other fields. Not that I have proof but it seems logical. In any case, we’re going to have to get good at giving instructions if we are going to tell AIs what code  to write.

Sunday, February 12, 2023

CS Students–Learn Your IDE

Eugene Wallingford had a great post on WHAT WHAT DOES IT TAKE TO SUCCEED AS A CS STUDENT? It’s got a lot of good advice and I recommend it to students in high school or university. For now I want to focus on one or two pieces of his advice. Specifically, “Get to know your programming environment”

For the most part, in class, teachers have time to do an introduction to the development environment but not much more. We run through “Hello World” or similar to walk students though creating a project entering code, and running their first program. That;s all we have (or perhaps all we make time) for.

Typically there is a lot more to a development environment than what we show students. Even a simple IDE like IDLE for Python or Visual Studio Code has a lot or options and functions we don’t go over in class.

Students who spend some of their own time exploring their development environment are going to have an easier time though out their course. Indeed, throughout their CS career.

Related to learning your development, Prof Wallingford suggests keeping your IDE open while reading through textbooks or other resources. That lets one more easily try out code examples while studying. That goes a long way towards understanding what one is reading. When I review textbooks or other teaching resources I always run the code examples for myself. In part , to see if they are correct of course but also to see for myself what students will see and learn from the example.

Writing code that is not specifically assigned for a course is always a help for learning. If a student takes the time to experiment with a project of their own interest they will do far better in the course they are taking.

Friday, January 27, 2023

Rhode Island Computer Museum

I spent some time looking at the Rhode Island Computer Museum web page today. A lot of interesting stuff. Some great information under the Education and Activities page. If you teach the history of computers this is a great resource with text and pictures.

The Collections gallery has a huge collection of images and descriptions of items they have as well. Check it out at Home (ricomputermuseum.org)

Monday, January 23, 2023

What Jobs Are Safe From Automation?

“It's tough to make predictions, especially about the future.” – Yogi Berra

That doesn't mean people don't try. Recent advances in Artificial Intelligence have a lot of people predicting what jobs are an are not likely to be replaced by computers. Technology is challenging the ideas about what jobs can and cannot be replaced by technology. Doug Peterson, who shares a lot of interesting articles, recently share this one predicting that leaders will not be replace. It's an optimistic article. 5 Reasons Leaders Shouldn't Worry That Generative A.I. Will Take Their Jobs | Inc.com

A lot of jobs we once thought were completely safe are being seen in a new way lately. AIs are creating what looks to many like art for example. This is forcing us to take a hard look at how we define art. Some recent visits to museums had me already asking “what is art?”

Today we joke about AI attempts to write short stories, poetry, and other narratives. A lot of our stories in movies an even books are formulaic. How long before AIs can write Hallmark Christmas movies I wonder? What used to be a joke may be a prediction of the future.

A lot of people are speculating on  the future end of the programmer profession. People have been predicting that would decades but we are closer to that than ever before. Software developers today think they are safe though because they (we) know that end users are terrible about describing what they want a program to do. Will the future bring courses and training on how to talk to AIs? Possibly. I can sure see the need for it.

People who are not teachers are suggesting that AIs will take over for human teachers. As someone who spent 15 years teaching I am not so sure about that. I think the human touch will remain important for the future. Teaching is a lot about reading people and establishing relationships. Wil AI be able to do that? I am not sure anyone knows.

One area I think people have an advantage over AI is that we are bad with risk analysis. What may seem like a flaw leads people with some luck, some imagination, and some hard work to beat the odds. We see potential needs when a pure look at the data would not see anything. And we are often willing to defy the odds for things we believe in. I am not sure AI will get there.

Thinking about the possibilities of AI and what it means for the future of work is a critical topic. It’s something we need everyone, but especially students, to be thinking about.