Roads Less Taken

A blend of programming, boats and life.

Nim Wrapping C

| Comments

Nim has all the language mechanisms needed to smoothly interoperate with C and C++. The rather large collection of wrapped C libraries (and that’s only those in the standard libs) is also a testament to this fact. In this article I explain my personal findings testing out the waters of wrapping a simple C library.

The basic approach to wrapping a simple C library is:

  1. Install Nim.
  2. Install c2nim using Babel or manually clone c2nim from github and build it.
  3. Use c2nim to translate the C header file(s) to a so called Nim wrapper.
  4. Make a small test showing it works.
  5. Write a so called “impure” intermediary library that uses the wrapper (next article)
  6. Make a test green and declare Victory (next article)

Okidoki… (roll up sleeves)

Bootstrapping Nim(rod)

| Comments

Technically Nim is still called Nimrod up to and including upcoming bugfix version 0.9.6. But then with the next version 0.10.0 it will be just Nim. Currently Nimrod is at 0.9.4. And oh, the current development version is 0.9.5 which will become 0.9.6 when released - the “odd and even” versioning scheme.

Nim can be a bit funky to get started with, typically due to a slight lack of documentation in certain areas that may be obvious to Nimmers (or Nimsters? Knights who say Nim?). This article tries to fill a few mental holes in the first steps.

Also, Nimsters like to do it in Nim - and often the reasons for this are very good, like maintaining portability or minimizing dependencies. Just don’t expect the classic autoconf dance here. As a Smalltalker I am fully versed in the NIH syndrome - which of course doesn’t always have to be a bad thing. Thankfully Nimmers also seem to balance it with a strong tradition of standing on the shoulders of giants.

So building Nim isn’t hard, but it’s also not obvious what is going on. There are of course binary installers available too, but hey, we want to hack!

Here Comes Nim!

| Comments

I just posted an article comparing some silly benchmarks between Cog Smalltalk and LuaJIT2. Now… let’s take a look at one of the latest “Cool Kids” on the language front, Nimrod - or as it has been renamed - Nim.

Cog vs LuaJIT2

| Comments

In the open source Smalltalk community we have a pretty fast VM these days - its called Cog and is written by the highly gifted and experienced Eliot Miranda who also happens to be a really nice guy! Cog is fast and its also still improving with some more developers joining recently.

Another very fast VM is LuaJIT2 for the Lua language (version 5.1), also written by a single individual with extraordinary programming talent - Mike Pall. LuaJIT2 is often mentioned as the fastest dynamically typed language (or VM) and even though Lua is similar to Smalltalk (well, its actually very similar to Javascript) its also clearly a different beast with other characteristics. If you start looking at the world of game development - then Lua appears everywhere.