Our polyglot take on the Global Day of Coderetreat
- by Tomás Ruiz López
- November 15, 2019
- functional programming• swift• bow• kotlin• arrow• scala• haskell
What’s a Coderetreat?
The Global Day of Coderetreat is an initiative to gather software professionals in a day-long event where they can discuss and learn new programming practices in an open environment. Small, yet teasing, coding challenges are proposed so that people can move away from the pressures of deadlines and take a look at different ways of solving problems. One of these challenges is Conway’s Game of Life.
The day is organized into five or six 45-minute sessions. In each session, Conway’s Game of Life must be solved with a different constraint which is provided by the event facilitators. For instance: no computers, just a paper.
What’s Conway’s Game of Life?
Conway’s Game of Life is an evolutionary game that requires no user input other than the initial state of the board. The game consists of a grid of cells that can either be alive or dead and follow a few rules to determine their next generation. These rules are:
- An alive cell with fewer than two neighbors will be dead in the next generation.
- An alive cell with two or three alive neighbors will remain alive in the next generation.
- An alive cell with more than three neighbors will be dead in the next generation.
- A dead cell with exactly three alive neighbors will come back to life in the next generation.
These rules are used in a coding challenge, where additional restrictions can be applied to practice different programming techniques.
Where is Global Day of Coderetreat celebrated?
There are many on-site events that you can check out on coderetreat.org. However, if you can’t make an event in person, you can still join people remotely and complete these challenges together!
Are you a facilitator?
If you are facilitating one of these events, you can consider adding constraints to solve Conway’s Game of Life in a more functional way. Here are some examples:
- Choose a pure Functional Programming (FP) language, like Haskell, or a hybrid language like Swift, Scala, or Kotlin, to code Conway’s Game of Life.
- Investigate if any of the libraries for FP in those languages can provide benefits for the resolution of the exercise. Arrow for Kotlin, Bow for Swift, or Cats for Scala are good candidates to help you with this task.
- Write functions without side-effects that return the same output from the same input.
- Variables cannot change their initial value.
- Take a look at how you can use Property-based Testing to verify the correctness of your implementation.
- Consider taking a completely different take on solving it; for instance, using Comonads!
Are you an attendee?
If you are an attendee, don’t worry about completing the challenge. Focus on practicing new techniques and exploring alternatives to what you usually do in your daily work routine. Ask for help if you get stuck!
We are looking forward to seeing what you come up with applying FP in different languages to solve this coding challenge! Next week, we will be publishing our solutions to Conway’s Game of Life in the four languages that we usually work with at 47 Degrees. Meanwhile, enjoy the Global Day of Coderetreat, and happy coding!