Monday, June 28, 2021

Phun with Phidgets

Recently I requested a free (for educators) starter kit from Phidgets. Phidgets are small controllers and sensors that are easy to use and with a helpful API. The starter kit includes a bunch of things to introduce the platform.

The Getting Started Kit provides an introduction to students and teachers. We offer a self-guided, online curriculum with challenges and projects for students.

• Programming languages: Python, Java, C#, Swift
• Device compatibility: Windows, macOS, Linux, iOS, Android
• What's in the box: VINT Hub, Push Buttons (2), LEDs (2), Humidity Phidget and all required cables
• Suitable for school grades: 9 – 12

I spent some time with the starter kit today. What I was looking for was pieces that were easy to assemble and sample code that was reliable and easy to use. That’s what I found.

The first thing I did was assemble a sort of control box with two push buttons and two LEDs. I plugged the controller in to my laptop with a USB cable and fired up Visual Studio.  There are samples and tutorials in Python, Java, Swift, and C#. The systems work with Windows, Mac OCS, and Raspberry Pi. Projects are available in a wide variety of IDES including Processing, Eclipse, NetBeans, and Visual Studio among others. That;s a lot of options. IT looks like more languages are supported less directly.

So anyway, I followed the starter tutorials to get a feel for both the type of tutorials supported and to get a feel for using the Phidgets themselves. They were very easy to follow with a lot of code you can copy and paste to get started. In a classroom I would spend some additional time explaining the code in more detail. Students could use this on their own but would really benefit from the sort of deeper explanation a teacher can provide. I do like that there are suggestions of next steps without sample code for the student. That should encourage students to experiment a bit. Solutions are available to educators on request though.

Besides the buttons and lights I ran though the sample code for the temperature and humidity device as well. Equally easy to use. I was gifted a couple of other devices – a Power Plug Phidget and a Distance Phidget. I have some Raspberry Pis around here somewhere so my plan is to try these Phidget devices with one of them. That will give me a chance to learn something about the Pi devices as well. I can see a lot of potential for interesting projects combining Raspberry Pi and Phidget devices.

These feel like the sort of devices I have been looking for to do a variety of hardware and software mixes. In other words, physical computing. There are classroom sets available that while not cheap are in range for a lot of schools. You can’t give hardware away for free and these devices are high quality and well worth the prices. IMHO.

Note that I got the kit and devices for free but without any expectations of quid quo pro. I really like this stuff.

Friday, June 25, 2021

Is Picking a First Programming Language the Hardest Problem in CS Education?

All of a sudden the subject of the first programming language is getting discussed everywhere. OK, maybe not every where but it is in Twitter, Blogs, and Facebook. At least. Mark Guzdial gets part of the blame (credit?) for this with his conversation starting post on the Blog@ACM Why Did We Ever Think the First Programming Language Didn't Matter? It’s hard to find the conversations on Twitter but several of the CS education groups on Facebook have conversations around this post. For example, the Computer Science Teachers group here.

Now this a a topic that comes up regularly. I’ve made reference to it myself several times. Back in 2017 I asked the question How important is the first programming language really? and answered that I thought it was important but that curriculum and the teacher were more important. The language has always mattered though.

In 2016, I posted a link to an article called How Your First Programming Language Warps Your Brain One can find similar opinions widely spread on the Internet with special attention paid to Dijkstra

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.

I think we have always known that a person’s first programming language has a major impact on how they view programming. My first language was FORTRAN and it took me a long time before I stopped writing FORTRAN programs in different languages.

What does this obvious importance of the first programming language mean for CS educators? Well, its complicated. For one thing,Elementary and middle school have different constraints than high schools which have different constraints from universities.

I had a conversation with a middle school student recently. She attended after school programs at a university near her that taught her Scratch. She loved it. At the same time she saw older students (she’s a rising 7th grader) using a text based language and found it intimidating. She’s not convinced that she can handle what she called “real programming.” I tried to encourage her but one conversation only goes so far.

Research tells us (the professionals) that block based language are a good first programming experience but if students don’t see it as authentic they may think that is as far as they can go. While block based languages give many the confidence and concept base to move on and advance are some students falling into the trap that it is not real enough? I don’t know.

