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;
}
2. C++
#include <iostream>
int main(){
std::cout << "Hello, World!\n";
}
3. C'#'
class HelloWorldApp{
static void Main(){
System.Console.WriteLine("Hello, world!");
}
}
4. Python
print("Hello, world!")
5. Java
public class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello, world!");
}
}
6. JavaScript
document.writeln('Hello, World!');
7. TypeScript
console.log("Hello, World!");
8. R
cat("Hello, World!")
9. Rust
fn main() {
println!("Hello, World!");
}
10. Go Lang
package main
func main() {
println("Hello, World!")
}
11. Lua
print("Hello, World")
12. Perl
use strict;
use warnings;
print("Hello, World!");
13. Haskell
putStrLn "Hello world"
14. Bash
echo 'Hello, world!'
15. Kotlin
fun main() {
println("Hello, World!")
}
16. Ruby
puts "Hello, World!"
18. Swift
import Swift
print("Hello, World!")
19. Julia
println("Hello, World!")
20. Dart
void main() {
print('Hello, World!');
}
21. Elixir
IO.puts("Hello, World!")
22. Groovy
println "Hello, World!"
23. Scala
object dev
{
// Main Method
def main(args: Array[String])
{
// prints Hello World
println("Hello, World!")
}
}
24. Ada
with Ada.Text_IO;
procedure Hello is
begin
Ada.Text_IO.Put_Line("Hello, world!");
end Hello;
25. Bosque
namespace NSMain;
entrypoint
function main(): String {
return "Hello, world!";
}
26. BASIC
PRINT "Hello, world!"
27. Cobol
display "Hello, world!".
28. D
import std.stdio;
void main()
{
writeln("Hello, World!");
}
29. F'#'
open System
[<EntryPoint>]
let main argv =
printfn "Hello, World!"
30. BrainF*ck
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
Why not add a few more in the comment section?
Top comments (65)
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
`
SERIOUSLY?!
I thought the same!
And what about Cow, intercal, whitespace, chef, Brainfuck or Malbolge?
It seems that bored people has no limits LoL
Thirty languages, and not a single Lisp? For shame. Three off the top of my head:
Scheme
Common Lisp
Clojure
What about SmallTalk then^^?
My lord! I beg pardon! 🥺
That was the first thing I looked and didn't find.
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
Who said Java is a hard language to learn?
Java is quite easy xD
;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
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
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
How about one for Windows 64?
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
Hello @muhimen123 , in Go(lang) you can reduce the loc.
import "fmt"
is not required, you could just use theprint/println
as you do with the rest of the hello-worlds. You can replace the code snippet with:Good article though :) It was fun, reminds me old times
Thanks. Changing the code right now!
@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
Something like this?
Yep, perfect
But remember, according to the documentation print() and println() are built-in functions for bootstrapping and not guaranteed to stay in the language.
Yes you are correct. If we want to be pedantic I would say the original post, which had
import "fmt"
in and usedfmt.Println
is better thanprintln()
but this post seems to be an exercise in "Hello, World! Code Golf" so not too fussed about itAlthough 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.
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!
Fair Enough
Shakespeare
Q#:
Y'all please just join and contribute to Rosetta Code.
Haskell one is wrong
is using the repl. And is not even printing a thing
Haskell would be Main = print "Hello world"
This isn't valid file or repl syntax.
For the repl:
For a
.hs
file:(function definitions are lower case, types and modules are capitalized)
putStrLn would probably be better for this, so it doesn't display the quotes
Bug in the post 🙄. Fixing it right now!
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