“Hello, World!” in 20 Different Programming Languages
We all know it and we’ve all written it, but what does the classic “Hello, World!” program look like across 20 different programming languages?
The “Hello, World!” program is a one that needs no introduction. It’s the very first step on every developers journey, but you might be surprised how different that step can look dependent on the language you choose…
Along the way, I’ll give a brief introduction to the language and my thoughts on each “Hello, World!” implementation.
1. Python
print("Hello, World!")
Python is a versatile and beginner-friendly language known for its simplicity and readability. The “print” function is used to display the “Hello, World!” message on the console.
I’m a python enthusiast so might be a bit biased, but love the one line simplicity for this implementation. Perfect for beginners!
2. Java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Java, a popular object-oriented language, requires a class definition. The “System.out.println” statement prints the message to the console.
Less beginner friendly than the Python version but not bad for a purely object oriented language.
3. C
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
C, a low-level language, uses the “printf” function from the standard library to print the message.
This is one of the more complex ones on the list but C is a lower level language so it’s excused.
4. C++
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
C++ is an extension of the C language with additional features. It utilizes the “std::cout” object from the “iostream” library to output the message.
Another member of the C family, so looks very similar to the C version of this program.
5. JavaScript
console.log("Hello, World!");
JavaScript, commonly used for web development, uses the “console.log” function to display the message in the browser console.
One liner, very clean and succinct.
6. Ruby
puts "Hello, World!"
Ruby, known for its simplicity and expressiveness, uses the “puts” method to output the message.
Yet another one line “Hello, World!” program; very nice!
7. Swift
import Swift
print("Hello, World!")
Swift, a modern language developed by Apple, employs the “print” function to display the message.
Easy and Simple to understand. Bravo!
8. Go
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
Go, designed for efficiency and simplicity, utilizes the “fmt.Println” function to print the message.
Bit more complex than most of the others. The “Println” command is clear though which is a plus.
9. Rust
fn main() {
println!("Hello, World!");
}
Rust, a systems programming language, employs the “println!” macro to output the message to the console.
Another clean implementation. I wonder what the “!” in “println!” means though.
10. PHP
<?php
echo "Hello, World!";
?>
PHP, widely used for web development, uses the “echo” statement to display the message in the browser.
This one is rather unique. Good showcase of what “Hello World!” looks like in tag language nonetheless.
11. Perl
print "Hello, World!\n";
Perl, known for its text-processing capabilities, uses the “print” function to output the message.
More of what I’ve said before. Clean one liner.
12. R
print("Hello, World!")
R, a language popular for data analysis and statistics, uses the “print” function to display the message.
Perfection. We’ve seen ones like this on the list already but this is the ideal “Hello World!” programmer to any novice programmer.
13. Kotlin
fun main() {
println("Hello, World!")
}
Kotlin, a modern language that interoperates with Java, utilizes the “println” function to print the message.
Pretty good.
14. MATLAB
disp('Hello, World!');
MATLAB, widely used in scientific and numerical computing, uses the “disp” function to display the message.
“disp” is a new keyword. MATLAB is a very unique language so its fitting.
15. Lua
print("Hello, World!")
Lua, a lightweight scripting language, employs the “print” function to output the message.
Beautiful.
16. Haskell
main = putStrLn "Hello, World!"
Haskell, a purely functional language, uses the “putStrLn” function to print the message.
This one’s rather distinct. The assignment is something you don’t normally see in a “Hello, World!” program.
17. Shell (Bash)
echo "Hello, World!"
Bash, a popular shell scripting language, uses the “echo” command to display the message.
Simple and clean.
18. TypeScript
console.log("Hello, World!");
TypeScript, a typed superset of JavaScript, employs the “console.log” function to output the message.
Same as JavaScript, which makes sense.
19. Scala
object HelloWorld {
def main(args: Array[String]): Unit = {
println("Hello, World!")
}
}
Scala, a modern object-oriented language, uses the “println” function to display the message.
A lot going on here. On a side note if you haven’t heard of Scala, it’s a good one to look into. One of my favourite functional languages.
20. Dart
void main() {
print("Hello, World!");
}
Dart, commonly used for Flutter app development, utilizes the “print” function to output the message.
A nice, clean version to finish up!
The Take Away
Well, there you go! That’s the famous “Hello, World!” program across 20 different programming languages.
It’s fascinating to see how such a simple program can give us glimpses into the different syntax, characteristics and features of each language.
Thanks For Reading and Happy Coding!