How the Grouper stole Christmas!
For the last few days I’ve been playing around with the excellent Advent of Code by Eric Wastl. I’m not normally attracted to programming contests but this time I’m having fun.
I’ve been playing a sort of a meta-game on top of the puzzles, trying to write all the solutions in a functional programming manner. I’ve been using Elixir for this and it’s been going great. There are many resources about Erlang and Elixir floating around. I warmly recommend at least learning about these languages, if you are interested in functional programming, concurrency and fault tolerance. Erlang also has pretty neat video documentation.
One of the many nice things about writing Erlang or Elixir programs is the tooling. Rebar3 (or the legacy Rebar) for Erlang and Mix for Elixir are great build tools which allow you to quickly set up a new project, manage its dependencies and build it. With one command, a new project is set up based on a conventional structure, and you are ready to start writing code, documentation and unit tests. Sure, an IDE usually does this for you, but if you prefer working in an editor, having a stand-alone command line tool for project management is very convenient. Erlang and Elixir have good integration with Emacs, Vim, and other newer editors, so working in a text editor doesn’t feel forced.
Anyway, to get to the point of this post, working with Elixir on these small puzzles made me think of what this would be like if I were solving them with C++. This is the language I’m using at work right now. The main project we’re working on is big, has it’s own extensive CMake configuration scripts, unit testing, documentation and integration with our CI system. But what about experimental code outside of that project? Whenever you get to the stage where a shell script for compiling isn’t enough anymore, you have to go through the tedium of writing the CMake project files, set up the project skeleton etc. Furthermore, having a framework for unit testing available from the beginning would make the experimentation phase much more productive.
I decided to tackle this problem once and for all, no more manually copy-pasting files between my projects like some savage. Merou is what I came up with. You can grab it on GitHub.
Merou is a Python script that creates new C++ projects based on a template and a series of parameters you provide, such as: project name, developer name, project description, github account. The goal is to have as much functionality in the new project as possible, from the beginning. Here’s what is currently available:
- Full CMake configuration with application and library part of the project
- Unit testing with Catch - catch.hpp is downloaded when creating the new project
- README.md with Travis-CI badge, link to issue tracker
- License file - MPL v2 is used for now. In the future, it should be possible to choose a license
- Example files for Travis-CI
- Some extra goodies
The GitHub repo contains a complete description of the project and its usage information, but here is how you’d create a new project with Mérou:
$ bin/merou --project_name MyNewProject \ --description Description of the project \ --developer_name Radu Popescu \ --github_user_name radupopescu \ --github_repo mynewproject \ -o ./
One thing to note is that the tool doesn’t create a new GitHub repo for you, nor does it set up Travis-CI by itself. If you’d like to use them, you need to do these steps by yourself.
I’d be very happy if you find Mérou useful. This project is brand new and most likely it has many bugs, missing features, and I guess the documentation could also be improved. Additionally, I’ve only tested it on my Macbook. I’d appreciate bug reports and feedback of any kind.
One last thing, what’s mérou?
Well, I had to give this program a short name and I didn’t want it to be ncpppc (for New C++ Project Creator). I had the Wikipedia page of the grouper fish open in a different tab (the title of this post now makes a little bit of sense, but still isn’t funny) so I picked that as the name. I chose mérou, which is French for grouper, for added exotic appeal. We can also call it Merou, without any accent, because typing “é” on a US International keyboard is very tedious. The script itself doesn’t have the accent in its name, either.
That’s all I have for today.