DEV Community

Cover image for "Hello, World!" but in 30 different languages!!!
Muhimen
Muhimen

Posted on • Updated on

"Hello, World!" but in 30 different languages!!!

Since the last week, I was scratching my head to figure out what post can I write in dev? I wanted it to be meaningful so that it can be useful for the readers. Then, I thought, if I can't write anything meaningful then I should write something absolutely meaningless. And here I am. Printing "Hello, World!" in 30 different languages(in no particular order). ENJOY!

[Spoiler alert: The last one is special!]

1. C

#include <stdio.h>
int main(void){
    printf("Hello, world!\n");
    return 0;
}
Enter fullscreen mode Exit fullscreen mode

2. C++

#include <iostream>
int main(){
 std::cout << "Hello, World!\n";
}
Enter fullscreen mode Exit fullscreen mode

3. C'#'

class HelloWorldApp{
 static void Main(){
 System.Console.WriteLine("Hello, world!");
 }
}
Enter fullscreen mode Exit fullscreen mode

4. Python

print("Hello, world!")
Enter fullscreen mode Exit fullscreen mode

5. Java

public class HelloWorld
   {
        public static void main(String[] args)
        {
             System.out.println("Hello, world!");
        }
   }
Enter fullscreen mode Exit fullscreen mode

6. JavaScript

document.writeln('Hello, World!');
Enter fullscreen mode Exit fullscreen mode

7. TypeScript

console.log("Hello, World!");
Enter fullscreen mode Exit fullscreen mode

8. R

cat("Hello, World!")
Enter fullscreen mode Exit fullscreen mode

9. Rust

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

Enter fullscreen mode Exit fullscreen mode

10. Go Lang

package main 
func main() { 
    println("Hello, World!") 
} 
Enter fullscreen mode Exit fullscreen mode

11. Lua

print("Hello, World")
Enter fullscreen mode Exit fullscreen mode

12. Perl

use strict; 
use warnings; 

print("Hello, World!"); 
Enter fullscreen mode Exit fullscreen mode

13. Haskell

putStrLn "Hello world"
Enter fullscreen mode Exit fullscreen mode

14. Bash

echo 'Hello, world!'
Enter fullscreen mode Exit fullscreen mode

15. Kotlin

fun main() {
    println("Hello, World!")
}
Enter fullscreen mode Exit fullscreen mode

16. Ruby

puts "Hello, World!"
Enter fullscreen mode Exit fullscreen mode

18. Swift

import Swift
print("Hello, World!")
Enter fullscreen mode Exit fullscreen mode

19. Julia

println("Hello, World!")
Enter fullscreen mode Exit fullscreen mode

20. Dart

void main() {
  print('Hello, World!');
}
Enter fullscreen mode Exit fullscreen mode

21. Elixir

IO.puts("Hello, World!")
Enter fullscreen mode Exit fullscreen mode

22. Groovy

println "Hello, World!"
Enter fullscreen mode Exit fullscreen mode

23. Scala

object dev
{
    // Main Method 
    def main(args: Array[String]) 
    {
        // prints Hello World
        println("Hello, World!") 
    }
}
Enter fullscreen mode Exit fullscreen mode

24. Ada

with Ada.Text_IO;
procedure Hello is
begin
   Ada.Text_IO.Put_Line("Hello, world!");
end Hello;
Enter fullscreen mode Exit fullscreen mode

25. Bosque

namespace NSMain;  
entrypoint  
function main(): String {  
 return "Hello, world!";  
}  
Enter fullscreen mode Exit fullscreen mode

26. BASIC

PRINT "Hello, world!"​
Enter fullscreen mode Exit fullscreen mode

27. Cobol

display "Hello, world!".
Enter fullscreen mode Exit fullscreen mode

28. D

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

29. F'#'

open System
[<EntryPoint>]
let main argv =
    printfn "Hello, World!"
Enter fullscreen mode Exit fullscreen mode

30. BrainF*ck

++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
Enter fullscreen mode Exit fullscreen mode

Why not add a few more in the comment section?

Discussion (66)

Collapse
aroldev profile image
Arol

What about "Chicken"?
Chicken is an esoteric programming language in which "chicken" is the only valid symbol.

Here is Hello World in chicken and It's true:
`
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken
chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken
`

