Pages

Tinker tailor

Coder, hacker, tinker tailor.
Ritchie, Thompson: Unix. Mailer.
Programming language, which shall it be,
Which shall it be that will speak to me?
Compiled, interpreted, strong or weak,
Java, Python, Snap! or Squeak?

The laws of physics apply to animate and inanimate matter alike. A computer screen doesn’t care an iota about fonts. And microprocessors execute instructions oblivious to the high-level languages programs are written in. In this sense, one’s choice of programming language doesn’t matter at all. But programming, like life and typography, is zealously embraced by converts of many competing religions.

Column 2 of More Programming Pearls: Confessions of a Coder, by Jon Bentley, is about associative arrays. Bentley begins with a conversation about language:

Anthropologist say that language has a profound affect on world view. That observation, usually known as Whorf’s hypothesis, is often summarized as “Man’s thought is shaped by his tongue.”

Like most programmers, my computing thought is shaped by my Algol-like tongue. PL/1, C and Pascal look pretty much alike to programmers like me, and it’s not hard for us to translate such code into Cobol or Fortran. Our old, comfortable thought patterns can be easily expressed in these languages.

But other languages challenge the way we think about computing. We are amazed by Lispers as they work magic with their S-expression and recursion, by APL fans who model the universe as the outer product of a couple of long vectors, and by Snobol programmers who seem to turn any problem into a big string. We Algolish programmers may find it painful to study these foreign cultures, but the exposure usually yields insight.

Toddlers learning to speak have no say in the languages they learn first. Our native tongues are thrust upon us by circumstance and by the choices of those who raise us. Which programming languages we learn first, however, is a decision that can be made more deliberately.

But if the College Board prescribes Java for AP Computer Science A (what a name) and principles/pals dictate that AP Computer Science A shall be the name of the course, then those are the circumstances some teachers and students will find themselves in. Some might breathe a sigh of relief: Thank God I didn’t have to choose. Some might grit their teeth. Others might not think twice. College professors who write and hope to sell books have dogs in the hunt. A visionary who cares more about his work than his bank-account balance (the former takes care of the latter) invented a hypothetical computer and an assembly language to go with it and the books, well-aware that they “may already be of little interest to anyone.”

Today, Google gives us Chrome, Microsoft produces Edge, Mozilla makes Firefox, Apple unleashes Safari, and all these sirens support JavaScript, HTML and CSS straight out of the box. Web browsers are everywhere and require little if any additional software or special configuration to be used as a platform for learning to program. That's one of the main reasons this sailor is attracted to those technologies.

I’m no language expert, but I doubt there’s much that’s seriously and inherently wrong with either strongly or loosely typed programming languages per se. It took a little while, but I’ve acquired a taste for JavaScript’s loose typing. On the other hand, I immediately fell for its built-in associative arrays. And the ease with which JavaScript can be used in the context of the web is noteworthy.

An argument for strongly typed, compiled languages like Java is articulated in a textbook I selected for a class I teach at VCHS. In Computer Science: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne write:

The programs that we are writing are very similar to their counterparts in several other languages, so our choice of language is not critical. We use Java because it is widely available, embraces a full set of modern abstractions, and has a variety of automatic checks for mistakes in programs, so it is suitable for learning to program. There is no perfect language, and you certainly will be programming in other languages in the future.

JavaScript is also widely available and embraces a full set of modern abstractions. But it has fewer automatic checks for mistakes in programs than Java has, at least prior to actually executing a program. This is because raw JavaScript programs are immediately interpreted, statement-by-statement, without an initial compilation step. That said, programming languages that compile into JavaScript do exist. And Java programs are interpreted too — after they are compiled into an intermediate language called Java bytecode, a.k.a. the instruction set of the Java virtual machine.

In The Craftsman, Richard Sennett quotes Elliot Felix, who talks about how replacing drawing by hand with CAD (computer-assisted design) programs impacts architecture students:

each action is less consequent than it would be [on] paper . . . each will be less carefully considered.
Automation isn’t always everything it’s cracked up to be.

* * *

Have you read what Peter Norvig has to say about learning to program in Teach Yourself Programming in Ten Years? What about what Paul Graham says about programming languages in Hackers and Painters? Did you read it?

Our neurons must be used . . .
not only to know but also to transform knowledge;
not only to experience but also to construct.

— Santiago Ramón y Cajal

(Read more Cajal at brainpickings.)