Thursday, May 11, 2017

Using Virtual Reality for Teaching Computer Science

Maybe you can help me? My gut tells me that virtual reality or even mixed reality can be useful for teaching computer science. How to do that is the question. I don’t want it to be just another device that students program. That’s not really innovative. I want to think of ways that help students learn computer science. I want them to “see” things that can not ordinarily be seen.hololens-military

My first thought was a virtual tour of a computer. While I do show students mother boards and other pieces of computers wouldn’t a “walk through” of a virtual computer be better? More interesting? On one hand a video, perhaps just an animation, can do that fairly well. On the other hand virtual reality is the opportunity to take different paths through the computer to trace things the way a student would like. A mixed reality tool would label items as a student looked at a physical device. Taking the tour would be more fun though.

How about following instructions as data through the pipeline in a CPU? That could be fun and make things more real to students. In fact a general walk through a CPU could be good. The improvement over a simple video would be the ability to travel non linearly. IS that enough? I’d like to find out.

How would virtually tracing the path of code in a program work? Could we set things up so a student could follow (visually) a variable through code to see what happens to it? Perhaps watching the variables as they appear (are instantiated) and disappear (as their scope expires)? The idea of being mixed in with the code ala TRON or The Matrix has a certain appeal to me.

Do these ideas make sense to people? Would they help? Do you have other ideas?  Is this even possible with current technology? Putting this together probably requires some talent, time, and even money. Who will do it first?

Monday, May 08, 2017

Pseudo Random Numbers Are Confusing

Random numbers are really useful in computer science. We use them a lot for simulations (or games – pretty much the same thing) and to make programs more interesting. But they are not as simple as might appear. First off they are not really random and secondly there are often timing issues. And then there is the whole testing situation. randomnumber_wordle

Let’s start with the first of these. Those of us who understand random numbers in CS understand that it is impossible for computers to calculate truly random numbers. Cryptography which really relies on true randomness uses all sorts of tricks and tools to generate groups of random numbers. No serious cryptography person would use a standard library for use in cryptography. But for most things we do  in high school computer science built in library random number tools are just fine.

Where things have gotten complicated for my students lately is with timing issues. The libraries we are using use time from the computer’s clock as a seed value for the generator. If you instantiate two different random number objects at the same time, or rather within a single clock interval, you get two lists with the same values. Whoops! This is pretty much the opposite of what students really want. They’re generally better with one variable than with two but that is not obvious to many beginners. After all if one is good two is better right? And even if you have one variable if you instantiate it over and over again in a tight loop you can also get a lot of duplicates. Various languages have various ways around this (static variables for example) but hardly obvious to a student who just heard (or read) about generating random numbers.

And then there is testing. Oh my. Seldom a student strong suit. After all if it compiles isn’t it right? The special problem with random numbers is how does one test if the data is different all the time? Visual Basic has a Randomize statement that makes things “more” random. If one doesn’t use it than the program will use the same random numbers every time. In other languages (libraries really) one can use a fixed seed value to get the same set of random values for each run. How ever one does it, it is useful to have a known set of data for testing purposes. Talking about this is an important part of the larger issues of understanding random numbers AND of testing program.

One of my tasks for this summer is going to be trying to document this better for students. I realize that I need to cover this in more depth if students are going to really be able to use random numbers effectively. I can only talk so much in a single semester course. Perhaps if I provide supplementary reading for homework it will help. It’s a theory.

Maybe I’ll bring random.org into the mix. Looks like some interesting tools there.

Monday, May 01, 2017

Punch Cards, Comments, and Learning From the Past

Doug Peterson, whose blog always makes me think, had a post last week about internal documentation. Specifically things like comments which a lot of the popular block languages don’t really do that well. Of course this made me think about my code and what I teach.

Punch CardsThe image to the right is some code I wrote in university. Yes, I have a 45 year old deck of punch cards and yes, that is a FORTRAN program. I ran into it while cleaning up this past weekend. Doug’s post had me looking at the code. And the comments.

The comments  are great. They really let me know what is going on. That’s good because my variable names are horrible. What ever was I thinking? I’d do things a lot differently today. And in fact I do do things differently today. I have written programs like this one several times and in several different languages over the years. The variable names are much better. We’ll talk about comments in a moment.

The first time I dug out this deck of cards was some years ago when I tried to rewrite this program in Visual Basic. The comments, one in particular, was critical for me making things work. I use this as an example for my students of why they should comment their code  in fact.

My most recent iteration of this program has been in TouchDevelop. I’m pleased to say my variable naming is MUCH better now. My commenting? Not so good. Part of the problem is the nature of the language. Comments are supported but somehow I never seem to think of them the same way as I do in other languages. This seems typical of block or drag and drop programming languages. (Doug brings this up which made me really think about it.)

Of course lack of commenting is not unique to drag and drop programming. Students have pointed out that some sample code I wrote and gave to them to learn from could use a lot more comments. BLUSH They are quite correct.  I really need to fix that. Perhaps I’ll take on as a summer task to well document the demo code I show students. I really should be modeling what I present.

I do worry that we are losing the focus on internal documentation these days. There is this theory that well written code with well chosen variable names and identifiers should be understandable without comments. Like many theories that doesn’t seem to work as well in practice though. Well, I’m off to comment some code.

Thursday, April 27, 2017

How important is the first programming language really?

We really need people who have never faced a room full of  students in their lives to teach us how to teach computer science.

Said no CS teacher ever.

What brought that on you may well ask. Long story. First Mark Guzdial posts about changes at Stanford (Stanford CS department updates introductory courses: Java is Gone) highlighting an experimental version of their first programming course to use JavaScript. Then it hits Reddit (Stanford is moving from using Java to JavaScript for their introductory CS course) where hundreds of comments follow. Yes, hundreds. Most appear to be from people who have never taught a class themselves but have strong opinions of what a first language should be. And the occasional journalist kicks in with something like Universities finally realize that Java is a bad introductory programming language

