sheepduke / life-game

Conway's Game of Life written in different languages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction

This repository uses different languages to demonstrate Conway’s Game of Life.

All the program accepts 2 arguments: size of board and number of initial random cells.

They will run for 100,000 rounds and exit.

It is created for 2 purposes:

  1. Provide a hello-word example.
  2. Provide a minimal benchmark.

Hierarchy

Each directory under root (this one) contains code written in one specific language.

Some Observations

I ran it with 40 board size and 800 initial seeds. C int array version is treated as the benchmark.

VersionTime(s)Environment
C (int array)1.08gcc 10.2.0
C++ (STL)1.6gcc 10.2.0
C++ (array)1.539gcc 10.2.0
Rust1.58cargo 1.47.0
OCaml3.8ocamlc 4.10.0, dune 2.6.1
Julia7.2Julia 1.5.2
Common Lisp10.8SBCL 1.4
Scala31.5Scala 3.1.2, JVM 11.0.14
Elixir (array)312Elixir 1.11.3/Erlang OTP 23
Elixir (map)281Elixir 1.11.3/Erlang OTP 23
Elixir (set)236Elixir 1.11.3/Erlang OTP 23
Elixir (ets)225Elixir 1.11.3/Erlang OTP 23

I would say OCaml is very impressive here. It is really a sweet point between development speed and runtime performance.

Also it is not fair for Elixir. The program is computing centric and the algorithm is not optimized for concurrency. In a IO bound scenario, I believe Elixir would have better performance.

About

Conway's Game of Life written in different languages.


Languages

Language:C 21.0%Language:Elixir 19.6%Language:Haskell 16.8%Language:C++ 13.4%Language:Common Lisp 9.9%Language:Rust 6.5%Language:Scala 4.6%Language:OCaml 4.2%Language:Julia 3.2%Language:Makefile 0.8%