The games are all setup to run a 100x50 (WxH) board for 500 generations. Most of them were originally written to be dynamic and find the terminal size or accept arguments but it was taking too much work to get all of that set up for each language and (imo) distracting from the purpose of this by shifting half of the work onto random argument parsing libraries rather than the languages themselves.
- Ada 95
- GCC Gnat
- GCC Gnatmake
- Bash
- C
- GCC
- GNU Make
- C++
- GCC
- Meson
- Ninja
- C#
- .NET 7.0 SDK
- COBOL
- GnuCOBOL
- Cython
- Python headers
- D
- GCC GDC
- Dart
- Fortran
- GCC GFortran
- F#
- .NET 7.0 SDK
- Go
- Haskell
- GHC
- Java
- Gradle
- Julia
- Lua
- Nim
- OCaml
- OCaml
- OPAM
- Dune
- Perl
- PHP 7+
- PowerShell
- Python
- Ruby
- Rust
- Cargo
- Typescript
- Node.js
- Yarn
- V
- Visual Basic
- .NET 7.0 SDK
- Zig
cd ada/
gnatmake src/game_of_life.adb
./game_of_life
cd bash/
./game_of_life.sh
cd c/
make
./game_of_life
cd cpp/
meson setup build
cd build
ninja
./game_of_life
cd csharp/
dotnet run
cd cobol/
make
./game_of_life
cd cython/
python setup.py build_ext --inplace
python main.py
cd d/
make
./game_of_life
cd dart/
dart run
cd fortran/
make
./game_of_life
cd fsharp/
dotnet run
cd go/
go run .
cd haskell/
ghc -o game_of_life main.hs game.hs board.hs
./game_of_life
cd java/
./gradlew run --console plain
cd julia/
julia game_of_life.jl
cd lua/
lua game_of_life.lua
cd nim/
nim c -r GameOfLife.nim
cd ocaml/
dune build
./_build/default/bin/main.exe
cd perl/
perl GameOfLife.pl
cd php/
php gameoflife.php
cd powershell/
pwsh Game-Of-Life.ps1
cd python/
python game_of_life.py
cd ruby/
ruby GameOfLife.rb
cd rust/
cargo run
cd typescript/
yarn install
yarn run start
cd v/
v run .
cd vb/
dotnet run
cd zig/
zig build run
There's an included script to build all version and run benchmarks. It requires hyperfine to run
python benchmark.py
--install
is only needed on the first run to install the script's dependencies
You can also specify how many iterations to run the benchmark (default 5), averaging the results
python benchmark.py --iterations 5
The set of languages to run in the benchmark can also be set. NOTE: Some languages, e.g. bash, powershell, are disabled by default for performance reasons. The default set is "ada,c,cpp,csharp,cobol,d,dart,fortran,fsharp,go,haskell,java,julia,lua,nim,perl,python,ruby,rust,typescript,vb,zig"
python benchmark.py --languages c,cpp,rust
# or
python benchmark.py --languages all
podman build -t game-of-life .
podman run --rm game-of-life
# or
podman run --rm game-of-life "python benchmark.py --iterations 5 --languages c,cpp,rust"
NOTE: Docker will also work
There's a prebuilt image on GitHub Container Registry since the container build is quite long, especially on low powered systems. Images will be available for x86_64 only.
podman pull ghcr.io/mrivnak/game-of-life:main
podman run --rm mrivnak/game-of-life:main
Provided is a devcontainer.json
file that will automatically setup a development environment for all of the languages in here, along with relevant extensions and language servers.