The "Hello world" program is usually the first introduction to any programming language. It demonstrates the minimum amount you need to write a C program. It looks like this in the C programming language:
A Hello World program in C. It demonstrates the minimum amount you need to write a C program.
In more modern languages however, this example isn't as useful anymore. Here's the same example in Python. Notice how it doesn't teach anything other than print
.
A Hello World program in Python. There's barely anything in it!
In today's world of more succint programming languages, we need a different "hello world" to demonstrate language features better. Here's what I propose:
A "better" Hello World program in JavaScript, showing more basic functionality than just printing lines.
This simple example demonstrates a few more things than printing strings, such as:
Functions: How to write a function with an argument, and returning values from functions. Also shows the naming convention for functions (
camelCase
).
Variables: How to assign variables.
Strings: Dealing with basic string functions.
I've started writing these kinds of programs for languages that I'm learning. Here's how it'd look like in Go, which I've added to my Go cheatsheet:
Here's an Elixir version, also at the Elixir cheatsheet: