Friday, November 08, 2019

Define Better

Someone posted an interesting question on Facebook.

Is using ++i(pre-increment) better than i++(post-increment) ?

My reply was to ask for a definition of “better.” The Facebook posts have a lot of answers from people who appear to not have written a compiler themselves and who making a lot of assumptions. But the point of this post is not to discuss which option is better for some nebulous definition of “better.” Rather is is to think about asking the question of what do we mean by “better?”

There are a lot of what I call religious arguments in computing. Tabs or spaces, curly braces in columns or have the open on the end of a line, what is the best programming language, and on and on. Most of them stem from differing definitions of “better.”

Sometimes things matter very much at one point in time but not at all later and yet the bias from early days remains. There was a time with memory was so tight that a single character variable name was much preferred to a longer more descriptive name because of the space used. Most of my readers probably don’t remember those days but I do. Fortunately I recognized when the change happened. Not everyone did so quickly.  This is possibly at the heart of some of the tabs vs spaces argument for at least some old timers.

Other issues have become moot or mostly moot because we have so much smarter compilers and interpreters these days. We have long been at the point where compilers write better low level code from high level code than even the best assembly language coders. I seriously doubt that there is a difference between the code generated for ++i or i++ as the incrementor in a for loop these days. Compilers are too smart for that. Compiler writers think long and hard about those sorts of things.

How doubly dimensioned arrays are declared used to make a bigger difference than it does today. I can remember thinking long and hard about how to declare and iterate through two dimensioned arrays. You pretty much had to know how the compiler would allocate memory and what cache would look like to get optimal performance. I don’t think many people think about that today except for the most performance critical applications. Applications we don’t give to beginners anyway. Compilers do a lot of optimization on this sort of process so we don’t have to think much about it. Artificial Intelligence and machine learning (see also AI-assisted Programming) are probably going to make compilers even better than they are today.

Today I think “better” in terms of programming should mean “easier for programmers.” Easier to write, easier to understand, easier to modify, and to allow programmers to think about the end result and not the assembly/machine language generated.  Let the software do what software is good at and people do what people are good at.

Thursday, November 07, 2019

AI-assisted Programming

As I said in yesterday’s blog post,Microsoft has been running their big MSIgnite event this week and making all sorts of announcements. One interesting announcement what improvements to what they call Visual Studio IntelliCode.  The idea is that they are using machine learning to help programmers with writing code. In the latest update are whole line completions and refactoring. Interesting.

I haven’t seen IntelliCode in use before and it is probably because it is not turned on by default. I did some searching and found that it can be turned on as an Extension (I had to search a bit under the Manage Extentions option) and then you can customize aspects of it from Tools –> Options –> IntelliCode. Oh, and you need Visual Studio or VS Code 2019 for this. I am using Visual Studio 2019 Community Edition which is free.

SO far I am not seeing obvious help from it but it may be that I have to do something more complicated in my code or write more code first. It does apparently take context into account for its suggestions and I may not have given it enough yet. But I’ll keep playing. And maybe I should look for some video demos online.

There are other things to think about though regardless of if it has been useful already. What is the training like? The write up I have seen says that it learns from examples on GitHub. Initially that scared me as literally anyone can upload to GitHub. One reference I found said  something about the 500 best repositories on GitHub. What ever that means. And what was the criteria for “500 best?”  What sort of standards will this learning suggest?

Some of the documentation talks about options for using other databases of code to train the system so that businesses can train the AI with their code and standards. As a teacher I wonder if there could be a training set for AP Computer Science A? I think Java is supported with IntelliCode in Visual Studio Code.

No doubt some will complain that it is “too much help” for beginners but I’m not sure about that. You still have to know enough to take or reject suggestions for one thing. And having the computer tell a beginner something like “you should make a method to reduce this redundant code” might be better received than the same comment from a human teacher.

Will this help students learn more or dumb down the process? I’m an optimist and think it will be a good thing. What are your thoughts and concerns?

Wednesday, November 06, 2019

Visual Studio Online–Possibilities for Education?

Microsoft has been running their big MSIgnite event this week and making all sorts of announcements.  One of them was a cloud-based development environment called Visual Studio Online.

OK, that looks interesting and I will probably try it out soon. It may be an answer for people pushed to Chromebooks,  others who are at one to one bring your own device schools, or just want students to wrote programs from home. I wonder how it works on otherwise underpowered older computers?  There is some concern about costs and that is something I need to understand.

Maybe I can find someone with an education focus at Microsoft to explain how it might work cost effectively for schools and students.  Or maybe I can figure it out through all the marketing hype. We’ll see but it sure does look worth looking into in more detail.

Question added later: I wonder if this will let me develop iPhone apps without buying a Mac? Anyone know?

Monday, November 04, 2019

CSTA at 15 #CSTAat15

The Computer Science Teachers Association is now 15 years old. I’ve been a member from the start and I have to say that in some ways it feels like it has always been there but in other ways it feels like it just started.  There was a K-12 computer science education community before CSTA. But it was small and one could easily feel alone. CSTA brought a new sense of community and togetherness. Most of all, perhaps, it brought us organization and a stronger sense of belonging.

There was the CS & IT Conference (now called the CSTA Annual Conference)  before CSTA as well but it didn’t have the same feeling of permanence and sustainability that CSTA brought to it. CSTA brought growth and strength to the conference. It’s been the annual highlight of my professional development for years now. Presenting at several of these conferences has been a huge privilege and honor. And added to my learning as well.

