Mech is a language for developing data-driven, reactive systems like robots, games, and interfaces. It makes composing, transforming, and distributing data easy, allowing you to focus on the essential complexity of your project.
You can try Mech online at try.mech-lang.org. Read about progress on our blog, and follow us on Twitter @MechLang.
Bouncing Balls Simulation
==========================
Â
This program is a forward kinematic simulation of three balls
bouncing in a 2D bounded arena. The balls are accelerated by
simulated gravity and are repelled by the bounds of the arena.
#balls = [|x<m> y<m> vy<m/s> vx<m/s>|
20 10 2.4 0
100 50 0 3
300 100 0 -5]
#gravity = 9.8<m/s^2>
#dt = 16<ms>
#bounds = [x<m>: 500 y<m>: 600]Â
Indented code runs in an asynchronous “block”. These blocks
are composable and reactive; they recompute automatically when
dependent data change, or some condition is met. This block
updates the state the balls every 16ms.
~ #dt
#balls.x,y :+= #balls.vx,vy * #dt
#balls.vy :+= #gravity * #dt
Â
The following block enforces boundary constraints, ensuring that
the balls will never leave the arena.
~ #dt
iy = #balls.x,y > #bounds
ix = #balls.x,y < 0
#balls.x,y{iy} := #bounds
#balls.x,y{ix} := 0
#balls.vx,vy{iy | ix} := -#balls.vx,vy * 80%
Usage and installation instructions can be found in the documentation or the main Mech repository.
Documentation is hosted online at mech-lang.org, and is open sourced on GitHub.
Mech is currently in the alpha stage of development. This means that while some features work and are tested, programs are still likely to crash and produce incorrect results. There is a "happy path" that works well, but it's quite narrow. We've implemented many language features, but most are incomplete and some are not yet implemented at all.
See ROADMAP.md for more.
Apache 2.0