How ever would we poor ignorant teachers get along without these experts? Fortunately for my sanity Mike Zamansky who actually is a teacher jumps in with some useful thought. A new first language? What's the follow up plan?

I believe that a first programming course is very important. The language used, while important, is not the biggest consideration. Rather is is the concepts covered (see Mike’s post) and how well the instructor does in preparing students for what comes next. The new course at Stanford is going to be taught by Eric Roberts who is one of the al time outstanding CS educators. I’d sign up for that course because of the instructor even if it was in COBOL.

Teacher is important. Curriculum is important. Projects and assignments that help learning are important. Language some where down the line.

I figure I’ve learned a new programming language about once every three years for the last 45. While I joke that I can still write a good FORTRAN program in any language the truth of the matter is that learning new languages changes how I code and how I think about problems. The first language got me hooked. But that was not the end all and be all. The first course is just the first course. There is a lot more to come and it would be a mistake to try to cram a four year undergraduate curriculum into a one semester (or even full year) high school course. And yet that is what some "experts" seem to be trying to do.


Wednesday, April 26, 2017

Surface Book–a first look

I’ve had two Surface Pros. A Surface Pro 3 and a Surface Pro 4. I love them. Make no mistake these have been idea travel computers for me. And powerful enough for just about everything I could want. They are also great for teaching as I can carry them around the room, use the tablet, and project wirelessly to my LCD projector. But I have had my eyes on the Surface Book for a while.

And now, thanks to the MIE Expert program and the Surface Experts program (https://education.microsoft.com/microsoft-innovative-educator-programs/mie-expert) I just received a new Surface Book. As someone who teaching computer science this means three things for me. 1) More disk space - more VS is being installed now 2) more memory (8gb) so emulators should run better for mobile development 3) a faster CPU.

Actually the more memory means the most to me. More disk is a close second. Modern CPUs are fast enough for just about everything I do. Also the screen on the Surface Book is larger which is also a nice thing.

As I said though memory and disk are big plusses for me. I’m not your average classroom teacher. I like to install lots of software (I’ve had as many as three versions of Visual Studio installed at once in the past) and I always want to try more things. The disk space on the Surface Pro limited me a bit. The Surface Book has twice as much disk so I have installed a bunch of Visual Studio things to play with. I may not need it all for teaching but I do for learning.

Memory is the next big item. My Surface Pros have 4gb of RAM. I can run mobile emulators but barely and I have to be very careful about what else is running. With the Surface Book and its 8gb that problem goes away. With my computer lab being updated to 8gb systems over the summer I now have a lot more options to my Mobile Development course next year. To say nothing of my own “needs” for mobile development.

The look of the Surface Book is nice as well. I’m not big on esthetics of computers but having a nice clean design is nice. I understand the keyboard (a very nice friendly keyboard BTW) comes off but I don’t need that very often. And I still have my Surface Pro 4 if I do.

All in all I am very happy with it so far. It’s everything the Surface Pro is but more. Just what a computer science teacher who can’t stop trying new things needs.

Wednesday, April 12, 2017

Code Slow Finish Fast

Looking through student code today brought this quote to mind.

“I didn't have time to write a short letter, so I wrote a long one instead.” Mark Twain

Students are always in a hurry to write the code for programming projects. No matter how strongly I suggest they think about the problem and design their code most of them start coding right away. This often results is a lot of code where a small amount of code will work just as well if not better.

Often the techniques for less code require a bit more thought. Setting up a long set of if statements with a bunch of different variable names is tedious but doesn’t always require as much planning as setting up an array and loop solution does. Students are in a hurry so they take what they think are shortcuts.

Experience tells of course. My version of Whack A Mole (our current programming project) can be changed from 5 possible “moles” to 6 by changing one 5 to a 6. Some of my students would have to write, well let’s just say I don’t want to do the math.  We’ll go over the options during our next class. The theme will be to think more before starting to code though.

Tuesday, March 28, 2017

Math vs Programming

MathTake a look at these two equations. I found the first one on Facebook. The second is my first attempt at rewriting it for the computer. What is the answer?

Well the first answer is 1. The second answer is 9. How is that possible? If you think about it there is a sort of implied parenthesis around 1/3. It’s pretty clear in the more traditional mathematical expression that one is to divide by one third and not 1 divided by three. imageA more accurate expression for the computer would have some parenthesis to make things obvious. That would give one the answer 1 that the traditional expression provides.

We see this sort of thing a lot – students assuming that equations in programming are exactly the same as the mathematical expressions their are used to using.  The most common issue is students thinking that the = sign allows copies from left to right as well as right to left. After all in mathematics the = sign means that both sides of the equation have the same value. That is not the same think as the = sign meaning copy the value on the right into the location on the left.

Some functional languages do things differently. The WeScheme IDE and DrRacket used by Bootstrap for example. That curriculum takes a much more algebra focused look at computer science. Or is that a more computer science focus approach to algebra? Either way it seems to be very effective. (Note that Bootstrap training is available though CSPdWeek and other venues.)

Those of us using other platforms though have a lot to contend with as we teach students how to build expressions that mean what students think they mean. Is it worth the effort? I tend to think so. But it is confusing at times.  Days like to today make me rethink things.

Computer Science Teachers Association T-shirt Campaign

Are you a computer science education super hero? You know you are so now you need the t-shirt. Get yours here and also support the computer science teachers association. cs hero

Just the thing to wear to the CSTA conference or really any education event. I would love to see lots of them at ISTE to let people know that CS educators are there