Tuesday, April 15, 2014

Programming Languages Are Horrible

A bunch of my students in my honors programming class made the same error yesterday. Remarkably today Bertrand Meyer had a post about the very same error in the CACM Blog (Go read it – it’s great - Those Who Say Code Does Not Matter) The short version of my student’s problem revolved around how C-style languages handle if statements with multi-statement actions. Take for example the following code:
   1:              if (booleanExpression)
   2:                  DoSomething();
   3:                  DoSomthingElse();
   4:              if (!booleanExpression)
   5:                  DoAction();

Students have a tendency to assume that if the expression in line 1 is true that both of the statements in lines 2 and 3 will be executed. Not so. The compiler assumes that (regardless of indentation) only the statement in line 2 will be executed if the expression in line 1 is true. The statement in line 3 will always be executed. This caused my students no end of trouble. The right way to do this is to enclose the two statements inside curly braces.

   1:              if (booleanExpression)
   2:               {
   3:                  DoSomething();
   4:                  DoSomthingElse();
   5:               }
   6:              if (!booleanExpression)
   7:                  DoAction();

This removes ambiguity. I try to get students to use the curly braces even for single line code blocks but it is not an easy sell.

This problem doesn't occur in all languages of course. Visual Basic, derived from that ancient of languages BASIC, doesn’t allow this to happen as easily. Trying to do this line for line conversion in Visual Basic gives me errors.

   1:          If (booleanExpression) Then
   2:              DoSomeThing()
   3:              DoSomethingElse()
   4:          If (Not booleanExpression) Then
   5:              DoAction()

The compiler refuses to deal with this code until End If statements are added to make things clear.

   1:          If (booleanExpression) Then
   2:              DoSomeThing()
   3:              DoSomethingElse()
   4:          End If
   5:   
   6:          If (Not booleanExpression) Then
   7:              DoAction()
   8:          End If

Now I am not saying that Visual Basic is not without flaws. All programming languages have flaws. But we do have to be aware of these flaws. The flaw that Meyer wrote about was the same basic error my students made but was made by professional developers in a product that impacted millions of people. It is so easy to make “rookie mistakes” in many languages.

So does this impact the tools we teach with? Honestly, not really. The APCS exam is based on Java which has all the same problems of other curly brace and semi-colon languages. [Let’s be honest – are those curly braces and semi-colons there for the programmers or the complier writers?]  Especially in high schools where we are largely at the whims of things outside our control (APCS exam and pressure from parents and students to teach industry languages) wind up using Java, C++, and maybe C# for many courses.

Oh sure a lot of us get by with various versions of BASIC (and take flack for it from “experts”) but there is always the pressure to “move on.” Most of us at the high school CS level have barely heard of Eiffel (invented and promoted by Meyer) or other languages that have been invented in academic institutions. These languages sometimes do influence the development of other programming languages but seldom seem to migrate into industry intact.

What does that mean for us as educators? It means we wind up teaching students have to solve bugs that they’d be better off if the language did not permit to happen in the first place. This problem has, I believe, contributed to the development, popularity and use of drag and drop block programming languages for beginners. But eventually we all push our students to learning crummy languages.

I don’t see an easy answer. It will probably have to be the universities who solve this first. High schools are allowed to follow trends in higher education. And I have seen a lot of professional development organizations influenced by language choices of recent graduates. Though that almost always requires a common choice by many top universities which seems to be less common all the time.

For a lot of professional developers, especially those who are self taught, seem to view doing things the hard way as a point of pride. Looking for tools (or languages) that make creating bugs harder is seen as a crutch by the “brogrammer” crowd.

Ah, well, maybe when the current generation gets to be my age and loses the desire to spend time tracking down easy to prevent bugs things will change.

Monday, April 14, 2014

Interesting Links–14 April 2014

Crazy busy weekend for me. The weather was great and I got a lot done outside. Left me too tired to write this up last night. Sorry for the early birds who usually get here before now. Hope people find some useful things anyway.

This is a fun video Domino Addition – simulating binary gates using dominos.

The good folks at Phillips Exeter are putting on a hackathon for middle and high schoolers May 17. Probably of interesting only to New Hampshire and some Maine and Massachusetts students. But looks like fun. http://www.hackexeter.com/

Looking for a new CS teaching job? Or looking to hire a computer science teacher? You will want to check out the  CSTA jobs board.

BIG NEWS via NCWIT! Students age 13+ have the chance to attend this year’s Apple WWDC conference for free on a scholarship.

Computer Science as a School District Marketing Tool on the CSTA blog. The private school I teach at definitely lets people know about or CS offerings when we meet with prospective students. In an age of growing school choice and of people picking where to live based on schools does your school or district make the most of it’s CS courses as a marketing tool?