I’ve taught a number of language as a first programming language over the years. Visual Basic, Java, C#, PASCAL, and I’m probably forgetting some language.I am not ready to say that there is one best first language though. It really depends on ones goals.

Selecting the right language is important. Important decisions are seldom simple or uncomplicated.

Monday, June 21, 2021

Why Are Arrays So Hard For Beginners?

Beginner programmers often, dare I say usually, struggle with arrays. Sometimes it is hard for experienced programmers like myself to understand why but with years of using them in many languages they’re second nature for us

Beginners have trouble differentiating between the index and the contents of a part of an array.That seems to be the most common issue. Somehow the idea that the index is, in some sense, part of the name and not the value being stored is hard for some to grasp. Though come to think of it, I never talked about an index as being like a name. Perhaps I should but as a very experienced programmer with a background in Assembly language words like index and offset are natural to me. Beginners should not need to know how arrays are stored and accessed at the Assembly or machine language levels. Perhaps I will discuss indexes as part of the name next time I teach arrays. What do others think? Or what sort of language do you use?

While vocabulary is important, and students should understand words like offset and index, perhaps we need vocabulary that is meaningful to beginners before we teach them the vocabulary of experts. It’s a thought.

And then there is the whole “index values start at zero” thing which I have written about in the past. Zero Zero Indexing Considered Harmful

The other think I have been thinking about that seems hard  for some beginners is the need to initialize an array. They tend to assume that if one declares an array the elements in it should be assigned some sort of default value. Of course some programming languages do this for some data types. Numeric types get set to zero for example. It’s seldom a good idea to depend on this action and most of us do teach students to initialize the elements in an array. It’s a great way to tie arrays and loops together early in the learning process. I wonder why there are not library routines for this sort of thing. The .NET Framework has Array.Sort, among other things, so why not Array.Initialize? That’s probably not practical for arrays of many types but for some of the built in types why not?

On Twitter last week someone suggested that perhaps the problem was with arrays themselves. That seems reasonable but solving that problem is for people smarter than me. I’m just asking questions.

Tuesday, June 15, 2021

Getting Excited for CSTA 2021

As a member of the CSTA Conference Committee, I attended the first of two presenter training sessions today. Wow! CSTA 2021 will be good. Now I have read most of the proposals for presentations and helped select them so I had a pretty good idea this is going to be a great conference but today brought home a couple of things for me.

The big one is the shear number of online tools that teachers are using to make online (and probably in-person) teaching more interactive and engaging.  I taught online last spring and in a mix of online and in-person this spring but I never had the time to lean about all of these tools. That is mainly because I retired at the end of the 2019/2021 school year and didn’t spend last summer learning about teaching online. I kind of wish I had though.Never say never even about returning to the classroom. But that aside, I am really looking forward to learning at the conference this summer.

CSTA 2021 is going to be awesome! Hope to see you there. So much to learn!

Friday, June 11, 2021

Exploring the Ternary Operator

I’ve never had a lot of use for the ternary operator. Until recently, I think I under appreciated it. I Don’t recall ever using it in professional development though that may be largely related to using languages that didn’t support it. I never taught it to beginners either. Between time available and topics to be covered it never rose to a high enough priority for me. I’m starting to rethink that. But first, what am I talking about?

In C-style languages the syntax is:

(expression-1) ? expression-2 : expression-3

There is a Boolean expression inside the parenthesis, followed by a ? and a value for a true case, a : and a value for a false case. For example:

(Player == WHITE) ? "White" : "Black";

Other languages have different formats. For example, in Python the true option comes before the Boolean expression.

[on_true] if [expression] else [on_false]
>>> x, y = 5, 6
>>> print("x" if x> y else "y")

We actually see this sort of thing in spreadsheets though I never really thought of it as a type of ternary operator. This example from Excel is really a ternary operation

=IF(G10 <  G11  ,"big","small")

Back in the day we had something not all that different in FORTRAN. There was (probably still is) an IF statement in FORTRAN that branches to one of three lines depending on if an arithmetic value is less than, equal to, or greater than zero.

IF ( N ) 10, 20, 30 

