Welcome! This is a blog about programming. And what better way to begin a blog about programming than with a clichéd post about Hello World? The ubiquitous introduction to a language, the purpose of the hello, world program is to get the user up and running in an environment, prove that their system is working and provide a taste of its syntax and philosophy. So let’s see what we can learn about some contemporary languages from how they present us with this allegedly straightforward task. Today, it’s the turn of everyone’s ‘armless snaky friend, Python.
Hello world in Python is simple, right?
It’s terse, requires no unnecessary boilerplate and gets straight to the point, which tends to be true of the language in general. Excellent. We are encouraged to run it in an interactive mode to begin with, so let’s do so.
>>> print("Hello, world!") Hello, world!
Like I said, simple! But let’s take a look at some of the implicit assumptions made here:
- The python executable needs to be available in our environment, and if it wasn’t initially, then we needed to run a simple installer or take a trip to the system’s package manager.
- We need to understand the process of the call-response mechanism that command line interfaces use in order to enter the print command and interpret its output.
- We must be competent in text entry via, perhaps, a keyboard.
- This can run on a device somewhere that we have access to, maybe a desktop PC.
- We are fluent enough in written English to understand that ‘print’ is a verb and ‘Hello, world!’ is an object. And that the quotation marks in the construct “some words” draws on the metaphor of someone speaking.
- We understand, implicitly or explicitly, what is meant by the verb or an object of a sentence, what speech is, and how to record it as text.
Okay, stop! At some point we need to able to take some of this for granted, or we’re going to get nowhere. So let’s try taking a look at the concepts presented in the program itself that the user will be expected to understand or learn:
- The pattern
name(argument)is a statement indicating that the command name will be invoked with the given argument.
- The symbol
- The symbol
"Hello, world!"is also to be interpreted as an atom, in this case a string of characters in which whitespace does not act as a separator. Similarly, the alphabetic characters, comma and exclamation mark are to be interpreted as glyphs with no other special meanings. Defining string literals is likewise always available to the user as part of the language.
- The act of entering a newline causes the command to be evaluated and run.
- When evaluated, the command represented by
Phew. That’s actually quite a cognitive load! And we’ve not even got into other ‘simple’ concepts such as numbers, variables, sequential execution, conditional execution, loops, and function definition…
Fortunately, as users become familiar with a language and its concepts, they become familiar with these patterns and shapes. They can internalize what various names and constructs mean and build their abstractions accordingly. These become a springboard for learning higher level abstractions. It’s very easy to forget how hard the first few steps can be, and Python is one of the simpler entry points.
At any rate, welcome to my blog. Expect a lot more of this kind of analysis, with an emphasis on design aspects of specific languages, general programming philosophy, the occasional tip or trick and many ridiculous puns. Have a nice day!