SHIP - Summer Hackers Immersion Program Really exciting looking summer program for computer science in Brooklyn NYC. I did a post about this last week but a link to the original announcement is worth re-sharing.

BTW I posted two other blog posts today about news from the CSTA members announcement list. If you didn’t see them or get the CSTA email check out:

Code: Echo–Programming Challenge

Using a coding challenge as a promotional event for a movie? This is a new one on me but it looks interesting. What I especially like is that they are sharing resources that students can incorporate into a game.


Here is a chance for your students to use their coding skills to win big!

Summer family movie EARTH TO ECHO is hosting "Code: Echo": a Challenge for students K-12 to create a game inspired by the film. Students can download assets and get creative.
PRIZES:
In each category there will be:

  • 1 grand prize winner ($5,000.00 + hometown screening)
  • 1 runner-up prize winner ($2,500.00)

WHO CAN ENTER
Students of all ages, a team with up to 4 friends, or an entire classroom.

Entries are due May 2nd. Start coding at www.codeechomovie.com.

Summer Work for Computer Science and Robotics Instructors

If you are a member of the CSTA you should have received this announcement via email. BUT if you didn’t or you are not a CSTA member (why not?) I thought this worth sharing.


Summer 2014 Employment Opportunities: Computer Science and Robotics Instructors

The Johns Hopkins University Center for Talented Youth (CTY) is seeking instructors for summer programs. CTY offers challenging academic programs for highly talented middle and high school students from across the country and around the world. Information regarding our summer programs can be found at www.cty.jhu.edu/summer. Positions are available at residential sites (room and board is provided in addition to salary) at various locations (see below) on the east and west coasts. A commuter site is also located in New York City.
We are currently seeking individuals with expertise in a number of Computer Science, Computer Programming, and Robotics courses. Graduate coursework is a desired qualification for instructor candidates.  Experience working with young students is a preferred qualification.

Active instructor openings at residential locations (room and board is provided in addition to salary):

  • Introduction to Robotics (5th and 6th graders): Bristol, RI and Chestertown, MD
  • Foundations of Programming (7th – 10th graders): Easton, PA
    ·         Fundamentals of Computer Science (7th – 10th graders): Lancaster, PA
  • Active instructor openings at commuter day site locations:
    • Introduction to Robotics (5th and 6th graders): New York City, NY

For detailed course descriptions, please visit

http://cty.jhu.edu/jobs/summer/courses/math_computer_science.html.
2014 Program Dates:
Session 1: June 29 - July 18
Session 2: July 19 - August 8
For a full list of locations and dates, please visit

http://cty.jhu.edu/jobs/summer/sites_dates.html.
More Information
Job Responsibilities, including salary:

http://cty.jhu.edu/jobs/summer/positions/residential/index.html

To apply, please visit

http://cty.jhu.edu/jobs/summer/apply/.
Please email resumes and inquiries directly to Peter Bruno, pbruno1@jhu.edu (Introduction to Robotics) or Joshu Fisher,jkfisher@jhu.edu (Foundations of Programming and Fundamentals of Computer Science).

Thursday, April 10, 2014

My Students Are Not Me

Sometime in elementary school a teacher taught number bases. I was fascinated. It was interesting. It was fun. It made perfect sense to me. I spent hours converting numbers from one base to another. For some reason base 5 and base 7 struck me as a lot of fun. I played with Binary and Octal as well. It just came easy. Lately I have been teaching (or trying) Binary to my students in our Explorations in Computer Science class. My students are not (to no ones surprise) me.

Some of them get it quickly. Some of the get it after a bit. And some of them just seem to think I am crazy. I have to remind myself that not everyone sees things the same. I have a lot of Resources For Teaching Binary Numbers (that is one of my most read posts BTW) and I am using a number of them. There is no one right way that works for everyone. I think I’ll keep trying.

I’m teaching classes and objects to my programming class these days and seeing the same sort of thing. Some people get it right away while others struggle.

Honestly I struggled with some of the concepts for a while myself. This is a big topic and I find that different people struggle with difference aspects of it. Why do we send messages for example. (see Don’t Just Grab the Wheel, Ask the Driver to Turn) The difference between getting methods and setting methods for an other. Again what was easy for me may be hard for others. And what was hard for me may come easy for others. I have to remind myself of that. It’s not all me and it is not all them.

There is never one right way to introduce a concepts to students. This is seldom more true than with computer science topics. So many of them are very far outside of a student’s previous experience. They often don’t have a good context to start with. It is up to me as a teacher to provide some context, some purpose, and to try and find enough ways to explain things that most (shooting for all) of my students to “get it.”

