Skip to content

Hello, World!

Get started in as many languages as possible

In this blog post, I wanted to write che classical Hello, World! getting started code in as many languages as possible.

Compiled languages (what happens before you run):

  1. the entire code is translated into machine language before execution,
  2. a file it generates (like .exe) so that you can run it directly,
  3. you get all your errors upfront during the build,
  4. once compiled, the code runs fast.

Interpreted languages (what happens while you run):

  1. code is translated line by line during execution,
  2. no separate build (or .exe), just write and run,
  3. errors show up only when the code hits that specific line,
  4. super useful for scripting and quick tests.

| Paradigm | Type | |:------------------:|:--------:| | OOP and procedural | compiled |

hello.ino
void setup() {
Serial.begin(9600);
Serial.println("Hello, World");
}
void loop() {}

| Paradigm | Type | |:----------:|:--------:| | procedural | compiled |

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

| Paradigm | Type | |:------------------:|:--------:| | OOP and procedural | compiled |

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

| Paradigm | Type | |:--------:|:--------:| | OOP | compiled |

hello.cs
Console.WriteLine("Hello, World!");

| Paradigm | Type | |:------------------:|:--------:| | OOP and procedural | compiled |

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

| Paradigm | Type | |:--------:|:-----------:| | OOP | interpreted |

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

| Paradigm | Type | |:----------:|:--------------------------------------:| | procedural | interpreted or just-in-time compiled |

Just-In-Time Compilation (JIT) is a compilation process in which code is translated from a higher-level language into machine code at runtime.

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

| Paradigm | Type | |:--------------------------------:|:--------------------------------------:| | procedural and multiple dispatch | interpreted or just-in-time compiled |

Multiple dispatch or multimethod): a function/method can be dynamically dispatched based on the run-time (dynamic) type or some other attribute of more than one of its arguments.

hello.jl
print("Hello, World!")

| Paradigm | Type | |:------------------:|:-----------:| | OOP and procedural | interpreted |

Kotlin mainly targets the JVM (Java Virtual Machine), but also compiles to JavaScript or native code via LLVM (for native iOS apps sharing business logic with Android app).

hello.kt
fun main() {
print("Hello, World!")
}

| Paradigm | Type | |:------------------:|:-----------:| | OOP and procedural | interpreted |

hello.py
if __name__ == '__main__':
print("Hello, World!")

| Paradigm | Type | |:------------------:|:--------:| | OOP and procedural | compiled |

hello.rs
// https://doc.rust-lang.org/rust-by-example/hello.html
fn main() {
// statements here are executed when the compiled binary is called
// print text to the console
println!("Hello World!");
}