How To Code Simple Data — Week 1a

A recap of what I learned in the first part of the edX/UBCx course HtC: Simple Data

Moving far far away from the “familiar” land of JavaScript, we take a step aside to learn a new language, Racket. The first part of Week 1 for this course teaches the fundamentals of “Beginning Student Language” a subset of Racket Language. Racket is a run-time compiled language (like JS) that is most easily written and run in the Dr Racket open source software. It is a whole lot different than JS.

Racket has different types from JS, and seems to be strongly typed. We have strings, booleans, images, numbers. We start all our calls with a paren, and the notation is a bit funny. To add two numbers we write (+ 2 2). With more math we can write (+ 2 (* 3 2)) which gives 8. To compare if six is more than two we write (> 6 2) and that would give a boolean true. We can define constants: (define image1 (circle 10 "solid" "red)). The IDE is a bit tough, as it doesn’t close parens automatically.

However when you make a mistake, the error reports are generally quite helpful about what you did wrong, usually a forgotten or misplaced paren. The software also has a great stepper tool for debugging! It also has (so far) thorough and helpful docs.

This course is aimed at those who have never programmed much, but it steps up the game pretty quickly. So far I am enjoying it, even if it’s another white male teaching :)


I will close with this bit of positivity from Professor Kiczales:

One of the great things about computer programming is these machines are not fragile. If you make a mistake, you get an error message, not quite the right thing happens, you just fix it.
I’m not saying we shouldn’t worry about errors in our programs. The design method we’re going to learn is going to help us prevent and find such errors.
All I’m saying is, if you get an error while you are working, don’t worry about it.