The goal of this project is to create near identical implementations of "Conway's Game of Life" (GOL) in multiple programming languages. I'm doing this in an effort to learn new programming languages, and get a rough idea of the syntax differences and runtime speed of each language with a naive implementation (no language specific optimizations that can't be applied to other languages).
In order to give a fair comparison, all implementations are coded as similarly as possible using features available in the core language (no frameworks where possible). Each implementation demonstrates basic control flow (if, for, foreach, while, etc), as well as core concepts of each language (such as variable assignment, method definition, arrays/lists, hashes/dictionaries, etc). It also uses standard OOP features (such as class definitions/variables/methods, instance variables/methods, class/variable/method visibility).
Note: Because I've kept all implementations as similar as possible, the runtime of some implementations may not run as fast as they could if I had used native patterns/optimized functions available only in that language. I want to avoid language specific optimizations where possible. However, there may be general optimizations that can be applied to all implementations which could speed things up. If anyone notices any, please open a Github issue detailing the possible improvement.
Note: These speed results are taken on a Macbook Pro 15" Retina (Mid 2018), 2.6 GHz Intel Core i7, with 32 GB of 2400 MHz DDR4 RAM.
The times were calculated by playing each simulation for long enough that the average tick time becomes stable (normally around 20s), and then grabbing the averages.
Place | Language | Tick Avg | Render Avg | Typed | Notes |
---|---|---|---|---|---|
1st. | Crystal | 0.105ms | 0.960ms | Static | Crystal 0.34.0 |
2nd. | Dart | 0.268ms | 0.548ms | Static | Dart 2.8.1 |
3rd. | Go | 0.288ms | 0.550ms | Static | Golang 1.14.2 |
4th. | Kotlin | 0.310ms | 0.257ms | Static | Kotlin 1.3.72 |
5th. | Java | 0.320ms | 0.258ms | Static | OpenJDK 14.0.1 |
6th. | C# | 0.322ms | 2.501ms | Static | Mono 6.8.0.105 |
7th. | Javascript | 0.602ms | 1.358ms | Dynamic | Firefox 76.0.1 |
8th. | Scala | 0.682ms | 0.315ms | Static | Scala 2.13.2 |
9th. | Nim | 1.186ms | 3.053ms | Static | Nim 1.2.0 |
10th. | Groovy | 1.310ms | 3.009ms | Static | Groovy 3.0.3 |
11th. | Swift | 1.470ms | 2.170ms | Static | Swift 5.1.3 |
12th. | Javascript | 1.579ms | 0.646ms | Static | Deno 1.0.0 |
13th. | Javascript | 1.823ms | 1.363ms | Dynamic | Chromium 81.0 |
14th. | PHP | 1.928ms | 1.646ms | Dynamic | PHP 7.3.11 |
15th. | Javascript | 2.298ms | 0.919ms | Static | Node 14.2.0 |
16th. | Ruby | 5.142ms | 3.428ms | Dynamic | Ruby 2.7.1 |
17th. | Python | 5.315ms | 5.237ms | Dynamic | Python 3.7.7 |
18th. | Lua | 5.597ms | 3.397ms | Dynamic | Lua 5.3.5 |
Note: Below is a table of functionality that differs between the various static typed languages.This list is not exhaustive, but includes some of the primary things that I came across while implementing each one.
Feature | C# | Crystal | Dart | Go | Groovy | Java | Kotlin | Nim | Scala | Swift | TypeScript |
---|---|---|---|---|---|---|---|---|---|---|---|
Runs Without Compiling |
|
|
|
|
|
|
|
|
|
|
|
Classes/Objects (Top Level) |
|
|
|
|
|
|
|
|
|
|
|
Classes/Objects (Nested) |
|
|
|
|
|
|
|
|
|
|
|
Class/Object Initializer |
|
|
|
|
|
|
|
|
|
|
|
Class/Object Methods |
|
|
|
|
|
|
|
|
|
|
|
Class/Object Method Visibility |
|
|
|
▵ |
|
|
|
|
|
|
|
Class/Object Variables |
|
|
|
|
|
|
|
|
|
|
|
Class/Object Variable Visibility |
|
|
|
▵ |
|
|
|
|
|
|
|
Instance Methods |
|
|
|
|
|
|
|
|
|
|
|
Instance Method Visibility |
|
|
|
▵ |
|
|
|
|
|
|
|
Instance Variables |
|
|
|
|
|
|
|
|
|
|
|
Instance Variable Visibility |
|
|
|
▵ |
|
|
|
|
|
|
|
Named Parameters/Arguments |
|
|
|
|
|
|
|
|
|
|
|
Default Parameters/Arguments |
|
|
|
|
|
|
|
|
|
|
|
semicolon optional |
|
|
|
|
|
|
|
|
|
|
|
return keyword optional |
|
|
|
|
|
|
|
|
|
|
|
Looping over Array (value) |
|
|
|
|
|
|
|
|
|
|
|
Looping over Hash (key/value) |
|
|
|
|
|
|
|
|
|
|
|
Custom Exceptions |
|
|
|
|
|
|
|
|
|
|
|
Exceptions Must Be Caught |
|
|
|
|
|
|
|
|
|
|
|
▵ visibility for package, not for object scope.
Note: Below is a table of functionality that differs between the various dynamic typed languages.This list is not exhaustive, but includes some of the primary things that I came across while implementing each one.
Feature | Javascript | Lua | PHP | Python | Ruby |
---|---|---|---|---|---|
Runs Without Compiling |
|
|
|
|
|
Classes/Objects (Top Level) |
|
|
|
|
|
Classes/Objects (Nested) |
|
|
|
|
|
Class/Object Initializer |
|
|
|
|
|
Class/Object Methods |
|
|
|
|
|
Class/Object Method Visibility |
|
|
|
|
|
Class/Object Variables |
|
|
|
|
|
Class/Object Variable Visibility |
|
|
|
|
|
Instance Methods |
|
|
|
|
|
Instance Method Visibility |
|
|
|
|
|
Instance Variables |
|
|
|
|
|
Instance Variable Visibility |
|
|
|
|
|
Named Parameters/Arguments |
|
|
|
|
|
Default Parameters/Arguments |
|
|
|
|
|
semicolon optional |
|
|
|
|
|
return keyword optional |
|
|
|
|
|
Looping over Array (value) |
|
|
|
|
|
Looping over Hash (key/value) |
|
|
|
|
|
Custom Exceptions |
|
|
|
|
|
Exceptions Must Be Caught |
|
|
|
|
|
This blog post was written for the Lockheed Martin Insight blog, sharing here for the external audience. Last month I started the Pluralsight summer camp by watching an interesting video in which the
Ken Schwaber & Jeff Sutherland The Scrum Guide The Definitive Guide to Scrum: The Rules of the Game November 2020 1 Purpose of the Scrum Guide We developed Scrum in the early 1990s. We wrote the first
Conway's Game of Life 就是用 Swift 编写的 Conway's Game of Life。
Game of Life 描述 According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970." Given a bo
本文向大家介绍python实现生命游戏的示例代码(Game of Life),包括了python实现生命游戏的示例代码(Game of Life)的使用技巧和注意事项,需要的朋友参考一下 生命游戏的算法就不多解释了,百度一下介绍随处可见。 因为网上大多数版本都是基于pygame,matlab等外部库实现的,二维数组大多是用numpy,使用起来学习成本比较高,所以闲暇之余写一个不用外部依赖库,con
本文向大家介绍详解Python 实现元胞自动机中的生命游戏(Game of life),包括了详解Python 实现元胞自动机中的生命游戏(Game of life)的使用技巧和注意事项,需要的朋友参考一下 简介 细胞自动机(又称元胞自动机),名字虽然很深奥,但是它的行为却是非常美妙的。所有这些怎样实现的呢?我们可以把计算机中的宇宙想象成是一堆方格子构成的封闭空间,尺寸为N的空间就有NN个格子。而
Camera Life 是一个用PHP 开发的相册管理系统
Running Life(开源)是基于HealthKit和高德地图开发的健康跑步助手。 效果图 功能 .动态绘制跑步路径 智能判别跑步状态. 记录跑步数据生成分享小卡片、微信分享 条形图展示消耗卡路里 技术 MVVM架构 基于高德地图实现动态绘制轨迹 CMMotionManager判断跑步状态 贝塞尔曲线与帧动画 CoreData HealthKit 现状 项目处于不断完善和重构当中,目