Nim Improves Async
Written by Kay Ewbank   
Monday, 12 March 2018

There's a new release of Nim, the systems programming language that focuses on performance, portability and expressiveness. Nim, which was formerly called Nimrod, is statically typed and compiled.

nim

 

Nim is strongly typed and has first class functions. It is object oriented, but with composition preferred over inheritance. Nim compiles to C as its default, but can be used with different compiler back-ends to produce JavaScript, C++, or Objective-C.

Nim's options include a deferred reference counting garbage collector that is fast, incremental and pauseless; or a soft real-time garbage collector that lets you specify its max pause time. There are also other optoins for garbage collection.

The work on the new release of Nim has mainly been aimed at cleaning up the standard library in preparation for v1.0, but there are some improvements aside from that. The work on the library does mean there are breaking changes in this release, including the [] indexing operator which takes a slice now raises an IndexError exception when it is out of bounds.

Away from the breaking changes, the developers say that the best improvement is a strformat module that implements string formatting that is very similar to Python 3’s f-strings. 

nim2

 

One nice touch is the documentation generator, which can now test your examples for you. You save a code sample, generate it documentation, and the code will compile and will be embedded in the procedure’s documentation. If your examples have an error in them then you will see it, together with a stack trace if your error occurs at runtime.

There's also a new mapLiterals macro that allows you to create array and sequence literals, and a new memory manager algorithm designed to reduce memory fragmentation.

The async improvements in the I/O modules of the standard library mean there is no longer an “upcoming” and standard asyncdispatch split, the former was merged and is now the default asyncdispatch implementation. A new getIoHandler procedure is now available that returns a handle to the underlying IO completion port or epoll/kqueue fd used by asyncdispatch. This means that the libraries now have more control over the event loop.  A new implementation of async await has also been added for the JavaScript backend in the asyncjs module.

The final main improvements are to the Nim package manager, Nimble. Its major new feature is the support for multiple Nimble packages in a single Git/Hg repository.

 nim

More Information

Nim Language Site

Related Articles

Nim 0.15 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, Facebook or Linkedin.

Banner


What Languages Do Devs Want to Learn?
17/11/2020

Python, of course. What comes as a surprise is the size of the margin between Python and the rest of the pack. The other unexpected finding is that JavaScript doesn't even make it into the top 10. So, [ ... ]



C# 9 and F# 5 Released With .NET 5
12/11/2020

Microsoft has released C# 9 and F# 5 as part of the .NET 5 release this week. Visual Basic is also included in the 5.0 SDK. It does not include language changes, but has improvements to [ ... ]


More News

square

 



 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Sunday, 11 March 2018 )