1 of 9

A new(-ish) general purpose programming language!!

Presentation by Benjamin N. Summerton

https://16bpp.net/

(@def-pri-pub)

2 of 9

So what is Nim?

  1. It’s a programming language, nothing more
  2. Fairly Python-like syntax
  3. Produces native binaries!
    1. Actually compiles to C/C++/Obj-C & more
  4. Quite flexible as a language
    • Gives you complete control over the syntax via templates & macros
  5. Been in development for almost a decade
    • Still very young though

“Guess My Number,” example adapted (and taken) from Rosetta Code.

Sample code:

3 of 9

A (very) Brief history and Rationale for Nim

  • 2005: First iteration of the compiler started
    • Written in Pascal
  • 2008: First Nim compiler that was written in Nim released. (Self hosting, yay!)
  • Current version: v0.17.2
    • Released 9/7/1017
    • New releases happen every couple of months
    • It’s probably going to be a while before v1.0.0 drops
  • Originally called Nimrod
    • Name only changed a few years ago
  • Rationale:� “People need to stop writing C.” - from some IRC session in #nim channel on freenode a while back

Our BDFL: Andreas Rumpf

4 of 9

Why you shouldn’t use Nim

  • The language isn’t fully “in place,”
    • Anything is subject to change
    • You could download the new release and then you application won’t compile�
  • The community is still fairly small
    • Doesn’t have any too many off the shelf bindings to existing libraries
    • Not too many blogs and external resources
  • Debugging sucks
  • You still have to think like a C programmer sometimes
  • Batteries are not fully included (yet)
    • Sometimes it’s like trying to harvest a AAAA battery from a 9v to shove into a AAA slot
  • It’s not at v1.0.0 yet
    • The compiler will give you a deprecation notice (and even help you update it sometimes!)
    • It’s very rare that something in the core has broken for me
  • We got Forum & IRC
    • FFI is nice, easy to use
    • Community members are very knowledgeable
      • Very easy to talk to compiler Devs
  • You can use GDB
  • You’ve got more flexibility than plain C�
  • There is still a lot available
    • Packages on nimble
    • c2nim tool helps with CFFI and porting
    • Sometimes writing things in pure Nim is fun

It’s fair to give you a warning first; though don’t despair...

5 of 9

What makes Nim awesome�(and special)

  • It feels like you’re writing Python
    • but you’re getting native binaries
    • We’ve also got an experimental JavaScript target�
  • You’ve got complete control over how the compiler acts
    • Like how lisp gives you macros? The AST is fully exposed for you to mess with at compile time�
  • If you’ve got a C library, you can use it in Nim
    • C++, Objective-C, & JS too!
    • You can also embed C as well
    • Some things like Qt are a bit harder though
      • Dat meta-object compiler…�
  • Since it becomes C* at the end of the day, you can plug it into the compiler of your choice: gcc, clang, intel, tinyc, etc…
    • You can also do ASM.js stuff via emscripten

6 of 9

Cool things that have been done with Nim (so far)

  • NimES, a NES emualtor by def-
    • https://github.com/def-/nimes
    • Works on desktop and web (via emcscripten)�
  • NEd, a text editor for Nim by Stefan Salewski
    • https://github.com/ngtk3/NEd
    • GTK3 & Gobject introspection bindings!
    • Shows off some of Nim’s tooling (e.g. nimsuggest)�
  • Jester, a server side web framework by dom96
    • https://github.com/dom96/jester
    • Our forum is built on top if it!�
  • x86_simd.nim, exposing dem SSE by bsegovia
    • https://github.com/bsegovia/x86_simd.nim
    • It’s like having a Mini-GPU do math for you
    • There was someone else doing GPGPU things before...

7 of 9

Tell Me about Game Development

It’s unfortunately a bit more “manual,” at the moment; we’re trying to make it better

  • Well Known Engines:
    • Unreal 4
    • Godot
    • Urho (kinda defunct though)�
  • Written in Nim:
    • FRAG
    • nimgame(2)
    • zengine (Name might change soon though)
      • I’m helping build this one�
  • Atomic Units:
    • OpenGL
    • SFML
    • SDL
    • solound
    • HTML5 Canvas
    • Web audio
    • GLFW
    • BGFX
    • We could be here for a while….

8 of 9

How to first Nim

Search for these in Google. I’d recommend doing them in order:

  1. Nim By Example
  2. Learn Nim in Y Minutes
  3. Nim Tutorial (Part 1)
  4. Nim Tutorial (Part 2)

Then find a project to make in Nim. The first thing I built for myself was a web scraper!

Then lastly, spend time time reading through the manual. It’s not that bad:

This is how I learned Nim, and it wasn’t painful at all. It was actually quite enjoyable; I swear.

9 of 9

Questions?

Official site: https://nim-lang.org/

GitHub: https://github.com/nim-lang/Nim

Forums: https://forum.nim-lang.org/

IRC: #nim on FreeNode

Gitter: nim-lang/Nim

Presentation by Benjamin N. Summerton

https://16bpp.net/

(@def-pri-pub)