Table of contents
- 1. Python
- 2. Java
- 3. C
- 4. C++
- 5. JavaScript / TypeScript / Node.js
- 6. Ruby
- 7. PHP
- 8. Swift
- 9. Go
- 10. C
- 11. Kotlin
- 12. Objective-C
- 13. R
- 14. Perl
- 15. Bash
- 16. Scala
- 17. Rust
- 18. Dart
- 19. Shell
- 20. Lua
- 21. SQL
- 22. Assembly
- 23. WebAssembly
- 24. Visual Basic .NET
- 25. COBOL
- 26. FORTRAN
- 27. Ada
- 28. Pascal
- 29. Prolog
- 30. Smalltalk
- BONUS
- 'Hello World' in Binary
Sure, here's a list of the top 30 programming languages along with a code example of how to write "Hello, World!" in each of them:
1. Python
print("Hello, World!")
2. Java
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
3. C
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
4. C++
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
5. JavaScript / TypeScript / Node.js
console.log("Hello, World!");
6. Ruby
puts "Hello, World!"
7. PHP
<?php
echo "Hello, World!";
?>
8. Swift
print("Hello, World!")
9. Go
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
10. C
using System;
class Program {
static void Main(string[] args) {
Console.WriteLine("Hello, World!");
}
}
11. Kotlin
fun main(args: Array<String>) {
println("Hello, World!")
}
12. Objective-C
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"Hello, World!");
}
return 0;
}
13. R
cat("Hello, World!\n")
14. Perl
print "Hello, World!\n";
15. Bash
#!/bin/bash
echo "Hello, World!"
16. Scala
object HelloWorld {
def main(args: Array[String]): Unit = {
println("Hello, World!")
}
}
17. Rust
fn main() {
println!("Hello, World!");
}
18. Dart
void main() {
print("Hello, World!");
}
19. Shell
echo "Hello, World!"
20. Lua
print("Hello, World!")
21. SQL
SELECT 'Hello, World!';
22. Assembly
section .text
global _start ;must be declared for linker (ld)
_start: ;tell inker entry point
mov edx, len ;message length
mov ecx, msg ;message to write
mov ebx, 1 ;file descriptor (stdout)
mov eax, 4 ;system call number (sys_write)
int 0x80 ;call karnel
mov eax, 1 ;system call number (sys_exit)
int 0x80 ;call karnel
section .data
msg db 'Hello, World!', 0xa ;there's our message
len equ $ - msg ;the length of the message
23. WebAssembly
(module
(func (export "sayHello") (result i32)
(i32.const 4)
(i32.const 1)
(i32.const 14)
(i32.const 4)
(call 0)
(i32.const 0)
(return)
)
(memory (export "memory") 1)
(data (i32.const 4) "Hello, World!\00")
)
24. Visual Basic .NET
Module HelloWorld
Sub Main()
Console.WriteLine("Hello, World!")
End Sub
End Module
25. COBOL
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY "Hello, World!".
STOP RUN.
26. FORTRAN
PROGRAM HELLO
PRINT *, "Hello, World!"
END PROGRAM HELLO
27. Ada
with Ada.Text_IO; use Ada.Text_IO;
procedure Hello_World is
begin
Put_Line("Hello, World!");
end Hello_World;
28. Pascal
program HelloWorld;
begin
Writeln('Hello, World!');
end.
29. Prolog
main :-
write('Hello, World!'), nl.
30. Smalltalk
'Hello, World!' displayNl
BONUS
Haskell
main :: IO ()
main = putStrLn "Hello, World!"
Self
"Hello, World!" print.
Clojure
(println "Hello, World!")
CoffeeScript
console.log "Hello, World!"
Elm
main =
Text.plainText "Hello, World!"
TOML
main =
Text.plainText "Hello, World!"
YAML
message: Hello, World!
'Hello World' in Binary
01001000 01100101 01101100 01101100 01101111 00101100 00101100 00101111 00101100 01101111 01101110 01100101 01110100 00101100 00101111 00101100 01101111 01101110 01100101 01101110 00101100 01101111 01101110 01101001 01101110 01100111 00101110 00101100 00101111 00101100 00101000 00101100 00101111 00101100 00101111 00101100 00101111