When learning a new programming language, developers frequently write “Hello, World!” as their first program. It provides a straightforward method of familiarising oneself with syntax, fundamental output functions, and compilation or interpretation procedures.
We’ll look at how to print “Hello, World!” in 50 different programming languages in this post.
This highlights the similarities of programming fundamentals while showcasing the diversity and syntactic variances among programming languages.
Here are the first 10 “Hello, World!” examples with explanations:
1. Python
Python is a popular high-level programming language known for its simplicity and readability.
print("Hello, World!")
This program prints “Hello, World!” to the console using the built-in print()
function.
2. Java
Java is a widely-used object-oriented programming language.
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
The main
method serves as the entry point, and System.out.println()
prints the message.
3. C
C is a foundational programming language known for its efficiency and low-level capabilities.
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
Here, printf()
from the standard I/O library outputs the message.
4. C++
C++ extends C with object-oriented features.
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
return 0;
}
cout
is used to print text to the console.
5. JavaScript
JavaScript is a versatile scripting language primarily used for web development.
console.log("Hello, World!");
console.log()
outputs the message in the browser console.
6. TypeScript
TypeScript is a superset of JavaScript with static typing.
console.log("Hello, World!");
It works similarly to JavaScript but with added type safety.
7. Swift
Swift is Apple’s programming language for iOS/macOS development.
print("Hello, World!")
print()
prints the message to the console.
8. Kotlin
Kotlin is a modern language used for Android and backend development.
fun main() {
println("Hello, World!")
}
println()
prints the message with a newline.
9. Ruby
Ruby is a dynamic, object-oriented language known for its readability.
puts "Hello, World!"
puts
prints the message with a newline.
10. PHP
PHP is a popular scripting language for web development.
<?php
echo "Hello, World!\n";
?>
echo
outputs text to the web page or console.
11. Go
Go (Golang) is a statically typed, compiled language known for concurrency support.
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
fmt.Println()
prints the message with a newline.
12. Rust
Rust is a systems programming language with a focus on safety and concurrency.
fn main() {
println!("Hello, World!");
}
println!()
is a macro that prints the message with a newline.
13. Dart
Dart is used for building web and mobile applications (e.g., Flutter framework).
void main() {
print("Hello, World!");
}
print()
outputs the message.
14. R
R is a programming language focused on statistical computing and graphics.
print("Hello, World!")
The print()
function outputs the message to the console.
15. Perl
Perl is a high-level, general-purpose programming language.
print "Hello, World!\n";
print
is used to output text.
16. Haskell
Haskell is a purely functional programming language.
main = putStrLn "Hello, World!"
putStrLn
prints the message with a newline.
17. Lua
Lua is a lightweight scripting language used in game development.
print("Hello, World!")
The print()
function outputs the message.
18. Elixir
Elixir is a functional programming language designed for scalability and maintainability.
IO.puts "Hello, World!"
IO.puts
prints the message with a newline.
19. Julia
Julia is designed for high-performance numerical computing.
println("Hello, World!")
println()
prints the message.
20. C#
C# is a multi-paradigm programming language developed by Microsoft.
using System;
class Program {
static void Main() {
Console.WriteLine("Hello, World!");
}
}
Console.WriteLine()
outputs the message.
21. Bash
Bash is a command-line scripting language used in Unix-based systems.
echo "Hello, World!"
The echo
command prints the message to the terminal.
22. Shell Script (sh)
Shell scripting is used for automating command execution in Unix-based systems.
#!/bin/sh
echo "Hello, World!"
The echo
command prints the text, and #!/bin/sh
specifies the shell interpreter.
23. Scala
Scala is a functional and object-oriented programming language that runs on the JVM.
object Main extends App {
println("Hello, World!")
}
println()
prints the message with a newline.
24. Objective-C
Objective-C was widely used for iOS/macOS development before Swift.
#import <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
printf()
prints the message to the console.
25. MATLAB
MATLAB is used for numerical computing and data analysis.
disp('Hello, World!')
disp()
displays the message in the command window.
26. F#
F# is a functional-first programming language on the .NET platform.
printfn "Hello, World!"
printfn
prints the message with a newline.
27. Groovy
Groovy is a JVM-based scripting language.
println "Hello, World!"
println
prints the message with a newline.
28. COBOL
COBOL is an old programming language used in business applications.
IDENTIFICATION DIVISION.
PROGRAM-ID. HelloWorld.
PROCEDURE DIVISION.
DISPLAY "Hello, World!".
STOP RUN.
DISPLAY
prints the message, and STOP RUN.
terminates the program.
29. Fortran
Fortran is one of the oldest programming languages, used in scientific computing.
program hello
print *, "Hello, World!"
end program hello
print *,
prints the message with a space separator.
30. Lisp
Lisp is a family of functional programming languages.
(print "Hello, World!")
print
outputs the message to the console.
31. Prolog
Prolog is a logic programming language used in AI and symbolic reasoning.
:- initialization(main).
main :- write('Hello, World!'), nl.
write/1
prints the message, and nl
adds a newline.
32. Scheme
Scheme is a minimalist Lisp dialect used in functional programming.
(display "Hello, World!") (newline)
display
prints the message, and newline
moves to the next line.
33. Erlang
Erlang is a concurrent functional programming language used in telecom and distributed systems.
-module(hello).
-export([start/0]).
start() -> io:fwrite("Hello, World!\n").
io:fwrite
prints the message.
34. Smalltalk
Smalltalk is an object-oriented, dynamically typed language.
Transcript show: 'Hello, World!'.
Transcript show:
prints the message.
35. Delphi (Object Pascal)
Delphi is a rapid application development language based on Pascal.
program HelloWorld;
begin
Writeln('Hello, World!');
end.
Writeln
prints the message with a newline.
36. Pascal
Pascal is an old structured programming language used in teaching and early software development.
program Hello;
begin
writeln('Hello, World!');
end.
writeln
prints the message with a newline.
37. TCL
TCL is a scripting language often used for automation and testing.
puts "Hello, World!"
puts
prints the message.
38. Rexx
Rexx is an interpreted scripting language.
say "Hello, World!"
say
prints the message to the console.
39. ABAP
ABAP is a language used for developing business applications in SAP.
REPORT ZHELLO.
WRITE 'Hello, World!'.
WRITE
prints the message.
40. J
J is a high-level, array-oriented programming language.
echo 'Hello, World!'
echo
prints the message.
41. Forth
Forth is a stack-based programming language.
." Hello, World!" CR
."
prints the message, and CR
moves to a new line.
42. OCaml
OCaml is a functional programming language with strong static typing.
print_endline "Hello, World!"
print_endline
prints the message followed by a newline.
43. Ada
Ada is a structured, statically typed language used in safety-critical applications.
with Ada.Text_IO;
procedure Hello is
begin
Ada.Text_IO.Put_Line("Hello, World!");
end Hello;
Put_Line
prints the message with a newline.
44. D
D is a systems programming language with high performance and safety.
import std.stdio;
void main() {
writeln("Hello, World!");
}
writeln()
prints the message with a newline.
45. Nim
Nim is a statically typed compiled language with Python-like syntax.
echo "Hello, World!"
echo
prints the message with a newline.
46. Haxe
Haxe is a multi-platform programming language.
class Main {
static function main() {
trace("Hello, World!");
}
}
trace()
outputs the message, usually in a debugging console.
47. Crystal
Crystal is a compiled language with Ruby-like syntax.
puts "Hello, World!"
puts
prints the message with a newline.
48. Apex
Apex is Salesforce’s proprietary programming language.
System.debug('Hello, World!');
System.debug
logs the message in the debug output.
49. PowerShell
PowerShell is a scripting language used for automation on Windows.
Write-Output "Hello, World!"
Write-Output
prints the message to the console.
50. VHDL
VHDL is a hardware description language used in FPGA and circuit design.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity HelloWorld is
end HelloWorld;
architecture Behavioral of HelloWorld is
begin
process
begin
report "Hello, World!";
wait;
end process;
end Behavioral;
report
prints the message in a simulation environment.
If you have doubt in which is the best programming language to learn, the below video might help 👇
Although the syntax, structure, and functions of programming languages vary, they all essentially aim to enable us to convey commands to a machine. Writing a rudimentary “Hello, World!” program is frequently the first step in learning a new language since it gives you a better understanding of its syntax, execution mechanism, and fundamental features.
Examining “Hello, World!” in 50 different languages demonstrates the variety of programming paradigms, including declarative, procedural, object-oriented, and functional.
Learning new languages broadens your problem-solving abilities and enhances your comprehension of software development, regardless of your level of experience. The next stage is to move past “Hello, World!” and become proficient in the language of your choosing by experimenting with variables, loops, functions, and more.
Thanks for reading, hope you found it useful. Please give a like as a sort of encouragement and also share this post in socials to show your extended support.
About Me 👨💻
Hi, I’m Dhanush Nehru — an Engineer, YouTuber and Content Creator. I love sharing my knowledge through articles and videos.
Feel free to connect with me on X , Instagram, Github or Youtube.