Hello, world! (Hsss! Ssss…)

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.

Python

Hello world in Python is simple, right?

print("Hello, world!")

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 print is to be interpreted as an atom, in this case an identifier representing a named command, which is implicitly always available to the user.
  • 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 print makes use of some aspect of the underlying machine to output its argument on a display, most likely the same console as where the input was made. The double-quotes are not included in the output, so there is some difference between the representation of the underlying string and the format of the glyphs that form the output. Oh, and by the way, the action of printing to the console occurs as a ‘side effect’ – something that cannot be expressed in the language directly.

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!

3 thoughts on “Hello, world! (Hsss! Ssss…)

  1. This is really helpful and interesting! I recently started learning Python, and “Hello, world!” was indeed the first thing I ever did. Though I did figure out how to type it right into my computer’s command prompt/terminal, which I didn’t know could be used for Python before (I had some experience with IDLE before when I was working on visual novels in Ren’Py, a program that uses the Python language). The number of steps that even this simple single line of code has is mind-boggling! And surely, it’ll only get more complex from here. 🤣

    Like

    1. Ah, neat! I’m glad and I hope you stick with it. Programming can be complicated, but the more you practise the easier it gets, and paradoxically when you start to get a feel for things they become less complex. It’s exactly the same reason why you don’t have to think very much about pushing individual keys on the keyboard after you’ve spent a lot of time typing. One of things I find most fun about programming is never running out of new things to learn or build 😀

      Liked by 2 people

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s