But enough history. What really changed my mind about this operator? As is typical for me I revalued it when I found a good use for it. I have been writing a version of the Reversi program in .NET and C#. I borrowed a bunch of Java code from my friend Tom Indelicato (read about that program here) Steal from the best is my motto and Tom is an outstanding programmer. Along with the syntactic changes moving from Java to C# I wrote a lot of code to make the game work in a graphical user interface. I made some different design decisions as well which changed how some things are handled. I created a user control class for the game squares for starters. As part of this I used three different integer values to indicate whether the square held a black disk,a white disk, or was empty.

In the past I have often used a Boolean value to indicate which of two players was the current player. Switching players is pretty simple with a Boolean value.

currentPlayer = !curentPlayer;

That wasn’t going to work if my player indicators were integers. I decided to use the ternary operator because I didn’t want to write multiple lines of code for something that simple. So I wrote:

Player = (Player == WHITE) ? BLACK : WHITE;

WHITE and BLACK are defined constants. The next thing I knew, I was finding uses for this operator in all sorts of places. The really cool thing (ok for a geek like me) was that I could use this statement inside other statements.

message = “No legal moves for " + ((Player == BLACK) ? "Black" : "White");

I guess this old dog can learn new (to him) tricks. Do you use/teach this operator? Are there other language features you have ignored until one day you realized they would be just right for something you were doing?

Thursday, June 03, 2021

Trip Report: Teaching as a Long Term Sub

Well, this is not actually a trip report but its something like it. I spend the last couple of months teaching at Phillips Exeter Academy as a long term substitute. It was an interesting experience for many reasons. Not the least of those was the pandemic precautions.  Everyone wore masks inside and out, there were clear dividers between all of the seats around the table (more about that table in a minute), and for most of the time faculty were tested for COVID twice a week. I was fully vaccinated before I started there and the school ran vaccination clinics for faculty and students during the term.

Phillips is different from most other schools. It is the literal definition of an exclusive New England boarding school for a start. With a very competitive admissions process one is not surprised that the students are smart and highly motivated. Many of the students I talked to were looking for more academic rigor than their local schools. Needless to say classroom management was never even close to an issue.

As I alluded to earlier, classes at PEA are taught around a table. It’s a big table but class size is limited to about 13. None of my classes were larger than 12 and two sections were 10 students. Yes, that’s wonderful for a teacher. Between the small class size and teaching around a table it is not easy for a student to get lost. Teaching around a table forces a more conversational method of teaching. Its very interactive. I really enjoyed the format.

Another part of the system there is something they call METIC. I forget what that stands for but basically what it is is a mid-term check in. Students in the class are given some time without the teacher present to discuss what was going well in the class, what is not going well, and what students and teacher can do to make the rest of the term go better. Now this can be hard on the ego for some teachers especially if students are hard on them. My students, and from what I hear  most students at PEA, are very respectful and honest. Following time without the teacher, the teacher returns and the items the students brought up (written on the white board) are discussed. For me as a new comer to the particular school environment this was extremely valuable. This is something I wish had happened earlier in my teaching career. I think it would have made me a better teacher.

Everything was not all smooth sailing of course. I took over the course in the fourth week of the term and my students had two other teachers in the first three weeks. Figuring out what students knew and didn’t know took me a while. I also had to figure out a plan for the rest of the term. Fortunately, other members of the CS department were incredibly helpful and supportive. I was give full access to curriculum from a previous time these two courses had been taught. This saved immeasurable amounts of prep time.They were also always available for my many questions about the courses and the school’s processes.

As I alluded to in my earlier post (Back in the Classroom Again) I had to reacquaint myself with Java and learn my way around two IDEs (Eclipse and Processing) that I had never used before. Its tough answering questions about IDEs when you have no real experience with them. Fortunately I am good at exploring menus and looking up things on the Internet. I’m far from expert at either IDE but I’m not totally lost either. I found Processing and its graphics library fun and interesting. My old experience with XNA from years ago helped me out there. Though I do wish Processing had some built in collision detection. Probably good for students to figure out and code that for themselves but I’ve been spoiled by .NET. I would use Processing again for Java.

Overall, I had a great experience. I learned a lot, got to work with great teachers, and teach some awesome students. I’m not unhappy about getting back into retirement though.