Entangled

Literate Programming for You and Me

 

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.

file:src/hello.sh
echo "Hello, Bash!"
bash src/hello.sh
Hello, Bash!

C++

This turns out to be one of the more wordy solutions.

file:src/hello.cc
#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-cpp
Hello, C++!

Go

Designed for simplicity and reasonable performance.

file:src/hello.go
package main

import "fmt"

func main() {
    fmt.Println("Hello, Go!")
}
go run src/hello.go
Hello, Go!

Haskell

Lingua franca of the functional programming community.

file:src/hello.hs
main :: IO ()
main = putStrLn "Hello, Haskell!"
mkdir -p build
ghc src/hello.hs -o build/hello-haskell
./build/hello-haskell
Hello, Haskell!

Javascript

Language of the web.

file:src/hello.js
console.log("Hello, Node!")
node src/hello.js
Hello, Node!

Julia

High performance language for scientific computing.

file:src/hello.jl
print("Hello, Julia!")
julia -O0 src/hello.jl
Hello, Julia!

Lua

Light-weight embeddable scripting language.

file:src/hello.lua
print("Hello, Lua!")
lua src/hello.lua
Hello, Lua!

OCaml

Functional language with focus on safety.

file:src/hello.ml
let () = Printf.printf "%s\n" "Hello, OCaml!"
ocaml src/hello.ml
Hello, OCaml!

Python

Well, Python is Python.

file:src/hello.py
print("Hello, Python!")
python src/hello.py
Hello, Python!

R

Popular for data analysis.

file:src/hello.r
write("Hello, R!", stdout())
R --vanilla -s  < src/hello.r
Hello, R!

Rust

Memory safe system programming language.

file:src/hello.rs
fn main() {
    println!("Hello, Rust!")
}
mkdir -p build
rustc src/hello.rs -o build/hello-rust
./build/hello-rust
Hello, Rust!

Scheme

My personal favourite.

file:src/hello.scm
(import (rnrs (6)))

(display "Hello, Scheme!") (newline)
guile src/hello.scm
Hello, Scheme!