Starter Kits for Functional Languages


#1

I’ve been exploring writing a starter kit for Erlang. I’m curious what the communities thoughts are on writing an API that is similar to the other languages without using OOP features.

I want to be careful with the API design choices, as right now we don’t have any purely functional languages with a starter kit, so whatever design choices are made might be shared with other functional languages like Haskell, Clojure, Elixir, etc.

It looks like the BEAM VM is set up for parallel async threads, so maybe having a message based API would work best? Instead of objects for self, ship, the board etc. maybe a message would be sent with an identifier for the object (perhaps as an atom)?

So for python3, we would have:

game_map = game.game_map

In Erlang we might instead us something like:

GameMap = get({game, game_map})

Using message passing would allow Erlang to make use of its brilliant concurrency system, which might make coding at the ship level much more interesting. I figured there should be a central function that creates handles the state of the board and objects and starts processes for each ship and its activities (and will be deleted on ship death).

Would love some thoughts from ya’ll!


#2

Halite II had a few starter kits for functional languages. Have a look at them here for inspiration: https://github.com/HaliteChallenge/Halite-II/tree/68a31a1f1a4591d403e25d665adc57b6ce9c8206/airesources


#3

I’ve made a skeletal OCaml starter package, but it’s a long way from being purely functional. You can see the code here if it’s of any interest, but it doesn’t answer your question about API choices for purely functional starters:

The input parsing uses mutable data structures, and I wouldn’t consider my API choices to be very deeply considered. It doesn’t use an object-oriented structure, so it may provide a starting point for discussion about non-OO API for starter packages. Even if that starting point is to say “that code is horrible”. :slight_smile:


#4

Thanks! I appreciate the response. I’ll look over your code for inspiration!