Collapse
muhimen123 profile image
Muhimen Author

SERIOUSLY?!

Collapse
ziizium profile image
Habdul Hazeez

I thought the same!

Collapse
joelbonetr profile image
JoelBonetR

And what about Cow, intercal, whitespace, chef, Brainfuck or Malbolge?

It seems that bored people has no limits LoL

Collapse
gypsydave5 profile image
David Wickes

Thirty languages, and not a single Lisp? For shame. Three off the top of my head:

Scheme

(display "Hello, world")

Common Lisp

(princ "Hello, world")

Clojure

(print "Hello, world")
Collapse
swiknaba profile image
Lud

What about SmallTalk then^^?

Transcript show: 'Hello, world!'.
Collapse
muhimen123 profile image
Muhimen Author

My lord! I beg pardon! 🥺

Collapse
myterminal profile image
Mohammed Ismail Ansari

That was the first thing I looked and didn't find.

Collapse
metruzanca profile image
Samuele Zanca • Edited on

Heres Hello world in Whitespace:

































source: github.com/rdebath/whitespace

edit: sadly I think dev.to's markdown based posts & commends doesn't like whitespace-lang

Collapse
muhimen123 profile image
Muhimen Author

Who said Java is a hard language to learn?

Collapse
metruzanca profile image
Samuele Zanca

Java is quite easy xD

Collapse
nexwebsites profile image
NexWebSites

;Don't forget Assembly Language:
section .text
global _start

_start:

mov edx, len

mov ecx, msg

mov ebx, 1

mov eax, 4

int 0x80

mov eax, 1

int 0x80

section .data
msg db 'Hello, world!',0xa
len equ $ - msg

Collapse
jmcp profile image
James McPherson

For completeness one should mention that this example is x86 assembler (not even amd64!), and for extra credit how about ARMv7, SPARC and POWER versions too? :p

Collapse
nexwebsites profile image
NexWebSites • Edited on

Yes, thought it would be better to start with the basics.

global _start
section .text
_start:
mov rdi,1

mov rsi,hello_world

mov rdx,hello_world_size

mov rax,1

syscall
mov rdi,0

mov rax,60

syscall

hello_world: db "Hello, world!",10
hello_world_size EQU $ - hello_world

Thread Thread
nexwebsites profile image
NexWebSites • Edited on

How about one for Windows 64?

Window 64 bit Assembly
extrn ExitProcess: PROC
extrn MessageBoxA: PROC

.data
caption db 'Windows 64-bit hello!', 0
message db 'Hello, world!', 0

.code

Start PROC
sub rsp,28h

mov rcx, 0

lea rdx, message
lea r8, caption
mov r9d, 0

call MessageBoxA
mov ecx, eax

call ExitProcess
Start ENDP
End

Collapse
kataras profile image
Gerasimos (Makis) Maropoulos • Edited on

Hello @muhimen123 , in Go(lang) you can reduce the loc. import "fmt" is not required, you could just use the print/println as you do with the rest of the hello-worlds. You can replace the code snippet with:

package main 
func main() { 
    println("Hello, World!") 
}
Enter fullscreen mode Exit fullscreen mode

Good article though :) It was fun, reminds me old times

Collapse
muhimen123 profile image
Muhimen Author

Thanks. Changing the code right now!

Collapse
heyitsols profile image
Oliver Leaver-Smith

@muhimen123 you need to change the fmt.Println line to just println, as you are still trying to use fmt, but not importing it any more

Thread Thread
muhimen123 profile image
Muhimen Author

Something like this?

package main 
func main() { 
    println("Hello, World!") 
} 
Thread Thread
heyitsols profile image
Oliver Leaver-Smith

Yep, perfect

Thread Thread
petergloor profile image
Peter Gloor

But remember, according to the documentation print() and println() are built-in functions for bootstrapping and not guaranteed to stay in the language.

Thread Thread
heyitsols profile image
Oliver Leaver-Smith

Yes you are correct. If we want to be pedantic I would say the original post, which had import "fmt" in and used fmt.Println is better than println() but this post seems to be an exercise in "Hello, World! Code Golf" so not too fussed about it

Collapse
kailyons profile image
Loralighte

Although I love this, my Fibonacci Project that I worked on with several other people to get currently 60 languages, I also made sure for more fair comparisons to keep them roughly the same. 60 was a lot too lol.

Collapse
muhimen123 profile image
Muhimen Author

Frankly speaking, when I first thought about this post I wanted to write 100 languages. But due to my SUPER procrastinations, I wasn't getting any progress after 30 languages. So I just hit the publish button!

Collapse
kailyons profile image
Loralighte

Fair Enough

Collapse
fabasoad profile image
Yevhen Fabizhevskyi

Shakespeare

The Infamous Hello World Program.

Romeo, a young man with a remarkable patience.
Juliet, a likewise young woman of remarkable grace.
Ophelia, a remarkable woman much in dispute with Hamlet.
Hamlet, the flatterer of Andersen Insulting A/S.


                    Act I: Hamlet's insults and flattery.

                    Scene I: The insulting of Romeo.

[Enter Hamlet and Romeo]

Hamlet:
 You lying stupid fatherless big smelly half-witted coward!
 You are as stupid as the difference between a handsome rich brave
 hero and thyself! Speak your mind!

 You are as brave as the sum of your fat little stuffed misused dusty
 old rotten codpiece and a beautiful fair warm peaceful sunny summer's
 day. You are as healthy as the difference between the sum of the
 sweetest reddest rose and my father and yourself! Speak your mind!

 You are as cowardly as the sum of yourself and the difference
 between a big mighty proud kingdom and a horse. Speak your mind.

 Speak your mind!

[Exit Romeo]

                    Scene II: The praising of Juliet.

[Enter Juliet]

Hamlet:
 Thou art as sweet as the sum of the sum of Romeo and his horse and his
 black cat! Speak thy mind!

[Exit Juliet]

                    Scene III: The praising of Ophelia.

[Enter Ophelia]

Hamlet:
 Thou art as lovely as the product of a large rural town and my amazing
 bottomless embroidered purse. Speak thy mind!

 Thou art as loving as the product of the bluest clearest sweetest sky
 and the sum of a squirrel and a white horse. Thou art as beautiful as
 the difference between Juliet and thyself. Speak thy mind!

[Exeunt Ophelia and Hamlet]


                    Act II: Behind Hamlet's back.

                    Scene I: Romeo and Juliet's conversation.

[Enter Romeo and Juliet]

Romeo:
 Speak your mind. You are as worried as the sum of yourself and the
 difference between my small smooth hamster and my nose. Speak your
 mind!

Juliet:
 Speak YOUR mind! You are as bad as Hamlet! You are as small as the
 difference between the square of the difference between my little pony
 and your big hairy hound and the cube of your sorry little
 codpiece. Speak your mind!

[Exit Romeo]

                    Scene II: Juliet and Ophelia's conversation.

[Enter Ophelia]

Juliet:
 Thou art as good as the quotient between Romeo and the sum of a small
 furry animal and a leech. Speak your mind!

Ophelia:
 Thou art as disgusting as the quotient between Romeo and twice the
 difference between a mistletoe and an oozing infected blister! Speak
 your mind!

[Exeunt]
Enter fullscreen mode Exit fullscreen mode
Collapse
vsymonenko profile image
VSymonenko

Q#:

namespace HelloWorld {
    open Microsoft.Quantum.Intrinsic;
    open Microsoft.Quantum.Canon;

    operation SayHello() : Result {
        Message("Hello from quantum world!");
        return Zero;
    }
}
Collapse
angt profile image
Adrien Gallouët • Edited on

Hello!
Below, the hfuck version:

$ ./h hhh hhh hhhh hhh hhhh hhhh h hhhhhhh h hhhhhhh hhhh h hh hhh hhh hhh hh hhh hh hhh hh hhh hhhh hhhh hhhh hhhhhhhh hh hhhhhhhh hhhh hhhh hhh hhh hhhhh hhhh h h h h h h hhhhh hhhh hhhh hhh hhhhh hhhhh hhhh hhhh hhhhh hhhh h hhhhh hh hh hhhhh hh hh hhhhh hhhh hhhh hhhh hhhhh h h h hhhhh hh hh hhhhh hh hh hhh hhhhh hhhh hhhh hhhh h hhhhh
Hello, World!

source: github.com/angt/hfuck

