A comprehensive Nix flake that contains examples of different programming languages, all implementing the same algorithm for easy comparison.
Each example prints "hello world!" and performs a computation about the Collatz Conjecture. All implementations are kept as similar as possible to showcase language differences while maintaining algorithmic consistency.
You can build and run any language example using Nix:
# Build and run Python example
nix run github:osbm/programming-languages#python
# Or you can first build and then run to compare compilation and execution times
nix build github:osbm/programming-languages#rust
nix run github:osbm/programming-languages#rust- Prints "hello world!"
- Computes Collatz sequences for numbers 1 to 1,000,000
- Finds the longest sequence and reports:
n*- The starting number with the longest sequencesteps- Number of steps in that sequencepeak- Highest value reached during computationxor_steps- XOR checksum of all step counts
- ✅ Assembly - Low-level programming
- ✅ Bash - Shell scripting
- ✅ Bun - Fast JavaScript runtime
- ✅ C - Classic systems programming
- ✅ C (assembly) - C with partial assembly implementation (contributed by bdrtr)
- ✅ C++ - Object-oriented systems programming
- ✅ C# - .NET object-oriented programming
- ✅ Clojure - Lisp dialect for JVM
- ✅ Crystal - Ruby-like syntax, C-like performance
- ✅ Cuda - GPU programming
- ✅ Cython - Python with C extensions
- ✅ D - Systems programming with garbage collection
- ✅ Dart - Client-optimized programming
- ✅ Deno - Modern JavaScript/TypeScript runtime
- ✅ Elixir - Concurrent functional programming
- ✅ Erlang - Fault-tolerant concurrent programming
- ✅ F# - .NET functional-first language
- ✅ Fish - Friendly shell scripting
- ✅ Fortran - Scientific and numerical computing
- ✅ Gleam - Type-safe for Erlang VM
- ✅ GLSL - Graphics shader language
- ✅ Go - Concurrent systems programming
- ✅ Go (concurrency) - Go but with concurrency (contributed by bdrtr)
- ✅ Haskell - Pure functional programming
- ✅ Java - Enterprise object-oriented programming
- ✅ JavaScript (Node.js) - Web and server scripting
- ✅ Julia - High-performance scientific computing
- ✅ Kotlin - Modern JVM language
- ✅ Lisp - Classic functional programming
- ✅ Lua - Lightweight scripting
- ✅ Nim - Efficient, expressive systems programming
- ✅ Nix - Functional package management language
- ✅ Nushell - Modern shell with a focus on data
- ✅ OCaml - ML family functional language
- ✅ Octave - MATLAB-compatible mathematical programming
- ✅ Perl - Text processing and scripting
- ✅ PHP - Web development scripting
- ✅ PowerShell - Object-oriented shell
- ✅ Prolog - Logic programming
- ✅ Python - General-purpose scripting
- ✅ PyPy - High-performance Python implementation
- ✅ R - Statistical computing
- ✅ Racket - Modern Lisp/Scheme
- ✅ Ruby - Elegant scripting language
- ✅ Rust - Memory-safe systems programming
- ✅ Scheme - Minimalist Lisp dialect
- ✅ TypeScript - Typed JavaScript
- ✅ V - Simple, fast compilation
- ✅ Zig - Simple, fast systems programming
- 🔄 Bend - Parallel programming language
All programs produce identical output (though some programs do not count all the way up to 1,000,000 due to performance constraints):
hello world!
collatz_longest(1..1000000)
n*=837799
steps=524
peak=2974984576
xor_steps=880
- Nix with flakes enabled
- Internet access (nix will take care of fetching dependencies)
Feel free to contribute new language implementations! Each language should:
- Print "hello world!"
- Implement the Collatz conjecture algorithm
- Produce the exact same numerical output
- Be buildable with Nix
- Follow the existing project structure
This project is open source and available under the MIT License.