Nim! pt2

Still exploring Nim



In my last post I mentioned I stumbled on a new language called Nim (formerly Nimrod), and I was able to sink my teeth into it only slightly more.

I tried install the beta package manager, but was having some problems that are to advanced for me at the moment (IE I really would rather spend my time on stuff to help me learn the language before I dig in and really try to help debug what is probably an OSX specific compiler issue).

Where to start? I like games, and a game that utilizes SDL2 presents a lot of challenges. The first challenge, then, is to get a program up and running that can hook into SDL2 – Nim already has a project to wrap the SDL2 library, and an example that can get a window displaying.

The trickiest part was actually just making sure the build command was composed correctly, since I really didn’t have to create any code (yet).

The complication is that I want my directory structure to look like this:

- bin/
  - (game executable)
- libs/
  - sdl2/
- src/
  - nimcache/
  - main.nim
- Makefile

Which isn’t like what I’ve seen so far (which is very, very little).

But it turns out Nim makes things super easy, this would be the all: target in the Makefile:

nimrod c -p:./libs/sdl2/src/ -o:../bin/out src/main.nim

A couple of things I learned from this: