DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for "Hello World" in 10 Languages
Rakesh KR
Rakesh KR

Posted on

"Hello World" in 10 Languages

Hello World πŸ‘‹πŸŒ

Let's go through the "Hello World" syntax in 10 languages πŸ±β€πŸ’».

Feel free to comment ✍️ your first πŸ₯‡ "Hello World" language.

1. Java

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

2. C

#include<stdio.h>
int main(){
printf("Hello World");
return 0;
}
Enter fullscreen mode Exit fullscreen mode

3. C++

#include<iostream>
int main (){
  std::cout << "Hello World";
  return 0;
}
Enter fullscreen mode Exit fullscreen mode

4. C#

public class Hello{
  public static void Main(String[] args){
    System.Console.WriteLine("Hello World");
  }
}
Enter fullscreen mode Exit fullscreen mode

5. Python

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

6. JS

console.log("Hello World");

alert("Hello World");

document.write("Hello World");
Enter fullscreen mode Exit fullscreen mode

7. GO

package main
import "fmt"

func main(){
    fmt.Println("Hello World")
}
Enter fullscreen mode Exit fullscreen mode

8. Kotlin

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

9. PHP

<?php
echo "Hello World";
?>
Enter fullscreen mode Exit fullscreen mode

10. Swift

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

Top comments (15)

Collapse
 
szabgab profile image
Gabor Szabo

Rust

fn main() {
    println!("Hello World")
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
lexlohr profile image
Alex Lohr

x86 asm (DOS .com executable)

org 0x100
mov dx, msg
mov ah, 9
int 0x21
int 0x20
msg db 'Hello World!', 0x0d, 0x0a, '$'
Enter fullscreen mode Exit fullscreen mode

x86 asm (Linux compatible)

; to build an ELF executable:
; nasm -f elf hello.asm && ld -s -o hello hello.o
section .text
  global _start
section .data
  msg db 'Hello World!, 0xa
  len equ $ - msg
section .text
_start:
mov edx, len
mov ecx, msg
mov ebx, 1
mov eax, 4
int 0x80
mov ebx, 0
mov eax, 1
int 0x80
Enter fullscreen mode Exit fullscreen mode

AWK

BEGIN {
  print "Hello World!"
}
Enter fullscreen mode Exit fullscreen mode

and last, not least:

CSS

document.body:before { content: "Hello, World!"; }
Enter fullscreen mode Exit fullscreen mode
Collapse
 
thomasbnt profile image
Thomas Bnt

Hello ! Cool post to learn a little more about syntax of others languages with an example! πŸ‘πŸΌ

Don't hesitate to put colors on your codeblock like this example for have to have a better understanding of your code 😎

console.log('Hello world!');
Enter fullscreen mode Exit fullscreen mode

Example of how to add colors and syntax in codeblocks

Collapse
 
szabgab profile image
Gabor Szabo

Bash

echo Hello World
Enter fullscreen mode Exit fullscreen mode
Collapse
 
sherrydays profile image
Sherry Day

ChatGPT

Hello, my name is world.
Enter fullscreen mode Exit fullscreen mode
Collapse
 
lum1nat profile image
Lum1naT

This reply makes me happy while making my blood boil.

Collapse
 
alexkapustin profile image
Oleksandr

Brainfuck:

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

en.wikipedia.org/wiki/Brainfuck

Collapse
 
ben profile image
Ben Halpern

Ruby

puts "Hello world!"
Enter fullscreen mode Exit fullscreen mode
Collapse
 
szabgab profile image
Gabor Szabo

Perl:

print "Hello World\n";
Enter fullscreen mode Exit fullscreen mode

or

use feature 'say';
say "Hello World";
Enter fullscreen mode Exit fullscreen mode
Collapse
 
artydev profile image
artydev

Nice presentation :-)
You could be interested by Rosetta Code

Regards

Collapse
 
amm834 profile image
Aung Myat Moe • Edited on

Php

echo "Hello world!"
Enter fullscreen mode Exit fullscreen mode

Lua

print "Hello Lua!"
Enter fullscreen mode Exit fullscreen mode
Collapse
 
gramian profile image
Christian Himpe

Scheme

(display "Hello World!")
Enter fullscreen mode Exit fullscreen mode
Collapse
 
szabgab profile image
Gabor Szabo

Groovy:

println "Hello World"
Enter fullscreen mode Exit fullscreen mode
Collapse
 
murphylee1408 profile image
Murphylee1408

<?php
$greeting = "Hello World";
echo $greeting;
?>

Collapse
 
draganclappcreator profile image
Dragan

Nice.
Here is one you probably don't know yet (since it comes from a language I created and nobody knows):
youtube.com/watch?v=ZnLQs6a5uy0

Join us at DEV Want to join the conversation?
Β 

It's easy! Become a DEV member to follow this post, comment, and more.