A book titled 'Stunning CSS' sits on top of another entitled 'JavaScript & JQuery".
Technology

Programmer’s Guide to the Galaxy

Posted on

Folk artist Joni Mitchell once sang that “you don’t know what you’ve got ‘til it’s gone.”

Boy, was she right.

Prospective Computer Science majors at Wesleyan must take COMP211 (Computer Science I) and COMP212 (Computer Science II).

Different professors teach these courses every semester, which could mean that the programming language of instruction changes as well.

I took COMP211 in the fall of my sophomore year. The professor taught the class using Python, a programming language I had heard of but never actually studied. My lack of experience didn’t cause much of a problem, though, since the lectures were fairly easy to follow.

In an early homework assignment, students had to write is_prime, a function that stated whether or not a given number x was prime (‘prime’ meaning that x’s only factors of multiplication are 1 and x):

A chunk of multi-colored of Python programming code is written against a purple background.
(This is the function is_prime as written in Python using the code editor Visual Studio Code.)

Although homework assignments and exams were sometimes difficult, COMP211 seemed like a walk in the park compared to COMP212.

I enrolled in COMP212 during the spring of 2020. At that time, COMP212 was taught using SMLNJ (Standard Meta-Language of New Jersey), which is a variation on the generic programming language of SML.

Studying SMLNJ required a lot of adaptation since I was already used to coding in Python. Even halfway into the semester, I still made mistakes while coding SMLNJ, mainly due to its structure being quite different from that of Python.

For a COMP212 homework assignment, students had to write mult, a function that defined basic multiplication of two numbers:

A chunk of blue, white, and orange SMLNJ programming code is written against a dark gray background.
(This is the function mult as written in SML using the code editor Atom.)

When defining a function in Python, you name the function, its purpose, and other important descriptors in a section known as the “specifications.”

In Python, the specifications are in pink and sandwiched between quotation marks. In SMLNJ, the specifications are gray and written in between asterisks and parentheses above the function.

In SMLNJ, you have to name the variable and describe its type in the same line; in the second screenshot, “int” is short for “integer”, which means the function’s inputs are numbers.

Also, since Python is more well-known than SMLNJ, it is easier to find programs that can both edit and test Python code.

For SMLNJ, you have to use a computer terminal, which is a built-in hardware device that displays data from a program or computing system.

While I am familiar with the terminal after having used it several times in COMP211, it adds to the onus of having to keep two applications open on your desktop:

A window for a computer terminal and another for a code editing program sit open on an Apple Mac desktop.
(Here’s a screenshot of my desktop with the terminal & Atom open.)

Although Python and SMLNJ have their respective differences, skilled programmers use the same process of structuring a similarity between the two languages is the order in which you write the code.

First, you “define” the function by giving it a name, stating its inputs, and writing its specifications in a comment. Next, you write the body of the function, which means implementing variables in order to receive an output.

After those two steps, you write some tests to determine whether your function is working properly.

(These are the tests I wrote for mult.)

If your tests are correct, you’re all set. If not, the terminal or code editor will tell you what went wrong, and you edit your function until your tests are correct.

Programming requires work, but learning how to code in different languages helps with versatility and being well-rounded.

I may claim that Python is “easier” to learn than SMLNJ, but would that be the case if I had studied SMLNJ first, then Python?

Who knows?

(featured image credit: @kobuagency via unsplash.)

css.php