After I left industry some years ago I ran for and won a seat on the CSTA Board. What a wonderful experience those four years were. Hectic as we changed Executive Directors during that time. It was a real time of transition. That wasn’t as smooth as many of us would have liked and I think we experienced some growing pains during those years. We’re on our third ED now but things seem to be well on track. Kudos to the Board (after me) who lead the way through the last couple of years and another ED transition. We have an amazing board at CSTA who work very hard for the membership.

The growth of chapters has been a big part of the CSTA story.  Fairly early on, CSTA developed programs to train and prepare chapter leaders and that has paid off in spades. There are more and stronger chapters than ever before. CSTA is both national AND local and that is important.

CSTA has helped train advocates among teachers and support them locally. CSTA members have advocated, lobbied, pushed, and otherwise promoted CS in their states, counties, school districts, and yes even nationally. Some of the companies and other groups get a lot of credit for the growth in computer science education in the US but the real heroes are individual teachers who alone or with other CSTA members did the ground work to make things happen.

From conferences to board membership to involvement with committees and connections with life long friends CSTA has been an important part of my life. I can’t wait to see what the next fifteen years bring.

Friday, November 01, 2019

Magic 8 Ball and Projects From Real Life

There has been a 12 inch tall Pez dispenser on my desk for a couple of years now. It’s a great visual aid for talking about stacks. Today I got a Magic 8 Ball as well. It turns out that a lot of my students were unfamiliar with this staple toy of my youth. Since I really like using the Magic 8 ball program as a demonstration I decided I really had to get a physical ball.

At this point in the semester we have covered loops and arrays and it is time to make programs more interesting by adding more data. I want to use something that makes sense and is not just a demo without meaning or purpose. Having code you can have some fun with is always a plus as well.

I went to Wikipedia and found the classic 8 ball answers and placed them in a text file. My demo reads the file into an array when the program loads. Once the array is built clicking a button displays a random answer. It’s pretty simple to code and we code it together as a class. Students love asking it questions when we’re done.

Usually I have students add their own answers to the text file and then modify the program to handle the new set of answers. We also talk about different ways this could be coded. What if we didn’t know how many answers/lines were in the file? Would be use a different loop and/or a different array type like an arrrylist? What options (methods or functions) should we use to provide the most flexibility?

This also provides students with some sample code to look at when I assign larger projects and expect them to do much more on their own. Is this a good project? Magic 8 ball says “Yes definitely.”

Friday, October 25, 2019

A Loop By Any Other Name

My first programming language was FORTRAN IV. As I recall we had Do loops. They worked pretty much the same as what we call For loops in most languages today. We didn’t have while loops but we did the same sorts of things with line numbers, if statements, and the powerful but “evil” Go To statement. As time went on I learned more ways of specifying looping constructs including recursion. Recursion took me some time to wrap my head around. Possibly because I used some languages that didn’t even support it back in the day.

These days there are all sorts of iteration loops of various complexity and power. For a software developer that is wonderful. For a teacher? Well, it means you have to make decisions about what to teach. For a one semester, first programming course I like to keep things simple. A C-family For loop has all sorts of possibilities from the simple to some pretty complex structures. Eventually students will learn many of them but I could probably spend half a quarter just on For loops if I tried to get everything possible in and understood. The cognitive load on some possibilities feels like it would be too much for many students.

Mostly I try to focus on the base concepts. A loop has a set up piece. Variables are set to a known starting state. A loop has some sort of comparison it see if it is finished. A counter it checked, a flag is checked, or maybe an interrupt happens. But something has to stop the loop sometime. usually but we can get into those times when an infinite look is useful later. And of course something has to happen that changes the values or states that the loop is checking.

Understanding these concepts will, I sure hope, prepare students for what ever syntax or iteration style they run into over time.

When we teach students for a career rather than just for a job the concepts are much more important than the programming language or the IDE. Concepts – what a concept!

Tuesday, October 22, 2019

How Many Words in That Text?

One of the projects I have used for years is a letter counter program. The idea is to count the occurrences of each individual letter. It’s a nice project that includes arrays, loops, and some string manipulation. This is the sort of thing that does have some real world utility. Cryptography uses word counts to try to crack substitution cyphers. Linguists use it to study languages. And that is just two of what comes to mind.

The next logical (to me anyway) step is to count words. I’ve been thinking about adding this in for a while. It is actually something I was assigned as a project many years ago when I was an undergraduate. It’s not as simple as counting letters. The most obvious method involved counting spaces. What happens if someone is old school and places two spaces after every period? Well, that is something to take into consideration. And what about other white space like tabs or line feeds? Or special characters?

Doug Peterson related in a recent post (About words) that two different programs gave him two different word counts for the same piece of text. The counts were off by 3 on a text of about 486 words. Not a huge percentage but on a book length text that could make a difference. Some articles in magazines are paid by the word. That means getting the count right means money.

Now people can count words with greater accuracy though I don’t want to do it myself. At some point someone is going to feed a lot of data into some artificial intelligence. Long sections of text that have accurate (human counted perhaps) word counts will be fed in and the AI will learn what words are and how to count them. It’s not going to happen until someone decides that developing this is worth the time and money. I wonder if it will be an academic or an industry researcher?

For the time being I think this will make an interesting conversation in class. Maybe we’ll have a contest to see  who can come up with the most accurate algorithm?