Collapse
gracrys profile image
Gracrys

Haskell one is wrong

is using the repl. And is not even printing a thing

Haskell would be Main = print "Hello world"

Collapse
spicydonuts profile image
Madeline Trotter

This isn't valid file or repl syntax.

For the repl:

putStrLn "Hello world"

For a .hs file:

module Main where

main = putStrLn "Hello world"

(function definitions are lower case, types and modules are capitalized)

Collapse
craigmc08 profile image
Craig McIlwrath

putStrLn would probably be better for this, so it doesn't display the quotes

Collapse
muhimen123 profile image
Muhimen Author

Bug in the post 🙄. Fixing it right now!

Collapse
spicydonuts profile image
Madeline Trotter

I'm not sure what it used to be, but this update isn't right. Here are two valid definitions: dev.to/spicydonuts/comment/ofod

Collapse
mmikowski profile image
Michael S. Mikowski • Edited on

Perl doesn't need use strict or use warnings for this trivial example. Why are you making it needlessly verbose? Using the same logic shouldn't we also use set -u and set -e in bash? Btw, fun post. Just trying to be fair.

Collapse
luizpf profile image
Luiz "Bills" • Edited on

PHP

<?= 'Hello, world!' ?>

JASS (language used in Warcraft III mods)

function InitTrig_Main takes nothing returns nothing
    call BJDebugMsg("Hello World")
endfunction
Collapse
louy2 profile image
Yufan Lou

Y'all please just join and contribute to Rosetta Code.

Rosetta Code currently has 1,017 tasks, 229 draft tasks, and is aware of 785 languages, though we do not (and cannot) have solutions to every task in every language.

Collapse
ynfle profile image
ynfle

Nim

echo "Hello, World!"
Collapse
harshrathod50 profile image
Harsh Rathod

Racket

#lang racket
"Hello, world!"
Enter fullscreen mode Exit fullscreen mode

Beef

using System;
class Hello {
  static void Main() {
    Console.WriteLine("Hello, World!");
  }
}
Enter fullscreen mode Exit fullscreen mode
Collapse
bero profile image
Roland Bengtsson

But you miss Delphi!

program HelloWorld;

{$APPTYPE CONSOLE}

begin
  WriteLn('Hello World');
end.
Collapse
amiamigo profile image
Ami Amigo

30 Languages!! No PHP?? Really??

Collapse
anuraghazra profile image
Anurag Hazra
Collapse
muhimen123 profile image
Muhimen Author

Didn't see that coming

Collapse
anuraghazra profile image
Anurag Hazra

Yeah because it's "nothing" 😏

Collapse
arieberesteanu profile image
Arie Beresteanu

Fortran

PROGRAM hello
PRINT *,"Hello, World!"
END PROGRAM hello

Collapse
k776 profile image
Kieran Pilkington

Heres a project I've done, 16 implements of Conways game of life: github.com/KieranP/Game-Of-Life-Im...

Collapse
km4 profile image
km4

console.log("Hello, World!"); or document.writeln('Hello, World!'); should be the same example in 6 and 7 points.

Collapse
johandalabacka profile image
Johan Dahl • Edited on

Prolog

write('Hello world').

Collapse
agtoever profile image
agtoever • Edited on

See this repo
(there is nothing wrong with reinventing the wheel... ;-))

Collapse
muhimen123 profile image
Muhimen Author

I thought I was the first person to do this. But you know, there is at least one person on the internet who has done something before you would do.
(But still, I enjoyed it)

Collapse
jmcp profile image
James McPherson

I think I need another coffee, because I thought you were going to be providing human language translations and show use of dgettext(...)

Good article.

Collapse
derek profile image
derek

Awesome!!!

Collapse
hasii2011 profile image
Humberto A Sanchez II

Funny

Collapse
joelbonetr profile image
JoelBonetR

No one:
Absolute no one:
PHP: echo('hello, world');

:D

Collapse
klausbert profile image
Klausbert

Fair enough.
Now, where are the unit tests?

Collapse
mehdico profile image
Mehdi Mousavi

PHP:

<?php
echo "Hello, World!";


also, I think Swift one is actually Objective-C!!!

Collapse
khambley profile image
Katherine Hambley

This. Is. Awesome. Great job!