Humans and computers use language to communicate with the world. Spoken languages such as Portuguese and English are used as a means of communication between humans. Computers also communicate with each other using various types of languages. These languages can take the form of protocols, binary signals, among other things. But when humans want to communicate with machines? That’s when a programming language comes to place.
Programming languages are the best way humans can communicate with computers, because it’s a middle ground between spoken languages and computer instructions. However, there’s a catch: generally speaking, computers do not understand programming languages by themselves. They need an interpreter or compiler that transforms the language into something easier for them to process, such as zeroes and ones: their native tongue, if you will.
Traditionally, when programmers start learning a new language, their first “words” are generally used to accomplish something very simple: to tell the computer to display “Hello, World!” to the screen. Let us see how we can do that in 5 different programming languages, and as a bonus, display “Hello, World!” in 5 different spoken languages as well.
- “Hello, World!” in C
- “Hello, World!” in Bash
- “Hello, World!” in Java
- “Hello, World!” in Python
- “Hello, World!” in C++
I want to start with the first programming language I’ve learned and the first spoken language I’ve learned: C and Portuguese, respectively. If you’re running a GNU/Linux distribution or another UNIX-like operating system, you may be able to see how to run the code.
“Hello, World!” in C
C is a simple, yet extremely powerful language, because it is what some developers call “low-level” language. That means it is closer of what a computer can understand by itself.
So here’s the code necessary to display “Hello, World!” in Portuguese, using the C language:
Here’s the output after compiling and running the code:
“Hello, World!” in Bash
Bash is an interpreted language. It means it does not need to be compiled. An interpreter translates the instructions one by one so the computer can understand it. In this case, we can create a script file that the interpreter will read line by line and interpret it.
So here’s the script to display “Hello, World!” in English, using Bash:
And here’s the output after running the script:
“Hello, World!” in Java
Java is a different kind of language. It is actually compiled to bytecode, which computers do not understand. Once compiled, this bytecode needs to be interpreted by a JVM (Java Virtual Machine), a special kind of program that will tell the computer what it should do based on the bytecode. Because the way it works, bytecode can be runned everywhere! Or at least everywhere as long as there’s a JVM running on that computer.
It also uses the Object-Oriented paradigm of dealing with code, so it is quite different to use as well. Here’s how we can display “Hello, World!” in French, using Java:
Here’s the output after compiling it to bytecode and running the bytecode:
“Hello, World!” in Python3
Python is another interpreted language. It’s very popular with automation scripts, but also in machine learning and data science.
A tip about Python that might help you if you are starting: always double-check your indentation and try to use an IDE that helps you with that. Consistent indentation is absolutely necessary with Python, otherwise the code will not run.
Here’s how we can display “Hello, World!” in Spanish, using Python:
And here’s the output after running the script:
“Hello, World!” in C++
Finally, let’s use C++. It is backwards compatible with C, so the C code we have used before will work here. But instead of doing that, we can use C++ specific code.
Here’s how to display “Hello, World!” in Italian, using C++:
Here’s the output after compiling and running the code:
That’s it! I hope you liked my first post! Goodbye, World!