Literate Polyglot
Hello World in 12 languages
The first thing you may want to do in a new programming language is write a “Hello, World!”. For Entangled, the problem is then: in which language do write our first example? We don’t want to play favourites, so here it is in 12 different languages.
Bash
Little loved language for scripting odds and ends.
echo "Hello, Bash!"bash src/hello.shHello, Bash!C++
This turns out to be one of the more wordy solutions.
#include <iostream>
#include <cstdlib>
int main() {
std::cout << "Hello, C++!" << std::endl;
return EXIT_SUCCESS;
}mkdir -p build
g++ src/hello.cc -o build/hello-cpp
./build/hello-cppHello, C++!Go
Designed for simplicity and reasonable performance.
package main
import "fmt"
func main() {
fmt.Println("Hello, Go!")
}go run src/hello.goHello, Go!Haskell
Lingua franca of the functional programming community.
main :: IO ()
main = putStrLn "Hello, Haskell!"mkdir -p build
ghc src/hello.hs -o build/hello-haskell
./build/hello-haskellHello, Haskell!Javascript
Language of the web.
console.log("Hello, Node!")node src/hello.jsHello, Node!Julia
High performance language for scientific computing.
print("Hello, Julia!")julia -O0 src/hello.jlHello, Julia!Lua
Light-weight embeddable scripting language.
print("Hello, Lua!")lua src/hello.luaHello, Lua!OCaml
Functional language with focus on safety.
let () = Printf.printf "%s\n" "Hello, OCaml!"ocaml src/hello.mlHello, OCaml!Python
Well, Python is Python.
print("Hello, Python!")python src/hello.pyHello, Python!R
Popular for data analysis.
write("Hello, R!", stdout())R --vanilla -s < src/hello.rHello, R!Rust
Memory safe system programming language.
fn main() {
println!("Hello, Rust!")
}mkdir -p build
rustc src/hello.rs -o build/hello-rust
./build/hello-rustHello, Rust!Scheme
My personal favourite.
(import (rnrs (6)))
(display "Hello, Scheme!") (newline)guile src/hello.scmHello, Scheme!