Skip to content

deviousasti/gameoflife-wasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conway's Game of Life

This is an implementation of Conway's Game of Life in F# using Bolero, which runs a compiled F# assembly entirely in Web Assembly. This is different from F# Fable which transpiles to Javascript.

There are no limitations on what portions of the library are available, rather any library can be used in Bolero, as evidenced by the use of Array2D functions.

recording

Implementation

There is no HTML component; the entire Model-View-Update (MVU) application is written in Elmish in Main.fs. The model is immutable, so all updates are transformations. (most implementations which use double-buffering and array mutations).

Observations

Interop with the JS runtime seems to be expensive, while calculating the diff is not costly.

The internal state is a 2D array. Since model state in Elmish is never mutated, it must be recreated every time.

 { model with state = state |> Array2D.mapi(fun i j _ -> alive i j state |> rules) }

So enough memory pressure is generated to cause a GC.

image

This is a minor GC and very fast (less than 1ms).

About

Conway's Game of Life in Web Assembly, built using Bolero

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published