Hello World in 35 Programming Languages

Hello World in 35 Programming Languages

A timeless custom known as the “Hello, World!” program marks the start of every programmer’s adventure in the wide world of programming. This surprisingly easy article examines the various ways that 35 different programming languages express this well-known statement. Every “Hello, World!” implementation offers a glimpse into the distinct syntax and personality of the language it represents, from traditional languages like C and Java to more contemporary and specialized languages like Kotlin and TypeScript.

1) C:

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

2) Java:

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

3) Python:

print("Hello, World!")

4) JavaScript:

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

5) C++:

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

6) Ruby:

puts 'Hello, World!'

7) Swift:

print("Hello, World!")

8) Go:

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

9) Kotlin:

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

10) Rust:

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

11) TypeScript:

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

12) PHP:

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

13) Perl:

print "Hello, World!\n";

14) Haskell:

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

15) Shell Script:

#!/bin/bash
echo "Hello, World!"

16) R:

cat("Hello, World!\n")

17) Objective-C:

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

18) Dart:

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

19) Lua:

print("Hello, World!")

20) Scala:

object HelloWorld {
    def main(args: Array[String]): Unit = {
        println("Hello, World!")
    }
}

21) VBScript:

MsgBox "Hello, World!"

22) PowerShell:

Write-Host "Hello, World!"

23) Matlab:

disp('Hello, World!')

24) COBOL:

IDENTIFICATION DIVISION.
PROGRAM-ID. HelloWorld.
PROCEDURE DIVISION.
    DISPLAY 'Hello, World!'.
    STOP RUN.

25) Fortran:

PROGRAM HelloWorld
WRITE(*,*) 'Hello, World!'
END PROGRAM HelloWorld

26) Ada:

with Ada.Text_IO;
procedure Hello_World is
begin
    Ada.Text_IO.Put_Line("Hello, World!");
end Hello_World;

27) Haxe:

class HelloWorld {
    static function main() {
        trace("Hello, World!");
    }
}

28) Groovy:

println "Hello, World!"

29) D:

import std.stdio;
void main() {
    writeln("Hello, World!");
}

30) Erlang:

-module(hello).
-export([world/0]).
world() ->
    io:format("Hello, World!~n").

31) OCaml:

print_endline "Hello, World!";

32) Julia:

println("Hello, World!")

33) Elm:

main = 
    Html.text "Hello, World!"

34) Clojure:

(println "Hello, World!")

35) Shell Script (Fish):

echo "Hello, World!"

Conclusion:

Here’s the end of this article. Which programming language you were aware of? The “Hello, World!” program is not merely an exercise in printing a greeting; it’s a symbolic handshake between a coder and a new programming language. Each language brings its own syntax and rules.

Share:

Author: Ayush Purawr