This as much as anything else is why teaching is so hard for some many people. It is easy to fall into the trap of saying “This explanation worked for me so it should work for everyone.” Well I think I’ll go now. I’m going to look at a video that may help some of my students.

Wednesday, April 09, 2014

Don’t Just Grab the Wheel, Ask the Driver to Turn

We’re learning about classes and related topics like data hiding and using methods rather than public data in my programming class these days. One of the students asked why we couldn’t just access public data from calling programs. One hears that all the time.

I asked him if when he was a passenger in a car he would ask the driver to turn or would he grab the wheel and turn it himself. I’m not sure is sunk in right away. The analogy didn’t seem to hit him as smoothly as it did me. The more I think about it the more I like it though.

We want the methods in a class to take care of the actions. We, the programmer using objects of that type, really don’t want to be making assumptions about how everything works internal to the class. There may be factors we don’t know about. Just like as a passenger in a car we may not be aware of things the driver is aware of.

The driver knows how responsive the car is, what sort of traffic there may be around the car, and a bunch of other things that we as a passenger may not be aware of. We’re much better off asking the driver to turn and letting them do it their way than taking things into our own hands.

This may be an analogy I can develop and use. Maybe it will help me to convince my students of the wisdom of data hiding and passing messages and requests.

Tuesday, April 08, 2014

Summer Hackers Immersion Program 2014

image

Mike Zamansky announced this program on his blog yesterday. (Announcing SHIP) It sounds amazing. It’s being run at St Joseph’s College in Brooklyn and is for students from all over New York City. Mike and his team are amazing teachers who are also getting support from NYC tech companies. This should be an outstanding opportunity for the students who are able to take part.

From Mike’s announcement:

SHIP is being hosted at St. Joseph's College in Brooklyn and runs from July 7th through July 31.

So, if you know a rising 9th through 12th grader in or around New York City let them know about this great opportunity.

Monday, April 07, 2014

Interesting Links 7 April 2014

Spring has sprung. Well at least the last of the snow is gone. Seems like late here but it hardly matters as I’ve been busy with school anyway. Seems like last week was slow for me on the Internet at least. Not to fear though I have a couple of links to share.

what is computational thinking? What indeed? This is a great explanation from the UK’s Computing At School site.

World Wide Access: Accessible Web Design video  I’m trying hard to get my students to understand the importance of making web pages accessible. This video from the University of Washington is a big help.

Why (And How) Students Are Learning To Code An infographic with a lot of information. 

Majors with the Most Pre-Graduation Job Offers. According to a recent study, students in these degrees receive more job offers before graduation.  Computer Science tops the list! 

How do we make programming languages more usable and learnable? A lot of discussion in the comments as well. Another great post by Mark Guzdial.

Senator Gillibrand Proposes New Legislation for Computer Science education 

Penn Scientists Teach Computer Programs How to Teach Programming  some news at Communications of the ACM.

Wednesday, April 02, 2014

Too Much Forgiveness

I’m teaching a little web development to my freshmen this week. Not a lot – it’s not a web development course – just enough to give them some idea of what is behind the screen. I’ve had students create a very simple profile page. The pages look pretty good when viewed in a web browser. The images are there. There are lists where there are web-developmentsupposed to be lists. And the hyperlinks (most of them) work. Sounds great right?

Well a lot of the code is a mess. <head> and <body> tags are missing. There is no proper closure to some of the list tags. And yet the pages work – for a basic definition of “work.” If I were a beginner placing my first web page on the Internet I’d be pleased. But I’m not. In fact knowing what I know about how things change I know in my gut that at some point pages like these will break and probably break badly. Eventually.

My job is to teach students to do things the right way. This is actually easier when doing the wrong thing causes thing to not work. Loading images breaks very easily but that is almost always a function of an incorrect specification of the file name or location. Operating system file systems are notoriously fussy. That is not always a bad thing because ambiguity is almost always a bad thing in computing. But web browsers are great at making assumptions about ambiguous HTML and doing (mostly) the right thing. Students are happy.

Next class we with have a long talk about what codes are missing or incorrect according to the standards. Someone will likely say “but it works fine in the web browser.” because these are teenagers and that is what teenagers say. I’ll come back with discussion of how small errors and code that can be ambiguous can cause unexpected problems later on and code develops. Hopefully they’ll accept that.

I’m thinking I need some new tools for them to use next time I teach this though. I need to look at software that verifies HTML and at least warns about errors. I have looked at the W3 Validator and it does some of what I need. I think I’ll keep looking as I don’t really want to write my own. Any suggestions? How do others check student web pages?