swarm-game / swarm

Resource gathering + programming game
Other
841 stars 52 forks source link

Add elaboration steps to make good code perform good #1563

Open xsebek opened 1 year ago

xsebek commented 1 year ago

Motivation

We should encourage writing good code™️, but with increasing number of robots it becomes necessary to do optimisations by hand to get good performance.

We should take this work from the players and developers and do this work during elaboration.

Example

Here is the code that we want to write:

def doN = \n. \f.  if (n > 0) {f; doN (n - 1) f} {} end;

doN (2 * 3) move; 

Instead we have to optimise it by hand if hundreds of robots will run this code:

move;move;move;  move;move;move;

Solution

Here are the tasks that are needed for the good code to perform good:

xsebek commented 1 year ago

@byorgey what do you think of this direction? 🙂

byorgey commented 1 year ago

Sounds good to me! I will also mention here that https://hackage.haskell.org/package/hegg might be useful for constant folding etc.