No Time To Play

A glance at the Nim programming language

by on Jun.08, 2017, under Off-topic

I love learning new things. That’s helped me stay on top of this ever-changing business we call IT. And part of the fun is how random it can be. Take the past two days: I was reading about the new zipapp module in Python; from that I moved to the setuptools suite, which in turn mentioned the reStructuredText file format. Curious to know what other tools support it, the next day I looked over a suitable list… which in turn mentioned the Nim programming language.

That made for a really busy evening.

Nim belongs to the new crop of application programming languages, like Go and Swift, that embrace garbage collection, type inference and high-level data structures to ease the burden of overworked software developers, while still providing the performance and simplified distribution that come with native code compilation. Unlike the others, however, Nim doesn’t have a powerful corporation behind it, instead being a community project.

First impression: for Unix-like platforms, Nim comes in a source package with few dependencies apart from a C compiler. It builds without a hitch, in a little more time than Python 3 (not that I measured), and runs out of the box without being installed. Setting up cross-compilation for Windows was as easy as installing MingW and adding a couple of lines to a configuration file; for other operating systems I’d need a virtual machine, but oh well. The generated executables aren’t too large despite the static linking, either.

On to the language proper, we’re talking a Python-lookalike, with a rich syntax and many different features. It can be overwhelming at first sight, but at least everything is crystal-clear: the mark of good design. The standard library is very pragmatic, too. Typically for the current generation of languages, it includes modules to deal with CSV, JSON and various databases, plus a HTTP client and server. Notably, a simple cross-platform TUI (text user interface) is provided by default, with the promise of a GUI toolkit to be added down the road.

Other conveniences include the ability for a source file to work as either a module or a main application, fine-grained numeric types, and precise control over memory allocation. A flexible syntax makes Nim well-suited for the creation of domain-specific languages, too. The object system is simple and quirky, but metaprogramming allows for layering a traditional class system on top, much like you can in Javascript or Lua. Other familiar features like exceptions and assertions are however built-in. To help with safety, you can declare types to exclude nil values, procedure arguments are immutable by default, and variables can be as well.

In the way of tools, Nim comes with the usual suite to assist with building, documentation and package management (but not testing — that’s handled by a standard library module).

As of this writing I’ve only played with Nim, and have no plans to use it seriously yet. But it’s an option to keep in mind for the future, especially as the project is still young, so there is ample room for improvement.

Creative Commons License
A glance at the Nim programming language by Felix Pleşoianu is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

:

Leave a Reply

Turn on pictures to see the captcha *

Posts by date

June 2017
M T W T F S S
« May    
 1234
567891011
12131415161718
19202122232425
2627282930  

Posts by month