Skip to main content

Hello World in 20 Programming Languages

· 2 min read
Phạm Quyết Thắng
Fullstack developer

Certainly, each of us has started programming with the classic "Hello, World!" program. It's a small but crucial step that helps you get familiar with the basic syntax of a new programming language. In this article, let's explore how "Hello, World!" is written in 20 popular programming languages (Java, C#, Python, JavaScript, PHP, ...).

Image

1. Python:

"Hello, world" Python

print("Hello, World!")

2. Java

"Hello, world" Java

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

3. JavaScript:

"Hello, world" JavaScript

console.log("Hello, World!");

4. C:

"Hello, world" C

#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}

5. C++:

"Hello, world" C++

#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
return 0;
}

6. C#:

"Hello, world" C#

using System;
class HelloWorld {
static void Main() {
Console.WriteLine("Hello, World!");
}
}

7. Ruby:

"Hello, world" Ruby

puts "Hello, World!"

8. PHP:

"Hello, world" PHP

<?php
echo "Hello, World!";
?>

9. Swift:

"Hello, world" Swift

print("Hello, World!")

10. Go:

"Hello, world" Go

package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}

11. Kotlin:

"Hello, world" Kotlin

fun main() {
println("Hello, World!")
}

12. Rust:

"Hello, world" Rust

fn main() {
println!("Hello, World!");
}

13. TypeScript:

"Hello, world" TypeScript

console.log("Hello, World!");

14. Dart:

"Hello, world" Dart

void main() {
print("Hello, World!");
}

15. Objective-C:

"Hello, world" Objective-C

#import <Foundation/Foundation.h>
int main() {
NSLog(@"Hello, World!");
return 0;
}

16. Shell Script:

"Hello, world" Shell Script

echo "Hello, World!"

17. R:

"Hello, world" R

cat("Hello, World!\n")

18. Perl:

"Hello, world" Perl

print "Hello, World!\n";

19. Haskell:

"Hello, world" Haskell

main :: IO ()
main = putStrLn "Hello, World!"

20.Lua:

"Hello, world" Lua

print("Hello, World!")