博客

不论是官方博客的翻译
还是中文社区的最新动态
你都能在这里找到

Version 1.6.0 released

Nim version 1.6 is now officially released!


This Month with Nim: September 2021

Four interesting projects our users worked on in September

This Month with Nim: August 2021

Three interesting projects our users worked on in August

Benchmarking the Beast

Benchmarking with the Sieve of Eratosthenes with efficient cache use

This Month with Nim: June 2021

Three interesting projects our users worked on in June

A New Home For Our Community

Take a look at some updates to our official IRC channel as well as new ways to connect to our community via Matrix.

NimConf 2021 - Nim Online Conference

NimConf 2021 will take place in about two weeks from now -- on June 26th.

This Month with Nim: May 2021

Four interesting projects our users worked on in May

Version 1.4.8 released

The Nim team is happy to announce version 1.4.8, our fourth patch release for Nim 1.4.


This Month with Nim: April 2021

Three interesting packages our users worked on in April

Versions 1.4.6 and 1.2.12 released

The Nim team is happy to announce the double patch release of versions 1.2.12 and 1.4.6.


This Month with Nim: March 2021

Four interesting packages our users worked on in March

Pattern matching in Nim

Nim fusion and pattern matching

This Month with Nim: Feburary 2021

Five interesting packages our users worked on in Feburary

Multithreading flavors: Choosing the right scheduler for the right job

Demystifying multithreading for IO and multithreading for Compute.

Versions 1.4.4 and 1.2.10 released

The Nim team is happy to announce the double patch release of versions 1.2.10 and 1.4.4.


This Month with Nim: January 2021

Seven interesting packages our users worked on in January

This Month with Nim

I will be starting a monthly blog post for community showcase entitled 'This Month with Nim'.

Nim Community Survey 2020 Results

The Nim community survey 2020 has been open for one month, and we have received 769 responses - we think this is a large enough sample to draw conclusions about our users and their habits. Before we go into details, we would like to thank all the people who took the time to respond. We really appreciate the feedback!


Nim in 2020: A short recap

A lot has happened in the Nim world in 2020: two new major releases, two new memory managements strategies (ARC and ORC), the first Nim conference, and much more.


Launching the 2020 Nim Community Survey

We are proud to announce the launch of the official 2020 Nim Community Survey!


ORC - Vorsprung durch Algorithmen

ORC - Algorithmic Advantages

Version 1.4.2 released

The Nim team is happy to announce version 1.4.2, our first patch release for Nim 1.4.


Advent of Nim 2020

Tuesday December 1st at 5 a.m. UTC will mark the start of the sixth incarnation of Advent of Code, popular programming contest started back in 2015. The author describes Advent of Code (AoC) as “a series of small programming puzzles for a variety of skill sets and skill levels in any programming language you like”.


Versions 1.2.8 and 1.0.10 released

The Nim team is happy to announce this double release of versions 1.2.8 and 1.0.10.


1.4.0版本发布

我们非常自豪地宣布,经过六个月的持续开发,Nim 1.4 版本已经发布了! 除了 1.0 版本之外,这可能是迄今为止最大的 Nim 版本,我们很高兴能够发布它。


Introduction to ARC/ORC in Nim

Nim is advancing towards more efficient memory management models. Let's talk about ARC/ORC and see how they will change the way memory works in Nim.

Hacktoberfest with Nim

Hacktoberfest is an annual event happening in October which celebrates open source software and encourages meaningful contributions to the open source ecosystem. To win a T-shirt or plant a tree, you must sign up on the Hacktoberfest site and make four pull requests to any repo on Github by the end of October.


Write Tracking for Nim (Part 2)

7 years ago I wrote how Nim would get “write tracking” as an alternative to adding const to Nim’s type system. This year it finally made it into Nim nightly! Since then the feature was reimplemented and all the details how it works did change.


1.2.6 版本和 1.0.8 发布

The Nim team is happy to announce this double release of versions 1.2.6 and 1.0.8.


Nim 中的光线追踪

我相信,如果你想从头开始一个渲染项目,Nim是最好用的语言。

NimConf 2020

NimConf is happening on Saturday June 20th 2020, don’t miss it!


1.2.2 版本现已发布

The Nim team is happy to announce version 1.2.2, our first patch release for Nim 1.2.


静态分析

Nim 处于一个绝佳的位置,可以与静态分析“结合”,它不必基于一些中间表示,但可以实现一个更类似于 Spark 的解决方案。

Nim Online Conference 2020

Mark the date: Saturday, June 20th 2020.


1.2.0 版本现已发布

在持续六个月的开发后,我们骄傲地宣布,Nim 1.2 版本发布了!

NimScript初体验

这两天刚接触Nim,这里分享一下关于NimScript的心得

使用Visual Studio Code调试Nim语言

由于Nim语言没有官方的IDE,开发程序起来会非常麻烦, 虽然也有人喜欢用纯文本编辑器来写程序,但项目大一些的话,还是IDE使用起来更方便。 好在Visual Studio Code十分强大,可以满足Nim开发的需求。

Nim的Debug尝试

Debug Nim with GDB

Nim Community Survey 2019 Results

Nim community survey 2019 has been open for 50 days, and we have received 908 responses, which is our record-high number (771 in 2018, 603 in 2017). Before we go into details, we would like to thank all the people who took the time to respond.

V1.0.6 发布!

Nim 团队很高兴为大家带来 1.0.6 版本发布的消息!这是我们在 Nim 1.0.0 之后带来的第三个补丁。

想了解更多关于 1.0.0 版本的信息,可以查阅 v1.0 发布说明.

本次的版本发布于前一个版本发布两个月之后, 包含了将近 60 次提交, 新修复了 15 个已知的错误、一些其他的 bug 修复、和文档优化, 这些都让我们的 1.0 发行版变得更好。

没有安全性相关的问题,但我们正努力保证每两个月发布一个新 1.0.x 版本的稳定周期。

提个醒:如果你还没有参加我们的 Nim 社区调研或者Nim 中文社区调研,就赶紧来参加吧!我们非常希望能听到您的意见!

安装 1.0.6

如果你已经使用 choosenim 安装了之前版本的 Nim ,升级到 1.0.6 版本会非常简单:

$ choosenim update stable

如果没有的话,你可以通过 这些教程来安装 choosenim, 当然你也可以根据网站 安装页 的说明直接安装 Nim 。

更新日志

Bug 修复

修复的 issues

  • 修复了”当使用 –styleCheck:error 命令造成的 Nim 标准库样式的问题” (#12687)
  • 修复了”new (ref MyObject) 无法在编译时工作的问题” (#12488)
  • 修复了”当访问虚拟机 (VM) 中错误的变量字段时,不会触发相应错误消息的问题” (#11727)
  • 修复了”使用没有初始化的 table 造成 orderedTable.del 函数崩溃的问题” (#12798)
  • 修复了”负数 * 0 导致的常量折叠 (Semfold) 的问题” (#12783)
  • 修复了”nimsuggest use command 不能返回 symbol 所有实例的问题” (#12832)
  • 修复了”allPathsAsgnResult 中的代码生成 (codegen) ICE 的问题” (#12827)
  • 修复了”for 循环中,同时出现 Static[T] 和 语法错误造成编译器崩溃的问题” (#12148)
  • 修复了”在 templates 和 tables 中出现未使用导入库的警告 (Incorrect unused import warning)” (#12885)
  • 修复”回归问题 (Regression) (1.0.4): 未声明的标识符: ‘readLines’ 和另一个回归问题” (#13013)
  • 修复了”nim doc 错误地处理导出局部符号 (export localSymbol) 的问题” (#13100)
  • 修复了”语法 (grammar) 中未定义的符号的问题” (#10665)
  • 修复了”所有发行版本都缺少 nimp-gdb 工具的问题” (#13104)
  • 修复了”[JS] 后端未定义 Move 标识符的问题” (#9674)
  • 修复”Error: usage of ‘isNil’ is a user-defined error 的提示信息” (#11440)

其他错误修复

  • 使 addQuoted 在 nimscript 上工作 (#12717)
  • 修复了在 db_mysql getRow() 函数中,当列 (column) 为空导致的错误
  • 修复了在构造之前,对象 (object) 被错误清零的问题 (#12814)
  • 添加了 cstrutils (#12858): 修复了热代码重载 (hotcodereloading) 造成的”csuCmpIgnoreStyle”错误
  • 更好的 clang_cl 支持 (#12896)
  • 修复了影响 nimBetterRun 正确性的命令行错误 (#12933)
  • 修复了无法同时使用 sugar.collect 和 for 循环宏的错误
  • –out 和 –outdir 支持路径替换 (#12796)
  • 修复了 nim.cfg 中错误符号导致的崩溃 (#13073)
  • 允许 buildIndex 使用 -o 选项 (#13037)
  • 删除了错位 (misplaced) 的分隔符 (#13085): 因为错位 (misplaced) 的分隔符不断破坏 Nim 在 Haiku 操作系统上的编译,所以被- 删除了。
  • 修复 asyncftpclient 的错误 (#13096)
  • 修复 ftp store 函数读取本地文件的错误 (#13108)
  • 修复全局 (global) 范围内 varargs 的 rtti sizeof 的问题 (#13125)
  • 当关键字被设置为零时,可以正确地从 CountTable 中删除关键字
  • 修复了 distros.nim 中的回归问题 (regression)
  • 修复了在 IRC 上报告的 times.nim 模块中出现的重要问题
  • c_fflush() the rawrite() 缓冲 (buffer)

文档改进

  • 修复了”Nim 可用工具 (Tools available with Nim)”中缺少”Documentation, Testament”的问题 (#12251)
  • 手册 (Manual) 更新: 自定义异常 (#12847)
  • times/getClockStr(): 修复文档中的错误
  • 修复了”lib/pure/parseutils.nim”代码块中的错误并改进了文档

2019 Nim 中文社区问卷调研

我们骄傲地宣布: 2019Nim中文社区问卷 启动! 无论你当前正在使用 Nim ,还是之前用过 Nim ,或者从未使用过 Nim ; 我们都想要听听你的观点。

由于官方使用的是国内无法访问的 Google Form,我们对官方问卷做了本地化,进行了翻译并加入了更符合国内环境的选项。

我们会在问卷结束后将结果反馈给官方,所以你的反馈将会帮助 Nim 项目了解到它的长处和不足, 并确定未来的开发优先级。而且会指导中文社区明年的发展重点和方向。

2019 Nim 中文社区调查问卷

完成这个问卷应该会占用你五分钟的时间。 2020 年 2 月之前你可以随时提交。 (由于“新冠”肺炎疫情的影响,我们取消了问卷的时间限制,但也请尽快完成,我们仍然可能会在不久的将来增加时间限制。) 如果你有任何的问题及反馈,请不要吝于告诉我们:

发邮件给我们 [email protected] , 或者在 Nim 论坛 中发言。

这已经是 Nim 官方举办社区问卷的第四个年头了。 你可以通过下面的链接查看过去几年的统计结果:

我们也恳请并感谢您将这份问卷传播给其他人。 你可以在你的社交帐号上,和你的同事、朋友和其他社区分享这份 MicroSoft Forms 的链接。

感谢您的参与!


2019 Nim 社区问卷调研启动

我们骄傲地宣布:官方 2019 Nim 社区问卷 启动! 无论你当前正在使用 Nim ,还是之前用过 Nim ,或者从未使用过 Nim ; 我们都想要听听你的观点。 你的反馈将会帮助 Nim 项目了解到它的长处和不足, 并确定未来的开发优先级。


1.0.4 版本现已发布!

Nim 团队很高兴为大家带来 1.0.4 版本发布的消息!这是我们在 Nim 1.0.0 之后发布的第二个补丁版本。

1.0.2 版本发布

Nim 团队很高兴公布 v1.0.2 版本, 这是在 1.0.0 之后我们首次发布补丁。


1.0 版本正式发布

Nim团队非常荣幸地宣布万众期待的1.0语言版本。

Nim语言之父对于1.0版本的个人感言

功夫不负有心人,我们终于做到了!万众瞩目的1.0版本来了。

实战Nim入门系列(一)——下载安装Nim环境

这是当前版本 (v1.0) 的系列教程,希望能帮助大家快速上手。

浅谈Nim Web开发

浅谈Nim Web开发

Windows下nim-lang 0.20版本安装,无法运行finish.exe的解决方案

Windows下 nim v0.20 版本安装,无法运行 finish.exe 的解决方案

Nim is a statically typed compiled systems programming language. 
It combines successful concepts from mature languages like Python,Ada and Modula.

Nim是一种静态类型编译的系统编程语言。
它结合了来自成熟语言(如Python、Ada和Modula)的成功概念。

Nim中文网站:https://nim-lang-cn.org/

下载页:https://nim-lang-cn.org/install.html

目录

  1. 安装Nim
  2. 无法运行finish.exe的解决方案

安装步骤

  1. 进入上方官方网站, 并根据你使用的操作系统, 下载最新的稳定版压缩包

  2. 解压到任意你喜欢的目录下

  3. 运行此目录下的finish.exe

  4. 根据提示进行环境变量的配置

  5. 根据提示进行MingW的下载和解压, 并配置目录下的bin目录到环境变量中, 所以无需解压到nim目录下

  6. 在finish.exe引导安装完成之后 (建议先重启电脑,防止环境变量不生效) , 打开一个命令行, 并输入:nim命令进行测试。 如果能够显示如下图像, 就说明安装成功了。

但在0.20版本安装的过程中,出现了finish.exe无法运行的情况,点击之后没有反应,后来终于找到了解决方案,并亲测有效。

无法运行finish_exe的解决方案

一、查找问题

  1. 在finish.exe同级目录下, 按住Shift键,同时右击文件夹的空白处, 选择在此处打开Poweshell(或者cmd)

  2. 输入并运行.\finish.exe

  3. 正常来说,有问题的话这里会直接抛出异常,并打印出错误原因; 没问题的话,这里会直接正常运行finish.exe

  4. 然后就可以根据报错,去查找答案了。

二、解决问题

Error: unhandled exception: file 'C:\user\xxx\.nimble\bin' does not exist [OSError]

参考资料:

https://github.com/nim-lang/Nim/issues/11676#issuecomment-510780848 (这条回复我写的,欢迎follow我~)

发生原因:

怀疑可能是因为finish.exe没有权限在【我的文档】 (姑且按Win7这么叫, 毕竟win8以后是用户名了, 其实正经应该叫%User Home%, 但是不知道该怎么翻译……) 中创建目录导致的。

解决方法:

手动在%User Home%中创建.nimble/目录,然后再试试在命令行中运行finish.exe,还不行就把.nimble/下的bin/也创建了。

我的是在把这两个都创建了之后就好了。


目前没有碰到其他问题, 如果有朋友遇到了其他问题的话, 欢迎来我的博客下面留言, 让我们一起帮助Nim快速成长(到1.0版本)!

—— 博客原文转自《乱世之牙


Nim中文官网现已上线!

Nim中文官网现已上线! 大家可以通过https://nim-lang-cn.org来访问。

足下

官网是我们的起点, 它不只是一个官网的中文镜像, 我们更希望它是一个国内Nim圈子的基地, 一个核心。 所有的资源都会围绕这个核心, 所以我们会认真地打磨它:

  • 我们会及时更新和翻译官网的博客和其他更新, 以便大家掌握第一手的Nim资讯

  • 我们会及时将国内的Nim资源整合起来, 让官网可以真正运行起来, 发挥它的作用, 走出一条中国特色的Nim发展道路。

  • 当你需要教程资料时, 我们希望你第一个想到的是去官网上找, 并且我们会尽全力让你能够在官网上找到你需要的一切。

  • 我们也会在官网上建立论坛上的优秀资源的索引, 定期更新及时、优质的论坛资源, 并推送到思否、CSDN、OSChina、微博等主流媒体上。

生态

我们的初衷是想要建立起国内的Nim开发者生态。

以官网为核心, 让Nim开发者们把注意力集中到这里:

  • 官网上有很多论坛的索引,有问题可以去论坛问,便于存档;

  • 官网上也尽量多地整理了QQ、微信群, 有紧急的问题可以去聊天工具上问,能够及时得到回复;

  • 也可以通过学习页面上的【社区资源】模块, 获取到国内主流媒体上先行者的问题、解答或者一些心得体会的博文;

  • 也可能会有线下的交流见面会,或者论坛、QQ群、微信群的一些活动, 让我们的社区有爱又团结,发挥出社区的力量。

而这些都可以从社区中查看, 我们也会将活动进行博客的推送, 你可以订阅RSS以及时获取这些令人振奋的消息。

修远

  • 目前官网中最关键的——文档,还没有能够完全翻译完, 学习文档两个模块中的中文文档还在由@sheldon紧锣密鼓地翻译中, 但是大家都是通过业余时间以非盈利的方式参与进来的, 难免工作之余精力优先, 所以也欢迎大家加入我们来贡献自己的力量。

  • 我们也欢迎你把自己的Nim博客推荐给我们! 我们欢迎各种方向,各种优质、高产的Nim博客, 我们会在学习页面的社区资源栏将你的博客挂上, 供大家学习。


new runtimes完成之日,就是Nim 1.0发布之时!

特别感谢@sheldon大佬的鼎力支持 和Nim开发集中营各位的帮助。

感谢大家的支持和等待,让我们一起创造Nim中文社区的繁荣,推动Nim的发展。


0.20.2现已发布

Nim团队很荣幸为大家带来0.20.2版本,这是我们为1.0版本准备的第二个RC版本。

请点击之前的版本发布日志 以查看更多关于0.20版本的信息,以及我们关于1.0及之后版本的计划。 此版本主要包含了对0.20.0(1.0 RC1)版本的BUG修复。

唯一的新功能是我们添加了名为toOpenArray的切片操作符, 现对JavaScript后端可用。

这次更新距离上一个版本的发布尽管只差了一个月, 但它却包含了超过200次的新commit,修复了超过70个被提出来的issues, 并且带来了很多应该能让Nim更加稳定的改进。

代码风格检查

在0.20.0版本发布后,我们改进了我们的代码样式检查器, 现在可以通过在启动Nim时加上--styleCheck:error标识, 这意味着可以对编译器和标准库进行代码风格检查了, 如果使用了不同的代码风格(比如:fooBarfoo_bar),那么这些代码将不会被编译。

Nimpretty

我们对于这个版本的关注点还有一个,那就是我们的nimpretty工具: 这是一个Nim的源码美化器, 用来把代码格式化得符合官方风格(NEP-1)。 我们进行了超过30个提交,以改善nimpretty体验,让它更有能力应对现实场景。

新的runtime

新的runtime进展很顺利,但它还没有达到预想的状态, 所以他在1.0版本中将作为一个可选的特性。 下一个重要的里程碑是使新的运行时与async一起工作。 只有完成这一点,我们才会真正地进行推广,让大家优先考虑它。

安装0.20.2版本

你之前如果已经使用choosenim来安装了旧版本的Nim, 那么更新到0.20.2版本将会非常的简单:

$ choosenim update stable

如果你之前并没有使用它,你可以通过 这篇介绍来获取choosenim。 当然你也可以直接根据我们的安装页面, 单独安装Nim。

(译者注:在Windows下的choosenim只支持32位的下载, 你可以在64位系统下进行安装,但是这样的话你的nim版本只能也使用32位的,否则会报错)

不向后兼容的更新

  • All strutils.rfind procs now take start and last like strutils.find with the same data slice/index meaning. This is backwards compatible for calls not changing the rfind start parameter from its default. (#11487)

    In the unlikely case that you were using rfind X, start=N, or rfind X, N, then you need to change that to rfind X, last=N or rfind X, 0, N. (This should minimize gotchas porting code from other languages like Python or C++.)

  • On Windows stderr/stdout/stdin are not opened as binary files anymore. Use the switch -d:nimBinaryStdFiles for a transition period.

影响标准库的更新

  • Mac OS X / BSD: TSa_Family is now the uint8 type, so type conversions like x.sin_family = uint16 toInt(nativesockets.AF_INET) need to be changed into x.sin_family = TSa_Family toInt(nativesockets.AF_INET).

库的新增

  • 用于JS的toOpenArray 现已可用。

库的更新

  • Fix async IO operations stalling even after socket is closed. (#11232)

  • More informative error message for streams.openFileStream. (#11438)

编译器更新

  • Better error message for IndexError for empty containers. (#11476)

  • Fix regression in semfold for old right shift. (#11477)

  • Fix for passing tuples as static params to macros. (#11423)

Bug修复

  • Fixed “nimpretty goes crazy with this snippet” (#10295)
  • Fixed “nimpretty doesn’t trim all whitespace on the right side of an export marker” (#10177)
  • Fixed “nimpretty gives invalid indentation to array elements” (#9505)
  • Fixed “nimpretty doesn’t indent correctly if preceding line ends with ;, { etc” (#10159)
  • Fixed “Nimpretty wrong indentation for doc comments” (#10156)
  • Fixed “HttpClient Documentation needs Proxy example” (#11281)
  • Fixed “nimpretty aligns comment annoyingly” (#9399)
  • Fixed “ENDB missing from Docs and TheIndex, remove ENDB from –fullhelp” (#11431)
  • Fixed “Nimrod on Documentation generator” (#11460)
  • Fixed “nimpretty (de)indents code where it shouldn’t” (#11468)
  • Fixed “nimpretty adds spaces where it shouldn’t” (#11470)
  • Fixed “nimpretty formats enums differently based on commas” (#11467)
  • Fixed “strutils.rfind start parameter is unecessarily unusual” (#11430)
  • Fixed “TinyC is not documented” (#11495)
  • Fixed “c2nim missing from 0.20.0” (#11434)
  • Fixed “nimsuggest doesn’t work unless compiled with -d:danger” (#11482)
  • Fixed “random.initRand crashes in Nim 0.20.0 JS backend” (#11450)
  • Fixed “0.20.0 fails to bootstrap when passing “–verbosity:2” (or 3) to koch” (#11436)
  • Fixed “Destructors lifting doesn’t work with inheritance” (#11517)
  • Fixed “std/sums missing from TheIndex” (#11543)
  • Fixed “sequtils module: link is broken” (#11546)
  • Fixed “Case Statement Macros do not work in functions above exported functions.” (#11556)
  • Fixed “newruntime: internal error when initializing a proc variable” (#11533)
  • Fixed “newruntime: error when modifying a sequence” (#11524)
  • Fixed “fmod and other math module functions are missing in js mode” (#4630)
  • Fixed “Object variants and new runtime” (#11563)
  • Fixed “newruntime exceptions” (#11577)
  • Fixed “nimpretty is not aware that the next line is a part of the same context” (#11469)
  • Fixed “Distinct procs fail to compile” (#11600)
  • Fixed “[SharedTables] Error: undeclared identifier: ‘defaultInitialSize’” (#11588)
  • Fixed “newSeqOfCap is not working in newruntime” (#11098)
  • Fixed “nimpretty destroys source with a source code filter” (#11532)
  • Fixed “Unexpected behaviour when constructing with result” (#11525)
  • Fixed “Regression in 0.20.0: Nested proc using outer scope variable fails to compile” (#11523)
  • Fixed “os:standalone Error: redefinition of ‘nimToCStringConv’ “ (#11445)
  • Fixed “No ambiguity error on field overloaded by field=” (#11514)
  • Fixed “object variants and new runtime part 2” (#11611)
  • Fixed “seq Error: unhandled exception: value out of range: 32772 “ (#11606)
  • Fixed “Compiled binary includes full path to internal nim files” (#11572)
  • Fixed “Newruntime: top-level string variable is empty after an array assignment” (#11614)
  • Fixed “Newruntime: raise ObjContructor() doesn’t compile” (#11628)
  • Fixed “Owned ref can be copied and causes double-free” (#11617)
  • Fixed “When compiling to JS (in -d:release) output contains toolchain path on dev’s machine” (#11545)
  • Fixed “wrong unicode string output” (#11618)
  • Fixed “unittest “generic instantiation too nested” error” (#11515)
  • Fixed “Last read of a var parameter generates sink instead of assignment” (#11633)
  • Fixed “const table with proc type does not compile anymore” (#11479)
  • Fixed “Can’t use offsetOf on object that ends with an UncheckedArray” (#11320)
  • Fixed “Newruntime/regression: Bad codegen for inline methods” (#11636)
  • Fixed “String or sequences inside a loop are not cleared in each iteration” (#11510)
  • Fixed “Nim -v doesn’t acknowledge new danger flag” (#11484)
  • Fixed “SIGSEGV while compiling when trying to instantiate a case type, that uses an enum with non-zero start” (#11585)
  • Fixed “Compile-time usage of parts of strutils fails when using -d:useNimRtl” (#8405)
  • Fixed “regression(0.20): finally block executed twice in VM” (#11610)
  • Fixed “exportc symbol not exported, leading to link error” (#11651)
  • Fixed “Render bug: opearator priority can be wrong for second argument” (#11662)
  • Fixed “Nim & C disagree on type size” (#6860)
  • Fixed “Spawn passes refs across threads” (#7057)
  • Fixed “BUG: “varargs[string, $]” calls $ n^2 times instead of n times (n=len(varargs))” (#8316)
  • Fixed “Problem with the same name for module and exported type” (#3333)
  • Fixed “–gc:go does not work anymore” (#11447)
  • Fixed “Error: inconsistent typing for reintroduced symbol” (#11494)
  • Fixed “Auto generated destructors for tuples/objects fail with “non-trivial” error…” (#11671)
  • Fixed “Regression: parameter default value + typedesc parameter causes compiler crash” (#11660)
  • Fixed “newruntime: undetected dangling ref” (#11350)
  • Fixed “Newruntime: setLen() not working on sequences of owned refs” (#11530)
  • Fixed “Incorrect overflow/underflow error in case statements” (#11551)
  • Fixed “cgen preprocessor directive placed after struct declaration” (#11691)
  • Fixed “continue in an except Exception as e block crashes the compiler.” (#11683)
  • Fixed “nimsuggest, nim check segfault when using bindSym and doAssert” (#10901)
  • Fixed “Nimpretty issue, multiline string of x length only causes output grow every time.” (#11700)
  • Fixed “Array indexed by distinct int doesnt work with iterators” (#11715)

Version 0.20.0 released

We are very proud to announce Nim version 0.20. This is a massive release, both literally and figuratively. It contains more than 1,000 commits and it marks our release candidate for version 1.0!

Version 0.19.6 released

The Nim team is happy to announce that the latest release of Nim, version 0.19.6, is now available. Nim is a systems programming language that focuses on performance, portability and expressiveness.

This is the third bugfix release of version 0.19. There are no breaking changes. The most important bugfixes are:

  • Boolean logic at compile time is now correct.
  • Bitwise operations on signed integers in VM are fixed.
  • Fixed object self-assignment order of evaluation.
  • Compiler no longer crashes with generic types and static generic parameters.
  • Fixed raising generic exceptions.

Installing 0.19.6

If you have installed a previous version of Nim using choosenim, getting Nim 0.19.6 is as easy as:

$ choosenim update stable

If you don’t have it already, you can get choosenim by following these instructions or you can install Nim by following the instructions on our install page.

Bugfixes

  • Fixed “32 bit signed xor broken on VM” (#10482)
  • Fixed “SetMaxPoolSize not heeded” (#10584)
  • Fixed “uint inplace add in if branch is omitted when compiled to JS” (#10697)
  • Fixed “Booleans Work Wrong in Compile-time” (#10886)
  • Fixed “Bug in setTerminate()” (#10765)
  • Fixed “Cannot raise generic exception” (#7845)
  • Fixed “Nim string definition conflicts with other C/C++ instances” (#10907)
  • Fixed “std/json fails to escape most non-printables, breaking generation and parsing” (#10541)
  • Fixed “object self-assignment order-of-evaluation broken” (#9844)
  • Fixed “Compiler crash with generic types and static generic parameters” (#7569)

Version 0.19.4 released

The Nim team is happy to announce that the latest release of Nim, version 0.19.4, is now available. Nim is a systems programming language that focuses on performance, portability and expressiveness.

This is mostly a bugfix release of version 0.19.2. There are no breaking changes. The most important bugfixes are:

  • The mark&sweep GC had a serious performance regression that has been fixed.
  • The produced tarballs now support koch tests.
  • Json escaping has been fixed.
  • The documentation for async procs was missing, fixed.

Installing 0.19.4

If you have installed a previous version of Nim using choosenim, getting Nim 0.19.4 is as easy as:

$ choosenim update stable

If you don’t have it already, you can get choosenim by following these instructions or you can install Nim by following the instructions on our install page.

Bugfixes

  • Fixed “Latest HEAD segfaults when compiling Aporia” (#9889)
  • Fixed “smtp module doesn’t support threads.” (#9728)
  • Fixed “toInt doesn’t raise an exception” (#2764)
  • Fixed “allow import inside block: makes N runnableExamples run N x faster, minimizes scope pollution” (#9300)
  • Fixed “regression: CI failing Error: unhandled exception: cannot open: /Users/travis/.cache/nim/docgen_sample_d/runnableExamples/docgen_sample_examples.nim [IOError]” (#10188)
  • Fixed “Discrepancy in Documentation About ‘f128 Type-Suffix” (#10213)
  • Fixed “Performance regression with –gc:markandsweep” (#10271)
  • Fixed “cannot call template/macros with varargs[typed] to varargs[untyped]” (#10075)
  • Fixed “–embedsrc does not work on macos” (#10263)
  • Fixed “terminal.nim colored output is not GCSAFE.” (#8294)
  • Fixed “Path in error message has ..\..\..\..\..\ prefix since 0.19.0” (#9556)
  • Fixed ““contributing” is listed as a module on theindex” (#10287)
  • Fixed “[Regression] converter to string leads fail to compile on 0.19” (#9149)
  • Fixed “oids counter starts at zero; spec says it should be random” (#2796)

Nim in 2018: A short recap

There were several big news in the Nim world in 2018 – two new major releases, partnership with Status, and much more. But let us go chronologically.

FOSDEM 2018 participation

The first week of February is reserved for FOSDEM, where members of Nim core development team were promoting the newly published book Nim in Action, selling Nim T-shirts, and meeting with Nim developers.

Version 0.18

In March 2018, version 0.18 has been released. With more than 1300 commits since the previous version, it was the biggest release of Nim so far.

It introduced strformat module with fmt and & operators for formatted string literals, the ability to have testable documentation examples with runnableExamples, and numerous async improvements. The TLSF algorithm has been implemented to reduce memory fragmentation, which made alloc and dealloc O(1) operations.

Partnership with Status.im

In August the partnership with Status was announced.

The Status team has chosen the Nim programming language as a base for the implementation of a sharding client for Ethereum, named Nimbus. With this partnership Status will support the Nim team with funding and resources needed to stay focused on the development of the Nim programming language.

This allowed hiring two full-time developers, tasked with fixing bugs, responding to issues, and developing the compiler, the standard library and the tooling.

Version 0.19

Version 0.19, released in September, took the crown from 0.18 as the biggest release yet, with more than 1400 new commits.

The biggest change introduced is that the nil state for strings and sequences is gone – the default value for these are "" and @[] (an empty string, and an empty sequence, respectively). This eliminates a major confusion-point for beginners, and makes Nim more pleasant for everybody.

This version introduced experimental as a pragma and a command line switch that can enable specific language extensions (it is not an all-or-nothing switch, like before). Other notable additions include func as an alias for a procedure with no side effects, supporting except in the export statement, so called “for-loop macros”, async working with exception handling (now it is possible to use await in a try statement), and more.

Hacktoberfest

In October our community participated in Hacktoberfest, resulting in impressive 275 closed issues and 160 merged pull requests – more detailed documentation, improved tests, general cleanup, and much more. These improvements will be part of 0.20 release, and some of them are already backported to the latest bugfix release – 0.19.2.

Nim in 2019

If you’re interested in seeing and hearing what has been done in 2018 directly from the core developers, take a look at Nim Development Blog 2018 on Youtube.

We have switched to a different release model, with a stable branch (currently that’s v0.19.x) which receives bugfixes, it is aimed at daily usage, and Nimble package development should target this version; and a devel branch which will become a new major release – v0.20, and serve as a release candidate for v1.0.

In 2019, the Nim team will continue to work towards that goal, which will mark the end of breaking changes to Nim. We are focusing on the main areas shown in Nim community survey 2018 as needed before Nim v1.0:

  • better documentation
  • better standard library
  • stabilization
  • implementing destructors and move semantics for a more flexible concurrency model and reduced memory usage

Community help is, as always, welcome. Report issues and bugs, make pull requests, consider donating or becoming a sponsor.


Version 0.19.2 released

The Nim team is happy to announce that the latest release of Nim, version 0.19.2, is now available. Nim is a systems programming language that focuses on performance, portability and expressiveness.

This is mostly a bugfix release of version 0.19.0. It adds RISC-V support and there are no breaking changes. The most important bugfixes are:

  • spawn can handle the empty seqs/strings that are internally represented as nil.
  • The most pressing bugs of the documentation generator have been fixed.
  • async streaming of the httpclient has been fixed.

Installing 0.19.2

If you have installed a previous version of Nim using choosenim, getting Nim 0.19.2 is as easy as:

$ choosenim update stable

If you don’t have it already, you can get choosenim by following these instructions or you can install Nim by following the instructions on our install page.

Compiler changes

  • Added support for the RISC-V 64 bit architecture named riscv64 (e.g. HiFive)

Bugfixes

  • Fixed “Nim 0.19.0 docs have incorrect Source/Edit links” (#9083)
  • Fixed “Json: compilation fails with aliased type” (#9111)
  • Fixed “https://nim-lang.org/docs/nre.html gives 404 error” (#9119)
  • Fixed “Leaving \\ at the end of a path in copyDir removes every file’s first char” (#9126)
  • Fixed “nim doc SIGSEGV: Illegal storage access.” (#9140)
  • Fixed “[doc] List of broken links in the doc site” (#9109)
  • Fixed “Fix incorrect examples in nre docs” (#9053)
  • Fixed “Clean up root of repo and release archives” (#4934)
  • Fixed “Concept/converter/generics-related compiler crash” (#7351)
  • Fixed “converter + concept causes compiler to quit without error” (#6249)
  • Fixed “Error: internal error” (#6533)
  • Fixed “Methods break static[T] (internal error: nesting too deep)” (#5479)
  • Fixed “Memory error when checking if a variable is a string in concept” (#7092)
  • Fixed “Internal error when using array of procs” (#5015)
  • Fixed “[Regression] Compiler crash on proc with static, used to compile in nim 0.16” (#5868)
  • Fixed “fixes/8099” (#8451)
  • Fixed “distinct generic typeclass not treated as distinct” (#4435)
  • Fixed “multiple dynlib pragmas with function calls conflict with each other causing link time error” (#9222)
  • Fixed “\0 in comment replaced with 0 in docs” (#8841)
  • Fixed “Async readAll in httpclient produces garbled output.” (#8994)
  • Fixed “runnableExamples should be run by nim doc even if symbol is not public” (#9216)
  • Fixed “[regression] project config.nims not being read anymore” (#9264)
  • Fixed “Using iterator within another iterator fails” (#3819)
  • Fixed “nim js -o:dirname main.nim writes nothing, and no error shown” (#9154)
  • Fixed “devel docs in nim-lang.github.io Source links point to master instead of devel” (#9295)
  • Fixed “Regular Expressions: replacing empty patterns only works correctly in nre” (#9306)
  • Fixed “counting the empty substring in a string results in infinite loop” (#8919)
  • Fixed “[nimpretty] raw strings are transformed into normal strings” (#9236)
  • Fixed “[nimpretty] proc is transfered to incorrect code” (#8626)
  • Fixed “[nimpretty] Additional new line is added with each format” (#9144)
  • Fixed ““%NIM%/config/nim.cfg” is not being read” (#9244)
  • Fixed “Illegal capture on async proc (except when the argument is seq)” (#2361)
  • Fixed “Jsondoc0 doesn’t output module comments.” (#9364)
  • Fixed “NimPretty has troubles with source code filter” (#9384)
  • Fixed “tfragment_gc test is flaky on OSX” (#9421)

  • Fixed “ansi color code templates fail to bind symbols” (#9394)
  • Fixed “SIGSEGV when converting lines to closure iterator, most likely caused by defer” (#5321)
  • Fixed “Compiler crash when creating a variant type” (#6220)
  • Fixed “old changelogs should be kept instead of erased” (#9376)

  • Fixed “Crash when closing an unopened file on debian 8.” (#9456)
  • Fixed “nimpretty joins regular and doc comment” (#9400)
  • Fixed “nimpretty changes indentation level of trailing comment” (#9398)
  • Fixed “Some bugs with nimpretty” (#8078)
  • Fixed “nimpretty not idempotent: keeps adding newlines below block comment” (#9483)
  • Fixed “nimpretty shouldn’t format differently whether there’s a top-level newline” (#9484)
  • Fixed “nimpretty shouldn’t change file modif time if no changes => use os.updateFile” (#9499)
  • Fixed “nimpretty adds a space before type, ptr, ref, object in wrong places” (#9504)
  • Fixed “nimpretty badly indents block comment” (#9500)
  • Fixed “nimpretty wrongly adds empty newlines inside proc signature” (#9506)
  • Fixed “Duplicate definition in cpp codegen” (#6986)
  • Fixed “nim doc strutils.nim fails on 32 bit compiler with AssertionError on a RunnableExample” (#9525)
  • Fixed “using Selectors, Error: undeclared field: ‘OSErrorCode’” (#7667)

  • Fixed “strutils.multiReplace() crashes if search string is “”” (#9557)
  • Fixed “Type which followed by a function and generated by a template will not shown in docs generated by nim doc” (#9235)
  • Fixed “Module docs: 2 suggestions…” (#5525)
  • Fixed “Missing docstrings are replaced with other text” (#9169)
  • Fixed “templates expand doc comments as documentation of other procedures” (#9432)
  • Fixed “Path in error message has ..\..\..\..\..\ prefix since 0.19.0” (#9556)
  • Fixed “Nim/compiler/pathutils.nim(226, 12) canon"/foo/../bar" == "/bar" [AssertionError]” (#9507)

  • Fixed “[Regression] Borrow stringify operator no longer works as expected” (#9322)
  • Fixed “[NimScript] Error: arguments can only be given if the ‘–run’ option is selected” (#9246)
  • Fixed “nim check: internal error: (filename: "vmgen.nim", line: 1119, column: 19)” (#9609)
  • Fixed “optInd missing indent specification in grammar.txt” (#9608)
  • Fixed “nimpretty should hardcode indentation amount to 2 spaces” (#9502)
  • Fixed “Nimpretty adds instead of removes incorrect spacing inside backticks” (#9673)
  • Fixed “Compiler segfault (stack overflow) compiling code on 0.19.0 that works on 0.18.0” (#9694)

Advent of Nim

Saturday December 1st at 5 a.m. UTC will mark the start of the fourth incarnation of Advent of Code, popular programming contest started back in 2015. The author describes Advent of Code (AoC) as “a series of small programming puzzles for a variety of skill sets and skill levels in any programming language you like”.

The rules of AoC are quite simple. Starting from December 1st until Christmas, every day at 5 a.m. UTC a new task is released. The tasks consist of two parts, where second part is revealed after you solve the first part, and it is a continuation and/or variation of the first part. You don’t submit your code, just the result of your calculation.

The participation in AoC is free (although, if you like it, consider donating), all you need to do is log in with your Github, Google, Twitter, or Reddit account.

Nim leaderboard

We are organizing the official Nim private leaderboard, where you can compete against other Nim users. To join the Nim leaderboard, all you have to do is use 40415-c732e66e code in the previous link.

The Nim team has decided to reward the best (fastest) player on Nim leaderboard, as well as the solutions which best showcase the power and capabilities of Nim language. Post a link to your AoC repository in this forum thread and share the solutions you’re most proud of, and maybe you’ll be one of the winners of “Nim in Action” book, Nim T-shirt, or stickers.

People usually share their solutions on r/adventofcode subreddit and we encourage you to share your Nim solutions there too.

If you have never participated in AoC before or you want to prepare yourself for the start of the competition by solving some tasks, take a look at the previous events.


Nim Community Survey 2018 Results

We have recently closed the 2018 Nim Community Survey. I am happy to say that we have received exactly 771 responses, huge thanks to all the people that took the time to respond. We’re incredibly thankful for this very valuable feedback.

For the results of the previous year’s survey, take a look at the 2017 results analysis.

Our survey ran from the 23rd of June 2018 until the 31st of July 2018. The goal of this survey was primarily to determine how our community is using Nim, in order to better understand how we should be improving it. In particular, we wanted to know what people feel is missing from Nim in the lead up to version 1.0. We have also asked our respondents about how well the Nim tools worked, the challenges of adopting Nim, the resources that they used to learn Nim and more.

This article goes through some of the highlights in the results for the survey and discusses them in the context of the previous year’s results. The aim is to understand our users and to figure out priorities for Nim’s future.

This time around I have decided to publish the Google Survey results page, for some this may be more interesting than reading the highlights. It’s available here: https://i.imgur.com/g7slQ8w.png.

Changes since the last survey

The questions in this survey were largely the same as last year’s, but there were some key changes. In particular, the following questions were added:

  • How do you learn about the new functionality added to Nim?
  • Should Nim 1.0 have been released already?

The following questions were removed:

  • Which direction should Nim’s GC/memory management take?
  • What domain do you work in currently?
  • What domain do you use Nim in?

The following questions were modified:

  • “How did you install Nim?” was changed to “How did you most recently install Nim?”
  • What improvements are needed before Nim v1.0 can be released?
    • This question was streamlined into a single long form question.

The “What critical libraries are missing in the Nim ecosystem?” and “What development tools, if any, can make you more productive when working with Nim?” questions were merged into “What features, tools, or libraries would you like Nim to have?”

We wanted to gain deeper knowledge of our contributor’s experiences, so a brand new section titled “Contributor questions” was introduced.

Do you use Nim?

Do you use Nim?

Like last year the respondents were split up into three groups:

  • Current users of Nim
  • Ex-Nim users
  • Those that never used Nim

This enabled each group to be targeted with specific questions. For example, ex-Nim users were asked why they’ve stopped using Nim.

This year the proportion of responses from current Nim users has grown from 43% to 47%. This is a slight increase in the proportion of Nim users answering the survey, but it’s important to note that the absolute number went up by over 100 users from last year.

How could we help make Nim more accepted at your company?

This was a free-form question so there were many different answers, but a few answers were very common. By far the most common request was “version 1.0.”

Other honourable mentions include “more documentation”, “more stability” and “Free balloons”. These mostly align well with the general wishes of our community so you will see similar answers in later questions as well.

What editor(s) do you use when writing Nim?

Editors used by Nim users

Visual Studio Code continues its dominance and has become even more dominant since the last survey. 51% of respondents selected Visual Studio Code, whereas only 35.5% selected it last year.

What is your experience with the following tools?

This questions gives a good idea about how popular Nim tools are and whether using them is enjoyable.

The most popular tool, as one might expect, is Nimble. The Nimble package manager also boasts a high like rating, with over 75% of respondents answering either “Like” or “Extreme Like” for Nimble.

The most unpopular tool is nimpretty, with 75% of respondents answering that they haven’t used it.

The most disliked tool is nimsuggest, although it is only disliked by 6% of the respondents.

How did you most recently install Nim?

How did you most recently install Nim?

Choosenim takes the crown as the most popular installation method, but only just barely. Other installation methods are also very popular.

Top reasons why programmers stopped using Nim

The reasons given vary widely which makes their analysis challenging. In order to make it easier to see the reasons at a high level, I went through and grouped them into generic categories.

Why did you stop using Nim?

This offers some good insight into why programmers have stopped using Nim.

The number one reason is Nim’s relative lack of maturity, many respondents have quoted this as the reason why they have stopped using Nim. In most cases the respondents simply want 1.0 to be released. Together with maturity, multiple respondents also mentioned a general lack of libraries and Nim’s small ecosystem. These respondents were all counted under the “Maturity” category. The “Missing library” category mostly counts respondents who mentioned a specific library that was missing. This category could have easily been merged into the “Maturity” category but wasn’t for greater detail.

The second reason, categorised as “Not sufficiently better than other languages”, was mostly the respondent specifying that they are happy with another language, or that their project is more suited to another language.

Stability was the third reason. For this category, the respondents mostly talked about the stability of Nim as a whole. In many cases this meant tools such as IDEs not working properly rather than the compiler being buggy, although the latter was prevalent as well.

Top reasons why programmers are not using Nim

This is similar to the previous section, but it focuses on respondents who do not use Nim. As previously these vary widely so they have been put into categories.

Why aren't you using Nim?

Note that this is based on the long-form question which was asked in addition to the multiple choice question.

It seems that the number one reason why respondents are not using Nim is because they do not see the value in it. Many of the respondents didn’t see a reason why learning Nim was worthwhile. This is reflected in the number 1 category: “Not sufficiently better than other languages”.

Lack of time is of course a big factor too and in many cases it ties in with respondents not seeing value in learning Nim.

Nim’s relative immaturity was another strong theme among the responses.

An interesting number of respondents specified that they simply didn’t have a project, or couldn’t come up with a project to write in Nim. It may be worth exposing newcomers to some project ideas to alleviate this.

Do you feel well informed in the direction that the Nim project is heading?

Do you feel well informed in the direction that the Nim project is heading?

This question was asked last year to gauge how well we are informing users about where the Nim project is heading. In comparison to last year, the proportion of respondents answering “Yes” has increased to 25.8% from 23.5%. This is positive but we should do better, while it is an increase it is relatively minor. We should look into further ways to inform our community of our roadmap and other plans for the future.

Should Nim 1.0 have been released already?

Should Nim 1.0 have been released already?

This is a new question, it’s aim is to gauge the feeling in the community around whether a stable 1.0 release of Nim should have been made already.

Right now, the results are fairly even and thus it’s hard to know what to take away from them.

What improvements are needed before Nim v1.0 can be released?

What improvements are needed before Nim v1.0 can be released??

The chart above shows the general trends of what respondents felt was needed for Nim v1.0 to be released.

It was surprising to see so many respondents mentioning destructors, it seems that many people are excited about this feature and want it to be included in v1.0 of Nim.

The top three improvements though were, in order, “Better Docs”, “Stabilization” and finally “Better Stdlib”.

For the first one, respondents generally asked for more polished documentation but a significant portion of them also asked for video tutorials. Many felt that video tutorials were a good way to learn a programming language, we have already created some live streams where we coded Nim projects but it is obvious that we need to do more. In particular, we should:

  • Create more video tutorial material
  • Ensure that our video tutorials are accessible to all and easy to find
  • Improve the general written documentation, both in its presentation but also in the amount of content available

For the second one, respondents generally asked for a more reliable experience with all language features. A reduction of compiler crashes and surprising behaviour was among the top wishes.

Finally for the “Better Stdlib” responses, many of them asked for a cleanup of the standard library. In particular the removal of deprecated functions but also the migration of some modules to a separate repository available via the Nimble package manager.

Last words

Thank you to each and every one of you who took the time to answer this survey. Your time is precious and we are deeply thankful that you used it to share your feedback.

Please remember that you do not need to wait for a survey in order to give us feedback, of course you’re more than welcome to wait if you wish, but ideally share your feedback with us immediately. We can be found in various different places, see the community page for links and instructions on how to get in touch: https://nim-lang.org/community.html.

If there are any questions about this survey I’m more than happy to answer them. Feel free to reach out to me on the community channels linked above.

Thanks for reading, and have a good day!


Welcome our new team member, Arne Döring!

We are glad that Arne Döring joined us as a fulltime core Nim developer.

Hacktoberfest with Nim

Hacktoberfest is an annual event happening in October which celebrates open source software and encourages meaningful contributions to the open source ecosystem.

To win a T-shirt, you must sign up on the Hacktoberfest site and make five pull requests to any repo on Github by the end of October. Even if you don’t manage to make five pull requests, you win Hacktoberfest stickers.

Nim would like to encourage you to participate in Hacktoberfest by contributing to the Nim repo or any other Nim-related repos.

How can you help?

  • bug-fixing
  • improving documentation
  • writing a library

Bug fixing

Nim repo has more than 1400 open issues, which might be overwhelming to start. Here are some categories you might find interesting:

  • Why don’t you start with some of easy issues?
  • You can help with cleanup.
  • You don’t want to write code? Plenty of issues involve documentation.
  • Everybody uses stdlib. How about fixing one of the more than 200 issues in the stdlib?
  • You want to earn some money while fixing bugs? Here are the issues with a bounty.
  • What are our priorities? Take a look at high priority issues.

Improving documentation

Poor documentation is often mentioned when people discuss Nim. Let’s make it better together!

Based on this research, the most used modules are: strutils, os, tables, math, sequtils, macros, times, unittest and json – improving these would be beneficial to most people, but feel free to choose any other Nim module.

For example, in the tables module what is missing is:

  • a general example which shows a usage of OrderedTable and CountTable,
  • for each procedure, a short example which shows the results of applying it.

How to go about improving these?

Open the source file for tables module and you’ll see that the general documentation is at the top of the file, and to make an example, put it inside of a runnableExamples block like this, which will make sure the code snippet stays valid:

proc addBar*(a: string): string =
  ## Adds "Bar" to ``a``.
  runnableExamples:
    doAssert "baz".addBar == "bazBar"
   
   result = a & "Bar"

For embedded code block documentation you can also use .. code-block:::

proc foo*() =
  ## Beginning of comment.
  ##
  ## .. code-block::
  ##    :test:
  ##    foo()
  ##
  ## Rest of comment.
  raise newException(Exception, "boo!")

The best examples are self-contained and specific. This means they show how to do one thing. You should use headings to make them as easy to understand as possible, for example:

## Initialising an empty table
## ---------------------------
##
## An empty table can be created on the stack or on the heap.
##
## Stack allocated table
## ~~~~~~~~~~~~~~~~~~~~~
##
## .. code-block:: nim
##    :test:
##   import tables
##   var phonebook = initTable[string, string]()
##
## Heap allocated table
## ~~~~~~~~~~~~~~~~~~~~~
##
## .. code-block:: nim
##    :test:
##   import tables
##   var phonebook = newTable[string, string]()

If your example is more than 5 lines of code, then it’s likely too long. Consider separating it into multiple examples.

Nim’s documentation generator uses reStructuredText, take a look at some references if you want to get more familiar with it.

Writing a library

There is a list of needed libraries, can you help us shorten it?

Once you have written a library, you can send a PR to nimble package repo to include your package in the official list of packages!

If writing a library seems like a too demanding task, you can help improve one of the existing Nim packages by adding a feature, fixing a bug, or writing more informative documentation.

I want to help, but I’ve run into some problem

If you need any help, the Nim community is very welcoming. Ask a question in Nim’s IRC Channel on Freenode, Nim’s room on Gitter or the Nim Telegram group and somebody will help you. Other communication channels can be found on our community page.

Happy coding!


Version 0.19.0 released

The Nim team is happy to announce that the latest release of Nim, version 0.19.0, is now available. Nim is a systems programming language that focuses on performance, portability and expressiveness.

Installing 0.19.0

If you have installed a previous version of Nim using choosenim, getting Nim 0.19.0 is as easy as:

$ choosenim update stable

If you don’t have it already, you can get choosenim by following these instructions or you can install Nim by following the instructions on our install page.

What’s new in 0.19.0

The nil state for strings/seqs is gone. Instead the default value for these is "" / @[]. Use --nilseqs:on for a transition period. This eliminates a large class of bugs that used to plague the average Nim code out there, including Nim’s standard library.

Accessing the binary zero terminator in Nim’s native strings is now invalid. Internally a Nim string still has the trailing zero for zero-copy interoperability with cstring. Compile your code with the new switch --laxStrings:on if you need a transition period.

These changes to strings and seqs give us more flexibility in how they are implemented and indeed alternative implementations are in development.

experimental is now a pragma and a command line switch that can enable specific language extensions, it is not an all-or-nothing switch anymore. We think this leads to a more robust development process where it’s clearly documented which parts of Nim are bleeding edge and which parts can be relied upon.

Other notable language additions:

  • Dot calls combined with explicit generic instantiations can now be written as x.y[:z] which is transformed into y[z](x) by the parser.
  • func is now an alias for proc {.noSideEffect.}.
  • Anonymous tuples with a single element can now be written as (1,) with a trailing comma.

  • In order to make for loops and iterators more flexible to use Nim now supports so called “for-loop macros”. See the manual for more details. This feature enables a Python-like generic enumerate implementation.

  • Case statements can now be rewritten via macros. See the manual for more information. This feature enables custom pattern matching.

  • The command syntax now supports keyword arguments after the first comma.

  • Thread-local variables can now be declared inside procs. This implies all the effects of the global pragma.

  • Nim now supports the except clause in the export statement.

  • Range float types, example range[0.0 .. Inf]. More details in language manual.

Breaking changes to be mindful of

  • The default location of nimcache for the native code targets was changed. Read the compiler user guide for more information.
  • Lots of deprecated symbols in the standard library that have been deprecated for quite some time now like system.expr or the old type aliases starting with a T or P prefix have been removed.
  • The exception hierarchy was slightly reworked, SystemError was renamed to CatchableError and is the new base class for any exception that is guaranteed to be catchable. This change should have minimal impact on most existing Nim code.

Async improvements

The “closure iterators” that Nim’s async macro is based on has been rewritten from the ground up and so async works completely with exception handling. Finally it is possible to use await in a try statement!

Nimble 0.9.0

This release includes a brand new version of Nimble. The new version contains a breaking change which you should read up on if you own hybrid packages. There are also the usual bug fixes and this release contains a lot of them.

For more information, see the Nimble v0.9.0 changelog.

Contributors to v0.19.0

Our contributors are amazing, and there is far too many to list here. Big thanks to all of you, we couldn’t have pulled off this release without you!

Changelog

Changes affecting backwards compatibility

Breaking changes in the standard library

  • re.split for empty regular expressions now yields every character in the string which is what other programming languages chose to do.
  • The returned tuple of system.instantiationInfo now has a third field containing the column of the instantiation.

  • cookies.setCookie no longer assumes UTC for the expiration date.
  • strutils.formatEng does not distinguish between nil and "" strings anymore for its unit parameter. Instead the space is controlled by a new parameter useUnitSpace.

  • The times.parse and times.format procs have been rewritten. The proc signatures are the same so it should generally not break anything. However, the new implementation is a bit stricter, which is a breaking change. For example parse("2017-01-01 foo", "yyyy-MM-dd") will now raise an error.

  • proc `-`*(a, b: Time): int64 in the times module has changed return type to times.Duration in order to support higher time resolutions. The proc is no longer deprecated.

  • The times.Timezone is now an immutable ref-type that must be initialized with an explicit constructor (newTimezone).

  • posix.Timeval.tv_sec has changed type to posix.Time.

  • math.`mod` for floats now behaves the same as mod for integers (previously it used floor division like Python). Use math.floorMod for the old behavior.

  • For string inputs, unicode.isUpper and unicode.isLower now require a second mandatory parameter skipNonAlpha.

  • For string inputs, strutils.isUpperAscii and strutils.isLowerAscii now require a second mandatory parameter skipNonAlpha.

  • osLastError is now marked with sideEffect
  • The procs parseHexInt and parseOctInt now fail on empty strings and strings containing only valid prefixes, e.g. “0x” for hex integers.

  • terminal.setCursorPos and terminal.setCursorXPos now work correctly with 0-based coordinates on POSIX (previously, you needed to use 1-based coordinates on POSIX for correct behaviour; the Windows behaviour was always correct).

  • lineInfoObj now returns absolute path instead of project path. It’s used by lineInfo, check, expect, require, etc.

  • net.sendTo no longer returns an int and now raises an OSError.
  • threadpool’s await and derivatives have been renamed to blockUntil to avoid confusions with await from the async macro.

Library additions

  • re.split now also supports the maxsplit parameter for consistency with strutils.split.
  • Added system.toOpenArray in order to support zero-copy slicing operations. This is currently not yet available for the JavaScript target.
  • Added getCurrentDir, findExe, cpDir and mvDir procs to nimscript.
  • The times module now supports up to nanosecond time resolution when available.
  • Added the type times.Duration for representing fixed durations of time.
  • Added the proc times.convert for converting between different time units, e.g days to seconds.
  • Added the proc algorithm.binarySearch[T, K] with the cmp parameter.
  • Added the proc algorithm.upperBound.
  • Added inverse hyperbolic functions, math.arcsinh, math.arccosh and math.arctanh procs.
  • Added cotangent, secant and cosecant procs math.cot, math.sec and math.csc; and their hyperbolic, inverse and inverse hyperbolic functions, math.coth, math.sech, math.csch, math.arccot, math.arcsec, math.arccsc, math.arccoth, math.arcsech and math.arccsch procs.
  • Added the procs math.floorMod and math.floorDiv for floor based integer division.
  • Added the procs rationals.`div, rationals.mod```, rationals.floorDiv and rationals.floorMod for rationals.
  • Added the proc math.prod for product of elements in an openArray.
  • Added the proc parseBinInt to parse a binary integer from a string, which returns the value.
  • parseOct and parseBin in parseutils now also support the maxLen argument similar to parseHexInt.
  • Added the proc flush for memory mapped files.
  • Added the MemMapFileStream.
  • Added a simple interpreting event parser template eventParser to the pegs module.
  • Added macros.copyLineInfo to copy lineInfo from other node.
  • Added system.ashr an arithmetic right shift for integers.

Library changes

  • The stdlib module future has been renamed to sugar.
  • macros.callsite is now deprecated. Since the introduction of varargs parameters this became unnecessary.

  • macros.astGenRepr, macros.lispRepr and macros.treeRepr now escapes the content of string literals consistently.
  • macros.NimSym and macros.NimIdent is now deprecated in favor of the more general NimNode.
  • macros.getImpl now includes the pragmas of types, instead of omitting them.
  • macros.hasCustomPragma and macros.getCustomPragmaVal now also support ref and ptr types, pragmas on types and variant fields.
  • system.SomeReal is now called SomeFloat for consistency and correctness.
  • algorithm.smartBinarySearch and algorithm.binarySearch is now joined in binarySearch. smartbinarySearch is now deprecated.
  • The terminal module now exports additional procs for generating ANSI color codes as strings.
  • Added the parameter val for the CritBitTree[int].inc proc.
  • An exception raised from a test block of unittest now shows its type in error message.
  • The compiler/nimeval API was rewritten to simplify the “compiler as an API”. Using the Nim compiler and its VM as a scripting engine has never been easier. See tests/compilerapi/tcompilerapi.nim for an example of how to use the Nim VM in a native Nim application.
  • Added the parameter val for the CritBitTree[T].incl proc.
  • The proc tgamma was renamed to gamma. tgamma is deprecated.
  • The pegs module now exports getters for the fields of its Peg and NonTerminal object types. Pegs with child nodes now have the standard items and pairs iterators.
  • The accept socket procedure defined in the net module can now accept a nil socket.

Language additions

  • Dot calls combined with explicit generic instantiations can now be written as x.y[:z] which is transformed into y[z](x) by the parser.
  • func is now an alias for proc {.noSideEffect.}.
  • In order to make for loops and iterators more flexible to use Nim now supports so called “for-loop macros”. See the manual for more details. This feature enables a Python-like generic enumerate implementation.

  • Case statements can now be rewritten via macros. See the manual for more information. This feature enables custom pattern matchers.

  • the typedesc special type has been renamed to just type.
  • static and type are now also modifiers similar to ref and ptr. They denote the special types static[T] and type[T].
  • Forcing compile-time evaluation with static now supports specifying the desired target type (as a concrete type or as a type class)
  • The type operator now supports checking that the supplied expression matches an expected type constraint.

Language changes

  • Anonymous tuples with a single element can now be written as (1,) with a trailing comma. The underlying AST is nnkTupleConstr(newLit 1) for this example. nnkTupleConstr is a new node kind your macros need to be able to deal with!
  • Indexing into a cstring for the JS target is now mapped to charCodeAt.
  • Assignments that would “slice” an object into its supertype are now prevented at runtime. Use ref object with inheritance rather than object with inheritance to prevent this issue.
  • The not nil type annotation now has to be enabled explicitly via {.experimental: "notnil"} as we are still not pleased with how this feature works with Nim’s containers.
  • The parser now warns about inconsistent spacing around binary operators as these can easily be confused with unary operators. This warning will likely become an error in the future.
  • The 'c and 'C' suffix for octal literals is now deprecated to bring the language in line with the standard library (e.g. parseOct).
  • The dot style for import paths (e.g import path.to.module instead of import path/to/module) has been deprecated.

  • The importcpp pragma now allows importing the listed fields of generic C++ types. Support for numeric parameters have also been added through the use of static[T] types. (#6415)

  • Native C++ exceptions can now be imported with importcpp pragma. Imported exceptions can be raised and caught just like Nim exceptions. More details in language manual.

  • nil for strings/seqs is finally gone. Instead the default value for these is "" / @[]. Use --nilseqs:on for a transition period.

  • Accessing the binary zero terminator in Nim’s native strings is now invalid. Internally a Nim string still has the trailing zero for zero-copy interoperability with cstring. Compile your code with the new switch --laxStrings:on if you need a transition period.

  • The command syntax now supports keyword arguments after the first comma.

  • Thread-local variables can now be declared inside procs. This implies all the effects of the global pragma.

  • Nim now supports the except clause in the export statement.

  • Range checked floating point types, for example range[0.0 .. Inf], are now supported.
  • The {.this.} pragma has been deprecated. It never worked within generics and we found the resulting code harder to read than the more explicit obj.field syntax.
  • “Memory regions” for pointer types have been deprecated, they were hardly used anywhere. Note that this has nothing to do with the --gc:regions switch of managing memory.

  • The exception hierarchy was slightly reworked, SystemError was renamed to CatchableError and is the new base class for any exception that is guaranteed to be catchable. This change should have minimal impact on most existing Nim code.

Tool changes

  • jsondoc2 has been renamed jsondoc, similar to how doc2 was renamed doc. The old jsondoc can still be invoked with jsondoc0.

Compiler changes

  • The undocumented #? braces parsing mode was removed.
  • The undocumented PHP backend was removed.

  • The VM’s instruction count limit was raised to 3 million instructions in order to support more complex computations at compile-time.

  • Support for hot code reloading has been implemented for the JavaScript target. To use it, compile your code with --hotCodeReloading:on and use a helper library such as LiveReload or BrowserSync.

  • A new compiler option --cppCompileToNamespace puts the generated C++ code into the namespace “Nim” in order to avoid naming conflicts with existing C++ code. This is done for all Nim code - internal and exported.

  • Added macros.getProjectPath and ospaths.putEnv procs to Nim’s virtual machine.

  • The deadCodeElim option is now always turned on and the switch has no effect anymore, but is recognized for backwards compatibility.

  • experimental is now a pragma / command line switch that can enable specific language extensions, it is not an all-or-nothing switch anymore.

  • Nintendo Switch was added as a new platform target. See the compiler user guide for more info.

  • macros.bindSym now capable to accepts not only literal string or string constant expression. bindSym enhancement make it also can accepts computed string or ident node inside macros / compile time functions / static blocks. Only in templates / regular code it retains it’s old behavior. This new feature can be accessed via {.experimental: “dynamicBindSym”.} pragma/switch.

  • On Posix systems the global system wide configuration is now put under /etc/nim/nim.cfg, it used to be /etc/nim.cfg. Usually it does not exist, however.

  • On Posix systems the user configuration is now looked under $XDG_CONFIG_HOME/nim/nim.cfg (if XDG_CONFIG_HOME is not defined, then under ~/.config/nim/nim.cfg). It used to be $XDG_CONFIG_DIR/nim.cfg (and ~/.config/nim.cfg).

    Similarly, on Windows, the user configuration is now looked under %APPDATA%/nim/nim.cfg. This used to be %APPDATA%/nim.cfg.

Bugfixes

  • Fixed “constructor pragma leads to “Most Vexing Parse” in c++ code gen” (#6837)

  • Fixed “[RFC] newFileStream(string, FileMode) returns nil” (#5588)
  • Fixed “Search feature doesn’t work on all docs pages “ (#7294)
  • Fixed “Wrong comparison with empty string in version 0.18” (#7291)
  • Fixed “doc2 css troubles” (#5293)
  • Fixed “SIGSEGV when passing empty array to strutils format” (#7293)
  • Fixed “strip() weird behavior “ (#7159)
  • Fixed “On Windows: When app type is GUI, error message can’t be seen, about missing DLL file or procedure” (#7212)
  • Fixed “Compiler crash: multiple exception types with infix as” (#7115)
  • Fixed “C++ template object: Internal Error mangleRecFieldName” (#6415)
  • Fixed “Undefined Behavior when using const/let tables (Nim v0.18.1)” (#7332)
  • Fixed “Codegen: forward type declarations can be used more aggressively” (#7339)
  • Fixed “asyncfile getFileSize issue in linux” (#7347)
  • Fixed “Compiler manual is not that clear about int literal” (#7304)
  • Fixed “Bad error message when writing to a data structure within read-only object” (#7335)
  • Fixed “Compiler crash using @[int]” (#7331)
  • Fixed “Redefinition of object in C when a proc with sink param is defined.” (#7364)
  • Fixed “[Regression] Missing type declarations in C code if members are used in {.emit.}” (#7363)
  • Fixed “(regression) dereferencing pointer to incomplete type” (#7392)
  • Fixed “In nested try statements finally is not executed” (#7414)
  • Fixed “json.to doesn’t work when Option[T] is inside an array” (#7433)
  • Fixed “https://nim-lang.org/docs/lib.html => If you are reading this you are missing nimblepkglist.js…” (#7400)
  • Fixed “json.to and Option[T] fails on JNull in JSON list literal” (#6902)
  • Fixed “inconsistent escaping of string literals” (#7473)
  • Fixed “streams.readLine(): string should raise IOError, but doesn’t” (#5281)

  • Fixed “Duplicate definition in cpp codegen” (#6986)
  • Fixed “error at compile-time when case branch has implicit return” (#7407)
  • Fixed “Still some issues with Static[T]” (#6843)
  • Fixed “[regression] compiler/nimeval execute("echo 1") => Error: cannot ‘importc’ variable at compile time” (#7522)
  • Fixed “Too many digits from float32 to string” (#7252)
  • Fixed “SIGSEGV: Illegal storage access. (Attempt to read from nil?)” (#7528)
  • Fixed “Catching C++ exceptions in Nim” (#3571)
  • Fixed “[RFC] Naming convention for in-place mutating procs” (#7551)
  • Fixed “Compiler SIGSEGV when trying to use invalid subrange type” (#6895)
  • Fixed “Internal error: invalid kind for first(tyTuple) with parallel block” (#2779)
  • Fixed “type checking issue when using an empty sequence embedded in a table” (#3948)
  • Fixed “Deprecate callsite builtin” (#7369)
  • Fixed “JS codegen - indexing into cstring.” (#4470)

  • Fixed “strutils.formatEng relies on a distinction of “” and nil string” (#6205)
  • Fixed “timeToTimeInfo issue” (#3678)
  • Fixed “checking object type for a pragma is not possible” (#7451)
  • Fixed “nnkBracketExpr.newTree now returns tuple of NimNodes breaking newTree chaining” (#7610)

  • Fixed ““newNilLitNode” printed when some objects’ AST is dumped shold be “newNilLit”” (#7595)

  • Fixed “string.replace() should throw an error when used with an empty string” (#7507)
  • Fixed “Threadpool awaitAny() problem on macOS” (#7638)
  • Fixed “TLineInfo on windows 32bit” (#7654)
  • Fixed “Object slicing can bite our arses” (#7637)
  • Fixed “A warning for unused but conflicting procs would be nice” (#6393)
  • Fixed “Using var return types will result in segfaults in some cases” (#5113)
  • Fixed “Borrowing for var T and lent T to improve Nim’s memory safety” (#7373)
  • Fixed “Documentation/implementation mismatch for –genScript flag” (#802)
  • Fixed “httpclient.generateHeaders() not setting Content-Length if body.len=0” (#7680)
  • Fixed “generic object descended from generic ref object sigmatch bug” (#7600)
  • Fixed “array construction of ptr generic object with subtype relation failed” (#7601)
  • Fixed “ambiguously typed/tuple combination with auto result type leads to a compile-time crash with SIGSEGV” (#7663)
  • Fixed “nim –linedir:on c file segfaults” (#7730)
  • Fixed “Better compiler warning/error messages” (#7749)

  • Fixed “Issues with finish.exe” (#7747)

  • Fixed “changed “encodeUrl” in lib/pure/uri.nim.” (#7700)
  • Fixed “Unexpected import required” (#7738)
  • Fixed “Strange interaction of add for string without explicit initialization” (#7766)
  • Fixed “Command invocation syntax doesn’t work with unary operators” (#7582)
  • Fixed “Command invocation syntax doesn’t work with unary operators” (#7582)
  • Fixed “3x performance regression” (#7743)
  • Fixed “seq is still nil in compile time” (#7774)
  • Fixed “Compiler segfault on sink proc for type with destructor under special condition” (#7757)
  • Fixed “Windows getch() does not correctly account for control keys” (#7764)
  • Fixed “thread local variable threadvar not working as expected (differs from C++ thread_local and D static)” (#7565)
  • Fixed “Setting a timeout causes assertion failures in httpclient” (#2753)
  • Fixed “Can’t convert expression when surrounded with parens using %*” (#7817)
  • Fixed “Line number missing in stdlib trace” (#6832)
  • Fixed “Filter skips lines with only single character” (#7855)
  • Fixed “[regression] nimscript.task crash the compiler” (#7696)
  • Fixed “IndexError in streams.readStr()” (#7877)
  • Fixed “IndexError in streams.readStr()” (#7877)
  • Fixed “generic “Error: cannot instantiate: ‘T’” with overload(regression)” (#7883)
  • Fixed “marshal.store generates invalid JSON” (#7881)
  • Fixed “inconsistent internal representation of generic objects array construction” (#7818)
  • Fixed “There’s no $ for openArray” (#7940)
  • Fixed “array and openarray arg vs. ptr/ref generic polymorphic issue” (#7906)
  • Fixed “Yield in try generate stack error “ (#7969)
  • Fixed “Bad codegen (runtime crash) when catching exceptions in a proc with no stack trace” (#7982)
  • Fixed “$ doesn’t work for CritBitTree[void]” (#7987)
  • Fixed “Assertion at runtime with await and json.to()” (#7985)
  • Fixed “[critbits[int]] When using inc to add new keys, only the first added key gets the value 1” (#7990)
  • Fixed “Error: obsolete usage of ‘defined’, use ‘declared’ instead” (#7997)

  • Fixed “C++ codegen: importcpp breaks for generic types.” (#7653)
  • Fixed “Bad line info in async code” (#6803)
  • Fixed “tmacrostmt immediate pragma cannot be removed” (#5930)
  • Fixed “parseBinInt” (#8018)
  • Fixed “RFC: Import Module Namespaces” (#7250)
  • Fixed “All symbols in concepts should be open by default” (#7222)
  • Fixed “static[T] issue with default arguments” (#6928)
  • Fixed “Compiler crash when casting a proc with asm statement to a pointer” (#8076)
  • Fixed “[regression]: nim doc produces <.html> instead of " ([#8097](https://github.com/nim-lang/Nim/issues/8097))

  • Fixed “[Regression] times.format interferes with strformat” (#8100)
  • Fixed “Regression: SIGSEGV caused by using is with string” (#8129)
  • Fixed “uninitialized procs variables are not nil at compile time” (#6689)
  • Fixed “unixToNativePath cause IndexError with Empty string or “.”” (#8173)

  • Fixed “Octal int literal behavior differs from parseOct - change parseOct?” (#8082)

  • Fixed “[travis] flaky test: “No output has been received” caused by no prompt on “already exists. Overwrite?” after nimble install” (#8227)

  • Fixed “noSideEffect in os module” (#5880)
  • Fixed “missing ospaths.absolutePath function to get absolute path from a path” (#8174)
  • Fixed “Render bug with prefix and implicit string/cstring conversion” (#8287)

  • Fixed “ospaths.isAbsolute: uncovering out of bound bugs after updating to 0.18.1 from 0.18.0: empty string and nil string now checked for out of bound errors” (#8251)
  • Fixed “Error: cannot 'importc' variable at compile time shows wrong context” (#7405)
  • Fixed “[regression] [times.format] Error: attempting to call undeclared routine: ‘format’” (#8273)
  • Fixed “htmlparser.untilElementEnd is not GC-safe” (#8338)
  • Fixed “nim check internal error” (#8230)
  • Fixed “nim doc fails when source file contains doAssertRaises in isMainModule” (#8223)
  • Fixed “Windows: can’t compile with var name “far”” (#8345)
  • Fixed “Render bug: procs with single if statement get incorrent indentation” (#8343)
  • Fixed “json.nim macro to does not support objects with distinct types” (#8037)
  • Fixed “macros.hasCustomPragma() crashes when working with variant fields” (#8371)
  • Fixed “await inside stmtListExpr inside a case stmt crashes compiler” (#8399)

  • Fixed “[os] failed operations (eg existsOrCreateDir) should show runtime context (eg file/dir) it failed for” (#8391)

  • Fixed “[ospaths] ospaths.nim says OSX is FileSystemCaseSensitive:true but should be false ; cmpPaths seems wrong” (#8349)
  • Fixed “excessiveStackTrace:on shows non-absolute file in stacktrace” (#7492)

  • Fixed “nim doc foo generates stuff that should be under a .gitignore’d directory” (#8323)
  • Fixed “type mismatch shows wrong type for union types T1|T2|T3|T4: only keeps T1 or T2, discards rest” (#8434)
  • Fixed “devel branch encodings.convert broken on Windows” (#8468)
  • Fixed “–app:gui gives an error on osx.” (#2576)
  • Fixed “non ordinal enums are not allowed in set constructor” (#8425)
  • Fixed “[nimweb] ./koch web -o:/tmp/d13/ => o is actually unused and docs output dir hardcoded regardless of o” (#8419)
  • Fixed “seq/string initialized with add or setLen being deallocated” (#7833)
  • Fixed “alloc fails after 4GB” (#7894)
  • Fixed “[feature request] macros.bindSym can accept computed string” (#7827)
  • Fixed “tfragment_alloc.nim (which allocates 4GB) often makes appveyor fail with out of memory” (#8509)
  • Fixed “echo not thread safe on windows, causing [appveyor] flaky test: Failure: reOutputsDiffer in tforstmt.nim” (#8511)
  • Fixed “./koch xz doesn’t check for dirty work tree” (#7292)
  • Fixed “non ordinal enums are not allowed in set constructor” (#8425)
  • Fixed “bad example in https://nim-lang.org/docs/docgen.html” (#8215)
  • Fixed “Ability to set a NimNode’s lineinfo” (#5617)
  • Fixed “winlean.nim has wrong definition for moveFileExA” (#8421)
  • Fixed “shr operator should keep the sign bit on signed types.” (#6255)
  • Fixed “proposal (with implementation): undistinct(T)” (#8519)
  • Fixed “.cache/projectname pollutes .cache - put in .cache/Nim/projectname instead” (#8599)

  • Fixed “Iterating closure iterator in nested function is empty” (#8550)
  • Fixed “[TODO] [feature] Nim error messages should show line contents, would save lots of debugging time” (#7586)
  • Fixed “Converter: {lit} parameter constraint is not respected in implicit conversion” (#7520)
  • Fixed “mapIt still can’t be used with openArray even after #8543, #8567: fails during bootstrap” (#8577)
  • Fixed “Config should be in its own directory” (#8653)
  • Fixed “sequtils.toSeq produces the sequence from the iterator twice if compiles(iter.len) == true” (#7187)
  • Fixed “$ for Option[string] types should double-quote the output” (#8658)

  • Fixed “Config should be in its own directory” (#8653)
  • Fixed “[feature request] compile time check for experimental features” (#8644)
  • Fixed “Changes in typedesc reforms” (#8126)
  • Fixed “json.% regression” (#8716)
  • Fixed “nim doc2 --project -o:doc/ cannot find files in subdirectories” (#8218)
  • Fixed “onFailedAssert does not affect doAssert” (#8719)

  • Fixed “[travis] [async] flaky test: tests/async/t7758.nim” (#8756)
  • Fixed “float literals are treated differently between manual and compiler” (#8766)
  • Fixed “[cmdline] [minor] --hint.foo:on as alias for --hint[foo]:on: avoids edge cases with [ that needs to be escaped on cmd line + other places” (#8739)

  • Fixed “Duplicate member error for union types” (#8781)
  • Fixed “nim c compiler/nimblecmd.nim fails: Error: type mismatch: got <StringTableRef, string>” (#8776)
  • Fixed “Compiler crash with $, converter and generics” (#4766)
  • Fixed “[unidecode] Fix the unidecode example” (#8768)
  • Fixed “[unidecode] Make loadUnidecodeTable use the path to unicode.dat on user’s system by default” (#8767)
  • Fixed “marshal.load() regression?” (#7854)
  • Fixed “[unidecode] Fix the unidecode example” (#8768)
  • Fixed “Converter applied when it should not be” (#8049)
  • Fixed “Pure enums allow using the same name but allow nonqualification with quirky behaviour” (#8066)

  • Fixed “Correctly redirect stderr when using osproc’s posix_spawn backend” (#8624)
  • Fixed “errorStream doesn’t seem to work” (#8442)
  • Fixed “Nested template: SIGSEGV at compile-time” (#8052)
  • Fixed “Error: undeclared identifier: '|' when using | inside a runnableExamples:” (#8694)
  • Fixed “runnableExamples doesn’t work at module level” (#8641)
  • Fixed “[runnableExamples] Hint: operation successful: runnableExamples even though operation failed: compile error is ignored” (#8831)
  • Fixed “runnableExamples don’t have own scope for imports” (#7285)
  • Fixed “nim check segfaults” (#8028)
  • Fixed “addQuoted gives unquoted result on cstring (works on string)” (#8847)
  • Fixed “[nimscript] exception handling broken: except BaseClass doesn’t work” (#8740)
  • Fixed “Unary . operator can’t be parsed” (#8797)
  • Fixed “system.on_raise works only for “single level”” (#1652)
  • Fixed “Final facelifiting nimrod -> nim” (#2032)
  • Fixed “marshal: document usage of “to”” (#3150)
  • Fixed “Name conflict between template and proc parameter” (#4750)
  • Fixed “Operator overloading bug with unittest check macro” (#5252)
  • Fixed “nim check crash due to typo” (#5745)
  • Fixed “Regression (?): ICE in transformImportAs” (#8852)
  • Fixed “generic match error” (#1156)
  • Fixed “Adding a mention of the unsafeAddr operator to the Nim manual” (#5038)
  • Fixed “using types should have higher precedence” (#8565)
  • Fixed “Add noSignalHandler documentation and examples” (#8224)
  • Fixed “-d:identifier is case insensitive (not partially case insensitive)” (#7506)
  • Fixed “addQuitProc argument requires {.noconv.} not documented” (#5794)
  • Fixed “Compilation error does not point to the actual wrong parameter” (#8043)
  • Fixed “Clean up examples” (#7725)
  • Fixed “Documentation footer timestamp is not UTC” (#7305)
  • Fixed “Regression: compiler stack overflow in transformIteratorBody/lowerStmtListExprs” (#8851)
  • Fixed “The writeStackTrace proc listed twice in docs” (#3655)
  • Fixed “Error: unhandled exception: n.kind == nkStmtListExpr [AssertionError]” (#8243)
  • Fixed “The writeStackTrace proc listed twice in docs” (#3655)
  • Fixed “Regression: stack trace line numbers are messed up for asserts” (#8928)

  • Fixed “Regression bug in lines()” (#8961)
  • Fixed “Core dump for RTree module – regression” (#8883)

  • Fixed “system.cmp returns different results for string on different operating systems” (#8930)
  • Fixed “scanf Invalid node kind nnkBracketExpr for macros.$” (#8925)

  • Fixed “Regression bug in lines()” (#8961)
  • Fixed “Typetraits arity: off-by-one for arrays” (#8965)
  • Fixed “strutils.nim(1533, 29) Error: illegal conversion from '-1' to '[0..9223372036854775807]' with strutils.replace on empty string at CT” (#8911)
  • Fixed “Iterators in combination with closures misbehave” (#3837)
  • Fixed “procCall is not documented” (#4329)
  • Fixed “scanf Invalid node kind nnkBracketExpr for macros.$” (#8925)
  • Fixed “Add exports section to documentation generator” (#1616)
  • Fixed “Improve error message for redefinitions” (#447)
  • Fixed “[minor] operator symbols in anchor text disappear, causing anchor clashes” (#7500)

  • Fixed “Incorrect executable name of the C compiler when performing crosscompilation” (#8081)
  • Fixed “[ICE/regression] when proc with var return type interacting with method” (#9076)

We're hiring!

This is your chance to get to work with one of the leading experts in compiler development, meta programming and language design.

Nim partners with Status.im

We're incredibly excited to announce the new partnership between Status and Nim.

Launching the 2018 Nim Community Survey

We are proud to announce the launch of the official 2018 Nim Community Survey! No matter whether you use Nim today, have used Nim previously, or never used Nim before; we want to know your opinions. Your feedback will help the Nim project understand its strengths and weaknesses, and to determine development priorities for the future.

Answer Survey

It shouldn’t take you much longer than 5 to 10 minutes to complete this survey. Submissions will be accepted until around the 23rd of July, depending on the response rates. If you have any questions or feedback, please don’t hesitate to get in touch with us via email at [email protected] or on the Nim Forum.

This is now the third year in which this survey has been running. An analysis of the results for the past years can be found at the following links:

We would appreciate your help in spreading the word about this survey. Share the Google Forms link on your social network feeds, with your colleagues and in other communities.

Thank you to everyone that helped develop and test the survey! Once the submission period ends, the results will be shown here and publicised via Twitter, the Nim Forum and IRC.

Thanks for your time!


Creating a simple macro

Nim is a powerful programming language that supports metaprogramming using macros. Though a lot of Nim programmers are unaware of their merits due to lack of learning resources. The first part of this series will discuss the use of macros to simplify the creation of boilerplate code in Nim.

Version 0.18.0 released

The Nim team is happy to announce that the latest release of Nim, version 0.18.0, is now available. Nim is a systems programming language that focuses on performance, portability and expressiveness.

Installing 0.18.0

If you have installed a previous version of Nim using choosenim, getting Nim 0.18.0 is as easy as:

$ choosenim update stable

If you don’t have it already, you can get choosenim by following these instructions or you can install Nim manually by following the instructions on our install page. Note that Windows users might still have an easier time with the unzip+finish.exe method of installing Nim which is described on the install page.

What’s new in 0.18.0

It’s been a while since our last release, but we’ve been busy. At over 1000 commits since the last release, v0.18.0 is one of (if not the) biggest releases of Nim ever.

We have mentioned multiple times that this will be a major release. Primarily because our goal has been to clean up the standard library significantly in preparation for v1.0. We’ve made massive progress in this release to achieve that goal. The downside is that this release has a much larger proportion of breaking changes than normal releases, but it is all in the spirit of a cleaner Nim v1.0.

Breaking changes to be mindful of

You will find that the [] indexing operator which takes a slice now raises an IndexError exception when it is out of bounds. Previously it would have simply returned the part of the string that was captured. You may find that your program hasn’t taken this into account and will now crash with an IndexError exception. To get back the previous behaviour, use the substr procedure. Here is an example of the issue and how to get around it:

var myString = "hello world"
doAssertRaises IndexError:
  discard myString[6 .. 45]
doAssert myString.substr(6, 45) == "world"

The $ operator now handles collections differently. For example:

doAssert $(@["23", "12"]) == "@[\"23\", \"12\"]"

# Whereas in 0.17.2:
doAssert $(@["23", "12"]) == "@[23, 12]"

An array[x, char] can no longer be converted to a cstring type. This has the side-effect of allowing $ to be defined on an array:

var x: array[5, char]

doAssert $x == r"['\x00', '\x00', '\x00', '\x00', '\x00']"

Be sure to check out the changelog below for a comprehensive list of breaking changes. If you run into any strange regressions feel free to pop into IRC, Gitter, Discord or any of the other chat rooms/forums we have available. Links to them all are available in our community page.

New features

Of course, this being a major new release, there are also plenty of new features.

Formatted string literals

The greatest new addition is the strformat module. It implements string formatting that is very similar to Python 3’s f-strings.

Formatted string literals are prefixed with fmt or the & operator:

import strformat

let name = "Fred"
let age = 24
let weight = 94.52

doAssert fmt"My name is {name}. I'm {age} years of age and weigh {weight:.3f}." ==
            "My name is Fred. I'm 24 years of age and weigh 94.520."

For more information, take a look at the strformat documentation.

Testable documentation examples

The documentation generator can now test your examples for you! This is done using the new runnableExamples macro.

proc add*(x, y: int): int =
  ## Adds two numbers together.
  ##
  ## Examples:
  ##
  runnableExamples:
    doAssert add(5, 5) == 10
    doAssert add(-5, 2) == -3

  x + y

If you save this as addLib.nim and then generate its documentation via nim doc addLib.nim, you should see something like this:

Hint: /tmp/addLib_examples  [Exec]
Hint: operation successful (13129 lines compiled; 0.492 sec total; 19.742MiB peakmem; Debug Build) [SuccessX]

The code under runnableExamples 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. This is great for ensuring that your documentation is up-to-date.

mapLiterals

This is a new macro that allows you to easily create array and sequence literals.

import sequtils

let x = mapLiterals([12, 34, 15, 1], uint32)
doAssert x is array[4, uint32]

New memory manager algorithm

The new TLSF algorithm has been implemented to reduce memory fragmentation. This has a side effect of making alloc and dealloc O(1) operations.

Async improvements

There have been a number of various improvements to the asynchronous IO modules in the stdlib. 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, it returns a handle to the underlying IO completion port or epoll/kqueue fd used by asyncdispatch. Main advantage of this is that libraries now have even greater control over the event loop. As an example, it allows much more efficient HTTP server implementations (one such implementation is called httpbeast).

A new implementation of async await has also been added for the JavaScript backend in the asyncjs module.

Nimble v0.8.10

In the release are also updates to the Nim package manager. The latest version of Nimble is included and contains multiple new features and bug fixes.

The major new feature is the support for multiple Nimble packages in a single Git/Hg repository.

Check out the changelog for a list of changes since Nimble’s last release.

Contributors to v0.18.0

Our contributors are amazing, and there is far too many to list here. Big thanks to all of you, we couldn’t have pulled off this release without you!

Changelog

Changes affecting backwards compatibility

Breaking changes in the standard library

  • The [] proc for strings now raises an IndexError exception when the specified slice is out of bounds. See issue #6223 for more details. You can use substr(str, start, finish) to get the old behaviour back, see this commit for an example.

  • strutils.split and strutils.rsplit with an empty string and a separator now returns that empty string. See issue #4377.

  • Arrays of char cannot be converted to cstring anymore, pointers to arrays of char can! This means $ for arrays can finally exist in system.nim and do the right thing. This means $myArrayOfChar changed its behaviour! Compile with -d:nimNoArrayToString to see where to fix your code.

  • reExtended is no longer default for the re constructor in the re module.

  • The behavior of $ has been changed for all standard library collections. The collection-to-string implementations now perform proper quoting and escaping of strings and chars.

  • newAsyncSocket taking an AsyncFD now runs setBlocking(false) on the fd.

  • mod and bitwise and do not produce range subtypes anymore. This turned out to be more harmful than helpful and the language is simpler without this special typing rule.

  • formatFloat/formatBiggestFloat now support formatting floats with zero precision digits. The previous precision = 0 behavior (default formatting) is now available via precision = -1.

  • Moved from stdlib into Nimble packages:
  • Proc toCountTable now produces a CountTable with values corresponding to the number of occurrences of the key in the input. It used to produce a table with all values set to 1.

    Counting occurrences in a sequence used to be:

    let mySeq = @[1, 2, 1, 3, 1, 4]
    var myCounter = initCountTable[int]()
    
    for item in mySeq:
      myCounter.inc item
    

    Now, you can simply do:

    let
      mySeq = @[1, 2, 1, 3, 1, 4]
      myCounter = mySeq.toCountTable()
    
  • If you use --dynlibOverride:ssl with OpenSSL 1.0.x, you now have to define openssl10 symbol (-d:openssl10). By default OpenSSL 1.1.x is assumed.

  • newNativeSocket is now named createNativeSocket.

  • newAsyncNativeSocket is now named createAsyncNativeSocket and it no longer raises an OS error but returns an osInvalidSocket when creation fails.

  • The securehash module is now deprecated. Instead import std / sha1.

  • The readPasswordFromStdin proc has been moved from the rdstdin to the terminal module, thus it does not depend on linenoise anymore.

Breaking changes in the compiler

  • \n is now only the single line feed character like in most other programming languages. The new platform specific newline escape sequence is written as \p. This change only affects the Windows platform.

  • The overloading rules changed slightly so that constrained generics are preferred over unconstrained generics. (Bug #6526)

  • We changed how array accesses “from backwards” like a[^1] or a[0..^1] are implemented. These are now implemented purely in system.nim without compiler support. There is a new “heterogeneous” slice type system.HSlice that takes 2 generic parameters which can be BackwardsIndex indices. BackwardsIndex is produced by system.^. This means if you overload [] or []= you need to ensure they also work with system.BackwardsIndex (if applicable for the accessors).

  • The parsing rules of if expressions were changed so that multiple statements are allowed in the branches. We found few code examples that now fail because of this change, but here is one:

    t[ti] = if exp_negative: '-' else: '+'; inc(ti)
    

    This now needs to be written as:

    t[ti] = (if exp_negative: '-' else: '+'); inc(ti)
    
  • The experimental overloading of the dot . operators now take an untyped parameter as the field name, it used to be a static[string]. You can use when defined(nimNewDot) to make your code work with both old and new Nim versions. See special-operators for more information.

  • yield (or await which is mapped to yield) never worked reliably in an array, seq or object constructor and is now prevented at compile-time.

Library additions

  • Added sequtils.mapLiterals for easier construction of array and tuple literals.

  • Added system.runnableExamples to make examples in Nim’s documentation easier to write and test. The examples are tested as the last step of nim doc.

  • Implemented getIoHandler proc in the asyncdispatch module that allows you to retrieve the underlying IO Completion Port or Selector[AsyncData] object in the specified dispatcher.

  • For string formatting / interpolation a new module called strformat has been added to the stdlib.

  • The ReadyKey type in the selectors module now contains an errorCode field to help distinguish between Event.Error events.

  • Implemented an accept proc that works on a SocketHandle in nativesockets.

  • Added algorithm.rotateLeft.

  • Added typetraits.$ as an alias for typetraits.name.

  • Added system.getStackTraceEntries that allows you to access the stack trace in a structured manner without string parsing.

  • Added parseutils.parseSaturatedNatural.

  • Added macros.unpackVarargs.

  • Added support for asynchronous programming for the JavaScript backend using the asyncjs module.

  • Added true color support for some terminals. Example:

    import colors, terminal
    
    const Nim = "Efficient and expressive programming."
    
    var
      fg = colYellow
      bg = colBlue
      int = 1.0
    
    enableTrueColors()
    
    for i in 1..15:
      styledEcho bgColor, bg, fgColor, fg, Nim, resetStyle
      int -= 0.01
      fg = intensity(fg, int)
    
    setForegroundColor colRed
    setBackgroundColor colGreen
    styledEcho "Red on Green.", resetStyle
    

Library changes

  • echo now works with strings that contain \0 (the binary zero is not shown) and nil strings are equal to empty strings.

  • JSON: Deprecated getBVal, getFNum, and getNum in favour of getBool, getFloat, getBiggestInt. A new getInt procedure was also added.

  • rationals.toRational now uses an algorithm based on continued fractions. This means its results are more precise and it can’t run into an infinite loop anymore.

  • os.getEnv now takes an optional default parameter that tells getEnv what to return if the environment variable does not exist.

  • The random procs in random.nim have all been deprecated. Instead use the new rand procs. The module now exports the state of the random number generator as type Rand so multiple threads can easily use their own random number generators that do not require locking. For more information about this rename see issue #6934

  • writeStackTrace is now proclaimed to have no IO effect (even though it does) so that it is more useful for debugging purposes.

  • db_mysql module: DbConn is now a distinct type that doesn’t expose the details of the underlying PMySQL type.

  • parseopt2 is now deprecated, use parseopt instead.

Language additions

  • It is now possible to forward declare object types so that mutually recursive types can be created across module boundaries. See package level objects for more information.

  • Added support for casting between integers of same bitsize in VM (compile time and nimscript). This allows to, among other things, reinterpret signed integers as unsigned.

  • Custom pragmas are now supported using pragma pragma, please see language manual for details.

  • Standard library modules can now also be imported via the std pseudo-directory. This is useful in order to distinguish between standard library and nimble package imports:

    import std / [strutils, os, osproc]
    import someNimblePackage / [strutils, os]
    

Language changes

  • The unary < is now deprecated, for .. < use ..< for other usages use the pred proc.

  • Bodies of for loops now get their own scope:

    # now compiles:
    for i in 0..4:
      let i = i + 1
      echo i
    
  • To make Nim even more robust the system iterators .. and countup now only accept a single generic type T. This means the following code doesn’t die with an “out of range” error anymore:

    var b = 5.Natural
    var a = -5
    for i in a..b:
      echo i
    
  • atomic and generic are no longer keywords in Nim. generic used to be an alias for concept, atomic was not used for anything.

  • The memory manager now uses a variant of the TLSF algorithm that has much better memory fragmentation behaviour. According to http://www.gii.upv.es/tlsf/ the maximum fragmentation measured is lower than 25%. As a nice bonus alloc and dealloc became O(1) operations.

  • The compiler is now more consistent in its treatment of ambiguous symbols: Types that shadow procs and vice versa are marked as ambiguous (bug #6693).

  • codegenDecl pragma now works for the JavaScript backend. It returns an empty string for function return type placeholders.

  • Extra semantic checks for procs with noreturn pragma: return type is not allowed, statements after call to noreturn procs are no longer allowed.

  • Noreturn proc calls and raising exceptions branches are now skipped during common type deduction in if and case expressions. The following code snippets now compile:
    import strutils
    let str = "Y"
    let a = case str:
      of "Y": true
      of "N": false
      else: raise newException(ValueError, "Invalid boolean")
    let b = case str:
      of nil, "": raise newException(ValueError, "Invalid boolean")
      elif str.startsWith("Y"): true
      elif str.startsWith("N"): false
      else: false
    let c = if str == "Y": true
      elif str == "N": false
      else:
        echo "invalid bool"
        quit("this is the end")
    
  • Pragmas now support call syntax, for example: {.exportc"myname".} and {.exportc("myname").}

  • The deprecated pragma now supports a user-definable warning message for procs.

    proc bar {.deprecated: "use foo instead".} =
      return
    
    bar()
    

Tool changes

  • The nim doc command is now an alias for nim doc2, the second version of the documentation generator. The old version 1 can still be accessed via the new nim doc0 command.

  • Nim’s rst2html command now supports the testing of code snippets via an RST extension that we called :test:::

    .. code-block:: nim
        :test:
      # shows how the 'if' statement works
      if true: echo "yes"
    

Bugfixes

  • Fixed “ReraiseError when using try/except within finally block” (#5871)
  • Fixed “Range type inference leads to counter-intuitive behvaiour” (#5854)
  • Fixed “JSON % operator can fail in extern procs with dynamic types” (#6385)
  • Fixed ““intVal is not accessible” in VM” (#6083)
  • Fixed “Add excl for OrderedSet” (#2467)
  • Fixed “newSeqOfCap actually doesn’t reserve memory” (#6403)
  • Fixed “[Regression] Nim segfaults” (#6435)
  • Fixed “Seq assignment is slower than expected” (#6433)
  • Fixed “json module issues with empty dicts and lists” (#6438)
  • Fixed “mingw installed via finish.exe fails to link if Nim located in path with whitespace” (#6452)
  • Fixed “unittest.check does not perform short-circuit evaluation” (#5784)
  • Fixed “Error while concatenating an array of chars.” (#5861)
  • Fixed “range initialization: [ProveInit] hint: Cannot prove that” (#6474)
  • Fixed “scanf can call procs with side-effects multiple times” (#6487)
  • Fixed “gcsafe detection problem” (#5620)
  • Fixed “C++ codegen: mitems generates invalid code.” (#4910)
  • Fixed “strange runtime behavior on macOS” (#6496)
  • Fixed “stdtmpl: invalid indentation after a line ending in question mark” (#5070)
  • Fixed “Windows: NAN troubles on c backend” (#6511)
  • Fixed “lib/nim/system/cellsets.nim(33, 31) Error: type mismatch while attempting to compile for 16bit CPUs” (#3558)
  • Fixed “Can’t compile dynlib with -d:useNimRtl and --threads:on” (#5143)
  • Fixed “var s = @[0,1,2,…] can generate thousand of single assignments in C code” (#5007)
  • Fixed “echo discards everything after a null character” (#1137)
  • Fixed “Turn off reExtended by default” (#5627)
  • Fixed “Bad Links in docs/backends.html” (#5914)
  • Fixed “Index out of bounds error in db_postgres when executing non parameter-substituted queries containing “?”” (#6571)
  • Fixed “Please add pipe2 support to posix stdlib” (#6553)
  • Fixed “Return semantics vary depending on return style” (#6422)
  • Fixed “parsecsv.open reports SIGSEGV when calling ‘open’ on missing file” (#6148)
  • Fixed “VCC: Nim generates non-compilable code for system.nim” (#6606)
  • Fixed “Generic subtype matches worse than a generic” (#6526)
  • Fixed “formatFloat inconsistent scientific notation” (#6589)
  • Fixed “Generated c code calls function twice” (#6292)
  • Fixed “Range type inference leads to counter-intuitive behvaiour” (#5854)
  • Fixed “New backward indexing is too limited” (#6631)
  • Fixed “Table usage in a macro (SIGSEGV: Illegal storage access.)” (#1860)
  • Fixed “Incorrect deprecation error” (#6634)
  • Fixed “Wrong indices in arrays not starting with 0” (#6675)
  • Fixed “if expressions” (#6609)
  • Fixed “BackwardsIndex: converter + [] + unrelated type[^1]: lib/system.nim(3536, 3) Error” (#6692)
  • Fixed “js backend 0.17.3: array bounds check for non zero based arrays is buggy” (#6532)
  • Fixed “HttpClient’s new API doesn’t work through a proxy for https URLs” (#6685)
  • Fixed “isServing isn’t declared and isn’t compiling” (#6707)
  • Fixed “[Regression] value out of range” (#6710)

  • Fixed “Error when using multisync macro” (#6708)

  • Fixed “formatFloat inconsistent scientific notation” (#6589)
  • Fixed “Using : (constructor arguments) for passing values to functions with default arguments causes a compiler crash.” (#6765)
  • Fixed “In-place object initialization leads to vcc incompatible code” (#6757)
  • Fixed “Improve parseCookies doc” (#5721)
  • Fixed “Parser regression with nested do notation inside conditional” (#6166)
  • Fixed “Request for better error message” (#6776)
  • Fixed “Testament tester does not execute test with exitcode only” (#6775)
  • Fixed “JS integer division off by one” (#6753)
  • Fixed “Regression: cannot prove not nil” (#5781)
  • Fixed “SIGSEGV: Illegal storage access. (Attempt to read from nil?) in generic proc” (#6073)
  • Fixed “Request for better error message” (#6776)
  • Fixed “Nim #head: sorting via reference hangs compiler” (#6724)
  • Fixed “Cannot cast pointer to char in cpp” (#5979)
  • Fixed “asynchttpserver replies with several errors on single request” (#6386)
  • Fixed “object variants superclass trigger bad codegen” (#5521)
  • Fixed “JS integer division off by one” (#6753)
  • Fixed “js backend compiler crash with tables indexed by certain types” (#6568)
  • Fixed “Jsgen bug with is” (#6445)
  • Fixed “Subrange definition with ..<” (#6788)
  • Fixed “fields not initialized: array with enum index type as object field.” (#6682)
  • Fixed “Can not delete data in table when table’s data type is kind of “not nil”” (#6555)
  • Fixed “tables.nim: Cannot prove that ‘n’ is initialized” (#6121)
  • Fixed “issues with ‘not nil’ applied to a closure proc” (#6489)
  • Fixed “not nil not working in some cases” (#4686)
  • Fixed “Cannot prove ‘@[v]’ is not nil” (#3993)

  • Fixed “Feature: support TCP_NODELAY in net.sockets” (#6795)
  • Fixed “Code that makes the compiler throw an error message and then hangs” (#6820)
  • Fixed “Code that makes the compiler throw an error message and then hangs” (#6820)
  • Fixed “Inconsistent behavior with sequence and string slicing” (#6223)
  • Fixed “Wrong behavior of “split” (proc and iterator)” (#4377)
  • Fixed “[Documentation] Invalid module name: [foo, bar]” (#6831)
  • Fixed “The destructor is not called for temporary objects” (#4214)
  • Fixed “Destructors does not work with implicit items iterator in for loop” (#985)
  • Fixed “Error in template when using the type of the parameter inside it” (#6756)
  • Fixed “should json.to() respect parent attributes?” (#5856)
  • Fixed “json ‘to’ macro can not marshalize into tuples” (#6095)
  • Fixed “json.to fails with seq[T]” (#6604)
  • Fixed “json.to() is not worth using compared to marshal.to[T]” (#5848)
  • Fixed “Memory not being released in time, running out of memory” (#6031)
  • Fixed “[Regression] Bad C codegen for generic code” (#6889)
  • Fixed “rollingFileLogger deletes file on every start.” (#6264)
  • Fixed “Remove/deprecate securehash module.” (#6033)
  • Fixed “[bug or not] object construction for seq[T] failed without space after colon” (#5999)
  • Fixed “issues with the random module” (#4726)
  • Fixed “Reassigning local var to seq of objects results in nil element in Object’s seq field” (#668)
  • Fixed “Compilation error with “newseq[string]”” (#6726)
  • Fixed “await inside array/dict literal produces invalid code - Part 2” (#6626)
  • Fixed “terminal.eraseline() gives OverflowError on Windows” (#6931)
  • Fixed “[Regression] sequtils.any conflicts with system.any” (#6932)
  • Fixed “C++ codegen: mitems generates invalid code.” (#4910)
  • Fixed “seq.mitems produces invalid cpp codegen” (#6892)
  • Fixed “Concepts regression” (#6108)
  • Fixed “Generic iterable concept with array crashes compiler” (#6277)
  • Fixed “C code generation “‘a’ is a pointer; did you mean to use ‘->’?”” (#6462)
  • Fixed “--NimblePath fails if a - in path which is not followed by a number” (#6949)
  • Fixed ““not registered in the selector” in asyncfile.close() for something that clearly was registered” (#6906)
  • Fixed “strange frexp behavior” (#6353)

  • Fixed “noreturn branches of case statements shouldn’t contribute to type” (#6885)
  • Fixed “Type inference for ‘if’ statements changed” (#6980)
  • Fixed “newest asyncdispatch recursion” (#6100)
  • Fixed “Ambiguous identifier between set type and proc” (#6965)

  • Fixed “Inconsistent behavior with sequence and string slicing” (#6223)

  • Fixed “Unsupported OpenSSL library imported dynamically” (#5000)
  • Fixed “nim check segfaults” (#6972)
  • Fixed “GC deadlock” (#6988)
  • Fixed “Create a seq without memory initialization” (#6401)
  • Fixed “Fix bug for getch on Windows while using the arrow keys” (#6966)
  • Fixed “runnableExamples doesn’t work in templates” (#7018)
  • Fixed “runnableExamples doesn’t work with untyped statement blocks” (#7019)

  • Fixed “Critical bug in parseBiggestFloat” (#7060)
  • Fixed “[RFC] strformat.% should be gone” (#7078)
  • Fixed “compiler crash on simple macro” (#7093)
  • Fixed “Make newlines sane again” (#7089)
  • Fixed “JS - Unicode enum string representation issue” (#6741)
  • Fixed “Strange behaviour of 0.17.3 (working ok in 0.17.2)” (#6989)
  • Fixed “Strange behaviour of 0.17.3 (working ok in 0.17.2)” (#6989)
  • Fixed “Compiler crash: try expression with infix as” (#7116)
  • Fixed “nimsuggest crash” (#7140)
  • Fixed “[RFC] Reintroduce readChar” (#7072)
  • Fixed “Copyright line needs updating” (#7129)
  • Fixed “-0.0 doesn’t result in negative zero in VM” (#7079)
  • Fixed “Windows large filesize” (#7121)
  • Fixed “Securehash is not parsimonious with MD5 and other hash modules” (#6961)
  • Fixed “os.findExe() shouldn’t look in current directory on posix, unless exe has a /” (#6939)
  • Fixed “compiles(...) with fatal pragma causes compiler to exit early” (#7080)
  • Fixed “NPE when compile macro that returns concrete value” (#5450)
  • Fixed “Using a variable of type int | float causes internal compiler error” (#6946)
  • Fixed “Unsigned integers could not be used as array indexes.” (#7153)
  • Fixed “countdown with uint causes underflow” (#4220)
  • Fixed “Inconsistent method call syntax” (#7200)
  • Fixed “Impossible to create an empty const array” (#6853)
  • Fixed “Strange UINT handling” (#3985)
  • Fixed “Bad codegen when passing arg that is part of return value destination” (#6960)
  • Fixed “No info about gcsafety in error message when global var is accessed in async proc” (#6186)
  • Fixed “Resolving package vs. local import ambiguities” (#2819)
  • Fixed “Internal error with type() operator” (#3711)
  • Fixed “newAsyncSocket should raise an OS error plus other inconsistencies” (#4995)
  • Fixed “mapLiterals fails with negative values” (#7215)
  • Fixed “fmWrite doesn’t truncate file with openAsync, unlike open()” (#5531)
  • Fixed “Move libsvm to an external nimble module” (#5786)
  • Fixed “Prevent acceptAddr gotcha with newSocket” (#7227)
  • Fixed “strtabs.getOrDefault is inconsistent with tables.getOrDefault” (#4265)

  • Fixed “Code falling through into exception handler when no exception thrown.” (#7232)
  • Fixed “the new generic inference rules are broken” (#7247)
  • Fixed “Odd ..< regression” (#6992)
  • Fixed “Different proc type inferred from default parameter” (#4659)
  • Fixed “Different proc type inferred from default parameter” (#4659)
  • Fixed “Testament sometimes ignores test failures” (#7236)
  • Fixed “New Allocator Fails On >=4GB Requests” (#7120)
  • Fixed “User pragmas hide effect specifications from sempass2” (#7216)
  • Fixed “C++: SIGABRT instead of IndexError for out-of-bounds” (#6512)
  • Fixed “An uncaught exception in cpp mode doesn’t show the exception name/msg” (#6431)

Nim is coming to FOSDEM

In just under a week, FOSDEM 2018 will be taking place in Brussels

yes command in Nim

Recently I stumbled upon a post which takes a closer look at the `yes` command line tool. The main purpose of it is to write endless stream of a single letter `y` at a ridiculous speed.

Nim in 2017: A short recap

This year has been filled with some pretty major achievements for us, because of this I decided to write a little article summarising what we’ve accomplished in 2017 and to give a bit of a preview of what’s in store for 2018.

The first Nim book

  • Nim in Action, the first Nim programming language book, went into production in late 2016 and I received the first printed copies in the following summer.
  • Of course, being the author, I am incredibly proud of this.
  • This book is considered “canon” for Nim v1. This means that we will do our best to not break anything that is contained within it for version 1.0. So don’t be afraid to buy a copy thinking that it will be out of date by the time 1.0 is released.

Nim at FOSDEM

  • Nim is coming to FOSDEM!
  • We are very happy to say that we have been allocated a stand at FOSDEM 2018 in Brussels. A lot of Nim folks (including the Nim creator Andreas Rumpf and myself) will be there to sell t-shirts, books and to promote Nim.
  • Join us on 3 & 4 February 2018 in Brussels!

Nim in production

Work towards v1.0

  • 3 releases this year: 0.16.0, 0.17.0 and 0.17.2
  • Upcoming release 0.18.0 contains many bug fixes and improvements, in particular a lot of stdlib changes. See the current changelog here.
    • “Upcoming” async has finally been merged.
    • A large revamp of the times module, with more to come. (Thanks @GULPF)
    • Multiple modules have been moved out of the stdlib to Nimble packages. (Thanks @lcrees)
    • Fixes to our handling of SSL certificate checks. (Thanks @FedericoCeratto)
    • The memory manager now implements the TLSF algorithm with the benefit that alloc and dealloc are now O(1) operations.
    • Many more changes by our awesome and devoted community.
  • Version 1.0 will mark the end of breaking changes to Nim. This won’t mean that Nim development will cease, many improvements will continue to be made and your source won’t require any changes to compile with each Nim release.
    • There will be some caveats to this which we will outline in the future.
    • We are already very good at exercising restraint when creating breaking changes, often creating a deprecation path to ease the pain of our users. This isn’t always the case though, after v1 is release it will be.

Nim livestreams

As always, I’d like to invite you to join our community to give us feedback or just to chill out with us, all the information you need to do so is available on our community page.

Thank you all for your incredible support so far, and have a happy new year!


Nim代码的文档化、分析和调试指南

本指南讨论了一些用于注释和生成文档、分析和调试nim代码的实用工具。


Nim Community Survey 2017 Results

We have recently closed the 2017 Nim Community Survey. I am happy to say that we have received exactly 603 responses, huge thanks go to the people that took the time to respond. We’re incredibly thankful for this very valuable feedback.

For the results of the previous year’s survey, take a look at the 2016 results analysis.

Our survey ran from the 23rd of June 2017 until the 14th of August 2017. The goal of this survey was to primarily determine how our community is using Nim, in order to better understand how we should be improving it. In particular, we wanted to know what people feel is missing from Nim in the lead up to version 1.0. We have also asked our respondents about how well the Nim tools worked, the challenges of adopting Nim, the resources that they used to learn Nim and more. We repeated the survey with the same questions this year to see how we did over the past year.

Unlike in the last year, this analysis will not go over all the results. Instead it will only go over the most interesting answers.

A word on the response count

In comparison to last year we unfortunately received 187 less responses. I suspect the reason for this decrease was the fact that we were not able to advertise the survey as well as the previous year, I got lucky last year by sharing a link to our survey in the Rust community survey results Hacker News thread. This year Rust’s results were late and so I didn’t get the same opportunity.

But with that in mind I think the number of responses is still good.

Do you use Nim?

Like last year we split up our respondents into three groups:

  • Current users of Nim
  • Ex-Nim users
  • Those that never used Nim

This allowed us to ask each group specific questions. For example, we asked ex-Nim users why they’ve stopped using Nim.

Do you use Nim?

This year the proportion of responses from current Nim users has grown from 39% to 44%, and as a result of this there is less responses from those that never used Nim (decrease from 37% to 30%). This is likely due to a higher proportion of responses from the Nim community.

But this isn’t the whole story, the number of ex-Nim users went up from 24% to 26%.

Nim users

This section includes answers from current Nim users only (44% of respondents).

How long have you been using Nim?

How long have you been using Nim?

Just like last year, a large proportion of our Nim users are new. This suggests that our community is growing and is a good sign. On the other end of the spectrum we can see that there is a significantly higher number of Nim users that have been using Nim for more than 24 months.

Nim at work and project size

The questions related to these topics got very similar results to last year:

  • 57.1% of Nim users’ projects are less than 1,000 lines of code.
  • 24.6% of Nim users’ work with Nim either full-time or part-time.
  • 52.5% of Nim users plan to use Nim at work.

How is Nim being used at work?

This was a free-form question so I will just pick out some of the common and interesting answers. According to the respondents, Nim is used at work for:

  • Command-line applications
  • Server-side analytics
  • DevOps
  • Scientific computing
  • Speeding up Python

How could we help make Nim more accepted at your company?

Another free-form question, I will pick out some of the things that respondents have identified:

  • Release of version 1.0 (a common theme)
  • Mature libraries and stability (a common theme)
  • Up to date documentation of every feature, with examples (a common theme)
    • More tutorials and videos
  • Enhance the stdlib, it needs to be more complete
  • Corporate sponsor
  • Visual Studio plugin
  • Lowering the barrier to entry for working with cross-compilers and interop with C
  • Free book
  • Compelling use cases
  • Porting to ARM cortex M (already done?)
  • “change cocky logo”
  • More informative errors
  • Lockfile support
  • Interfaces
  • More data processing tools
  • GUI creator for Windows
  • “idk lol”

Nim and its tools

In this section of the survey, we wanted to find out the tools that Nim users are utilising when developing Nim applications.

What editor(s) do you use when writing Nim?

Programmers swear by their editors. What does the Nim community prefer?

Editors used by Nim users

There is still a large number of Vim users, but now they are overwhelmed by the Visual Studio Code users. VS Code has gone from 16.5% to 35.5%!

Operating systems, Nim version and Nim code breakage

Again, the results for these questions are very similar to last year. I will simply provide a summary:

  • Linux is still the most popular development platform, with Windows second and macOS third.
  • The same is true for the target platform. But in addition to this, a large 19% of respondents are targeting Android, 16.7% are targeting JavaScript, 10.5% are targeting iOS and 10.1% are targeting embedded platforms.
  • The current release of Nim (0.17.0) is the most used at 68.8%, with Git HEAD second at 33.1%.
  • 52.2% of respondent’s code was never broken by a Nim upgrade.
  • Of those whose code was broken, for 29.3% of the respondent’s it was little work to fix.

Install method

We wanted to find out how users are installing Nim. In particular I wanted to find out whether choosenim was getting adopted.

Installation method

It seems that the majority are still in fact installing Nim by cloning the Nim repo manually. This makes sense as Nim is still evolving quickly, for most people it makes sense to stay on the bleeding edge.

What critical libraries are missing in the Nim ecosystem?

This is a good list of projects for the Nim community to take up. The respondent’s were asked to freely give libraries that they need, here are their (mostly raw) answers (duplicates left in to show popularity):

  • High-level HTTP library (like “requests” in Python)
  • First-class libraries rather than C wrappers.
  • Bass audio library
  • Distributed computing libraries
  • REPL
  • Stabilsing async libraries
  • Rails-like framework, ORM, webdriver, Electron-like thing
  • KD-Tree, Blas/Lapack
  • Qt GUI bindings
  • Excel XLSX Read/Write
  • Pandas-like, more statistical libraries
  • Linear algebra, plotting, science
  • UI
  • Simple gui, like tkinter or wxwidgets.
  • Db/queues high level connectors
  • Pandas like dataframes, a well documented web framework, ORM
  • Gui
  • html5 parser
  • excel reader, dataframe. numpy/scipy-like scientific calculation lib.
  • python2nim converter
  • OpenPGP
  • Easier way to add a language backend
  • parsing
  • multithreaded web framework
  • embedded I/O
    • I think the libraries are there but the documentation is abit lacking.
  • oracle oci
  • Kerberos auth library (c wrapping), pandas like lib (there is one more features will be nice)
  • native support for big numbers
  • iterutils, date (native nim excluding time, usable at compile time in const), asyncdb
  • a wysiwyg for guis
  • cancelable async timers, gui, random, collections (unified), and would be nice to redesign the whole stdlib
  • Android support
  • OpenGL, Vulkan (all API for game development)
  • Maybe theese exists already but for network equipment SSH, Expect tooling I’d love, and also parsing of config files libraries.
  • Interfaces
  • Lib to make working with dates and times more easy, like pytz for Python.
  • I’m always amazed at how complete the standard lib for such a (still) small project; more libs for data processing would be great (Neo seems to be a very good start)
  • GUI, I would like Qt
  • orm
  • Machine Learning, Pandas-like
  • More object oriented paradigms, especially interfaces, that is a language construct informing you that you forgot to implement a function required to conform to an interface, it doesn’t really need to be a “classic” example, because i know Nim developers think out of the box (I love the vtable system, which is not tied to a particular class ;) )
  • Machine learning and scientific computing libraries
  • Qt bindings
  • Thrift, Cassandra drivers, Scientific computing
  • scientific plotting
  • GUI, Matrix works
  • I like the libs, but I wish there was a wrapper for the steamsdk from Valve.
  • The only thing that i’ve been missing so far as a good ORM for working with relational data in an Object Oriented manner. I always want to help improve the MongoDb driver.
  • Numerical/scientific computing (features like Numpy/Scipy)
  • CGAL, Boost, Qt
  • simple cross-platform UI
  • fltk (for me personally), pandas like lib
  • wrapper of Microsoft RPC (rpc4), easy to use Windows GUI
  • concurrent data structures
  • more trees: tries, quad/octrees, more macro utilities
  • Maybe something more related to scientific computing (linalg libraries, etc.)
  • Self aligned SIMD vector types.
  • A database driver for Cassandra
  • Better redis client
  • It would be good to have some sort of GUI support
  • Built in efficient vec2/3/4 types, everyone duplicates that
  • compile time reflection
  • websockets
  • I’d like to see a Nim implementation of multiformats and other IPFS technologies
  • Although there are libraries, better support for linear algebra/scientific computing/data plotting would be very nice. Similarly, a standardized game library would be wonderful.
  • Numerical computing/Data Science tools
  • Standard and production-ready async support
  • More GUI and networking suppport
  • multithreading
  • GUI
  • web framework
  • charting/plotting libraries, numerical libraries, graphics libraries…some of these exist or can easily be created by binding to C or C++, but that is hard for a noobie, so perhaps better doc in that area with frequent examples would help
  • A good cross platform graphics library and a UI library built on top of it, but I’m intending to start working on these in the future as open source projects (based on OpenGL).
  • Fast low level socket library (epool, kqueue)
  • modern GUI library
  • opengl
  • gui library
  • a scientific math and plotting library
  • numerics. Gui wrapper (ngtk is nice). for me personally, geospatial and image processing libraries
  • a matplotlib equivalent
  • Pure Nim database libraries; Libraries for common HTTP I/O (files, chunked transfers, etc.)

What development tools can make you more productive when working with Nim?

Summarising again:

  • Debugger (very common theme)
  • Documentation
  • Various IDE plugins (IntelliJ, Visual Studio)
  • Better cross-compiler support

Previous Nim users

How long did you use Nim before you stopped?

How long did you use Nim before you stopped?

This question is new. It shows that ex-Nim users are fairly equally distributed based on the amount of time they used Nim before deciding to stop.

Reasons why respondents stopped using Nim

This was a free-form question. Some of the common answers were as follows:

  • Lack of time (this is actually a very common reason)
  • No good editor support
  • Lack of stability/maturity
  • No killer use case
  • Nim is a running target
  • Metaprogramming too unstable

Here are some other interesting reasons:

  • Compiler doesn’t conform to Unix traditions and outputs HUGE binaries.
  • Lack of GOTO.
  • Nim generated broken C code.
  • “I found myself working on the compiler instead of using the language.”
  • “proc and echo are weird, I think that def and print are better”
  • “really dislike the fact that if you do import foo you get a lot of new names in your namespace and sometimes have to exclude; find Python’s explicit approach much more robust and clear.”
  • “Compiler doesn’t conform to Unix traditions and outputs HUGE binaries.”
  • “Changes to the core libraries to rely too much on exceptions. I don’t like exceptions.”

Non-users of Nim

Reasons for not using Nim

As with the previous year, the most popular answer to this question was once again to do with maturity of Nim as well as lack of libraries and good IDE support.

There were also a number of free-form answers to this question:

  • GC
  • Small user base
  • Dislikes significant whitespace
  • No corporate backing
  • Waiting for 1.0
  • Unpredictable performance (according to the respondent Go has predictable performance behaviours whereas Nim doesn’t)
  • Language appears overcomplicated
  • Uncertainty about future
  • Just waiting for free time

Nim’s future

What improvements are needed before v1.0 can be released?

This received a number of free-form answers which I will outline here:

  • Documentation
  • It’s ready now!
  • Getting rid of warts that HN/Reddit comments about
  • Get rid of forward declarations
  • Improve error messages
  • Concepts
  • Improve stdlib

Which direction should Nim’s GC/Memory management take?

Which direction should Nim's GC/Memory management take?

There was a number of free-form answers as well. Most of them spoke about providing all approaches, i.e. the “have the cake and eat it too” approach. Many are conscious of the fact that a GC makes programming smoother so they don’t want the Rust model, but for use cases where it’s necessary they do want it.

Last words

Like last year, at the end of the survey we gave our respondents a chance to speak their mind about anything they wish, with a simple question: “Anything else you’d like to tell us?”

There was a lot of great feedback given in this question from people who obviously really care deeply about Nim. There is too much to outline here, but rest assurred that we will take it all into account and do our best to act on it.

In addition to feedback, we were also overwhelmed by the amount of positive comments in the answers to this question. There was a lot of support from the community thanking us for our work and determination.

I’ll let some quotes speak for themselves:

Keep up the good job. I love Nim!
Great work so far, keep it going!
Please just keep up the excelent work. Nim is awesome!
Awesome language, and great community!

Our community is truly brilliant. We thank each and every one of you for filling out this survey and hope that you will help us tackle some of the challenges that face Nim.

This survey was a good place to give us feedback, but please don’t wait for the next one. We are always looking to hear more from you and we hope that you will participate in discussions relating to this survey as well the future of Nim.

Thanks for reading, and have a good day!


Version 0.17.2 released

The Nim team is happy to announce that the latest release of Nim, version 0.17.2, is now available. Nim is a systems programming language that focuses on performance, portability and expressiveness.

The major new feature in this release is the support for .nimble-link files. This has been added in order to support the latest Nimble version with its “develop” feature. For more information, see nimble.

This is however primarily a bug fix release, with the most important bugfixes including the long standing codegen bugs that triggered GC crashes. Updating is recommended!

Be sure to check out the changelog below for a comprehensive list of changes.

This release also includes version 0.8.8 of the Nimble package manager, be sure to check out its changelog for a list of changes since its last release.

You can download the latest release of Nim from the download page. If you’re using choosenim then you can easily update to the latest version by running the following:

$ choosenim update stable

Changelog

Changes affecting backwards compatibility

  • The changes made to the do notation parsing rules in v0.17.0 have been reverted.

Bugfixes

The list below has been generated based on the commits in Nim’s git repository. As such it lists only the issues which have been closed via a commit, for a full list see this link on Github.

  • Fixed “Fixed syslocks for ios” (#5804)
  • Fixed “OpenBSD pthread issue” (#5920)
  • Fixed “JS backend doesn’t copy ‘object’ when adding to ‘seq’” (#4139)
  • Fixed “sequtils insert produces wrong result in a case of sequence of objects in JS” (#5933)
  • Fixed “Index out of bounds error while using sets with cstring in JS” (#5969)
  • Fixed “Compiler crash when a proc marked as gcsafe moves around non-gcsafe closures” (#5959)
  • Fixed “type with packed pragma is not properly packed” (#5824)
  • Fixed “httpclient Docs Wrong” (#5863)
  • Fixed “{.async.} doesn’t work with do notation” (#5995)
  • Fixed “Sigmatch error in fitting anonymous tuples to generic types” (#5890)
  • Fixed “Nested array alias type leads to compile-time and run-time bugs” (#5962)
  • Fixed “Static - Default value for static arg - Cannot instantiate” (#5864)
  • Fixed “constant of generic type becomes all zero when assigning to a local value” (#5756)
  • Fixed “User defined arithemetic in generic types” (#5106)
  • Fixed “Overloading with static[] leads to strange error” (#5017)
  • Fixed “Compiler crash” (#2730)
  • Fixed “Compiler segfaults on non-recursive code” (#4524)
  • Fixed “static[T] generic type cause invalid type” (#3784)
  • Fixed “Using static generic params on procs often fails to compile” (#1017)
  • Fixed “Inferring nested static[T] “ (#3153)
  • Fixed “another static_t problem” (#3152)
  • Fixed “Generic code can cause attempts to use constructors for unrelated types to fail” (#1051)
  • Fixed “Internal Error with with static generic parameters” (#1082)
  • Fixed “Internal error with enumerable concept and map proc” (#5968)
  • Fixed “Concept - strange behaviour” (#4020)
  • Fixed “Compiler crash while wrapping concepts” (#5127)
  • Fixed “Using generic concept parameter causes stack overflow” (#4737)
  • Fixed “About ambiguous concept” (#5888)
  • Fixed “Concepts don’t play well with distinct primitive types, e.g. distinct float or string” (#5983)
  • Fixed “Error with generic concepts” (#5084)
  • Fixed “the ^ operator fails on floats” (#5966)
  • Fixed “Documentation: times.nim” (#6010)
  • Fixed “[Regression] Nim js crashes” (#5946)
  • Fixed “Times module compiled in JS failed to compare values” (#6021)
  • Fixed “JS: tables assignment breaks with importcpp’s in scope (internal error: genAddr: nkDerefExpr)” (#5846)
  • Fixed “Object constructor violates copy semantics, allows modifying immutable [js only]” (#4703)
  • Fixed “No bounds checking in JS target?” (#5563)
  • Fixed “js: genDeref compiler crash” (#5974)
  • Fixed “JS: internal error in genDeref” (#5379)
  • Fixed “JS: compiler internal error” (#5517)
  • Fixed “JS codegen produces circular structure” (#6035)
  • Fixed ““nim doc” SIGSEGV when foo*(a: proc)” (#6030)
  • Fixed “Value redefinition not detected in {.pure.} enum” (#6008)
  • Fixed “unexpected option : ‘-o’” (#6069)
  • Fixed “Nimsuggest crashes in sempass2.useVar” (#6067)
  • Fixed “Nim compiler generates variables for discarded proc return values” (#6037)
  • Fixed “js target bug with operator +=” (#5608)
  • Fixed “Nim Tutorial (Part I) need update” (#6062)
  • Fixed “Error after codegen when shadowing template arg” (#4898)
  • Fixed “Threadpool doesn’t work after sync” (#6090)
  • Fixed “parsecfg silently fails to store and retrieve negative integers” (#6046)
  • Fixed “async + threads:on + globals = error” (#5738)
  • Fixed “Strange behaviour when importing locks for use in a generic type” (#6049)
  • Fixed “js backend failed to compile try…except new syntax” (#5986)
  • Fixed “Different handling of .emit with and without native debugger” (#5989)
  • Fixed “Structure packing and alignment issue on Windows.” (#4763)
  • Fixed “ICE on discard seq.len” (#6118)
  • Fixed “ICE: genRecordField 3” (#5892)
  • Fixed “JS exportc regression?” (#6096)
  • Fixed “ReraiseError when using try/except within finally block” (#5871)

  • Fixed “Inconsistent os:standalone behavior” (#6131)
  • Fixed “.cfg files (, parsecfg) and quoting” (#499)
  • Fixed “SIGSEGV: Illegal storage access. (Attempt to read from nil?)” (#6127)
  • Fixed “Nim Tutorial doc bugs” (#6125)

  • Fixed “union type compile error..” (#6016)
  • Fixed “Failure to compile stdlib/system with VCC, C++ and threads:on on i386” (#6196)
  • Fixed “GC bug resulting in random crashes” (#6234)
  • Fixed “deque.nim: Doc says removeLast proc, but not defined “ (#6110)
  • Fixed “Nim crashes when instancing with incorrect arg sintax” (#5965)
  • Fixed “Equality of OrderedTable is incorrect” (#6250)
  • Fixed “0.17.0 Regression: Statement macro from tutorial does not compile anymore” (#5918)

  • Fixed “httpclient crash when performing get request” (#6284)
  • Fixed “GC bug” (#6279)
  • Fixed “Minor typo in system.nim” (#6288)
  • Fixed “Incorrect render of GenericParams” (#6295)
  • Fixed “Wrong [XDeclaredButNotUsed] hint” (#3583)
  • Fixed “Segfault when using reorder pragma” (#6306)
  • Fixed “execvpe not available on older linux versions” (#1734)
  • Fixed “tables.[]=A should support val = 0” (#4366)
  • Fixed “nimble and koch executables in win32 distribution are x64, not x86” (#6147)
  • Fixed “nim-0.17.0_x32.zip contains some 64-bit binaries” (#6028)
  • Fixed “Inherited fields are not set in some cases, using object literals” (#6294)
  • Fixed “existsEnv declared twice in develop branch ospaths and nimscript” (#6327)

Launching the 2017 Nim Community Survey

We are proud to announce the launch of the official 2017 Nim Community Survey! No matter whether you use Nim today, have used Nim previously, or never used Nim before; we want to know your opinions. Your feedback will help the Nim project understand its strengths and weaknesses, and to determine development priorities for the future.

It shouldn’t take you much longer than 5 to 10 minutes to complete this survey. Submissions will be accepted until around the 23rd of July, depending on the response rates. If you have any questions or feedback, please don’t hesitate to get in touch with us via email at [email protected] or on the Nim Forum.

We would appreciate your help in spreading the word about this survey. Share the above link on your social network feeds, with your colleagues and in other communities.

Thank you to everyone that helped develop and test the survey! Once the submission period ends, the results will be shown here and publicised via Twitter, the Nim Forum and IRC.

Thanks for your time!


Faster Command Line Tools in Nim

This is a guest post by Euan Torano cross-posted from Faster Command Line Tools in Nim. If you would like to publish articles as a guest author on nim-lang.org then get in touch with us via Twitter or otherwise.

After having read the blog post titled Faster Command Line Tools in D by Jon Degenhardt on the D Blog, I was interested to see how Nim would stack up performing the same task.

Rather than explain the task again, I might as well quote the reference post that inspired me:

It’s a common programming task: Take a data file with fields separated by a delimiter (comma, tab, etc), and run a mathematical calculation involving several of the fields. Often these programs are one-time use scripts, other times they have longer shelf life. Speed is of course appreciated when the program is used more than a few times on large files.

The specific exercise we’ll explore starts with files having keys in one field, integer values in another. The task is to sum the values for each key and print the key with the largest sum.

With the first field as key, second field as value, the key with the max sum is B, with a total of 13.

Fields are delimited by a TAB, and there may be any number of fields on a line. The file name and field numbers of the key and value are passed as command line arguments.

Implementing the Nim program, first try

This is quite a simple program. All that we need to do is read a file, parse it as CSV data with a tab delimiter and sum the counts.

Luckily, Nim’s standard library has many useful modules to help with common tasks like these:

  • The streams module provides a FileStream type for reading from and writing to files.
  • The parsecsv module provides a simple high performance CSV parser.
  • The tables module provides a CountTable type designed to map a key to its number of occurrences - precisely the task we’re trying to accomplish!

The code is pretty simple, so let’s start by looking at it in its entirety:

import os, strutils, streams, tables, parsecsv

const
  Delim = '\t'

proc main() =
  if paramCount() < 3:
    quit("synopsis: " & getAppFilename() & " filename keyfield valuefield")

  let
    filename = paramStr(1)
    keyFieldIndex = parseInt(paramStr(2))
    valueFieldIndex = parseInt(paramStr(3))
    maxFieldIndex = max(keyFieldIndex, valueFieldIndex)

  var
    sumByKey = newCountTable[string]()
    file = newFileStream(filename, fmRead)

  if file == nil:
    quit("cannot open the file " & filename)

  defer: file.close()

  var csv: CsvParser
  open(csv, file, filename, separator=Delim)

  while csv.readRow():
    if len(csv.row) > maxFieldIndex:
      sumByKey.inc(csv.row[keyFieldIndex], parseInt(csv.row[valueFieldIndex]))

  if sumByKey.len() == 0:
    echo "No entries"
  else:
    let largest = sumByKey.largest()
    echo "max_key: ", largest[0], " sum: ", largest[1]

main()

Most of this should be pretty self explanatory. I’ve used the same names as those used in the D code samples provided in the original blog post to keep things looking similar.

Obviously the start of the program is all about making sure we have enough command line arguments, and collecting them up. In Nim, we use paramStr() from the os module to access command line arguments.

From there, we create a new count table, open the CSV file for reading (fmRead opens the file in read mode) and start the CSV parser.

We then read through all of the rows in the CSV file, and if the row has enough fields to be a valid row, we increment its entry within the count table.

Benchmarking Speed

With this initial implementation complete, I built it in release mode (nim c -d:release test_csv.nim) and benchmarked it against the Python implementation and the final optimised D implementation (max_column_sum_by_key_v4b.d).

The versions of the tools used in this post are as follows:

  • Python: Python 2.7.13
  • DMD: DMD64 D Compiler v2.074.0
  • LDC: LDC - the LLVM D compiler (1.2.0): based on DMD v2.072.2 and LLVM 4.0.0
  • Nim: Nim Compiler Version 0.17.0 (2017-05-18) [MacOSX: amd64]
  • Clang: Apple LLVM version 8.1.0 (clang-802.0.42)

Testing was performed against the D version compiled using both the reference DMD D compiler, and the LDC LLVM based D compiler. The compilation switches used for the D versions were as follows:

  • DMD: dmd -O -release -inline -boundscheck=off -of=./D/csv_test ./D/csv_test.d
  • LDC: ldc2 -of=./D/csv_test_ldc -O -release -boundscheck=off ./D/csv_test.d

I then ran all of these implementations against the same ngram file from the Google Books project, making sure I got the expected output, which is as follows:

max_key: 2006 sum: 22569013

The benchmark was ran on my mid 2014 MacBook Pro with a 2.8GHz Intel Core i7 running macOS Sierra 10.12.4. The benchmark made use of the repeat.rb script from Kostya’s benchmarks project to run each version 10 times and report the fastest run time. This script also provides the added bonus of providing the peak amount of memory used by each version. Here are the results:

Python...
max_key: 2006 sum: 22569013
21.70s
max_key: 2006 sum: 22569013
32.06s
max_key: 2006 sum: 22569013
17.83s
max_key: 2006 sum: 22569013
18.29s
max_key: 2006 sum: 22569013
23.73s
max_key: 2006 sum: 22569013
18.09s
max_key: 2006 sum: 22569013
17.58s
max_key: 2006 sum: 22569013
17.86s
max_key: 2006 sum: 22569013
16.92s
max_key: 2006 sum: 22569013
15.98s

MIN TIME: 15.98s
PEAK MEM: 7.9Mb

D (DMD)...
max_key: 2006 sum: 22569013
2.45s
max_key: 2006 sum: 22569013
2.33s
max_key: 2006 sum: 22569013
2.24s
max_key: 2006 sum: 22569013
2.36s
max_key: 2006 sum: 22569013
2.28s
max_key: 2006 sum: 22569013
2.21s
max_key: 2006 sum: 22569013
2.28s
max_key: 2006 sum: 22569013
2.21s
max_key: 2006 sum: 22569013
2.28s
max_key: 2006 sum: 22569013
2.30s

MIN TIME: 2.21s
PEAK MEM: 2.3Mb

D (LDC)...
max_key: 2006 sum: 22569013
1.42s
max_key: 2006 sum: 22569013
1.34s
max_key: 2006 sum: 22569013
1.34s
max_key: 2006 sum: 22569013
1.33s
max_key: 2006 sum: 22569013
1.88s
max_key: 2006 sum: 22569013
1.31s
max_key: 2006 sum: 22569013
1.35s
max_key: 2006 sum: 22569013
1.36s
max_key: 2006 sum: 22569013
1.29s
max_key: 2006 sum: 22569013
1.26s

MIN TIME: 1.26s
PEAK MEM: 2.4Mb

Nim...
max_key: 2006 sum: 22569013
1.36s
max_key: 2006 sum: 22569013
1.30s
max_key: 2006 sum: 22569013
1.31s
max_key: 2006 sum: 22569013
1.35s
max_key: 2006 sum: 22569013
1.36s
max_key: 2006 sum: 22569013
1.45s
max_key: 2006 sum: 22569013
1.47s
max_key: 2006 sum: 22569013
1.50s
max_key: 2006 sum: 22569013
1.53s
max_key: 2006 sum: 22569013
1.56s

MIN TIME: 1.30s
PEAK MEM: 1.9Mb

D (compiled with LDC and using the fifth iteration of the code from the original blog post) comes in fastest at 1.26 seconds. Nim comes in second, at 1.30 seconds - only 0.04 seconds behind.

Nim does use 0.5Mb less memory than the D version built with LDC, and is doing slightly more work - the parsecsv module will handle escaped values, unlike the naive approach of simply splitting strings on the tab character.

Python is clearly the loser, taking 12 times as long to complete the processing as the Nim version does and using 4 times the memory to do so.

This test also shows the gulf between the DMD and LDC compilers. The same code compiled with the DMD compiler takes almost a whole second longer to execute than it does when compiled with LDC, though it does use 0.1Mb less memory at its peak.

I’m sure that with some tuning, I could get the Nim version to perform even quicker, but for a 0.04 second time difference, I decided not to put that effort in.

Benchmarking compilation times

Having come this far, I though I might as well benchmark how long compilation times are for the two D implementations and the Nim implementation. Obviously, the Python implementation is excluded from this test.

I cleared out all build artefacts (such as the *.o files for D and the nimcache folder for Nim) along with the built executables, then simply timed each build. Here are the results:

  • DMD: real 0m0.947s
  • LDC: real 0m2.296s
  • Nim: real 0m0.955s

It turns out that the DMD compiler is much quicker than the LDC compiler. Obviously all the optimisations that LLVM makes take a little while longer to complete.

Conclusion

And that was the end of my little test. It turns out that Nim can certainly hold its own when it comes to parsing CSV files.

I’d be interested to see how things run on other machines and operating systems to see how things are across platforms. I’m also sure there are far better ways I could benchmark these implementations, which is why I’ve posted the project publicly on GitHub - I’d welcome any enhancements to any of the versions or the benchmarking scripts, and would certainly welcome some more results to see how things stack up!


Version 0.17.0 released

The Nim team is happy to announce that the latest release of Nim, version 0.17.0, is now available. Nim is a systems programming language that focuses on performance, portability and expressiveness.

This release fixes the most important regressions introduced in version 0.16.0. In particular memory manager and channel bugs have been fixed. There was also many significant improvements to the language, in particular a lot of work was put into concepts. Zahary has been leading this effort and we thank him for his hard work. Be sure to check out the changelog below for a comprehensive list of changes.

The NSIS based installer is not provided anymore as the Nim website moved to https and this caused NSIS downloads to fail. The latest version of Nim for Windows can still be downloaded as a zip archive from the downloads page.

We would also like to invite you to test a brand new tool that aims to make the installation and management of multiple Nim versions much easier. This tool is called choosenim and allows you to install the latest version of Nim with a single command. Check out the installation instructions on GitHub to give it a go, but keep in mind that this tool is still experimental.

This release also includes version 0.8.6 of the Nimble package manager, be sure to check out its changelog for a list of changes since its last release.

Changelog

Changes affecting backwards compatibility

  • There are now two different HTTP response types, Response and AsyncResponse. AsyncResponse’s body accessor returns a Future[string]!

    Due to this change you may need to add another await in your code.

  • httpclient.request now respects the maxRedirects option. Previously redirects were handled only by get and post procs.
  • The IO routines now raise EOFError for the “end of file” condition. EOFError is a subtype of IOError and so it’s easier to distinguish between “error during read” and “error due to EOF”.
  • A hash procedure has been added for cstring type in hashes module. Previously, hash of a cstring would be calculated as a hash of the pointer. Now the hash is calculated from the contents of the string, assuming cstring is a null-terminated string. Equal string and cstring values produce an equal hash value.
  • Macros accepting varargs arguments will now receive a node having the nkArgList node kind. Previous code expecting the node kind to be nkBracket may have to be updated.
  • memfiles.open now closes file handles/fds by default. Passing allowRemap=true to memfiles.open recovers the old behavior. The old behavior is only needed to call mapMem on the resulting MemFile.
  • posix.nim: For better C++ interop the field sa_sigaction*: proc (x: cint, y: var SigInfo, z: pointer) {.noconv.} was changed to sa_sigaction*: proc (x: cint, y: ptr SigInfo, z: pointer) {.noconv.}.
  • The compiler doesn’t infer effects for .base methods anymore. This means you need to annotate them with .gcsafe or similar to clearly declare upfront every implementation needs to fulfill these contracts.
  • system.getAst templateCall(x, y) now typechecks the templateCall properly. You need to patch your code accordingly.
  • macros.getType and macros.getTypeImpl for an enum will now return an AST that is the same as what is used to define an enum. Previously the AST returned had a repeated EnumTy node and was missing the initial pragma node (which is currently empty for an enum).
  • macros.getTypeImpl now correctly returns the implementation for a symbol of type tyGenericBody.
  • If the dispatcher parameter’s value used in multi method is nil, a NilError exception is raised. The old behavior was that the method would be a nop then.
  • posix.nim: the family of ntohs procs now takes unsigned integers instead of signed integers.
  • In Nim identifiers en-dash (Unicode point U+2013) is not an alias for the underscore anymore. Use underscores instead.
  • When the requiresInit pragma is applied to a record type, future versions of Nim will also require you to initialize all the fields of the type during object construction. For now, only a warning will be produced.
  • The Object construction syntax now performs a number of additional safety checks. When fields within case objects are initialized, the compiler will now demand that the respective discriminator field has a matching known compile-time value.
  • On posix, the results of waitForExit, peekExitCode, execCmd will return 128 + signal number if the application terminates via signal.
  • ospaths.getConfigDir now conforms to the XDG Base Directory specification on non-Windows OSs. It returns the value of the XDG_CONFIG_DIR environment variable if it is set, and returns the default configuration directory, “~/.config/”, otherwise.
  • Renamed the line info node parameter for newNimNode procedure.
  • The parsing rules of do changed.

      foo bar do:
        baz
    

    Used to be parsed as:

      foo(bar(do:
        baz))
    

    Now it is parsed as:

      foo(bar, do:
        baz)
    

Library Additions

  • Added system.onThreadDestruction.

  • Added dial procedure to networking modules: net, asyncdispatch, asyncnet. It merges socket creation, address resolution, and connection into single step. When using dial, you don’t have to worry about the IPv4 vs IPv6 problem. httpclient now supports IPv6.

  • Added to macro which allows JSON to be unmarshalled into a type.

      import json
    
      type
        Person = object
          name: string
          age: int
    
      let data = """
        {
          "name": "Amy",
          "age": 4
        }
      """
    
      let node = parseJson(data)
      let obj = node.to(Person)
      echo(obj)
    

Tool Additions

  • The finish tool can now download MingW for you should it not find a working MingW installation.

Compiler Additions

  • The name mangling rules used by the C code generator changed. Most of the time local variables and parameters are not mangled at all anymore. This improves the debugging experience.
  • The compiler produces explicit name mangling files when --debugger:native is enabled. Debuggers can read these .ndi files in order to improve debugging Nim code.

Language Additions

  • The try statement’s except branches now support the binding of a caught exception to a variable:

        try:
          raise newException(Exception, "Hello World")
        except Exception as exc:
          echo(exc.msg)
    

    This replaces the getCurrentException and getCurrentExceptionMsg() procedures, although these procedures will remain in the stdlib for the foreseeable future. This new language feature is actually implemented using these procedures.

    In the near future we will be converting all exception types to refs to remove the need for the newException template.

  • A new pragma .used can be used for symbols to prevent the “declared but not used” warning. More details can be found here.
  • The popular “colon block of statements” syntax is now also supported for let and var statements and assignments:

      template ve(value, effect): untyped =
        effect
        value
    
      let x = ve(4):
        echo "welcome to Nim!"
    

    This is particularly useful for DSLs that help in tree construction.

Language changes

  • The .procvar annotation is not required anymore. That doesn’t mean you can pass system.$ to map just yet though.

Bugfixes

The list below has been generated based on the commits in Nim’s git repository. As such it lists only the issues which have been closed via a commit, for a full list see this link on Github.

  • Fixed “Weird compilation bug” (#4884)
  • Fixed “Return by arg optimization does not set result to default value” (#5098)
  • Fixed “upcoming asyncdispatch doesn’t remove recv callback if remote side closed socket” (#5128)
  • Fixed “compiler bug, executable writes into wrong memory” (#5218)
  • Fixed “Module aliasing fails when multiple modules have the same original name” (#5112)
  • Fixed “JS: var argument + case expr with arg = bad codegen” (#5244)
  • Fixed “compiler reject proc’s param shadowing inside template” (#5225)
  • Fixed “const value not accessible in proc” (#3434)
  • Fixed “Compilation regression 0.13.0 vs 0.16.0 in compile-time evaluation” (#5237)
  • Fixed “Regression: JS: wrong field-access codegen” (#5234)
  • Fixed “fixes #5234” (#5240)
  • Fixed “JS Codegen: duplicated fields in object constructor” (#5271)
  • Fixed “RFC: improving JavaScript FFI” (#4873)
  • Fixed “Wrong result type when using bitwise and” (#5216)
  • Fixed “upcoming.asyncdispatch is prone to memory leaks” (#5290)
  • Fixed “Using threadvars leads to crash on Windows when threads are created/destroyed” (#5301)
  • Fixed “Type inferring templates do not work with non-ref types.” (#4973)
  • Fixed “Nimble package list no longer works on lib.html” (#5318)
  • Fixed “Missing file name and line number in error message” (#4992)
  • Fixed “ref type can’t be converted to var parameter in VM” (#5327)
  • Fixed “nimweb ignores the value of –parallelBuild” (#5328)
  • Fixed “Cannot unregister/close AsyncEvent from within its handler” (#5331)
  • Fixed “name collision with template instanciated generic inline function with inlined iterator specialization used from different modules” (#5285)
  • Fixed “object in VM does not have value semantic” (#5269)
  • Fixed “Unstable tuple destructuring behavior in Nim VM” (#5221)
  • Fixed “nre module breaks os templates” (#4996)
  • Fixed “Cannot implement distinct seq with setLen” (#5090)
  • Fixed “await inside array/dict literal produces invalid code” (#5314)

  • Fixed “asyncdispatch.accept() can raise exception inside poll() instead of failing future on Windows” (#5279)
  • Fixed “VM: A crash report should be more informative” (#5352)
  • Fixed “IO routines are poor at handling errors” (#5349)
  • Fixed “new import syntax doesn’t work?” (#5185)
  • Fixed “Seq of object literals skips unmentioned fields” (#5339)
  • Fixed “sym is not accessible in compile time” (#5354)
  • Fixed “the matching is broken in re.nim” (#5382)
  • Fixed “development branch breaks in my c wrapper” (#5392)
  • Fixed “Bad codegen: toSeq + tuples + generics” (#5383)
  • Fixed “Bad codegen: toSeq + tuples + generics” (#5383)
  • Fixed “Codegen error when using container of containers” (#5402)
  • Fixed “sizeof(RangeType) is not available in static context” (#5399)
  • Fixed “Regression: ICE: expr: var not init ex_263713” (#5405)
  • Fixed “Stack trace is wrong when assignment operator fails with template” (#5400)
  • Fixed “SIGSEGV in compiler” (#5391)
  • Fixed “Compiler regression with struct member names” (#5404)
  • Fixed “Regression: compiler segfault” (#5419)
  • Fixed “The compilation of jester routes is broken on devel” (#5417)
  • Fixed “Non-generic return type produces “method is not a base”” (#5432)
  • Fixed “Confusing error behavior when calling slice[T].random” (#5430)
  • Fixed “Wrong method called” (#5439)
  • Fixed “Attempt to document the strscans.scansp macro” (#5154)
  • Fixed “[Regression] Invalid C code for _ symbol inside jester routes” (#5452)
  • Fixed “StdLib base64 encodeInternal crashes with out of bound exception” (#5457)
  • Fixed “Nim hangs forever in infinite loop in nre library” (#5444)

  • Fixed “Tester passes test although individual test in suite fails” (#5472)
  • Fixed “terminal.nim documentation” (#5483)
  • Fixed “Codegen error - expected identifier before ‘)’ token (probably regression)” (#5481)
  • Fixed “mixin not works inside generic proc generated by template” (#5478)
  • Fixed “var not init (converter + template + macro)” (#5467)
  • Fixed “== for OrderedTable should consider equal content but different size as equal.” (#5487)
  • Fixed “Fixed tests/tester.nim” (#45)
  • Fixed “template instanciation crashes compiler” (#5428)
  • Fixed “Internal compiler error in handleGenericInvocation” (#5167)
  • Fixed “compiler crash in forwarding template” (#5455)
  • Fixed “Doc query re public/private + suggestion re deprecated” (#5529)
  • Fixed “inheritance not work for generic object whose parent is parameterized” (#5264)
  • Fixed “weird inheritance rule restriction” (#5231)
  • Fixed “Enum with holes broken in JS” (#5062)
  • Fixed “enum type and aliased enum type inequality when tested with operator is involving template” (#5360)
  • Fixed “logging: problem with console logger caused by the latest changes in sysio” (#5546)
  • Fixed “Crash if proc and caller doesn’t define seq type - HEAD” (#4756)
  • Fixed “path config option doesn’t work when compilation is invoked from a different directory” (#5228)
  • Fixed “segfaults module doesn’t compile with C++ backend” (#5550)
  • Fixed “Improve joinThreads for windows” (#4972)
  • Fixed “Compiling in release mode prevents valid code execution.” (#5296)
  • Fixed “Forward declaration of generic procs or iterators doesn’t work” (#4104)
  • Fixed “cant create thread after join” (#4719)
  • Fixed “can’t compile with var name “near” and –threads:on” (#5598)
  • Fixed “inconsistent behavior when calling parent’s proc of generic object” (#5241)
  • Fixed “The problem with import order of asyncdispatch and unittest modules” (#5597)
  • Fixed “Generic code fails to compile in unexpected ways” (#976)
  • Fixed “Another ‘User defined type class’ issue” (#1128)
  • Fixed “compiler fails to compile user defined typeclass” (#1147)
  • Fixed “Type class membership testing doesn’t work on instances of generic object types” (#1570)
  • Fixed “Strange overload resolution behavior for procedures with typeclass arguments” (#1991)
  • Fixed “The same UDTC can’t constrain two type parameters in the same procedure” (#2018)
  • Fixed “More trait/concept issues” (#2423)
  • Fixed “Bugs with concepts?” (#2882)

  • Fixed “Improve error messages for concepts” (#3330)
  • Fixed “Dynamic dispatch is not working correctly” (#5599)
  • Fixed “asynchttpserver may consume unbounded memory reading headers” (#3847)
  • Fixed “nim check crash due to missing var keyword” (#5618)
  • Fixed “Unexpected template resolution” (#5625)
  • Fixed “Installer fails to download mingw.zip” (#5422)
  • Fixed “Exception name and parent get lost after reraising” (#5628)
  • Fixed “generic ref object typeRel problem” (#5621)
  • Fixed “typedesc typeRel regression” (#5632)
  • Fixed “http client respects only one “Set-Cookie” header” (#5611)
  • Fixed “Internal assert when using compiles” (#5638)
  • Fixed “Compiler crash for variant type.” (#4556)
  • Fixed “MultipartData in httpclient.Post appears to break header” (#5710)

  • Fixed “setCookie incorrect timestamp format” (#5718)
  • Fixed “[Regression] strdefine consts cannot be passed to a procvar” (#5729)
  • Fixed “Nim’s –nimblepaths picks 1.0 over #head” (#5752)
  • Fixed “Async writes are not queued up on Windows” (#5532)
  • Fixed “float32 literals are translated to double literals in C” (#5821)
  • Fixed “LibreSSL isn’t recognized as legit SSL library” (#4893)
  • Fixed “exception when using json “to” proc” (#5761)

Version 0.16.0 released

We’re happy to announce that the latest release of Nim, version 0.16.0, is now available!

As always, you can grab the latest version from the downloads page.

This release includes over 80 bug fixes and improvements. To see a full list of changes, take a look at the detailed changelog below.

Some of the most significant changes in this release include: a major new Nimble release, an improved import syntax, and the stabilisation of name mangling rules enabling faster compile times.

The new Nimble release that is included with Nim 0.16.0 includes a variety of new features and bug fixes. The most prominent of which is the improved output system, as shown in the figure below.

Nimble 0.8.0

For a full list of changes in Nimble, see its changelog.

The new import syntax makes it easier to import multiple modules from the same package or directory. For example:

import compiler/ast, compiler/parser, compiler/lexer
import compiler / [ast, parser, lexer]

The two are equivalent, but the new latter syntax is less redundant.

Finally, the code responsible for name mangling in the generated C and C++ code has been improved to reduce compile times. In particular, compile-time for the common edit-compile-run cycles have been reduced.

Changelog

Changes affecting backwards compatibility

  • staticExec now uses the directory of the nim file that contains the staticExec call as the current working directory.
  • TimeInfo.tzname has been removed from times module because it was broken. Because of this, the option "ZZZ" will no longer work in format strings for formatting and parsing.

Library Additions

  • Added new parameter to error proc of macro module to provide better error message
  • Added new deques module intended to replace queues. deques provides a superset of queues API with clear naming. queues module is now deprecated and will be removed in the future.

  • Added hideCursor, showCursor, terminalWidth, terminalWidthIoctl and terminalSize to the terminal (doc) module.

  • Added new module distros (doc) that can be used in Nimble packages to aid in supporting the OS’s native package managers.

Tool Additions

Compiler Additions

  • The C/C++ code generator has been rewritten to use stable name mangling rules. This means that compile times for edit-compile-run cycles are much reduced.

Language Additions

  • The emit pragma now takes a list of Nim expressions instead of a single string literal. This list can easily contain non-strings like template parameters. This means emit works out of the box with templates and no new quoting rules needed to be introduced. The old way with backtick quoting is still supported but will be deprecated.

    type Vector* {.importcpp: "std::vector", header: "<vector>".}[T] = object
    
    template `[]=`*[T](v: var Vector[T], key: int, val: T) =
      {.emit: [v, "[", key, "] = ", val, ";"].}
    
    proc setLen*[T](v: var Vector[T]; size: int) {.importcpp: "resize", nodecl.}
    proc `[]`*[T](v: var Vector[T], key: int): T {.importcpp: "(#[#])", nodecl.}
    
    proc main =
      var v: Vector[float]
      v.setLen 1
      v[0] = 6.0
      echo v[0]
    
  • The import statement now supports importing multiple modules from the same directory:

    import compiler / [ast, parser, lexer]
    

    Is a shortcut for:

    import compiler / ast, compiler / parser, compiler / lexer
    

Bugfixes

The list below has been generated based on the commits in Nim’s git repository. As such it lists only the issues which have been closed via a commit, for a full list see this link on Github.

  • Fixed “staticRead and staticExec have different working directories” (#4871)
  • Fixed “CountTable doesn’t support the ‘==’ operator” (#4901)
  • Fixed “documentation for module sequtls apply proc” (#4386)
  • Fixed “Operator == for CountTable does not work.” (#4946)
  • Fixed “sysFatal (IndexError) with parseUri and the / operator” (#4959)
  • Fixed “initialSize parameter does not work in OrderedTableRef” (#4940)
  • Fixed “error proc from macro library could have a node parameter” (#4915)
  • Fixed “Segfault when comparing OrderedTableRef with nil” (#4974)
  • Fixed “Bad codegen when comparing isNil results” (#4975)
  • Fixed “OrderedTable cannot delete entry with empty string or 0 key” (#5035)
  • Fixed “Deleting specific keys from ordered table leaves it in invalid state.” (#5057)
  • Fixed “Paths are converted to lowercase on Windows” (#5076)
  • Fixed “toTime(getGMTime(…)) doesn’t work correctly when local timezone is not UTC” (#5065)
  • Fixed “out of memory error from test= type proc call when parameter is a call to a table’s [] proc” (#5079)
  • Fixed “Incorrect field order in object construction” (#5055)
  • Fixed “Incorrect codegen when importing nre with C++ backend (commit 8494338)” (#5081)
  • Fixed “Templates, {.emit.}, and backtick interpolation do not work together” (#4730)
  • Fixed “Regression: getType fails in certain cases” (#5129)
  • Fixed “CreateThread doesn’t accept functions with generics” (#43)
  • Fixed “No instantiation information when template has error” (#4308)
  • Fixed “realloc leaks” (#4818)
  • Fixed “Regression: getType” (#5131)
  • Fixed “Code generation for generics broken by sighashes” (#5135)
  • Fixed “Regression: importc functions are not declared in generated C code” (#5136)
  • Fixed “Calling split(“”) on string hangs program” (#5119)
  • Fixed “Building dynamic library: undefined references (Linux)” (#4775)
  • Fixed “Bad codegen for distinct + importc - sighashes regression” (#5137)
  • Fixed “C++ codegen regression: memset called on a result variable of importcpp type” (#5140)
  • Fixed “C++ codegen regression: using channels leads to broken C++ code” (#5142)
  • Fixed “Ambiguous call when overloading var and non-var with generic type” (#4519)
  • Fixed “[Debian]: build.sh error: unknown processor: aarch64” (#2147)
  • Fixed “RFC: asyncdispatch.poll behaviour” (#5155)
  • Fixed “Can’t access enum members through alias (possible sighashes regression)” (#5148)
  • Fixed “Type, declared in generic proc body, leads to incorrect codegen (sighashes regression)” (#5147)
  • Fixed “Compiler SIGSEGV when mixing method and proc” (#5161)
  • Fixed “Compile-time SIGSEGV when declaring .importcpp method with return value “ (#3848)
  • Fixed “Variable declaration incorrectly parsed” (#2050)
  • Fixed “Invalid C code when naming a object member “linux”” (#5171)
  • Fixed “[Windows] MinGW within Nim install is missing libraries” (#2723)
  • Fixed “async: annoying warning for future.finished” (#4948)
  • Fixed “new import syntax doesn’t work?” (#5185)
  • Fixed “Fixes #1994” (#4874)
  • Fixed “Can’t tell return value of programs with staticExec” (#1994)
  • Fixed “startProcess() on Windows with poInteractive: Second call fails (“Alle Pipeinstanzen sind ausgelastet”)” (#5179)

Nim in Action is going into production!

I am very happy to say that just last week I have put the finishing touches on Nim in Action. The final manuscript has been submitted to Manning (the book's publisher), and the printed version is expected to start shipping in March 2017 (give or take 1 month).

Version 0.15.2 released

We’re happy to announce that the latest release of Nim, version 0.15.2, is now available!

As always, you can grab the latest version from the downloads page.

This release is a pure bugfix release fixing the most pressing issues and regressions of 0.15.0. For Windows we now provide zipfiles in addition to the NSIS based installer which proves to be hard to maintain and after all these months still has serious issues. So we encourage you download the .zip file instead of the .exe file! Unzip it somewhere, run finish.exe to detect your MingW installation, done. finish.exe can also set your PATH environment variable.

Bugfixes

The list below has been generated based on the commits in Nim’s git repository. As such it lists only the issues which have been closed via a commit, for a full list see this link on Github.

  • Fixed “NimMain not exported in DLL, but NimMainInner is” (#4840)
  • Fixed “Tables clear seems to be broken” (#4844)
  • Fixed “compiler: internal error” (#4845)
  • Fixed “trivial macro breaks type checking in the compiler” (#4608)
  • Fixed “derived generic types with static[T] breaks type checking in v0.15.0 (worked in v0.14.2)” (#4863)
  • Fixed “xmlparser.parseXml is not recognised as GC-safe” (#4899)
  • Fixed “async makes generics instantiate only once” (#4856)
  • Fixed “db_common docs aren’t generated” (#4895)
  • Fixed “rdstdin disappeared from documentation index” (#3755)
  • Fixed “ICE on template call resolution” (#4875)
  • Fixed “Invisible code-block” (#3078)
  • Fixed “nim doc does not generate doc comments correctly” (#4913)
  • Fixed “nim doc2 fails on ARM when running against lib/pure/coro.nim” (#4879)
  • Fixed “xmlparser does not unescape correctly” (#1518)
  • Fixed “[docs] mysterious “raise hook”” (#3485)
  • Fixed “assertion failure in non-release Nim when compiling NimYAML” (#4869)
  • Fixed “A closure causes nimscript to fail with unhandled exception” (#4906)
  • Fixed “startProcess changes working directory” (#4867)
  • Fixed “bindsym to void template produces ICE” (#4808)
  • Fixed “readline(TFile, var string) segfaults if second argument is nil” (#564)
  • Fixed “times.parse gives the wrong day of the week for the first hour of the day.” (#4922)
  • Fixed “Internal error when passing parameter proc inside .gcsafe closure” (#4927)
  • Fixed “Upcoming asyncdispatch doesn’t compile with C++ backend on OS X” (#4928)

Version 0.15.0 released

We’re happy to announce that the latest release of Nim, version 0.15.0, is now available!

As always, you can grab the latest version from the downloads page.

This release includes almost 180 bug fixes and improvements. To see a full list of changes, take a look at the detailed changelog below.

Some of the most significant changes in this release include: improvements to the documentation, addition of a new multisync macro, and a new HttpClient implementation.

Documentation

All pages in the documentation now contain a search box and a drop down to select how procedures should be sorted. This allows you to search for procedures, types, macros and more from any documentation page.

Doc search

Sorting the procedures by type shows a more natural table of contents. This should also help you to find procedures and other identifiers.

Doc sort

Multisync macro

The multisync macro was implemented to enable you to define both synchronous and asynchronous IO procedures without having to duplicate a lot of code.

As an example, consider the recvTwice procedure below:

proc recvTwice(socket: Socket | AsyncSocket): Future[string] {.multisync.} =
  result = ""
  result.add(await socket.recv(25))
  result.add(await socket.recv(20))

The multisync macro will transform this procedure into the following:

proc recvTwice(socket: Socket): string =
  result = ""
  result.add(socket.recv(25))
  result.add(socket.recv(20))

proc recvTwice(socket: AsyncSocket): Future[string] {.async.} =
  result = ""
  result.add(await socket.recv(25))
  result.add(await socket.recv(20))

Allowing you to use recvTwice with both synchronous and asynchronous sockets.

HttpClient

Many of the httpclient module’s procedures have been deprecated in favour of a new implementation using the multisync macro. There are now two types: HttpClient and AsyncHttpClient. Both of these implement the same procedures and functionality, the only difference is timeout support and whether they are blocking or not.

See the httpclient module documentation for more information.

Changelog

Changes affecting backwards compatibility

  • The json module now uses an OrderedTable rather than a Table for JSON objects.

  • The split (doc) procedure in the strutils module (with a delimiter of type set[char]) no longer strips and splits characters out of the target string by the entire set of characters. Instead, it now behaves in a similar fashion to split with string and char delimiters. Use splitWhitespace to get the old behaviour.

  • The command invocation syntax will soon apply to open brackets and curlies too. This means that code like a [i] will be interpreted as a([i]) and not as a[i] anymore. Likewise f (a, b) means that the tuple (a, b) is passed to f. The compiler produces a warning for a [i]::

    Warning: a [b] will be parsed as command syntax; spacing is deprecated

    See Issue #3898 for the relevant discussion.

  • Overloading the special operators ., .(), .=, () now needs to be enabled via the {.experimental.} pragma.

  • immediate templates and macros are now deprecated. Use untyped (doc) parameters instead.

  • The metatype expr is deprecated. Use untyped (doc) instead.

  • The metatype stmt is deprecated. Use typed (doc) instead.

  • The compiler is now more picky when it comes to tuple types. The following code used to compile, now it’s rejected:

    import tables
    var rocketaims = initOrderedTable[string, Table[tuple[k: int8, v: int8], int64]]()
    rocketaims["hi"] = {(-1.int8, 0.int8): 0.int64}.toTable()
    

    Instead be consistent in your tuple usage and use tuple names for named tuples:

    import tables
    var rocketaims = initOrderedTable[string, Table[tuple[k: int8, v: int8], int64]]()
    rocketaims["hi"] = {(k: -1.int8, v: 0.int8): 0.int64}.toTable()
    
  • Now when you compile console applications for Windows, console output encoding is automatically set to UTF-8.

  • Unhandled exceptions in JavaScript are now thrown regardless of whether noUnhandledHandler is defined. But the stack traces should be much more readable now.

  • In JavaScript, the system.alert procedure has been deprecated. Use dom.alert instead.

  • De-deprecated re.nim because there is too much code using it and it got the basic API right.

  • The type of headers field in the AsyncHttpClient type (doc) has been changed from a string table to the specialised HttpHeaders type.

  • The httpclient.request (doc) procedure which takes the httpMethod as a string value no longer requires it to be prefixed with "http" (or similar).

  • Converting a HttpMethod (doc) value to a string using the $ operator will give string values without the "Http" prefix now.

  • The Request (doc) object defined in the asynchttpserver module now uses the HttpMethod type for the request method.

Library Additions

  • Added readHeaderRow and rowEntry to the parsecsv (doc) module to provide a lightweight alternative to Python’s csv.DictReader.

  • Added setStdIoUnbuffered proc to the system module to enable unbuffered I/O.

  • Added center and rsplit to the strutils (doc) module to provide similar Python functionality for Nim’s strings.

  • Added isTitle, title, swapCase, isUpper, toUpper, isLower, toLower, isAlpha, isSpace, and capitalize to the unicode.nim (doc) module to provide unicode aware case manipulation and case testing.

  • Added a new module strmisc (doc) to hold uncommon string operations. Currently contains partition, rpartition and expandTabs.

  • Split out walkFiles in the os (doc) module to three separate procs in order to make a clear distinction of functionality. walkPattern iterates over both files and directories, while walkFiles now only iterates over files and walkDirs only iterates over directories.

  • Added a synchronous HttpClient in the httpclient (doc) module. The old get, post and similar procedures are now deprecated in favour of it.

  • Added a new macro called multisync allowing you to write procedures for synchronous and asynchronous sockets with no duplication.

  • The async macro will now complete FutureVar[T] parameters automatically unless they have been completed already.

Tool Additions

  • The documentation is now searchable and sortable by type.
  • Pragmas are now hidden by default in the documentation to reduce noise.
  • Edit links are now present in the documentation.

Compiler Additions

  • The -d/--define flag can now optionally take a value to be used by code at compile time. (doc)

Nimscript Additions

  • It’s possible to enable and disable specific hints and warnings in Nimscript via the warning and hint procedures.

  • Nimscript exports a proc named patchFile which can be used to patch modules or include files for different Nimble packages, including the stdlib package.

Language Additions

  • Added {.intdefine.} and {.strdefine.} macros to make use of (optional) compile time defines. (doc)

  • If the first statement is an import system statement then system is not imported implicitly anymore. This allows for code like import system except echo or from system import nil.

Bugfixes

The list below has been generated based on the commits in Nim’s git repository. As such it lists only the issues which have been closed via a commit, for a full list see this link on Github.

  • Fixed “RFC: should startsWith and endsWith work with characters?” (#4252)

  • Fixed “Feature request: unbuffered I/O” (#2146)
  • Fixed “clear() not implemented for CountTableRef” (#4325)
  • Fixed “Cannot close file opened async” (#4334)
  • Fixed “Feature Request: IDNA support” (#3045)
  • Fixed “Async: wrong behavior of boolean operations on futures” (#4333)
  • Fixed “os.walkFiles yields directories” (#4280)
  • Fixed “Fix #4392 and progress on #4170” (#4393)
  • Fixed “Await unable to wait futures from objects fields” (#4390)
  • Fixed “TMP variable name generation should be more stable” (#4364)
  • Fixed “nativesockets doesn’t compile for Android 4.x (API v19 or older) because of gethostbyaddr” (#4376)
  • Fixed “no generic parameters allowed for ref” (#4395)
  • Fixed “split proc in strutils inconsistent for set[char]” (#4305)
  • Fixed “Problem with sets in devel” (#4412)
  • Fixed “Compiler crash when using seq[PNimrodNode] in macros” (#537)
  • Fixed “ospaths should be marked for nimscript use only” (#4249)
  • Fixed “Repeated deepCopy() on a recursive data structure eventually crashes” (#4340)
  • Fixed “Analyzing destructor” (#4371)
  • Fixed “getType does not work anymore on a typedesc” (#4462)
  • Fixed “Error in rendering empty JSON array” (#4399)
  • Fixed “Segmentation fault when using async pragma on generic procs” (#2377)
  • Fixed “Forwarding does not work for generics, | produces an implicit generic” (#3055)
  • Fixed “Inside a macro, the length of the seq data inside a queue does not increase and crashes” (#4422)
  • Fixed “compiler sigsegv while processing varargs” (#4475)
  • Fixed “JS codegen - strings are assigned by reference” (#4471)
  • Fixed “when statement doesn’t verify syntax” (#4301)
  • Fixed “.this pragma doesn’t work with .async procs” (#4358)
  • Fixed “type foo = range(…) crashes compiler” (#4429)
  • Fixed “Compiler crash” (#2730)
  • Fixed “Crash in compiler with static[int]” (#3706)
  • Fixed “Bad error message “could not resolve”” (#3548)
  • Fixed “Roof operator on string in template crashes compiler (Error: unhandled exception: sons is not accessible [FieldError])” (#3545)
  • Fixed “SIGSEGV during compilation with parallel block” (#2758)
  • Fixed “Codegen error with template and implicit dereference” (#4478)
  • Fixed “@ in importcpp should work with no-argument functions” (#4496)
  • Fixed “Regression: findExe raises” (#4497)
  • Fixed “Linking error - repeated symbols when splitting into modules” (#4485)
  • Fixed “Error: method is not a base” (#4428)
  • Fixed “Casting from function returning a tuple fails” (#4345)
  • Fixed “clang error with default nil parameter” (#4328)
  • Fixed “internal compiler error: openArrayLoc” (#888)
  • Fixed “Can’t forward declare async procs” (#1970)
  • Fixed “unittest.check and sequtils.allIt do not work together” (#4494)
  • Fixed “httpclient package can’t make SSL requests over an HTTP proxy” (#4520)
  • Fixed “False positive warning “declared but not used” for enums.” (#4510)
  • Fixed “Explicit conversions not using converters” (#4432)

  • Fixed “Unclear error message when importing” (#4541)
  • Fixed “Change console encoding to UTF-8 by default” (#4417)

  • Fixed “Typedesc ~= Generic notation does not work anymore!” (#4534)
  • Fixed “unittest broken?” (#4555)
  • Fixed “Operator “or” in converter types seems to crash the compiler.” (#4537)
  • Fixed “nimscript failed to compile/run – Error: cannot ‘importc’ variable at compile time” (#4561)
  • Fixed “Regression: identifier expected, but found …” (#4564)
  • Fixed “varargs with transformation that takes var argument creates invalid c code” (#4545)
  • Fixed “Type mismatch when using empty tuple as generic parameter” (#4550)
  • Fixed “strscans” (#4562)
  • Fixed “getTypeImpl crashes (SIGSEGV) on variant types” (#4526)
  • Fixed “Wrong result of sort in VM” (#4065)
  • Fixed “I can’t call the randomT: T” (#4353)
  • Fixed “invalid C code generated (function + block + empty tuple)” (#4505)

  • Fixed “performance issue: const Table make a copy at runtime lookup.” (#4354)
  • Fixed “Compiler issue: libraries without absolute paths cannot be found correctly” (#4568)
  • Fixed “Cannot use math.^ with non-int types.” (#4574)
  • Fixed “C codegen fails when constructing an array using an object constructor.” (#4582)
  • Fixed “Visual Studio 10 unresolved external symbol _trunc(should we support VS2010?)” (#4532)
  • Fixed “Cannot pass generic subtypes to proc for generic supertype” (#4528)
  • Fixed “Lamda-lifting bug leading to crash.” (#4551)
  • Fixed “First-class iterators declared as inline are compiled at Nim side (no error message) and fail at C” (#2094)
  • Fixed “VS2010-warning C4090 : ‘function’ : different ‘const’ qualifiers” (#4590)
  • Fixed “Regression: type mismatch with generics” (#4589)
  • Fixed “„can raise an unlisted exception“ when assigning nil as default value” (#4593)
  • Fixed “upcoming asyncdispatch.closeSocket is not GC-safe” (#4606)
  • Fixed “Visual Studio 10.0 compiler errors, 12.0 warning” (#4459)
  • Fixed “Exception of net.newContext: result.extraInternalIndex == 0 [AssertionError]” (#4406)
  • Fixed “error: redeclaration of ‘result_115076’ with no linkage” (#3221)
  • Fixed “Compiler crashes on conversion from int to float at compile time” (#4619)
  • Fixed “wrong number of arguments regression in devel” (#4600)
  • Fixed “importc $ has broken error message (and is not documented)” (#4579)
  • Fixed “Compiler segfaults on simple importcpp in js mode [regression]” (#4632)
  • Fixed “Critical reference counting codegen problem” (#4653)
  • Fixed “tables.nim needs lots of {.noSideEffect.}” (#4254)
  • Fixed “Capture variable error when using => macro” (#4658)
  • Fixed “Enum from char: internal error getInt” (#3606)
  • Fixed “Compiler crashes in debug mode (no error in release mode) with Natural discriminant in object variants” (#2865)
  • Fixed “SIGSEGV when access field in const object variants” (#4253)
  • Fixed “varargs cannot be used with template converter.” (#4292)
  • Fixed “Compiler crashes when borrowing $” (#3928)
  • Fixed “internal error: genMagicExpr: mArrPut” (#4491)
  • Fixed “Unhelpful error message on importc namespace collision” (#4580)
  • Fixed “Problem with openarrays and slices” (#4179)
  • Fixed “Removing lines from end of file then rebuilding does not rebuild [js only?]” (#4656)
  • Fixed “getCurrentException and getCurrentExceptionMsg do not work with JS” (#4635)
  • Fixed “generic proc parameter is not inferred if type parameter has specifier” (#4672)
  • Fixed “Cannot instantiate generic parameter when it is parent type parameter” (#4673)
  • Fixed “deepCopy doesn’t work with inheritance after last commit” (#4693)
  • Fixed “Multi-methods don’t work when passing ref to a different thread” (#4689)
  • Fixed “Infinite loop in effect analysis on generics” (#4677)
  • Fixed “SIGSEGV when compiling NimYAML tests” (#4699)

  • Fixed “Closing AsyncEvent now also unregisters it on non-Windows platforms” (#4694)
  • Fixed “Don’t update handle in upcoming/asyncdispatch poll() if it was closed” (#4697)
  • Fixed “generated local variables declared outside block” (#4721)
  • Fixed “Footer Documentation links, & Community link point to the wrong place under news entries” (#4529)
  • Fixed “Jester’s macro magic leads to incorrect C generation” (#4088)
  • Fixed “cas bug in atomics.nim” (#3279)
  • Fixed “nimgrep PEG not capturing the pattern ‘A’” (#4751)
  • Fixed “GC assert triggers when assigning TableRef threadvar” (#4640)
  • Fixed “.this pragma conflicts with experimental ptr dereferencing when names conflict” (#4671)
  • Fixed “Generic procs accepting var .importcpp type do not work [regression]” (#4625)
  • Fixed “C Error on tuple assignment with array” (#4626)
  • Fixed “module securehash not gcsafe” (#4760)

  • Fixed “Nimble installation failed on Windows x86.” (#4764)
  • Fixed “Recent changes to marshal module break old marshalled data” (#4779)
  • Fixed “tnewasyncudp.nim test loops forever” (#4777)
  • Fixed “Wrong poll timeout behavior in asyncdispatch” (#4262)
  • Fixed “Standalone await shouldn’t read future” (#4170)
  • Fixed “Regression: httpclient fails to compile without -d:ssl” (#4797)
  • Fixed “C Error on declaring array of heritable objects with bitfields” (#3567)
  • Fixed “Corruption when using Channels and Threads” (#4776)
  • Fixed “Sometimes Channel tryRecv() erroneously reports no messages available on the first call on Windows” (#4746)
  • Fixed “Improve error message of functions called without parenthesis” (#4813)
  • Fixed “Docgen doesn’t find doc comments in macro generated procs” (#4803)
  • Fixed “asynchttpserver may consume unbounded memory reading headers” (#3847)
  • Fixed “TLS connection to api.clashofclans.com hangs forever.” (#4587)

Nim Community Survey Results

We have recently closed the 2016 Nim Community Survey. I am happy to say that we have received exactly 790 responses, huge thanks go to the people that took the time to respond. We’re incredibly thankful for this very valuable feedback.

This survey was inspired in part by the 2016 State of Rust survey. You will note that many of the questions were modelled after Rust’s survey. One of the reasons for doing this was to allow us to easily compare our results against the results obtained in the Rust survey. In addition, we of course also liked many of their questions.

Our survey ran from the 23rd of June 2016 until the 8th of August 2016. The response numbers are impressive considering Nim’s community size; at 790 they make up just over 25% of the Rust survey’s responses.

The goal of this survey was to primarily determine how our community is using Nim, in order to better understand how we should be improving it. In particular, we wanted to know what people feel is missing from Nim in the lead up to version 1.0. We have also asked our respondents about how well the Nim tools worked, the challenges of adopting Nim, the resources that they used to learn Nim and more.

It is my hope that we will be able to run a similar survey in a years time, doing so should give us an idea of whether we are improving. With these general facts in mind, let’s begin looking at specific questions.

How did you find out about Nim?

The rationale for the first question was simple, we wanted to know where our respondents found out about Nim. This is an interesting question for us, as we do occasionally get users asking us why it took so long for them to hear about Nim. It allows us to see how effective each website is at spreading the word about Nim.

How did you find out about Nim?

The majority of our respondents found Nim via Reddit, HackerNews or a search engine such as Google. These results are not altogether surprising. There were also a lot of “Other” responses, some of which were a bit more interesting. These included multiple mentions of habrahabr.ru, Dr. Dobb’s, and lobste.rs.

Do you use Nim?

Just like the Rust survey creators, we wanted to ensure that our survey was open to both Nim users as well people who never used Nim. In addition to those two groups, we have also included a third group of people: ex-Nim users. All three are interesting, for many different reasons. Nim users can tell us how they are using Nim and also how Nim’s tooling can improve. Ex-Nim users give us an idea of why they stopped using Nim. Finally, respondents who never used Nim can tell us the reasons for not adopting it.

Do you use Nim?

It’s nice to see that we have such a good range of respondents. The Rust survey had a much larger number of Rust users amongst their respondents, with no distinction between users that never used Rust and users that stopped using Rust.

Should we consider your answers to be invalid?

This was something I thought would be interesting to have, after I saw it being used in another survey. While it does pinpoint possibly invalid respondents, I have opted against filtering those out. Mainly because that would require re-creating each of the charts generated by Google Forms manually.

Should we consider your answers to be invalid?

According to the responses to this question, around 94% of our responses can be considered reliable.

Nim users

The following questions were answered only by the 38.9% of our respondents who identified themselves as Nim users.

How long have you been using Nim?

How long have you been using Nim?

A large proportion of our Nim users were new. This is good news as it means that our community is growing, with a large proportion of new Nim users that could become long-term Nimians. In total, more than 35% of Nim users can be considered new having used Nim for less than 3 months. With 18% of Nim users that can be considered very new having used Nim for less than a month. This could suggest that 18% of our users have only just found out about Nim in the last week or so and have not yet got the chance to use it extensively.

The high percentages of long term Nim users are encouraging. They suggest that many users are continuing to use Nim after making it through the first few months. The sharp drop at 7-9 months is interesting, but may simply be due to the fact that there were fewer newcomers during that period, or it could be because our respondents are more likely to estimate that they have been using Nim for a year or half a year rather than the awkward 7-9 months.

Time using Nim and Rust

The results for Nim and Rust are actually remarkably similar. They both show a drop at 7-9 months, although Rust’s isn’t as dramatic. Nim on the other hand has a significantly higher percentage of new Nim users.

Do you use Nim at work?

An important aspect of a language’s adoption is whether it is being used for “real” work. We wanted to know how many people are using Nim in their day jobs and under what circumstances it is used.

Do you use Nim at work?

While a vast majority of our users are not using Nim at work, more than 25% of them are. It’s encouraging to see such a high number already, even before we have released version 1.0. In fact, this percentage is likely close to 30%, because many of the “Other” responses mention using Nim for the likes of internal tools or small scripts to help with the respondent’s work.

Do you use Rust at work?

Interestingly, a larger percentage of Nim users are using Nim at work than Rust users. The sample sizes are of course vastly different, but it’s still an interesting result. Combined, nearly 1/5th of Rust users are using Rust commercially whereas more than a quarter of Nim users are using Nim commercially.

Approximately how large are all the Nim projects that you work on?

Finding out how large the Nim projects worked on by Nim users are is also very valuable.

Nim project size for all users

This shows us that currently Nim is primarily being used for small scripts and applications, with nearly 60% of the projects consisting of less than 1,000 lines of code. This makes sense as many of our users are not using Nim professionally, but are doing so in their spare time.

Nim project size for work users

The numbers for part-time and full-time work users of Nim tell a different story. Over 70% of the projects written by full-time users are between 10,001 and 100,000 lines of code. Part-time users show a slightly different trend, with many more small projects, the majority being between 1,000 and 10,000 lines of code.

Overall it’s good to see that there is a few large projects out there which are composed of more than 100,000 lines of code. We expect to see the amount of large projects to grow with time, especially with version 1.0 on the way.

Nim project size for work users (Nim vs. Rust)

In comparison to Rust the proportion of project sizes for full-time users is vastly different. This is likely due to our small sample size. Project sizes for part-time users between Rust and Nim are somewhat similar, with differences of around 10% for each project size.

Do you plan to try to use Nim at work?

Planning to use Nim at work?

It’s also encouraging to see that over 50% of Nim users are planning to use Nim at work! This is slightly more than Rust’s 40% and should help Nim’s adoption into even more areas.

Nim and its tools

In this section of the survey, we wanted to find out the tools that Nim users are utilising when developing Nim applications.

What editor(s) do you use when writing Nim?

Programmers are very specific when it comes to their editor of choice, because of that it’s good to know which editor is most popular among our community.

Editors used by Nim users

Looks like Vim is the winner with almost 30%. Followed by Sublime Text and Emacs. Aporia, the Nim IDE, gets a respectable 15.5%. There was also more than 17% of answers which included “Other” editors, such as: Notepad++, Geany, gedit, and Kate.

What operating system(s) do you compile for and run your Nim projects on?

This question gave us information about the most popular target operating systems, as well as some of the more obscure ones. We have asked this question to find out the platforms on which Nim applications run on most frequently.

Target operating systems

This question allowed multiple choices, so each percentage is out of the total number of respondents for this question. For example, 80.7% of the respondents selected “Linux” but only 26.6% selected OS X.

This makes Linux by far the most popular target for Nim applications. Some “Other” targets included: BSD (OpenBSD, FreeBSD), iOS, Android, and JavaScript. It’s great to see Nim being used on such a wide variety of platforms.

What operating system(s) do you develop Nim projects on?

With this question, we wanted to know what operating systems are used for development.

Development operating systems

This question also allowed multiple choices and ended up with very similar results.

You can see that Linux is also the most popular developmental platform for Nim. But it’s more popular as a target platform.

Which version(s) of Nim do you use for your applications?

Version use

At the time of this survey, version 0.14.2 was the latest stable release. It’s no wonder that it is the most commonly used release of Nim. It’s good to see that the older versions are not used as often. The high use of Git HEAD (devel) (nightly builds) isn’t surprising, Nim is still evolving rapidly and our release schedule is not regular or frequent.

Once we go past the 1.0 release, we expect to see much less use of the unstable devel branch.

Has upgrading to a new version of the Nim compiler broken your code?

Breakage

Despite the unstable nature of Nim in the lead up to version 1.0, whenever we make breaking changes we do our best to deprecate things and ensure that old code continues to work for our users. Of course sometimes this is not possible and other times it is simply easier to add a breaking change.

This question was asked to determine how much our user base is affected by breaking changes between Nim versions. We decided to have three possible answers for this question in order to give us an idea how frequent the breakage was.

It’s incredible to see that over 50% of our users have not experienced any breakage after upgrading. We expect this number to increase significantly after version 1.0 is released. Of the users that did experience breakage, over 80% of them said that it was a rare occurrence.

In comparison to Rust, our results show that there was a higher percentage of users experiencing breakage as a result of an upgrade. This is to be expected, because Nim is still in its pre-1.0 period, whereas Rust 1.0 has been released over a year ago now.

Unfortunately while we are still in this pre-1.0 period, releases will likely introduce breaking changes as we refine certain aspects of Nim such as its standard library, so the number of users experiencing breaking changes may increase.

If so, how much work did it take to fix it?

difficulty fixing breakage

Thankfully most of the breakage experienced by Nim users was very easy to fix.

If you used Nimble, do you like it?

Do you like Nimble?

Nimble is the Nim package manager, a tool that is very important in Nim’s ecosystem as it allows developers to easily install dependencies for their software.

The majority of respondents rated it as a 4, showing us that the majority does like Nimble. With over 55% rating it a 4 or 5. This percentage isn’t as overwhelming as the 94.1% of users that rated Cargo a 4 or 5 in the Rust survey. Based on these results I think that we definitely need to do a better job with Nimble.

In our next survey, it might be a good idea to ask more questions about Nimble to determine how exactly it can be improved.

What aspects of Nim do you find most appealing?

What aspects of Nim do you find most appealing?

We were interested to know the features of Nim that appeal most to our users. More than 80% of our respondents selected “Execution Speed” as one of the features that appeal to them. With “Development Speed” and “Readability” tying for second place and “Metaprogramming” at third place.

The options given to our respondents are rather predictable, they do show us which of these features have the highest appeal though. What’s more interesting are the “Other” answers.

By far the most popular “Other” answer was related to Nim’s compilation to C. Many users mentioned that they like how easy it is to interface with C libraries and the great portability that compiling to C offers.

What aspects of Nim do you find most displeasing?

What aspects of Nim do you find most displeasing?

It was only natural to ask this question. The results are almost perfectly opposite to the previous question’s answers, with almost 50% of respondents selecting “Debugging Tools” as the most displeasing aspect of Nim. With “Documentation” and “Testing Tools” in second and third place respectively. There is also a much larger number of “Other” answers to this question.

The “Other” answers for this question vary a lot. Here is a selection of them, ordered by frequency:

  • Small community size.
  • Lack of in-depth tutorials.
  • Quality of error messages.
  • Forward declarations and no cyclic imports.
  • Bugs in the standard library.
  • No good IDE.
  • No REPL.
  • No major version.
  • Bugs in the compiler.
  • Lack of libraries.
  • Difficulty installing on Windows.
  • Non-intuitive semantics of various constructs.
  • Lack of immutable collections.
  • Async/await not being production ready.
  • Lack of shared collections for threads.
  • No Haxe target.
  • Memory safety.

We hope that we can improve these things with time. Many of these issues are already being worked on, including the removal of the need for forward declarations. Some of these issues like our small community size are difficult to fix, but we will nonetheless do our best.

Previous Nim users

For users that have used Nim before but decided against using it, we asked just one specific question. The proportion of our respondents that answered it was 24%.

Why did you stop using Nim?

I stopped using Nim because...

Again, this question got a lot of “Other” answers. Apart from that, the most popular reason for leaving Nim is that it is not stable. Followed by the a lack of needed libraries and packages and the instability of the standard library.

  • Lack of IDE support.
  • Style insensitive.
  • Documentation.
  • Dislike the syntax.
  • Community is too small.
  • Missing language features (for example RAII).
  • No opportunities to use it at work.
  • Messy standard library.

The first item, “Lack of IDE support”, was mentioned by multiple respondents. In the future we should look into ensuring that major IDEs have plugins which enable easy Nim development.

Based on some of the “Other” answers, it seems that many of the respondents have not used Nim for very long, for example many respondents complained about installation issues which they would have run into before getting a chance to use Nim. Because of this I would consider them not ex-Nim users but developers that have not had a chance to try Nim fully. Next time we should also ask how long the respondent has used Nim for to get a better idea of whether they had a chance to use Nim for extended periods of time.

Non-Nim users

We also wanted to know the reasons why developers decided against using Nim.

Why do you not use Nim?

I don't use Nim because...

The most common reason that people have for not using Nim is that it is not yet ready for production. Thankfully this will improve with time. IDE support is also a prominent factor just as we’ve seen in previous results.

There is also a lot of “Other” answers, let’s have a look at a selection of them. Some of the most prominent ones, in order of frequency, include:

  • No time to use/learn it
  • Syntax
  • Documentation is incomplete
  • Garbage Collection
  • Prefer functional paradigm
  • Small community
  • Style insensitivity/Case insensitivity

One respondent made a very good suggestion: they said that the “Do you use Nim?” question should have included “No, but I intend to” as an answer. Definitely something we will do in the next survey. Indeed, many respondents mentioned that they were planning on trying out Nim but that they just have no time to do so, this is very encouraging!

Learning Resources

We wanted to get an idea of how Nim users are learning Nim. Every respondent answered this question, no matter what they answered for the “Do you use Nim?” question.

Which learning resources, if any, did you use to learn Nim?

learning resources

The idea behind this question was to understand which learning resources were most popular among our user base. The Nim tutorial is by far the most popular. In previous questions, we saw respondents mentioning that the Nim tutorial does not go into enough detail about Nim. Thanks to this information we can come to the conclusion that the tutorial needs to be improved significantly to make sure that it gives our users the necessary information to use Nim effectively.

Indeed, many users also use the Nim manual to learn Nim. This manual has been written as a specification and so is not ideal for teaching Nim. Many of the concepts in the Nim manual need to be explained in a lot more detail in the Nim tutorial.

Of course, it’s exciting to see our respondents using other materials to learn Nim. In particular I am excited to see that over 15% of the respondents have used Nim in Action to learn Nim. I expect that more and more users will pick up the book after it is fully published.

Nim in Action

As the author of Nim in Action, I wanted to get some statistics surrounding my book. With this in mind, I have created some questions relating to it.

Have you read Nim in Action?

Have you read Nim in Action?

It’s good to see that over 50% of respondents have read the book or are at least planning to read it. Keep in mind that this question was answered by all respondents, not just Nim users.

.. container:: standout

Are you interested in purchasing a copy of Nim in Action? If so, you can use code wm090416lt to get 50% off the printed book today only! If you purchase it now you will get access to an early access copy of Nim in Action in eBook form and will be able to take part in the development of this book.

Did you enjoy Nim in Action?

Did you enjoy Nim in Action?

Of the people that read Nim in Action it’s nice to see that almost 70% have enjoyed it.

Nim’s future

What improvements are needed before Nim v1.0 can be released?

We were interested to know what our users believe is needed before Nim version 1.0 can be released.

What is needed before 1.0 can be released?

It appears that the standard library is the biggest concern. With more than half of all respondents selecting “The standard library needs to reviewed and any problems with it fixed”. This is in fact something we are already planning to address, so it’s good to see that the majority agrees with us.

A large proportion of users also believes that the language is great as-is and that we should focus on stabilising the compiler. This somewhat contradicts the majority. But perhaps most of them thought that “The language” excludes the standard library.

For this question, we decided to give our respondents a dedicated place to give general feedback about what they feel is needed before v1.0 can be released. We received over 200 responses to that. Many of these responses reflect what we have already seen: that the documentation needs to improve, that we need a good Nim IDE, stability for experimental features such as concepts, the standard library needs to be cleaned up.

Unfortunately many respondents used this question to say what needs to be fixed in Nim in general, not what is definitely necessary before 1.0 can be released.

Community demographics

What domain do you work in currently?

Work domains

Nim users are working in a wide variety of domains. It is encouraging to see people from so many different backgrounds taking part in this survey.

What programming languages are you most comfortable with?

Programming languages

Python and C are the top two programming languages that our respondents are most comfortable with. This is not altogether surprising.

Last words

At the end of the survey we gave our respondents a chance to speak their mind about anything they wish, with a simple question: “Anything else you’d like to tell us?”

There was a lot of great feedback given in this question from people who obviously really care deeply about Nim. There is too much to outline here, but rest assurred that we will take it all into account and do our best to act on it.

In addition to feedback, we were also overwhelmed by the amount of positive comments in the answers to this question. There was a lot of support from the community thanking us for our work and determination.

I’ll let some quotes speak for themselves:

You rock, seriously.
Nim rocks! Keep it up! Thank you very much!
You've made great progress on the language without any corporate backing, that is amazing. I wish Nim becomes one of the top used languages in a few years.
Nim is elegant and wonderful! Keep at it!

Our community is truly brilliant. We thank each and every one of you for filling out this survey and hope that you will help us tackle some of the challenges that face Nim.

This survey was a good place to give us feedback, but please don’t wait for the next one. We are always looking to hear more from you and we hope that you will participate in discussions relating to this survey as well the future of Nim.

Thanks for reading, and have a good day!


BountySource Update: The Road to v1.0

This was cross-posted from update #4 on BountySource.

We are now in the fourth month of the Nim BountySource fundraiser and here is this month’s update[1]. Once again this month, we have beat our previous donation record of $1280 having raised over $1600 over the course of July! That’s now 4 months in a row that your monthly donations have been increasing. As always we are absolutely blown away by your contributions, myself and the rest of the Nim team are extremely thankful for them. It’s not only helping us pay for the necessary expenses (like for example the server that http://nim-lang.org runs on) but it also inspires us to keep going and to make Nim the best programming language that it can be.

As mentioned in last month’s update, we have begun the process of engaging with the Nim community through a survey. This survey has now been open for more than a month and will be closing very soon (in about 2 days), so if you haven’t answered it yet, now would be a perfect time to do so. You can find the survey here: http://nim-lang.org/survey.

The survey itself has been designed for three types of people: Nim users, ex-Nim users and people who have never used Nim before. This means that you have no excuse not to answer it[2]. There are almost 700 submissions and after the survey is finalised, a blog post will be written with a thorough analysis.

It is my hope that the survey analysis will give the Nim team a good idea of what needs to be implemented before version 1.0 can be released. Personally, I hope to make a thorough review of the standard library to ensure that it is ready for the “1.0 backwards compatibility lock”[3]. Although I myself have been very busy lately[4], Araq has been working very hard to fix High Priority issues, ahead of the 1.0 release. And as always, there has also been a lot of pull requests from a wide range of Nim users.

Lastly, I would like to mention Nim in Action once again. I have recently finished the final chapter. All that remains now are corrections (based mainly on your feedback, huge thanks to everyone for reading!) and a final review. The book will then be put into production[5] with an estimated print date of around the 20th of January (as usual delays are very much possible). If you have not yet picked up the book, now would be a perfect time to do so. There is still time for you to give feedback about the book, and for me to improve it based on your remarks. It is not often that you can influence a book in this way, and it is my hope that you will help me make this book one of the best resources for learning Nim!

As always, many thanks for reading and if you have any questions or feedback feel free to get in touch via email at [email protected] or via Twitter.

1 - These updates have so far been fairly regular and it is my hope to write at least one a month. Yep, I am patting myself on the back :)

2 - I joke of course, don’t worry about if you don’t have the time :)

3 - After version 1.0, it is typical for a piece of software (especially a programming language) to ensure that backwards compatibility is not broken between further minor versions until a new major version such as 2.0 is released.

4 - Writing a book, moving to Switzerland to start a new job, and playing Pokemon Go has certainly kept me busy.

5 - Basically the brilliant guys at Manning will process the book so that it looks good in a printed format.


Launching the 2016 Nim Community Survey

We are proud to announce the official 2016 Nim Community Survey! No matter whether you use Nim today, have used Nim previously, or never used Nim before; we want to know your opinions. Your feedback will help the Nim project understand its strengths and weaknesses, and to determine development priorities for the future.

It shouldn’t take you much longer than 5 to 10 minutes to complete this survey. Submissions will be accepted until around the 23rd of July, depending on the response rates. If you have any questions or feedback, please don’t hesitate to get in touch with us via email at [email protected] or on the Nim Forum.

We would appreciate your help in spreading the word about this survey. Share the above link on your social network feeds, with your colleagues and in other communities.

Thank you to everyone that helped develop and test the survey! Once the submission period ends, the results will be shown here and publicised via Twitter, the Nim Forum and IRC.

Thanks for your time!


Version 0.14.2 released

Version 0.14.2 is just a bugfix release that fixes the most pressing regressions. In particular, the tar.xz now supports documentation generation, and the Windows installers bundle the latest stable nimble release.

The news about the 0.14.0 release are still relevant, so check them out here.


Version 0.14.0 released

It’s been a while since the last release, but we’ve been very busy in the meantime. In addition to working on Nim we have started a BountySource campaign and announced the pre-release of a new Nim book titled Nim in Action. Our BountySource campaign has already been very successful, helping us raise enough funds to surpass 4 of our monthly goals. The companies and individuals that made this possible are listed on our brand new sponsors page.

This release includes over 260 bug fixes. As mentioned in the previous release announcement, one of the focuses of this release was going to be improvements to the GC. Indeed, the most prominent fixes are related to the GC not collecting cycles properly. This was a major problem that was triggered typically when applications using asynchronous I/O were left running for long periods of time.

There have also been many fixes to the way that the compiler sources are installed. Some applications such as Nimble depend on these sources and they are now included in the release tarballs. This should fix many of the problems that users experienced trying to compile the Nimble package manager.

Finally, you will find multiple changes in the standard library. Some of which unfortunately affects backwards compatibility. This includes the random procedures being moved to a new random module, HTTP headers being stored in a new HttpHeaders object and the round procedure in the math module being changed to return a float instead of an int. You can find a full list of such changes below.

Together with the new release of Nim, we are also releasing a new version of Nimble. The release notes for it are available on GitHub.

As always you can download the latest version of Nim from the download page.

We hope that you will like this new release. Let us know if you run into any trouble, have any questions or want to give some feedback. You can get in touch with us on the Forum, IRC, Twitter, or via email [email protected].

Happy coding!

Changes affecting backwards compatibility

  • --out and --nimcache command line arguments are now relative to current directory. Previously they were relative to project directory.
  • The json module now stores the name/value pairs in objects internally as a hash table of type fields*: Table[string, JsonNode] instead of a sequence. This means that order is no longer preserved. When using the table.mpairs iterator only the returned values can be modified, no longer the keys.
  • The deprecated Nim shebang notation #! was removed from the language. Use #? instead.
  • Typeless parameters have been removed from the language since it would clash with using.
  • Procedures in mersenne.nim (Mersenne Twister implementation) no longer accept and produce int values which have platform-dependent size - they use uint32 instead.
  • The strutils.unindent procedure has been rewritten. Its parameters now match the parameters of strutils.indent. See issue #4037. for more details.
  • The matchers module has been deprecated. See issue #2446 for more details.
  • The json.[] no longer returns nil when a key is not found. Instead it raises a KeyError exception. You can compile with the -d:nimJsonGet flag to get a list of usages of [], as well as to restore the operator’s previous behaviour.
  • When using useMalloc, an additional header containing the size of the allocation will be allocated, to support zeroing memory on realloc as expected by the language. With this change, alloc and dealloc are no longer aliases for malloc and free - use c_malloc and c_free if you need that.
  • The json.% operator is now overloaded for object, ref object and openarray[T].
  • The procs related to random number generation in math.nim have been moved to its own random module and been reimplemented in pure Nim.
  • The path handling changed. The project directory is not added to the search path automatically anymore. Add this line to your project’s config to get back the old behaviour: --path:"$projectdir". (The compiler replaces $projectdir with your project’s absolute directory when compiling, so you don’t need to replace $projectdir by your project’s actual directory!). See issue #546 and this forum thread for more information.
  • The round function in math.nim now returns a float and has been corrected such that the C implementation always rounds up from .5 rather than changing the operation for even and odd numbers.
  • The round function now accepts a places argument to round to a given number of places (e.g. round 4.35 to 4.4 if places is 1).
  • In strutils.nim, formatSize now returns a number representing the size in conventional decimal format (e.g. 2.234GB meaning 2.234 GB rather than meaning 2.285 GB as in the previous implementation). By default it also uses IEC prefixes (KiB, MiB) etc and optionally uses colloquial names (kB, MB etc) and the (SI-preferred) space.
  • The == operator for cstring now implements a value comparison for the C backend (using strcmp), not reference comparisons anymore. Convert the cstrings to pointers if you really want reference equality for speed.
  • HTTP headers are now stored in a HttpHeaders object instead of a StringTableRef. This object allows multiple values to be associated with a single key. A new httpcore module implements it and it is used by both asynchttpserver and httpclient.

The using statement

The using statement now has a different meaning.

In version 0.13.0, it was used to provide syntactic convenience for procedures that heavily use a single contextual parameter. For example:

var socket = newSocket()
using socket

connect("google.com", Port(80))
send("GET / HTTP/1.1\c\l")

The connect and send calls are both transformed so that they pass socket as the first argument:

var socket = newSocket()

socket.connect("google.com", Port(80))
socket.send("GET / HTTP/1.1\c\l")

Take a look at the old version of the manual to learn more about the old behaviour.

In 0.14.0, the using statement instead provides a syntactic convenience for procedure definitions where the same parameter names and types are used repeatedly. For example, instead of writing:

proc foo(c: Context; n: Node) = ...
proc bar(c: Context; n: Node, counter: int) = ...
proc baz(c: Context; n: Node) = ...

You can simply write:

{.experimental.}
using
  c: Context
  n: Node
  counter: int

proc foo(c, n) = ...
proc bar(c, n, counter) = ...
proc baz(c, n) = ...

Again, the manual has more details.

You can still achieve a similar effect to what the old using statement tried to achieve by using the new experimental this pragma, documented here.

Generic type classes

Generic type classes are now handled properly in the compiler, but this means code like the following does not compile any longer:

type
  Vec3[T] = distinct array[3, T]

proc vec3*[T](a, b, c: T): Vec3[T] = Vec3([a, b, c])

While every Vec3[T] is part of the Vec3 type class, the reverse is not true, not every Vec3 is a Vec3[T]. Otherwise there would be a subtype relation between Vec3[int] and Vec3[float] and there is none for Nim. The fix is to write this instead:

type
  Vec3[T] = distinct array[3, T]

proc vec3*[T](a, b, c: T): Vec3[T] = Vec3[T]([a, b, c])

Note that in general we don’t advise to use distinct array, use object instead.

Library Additions

  • The rlocks module has been added providing a reentrant lock synchronization primitive.
  • A generic “sink operator” written as &= has been added to the system and the net modules. This operator is similar to the C++ << operator which writes data to a stream.
  • Added strscans module that implements a scanf for easy input extraction.
  • Added a version of parseutils.parseUntil that can deal with a string until token. The other versions are for char and set[char].
  • Added splitDecimal to math.nim to split a floating point value into an integer part and a floating part (in the range -1<x<1).
  • Added trimZeros to strutils.nim to trim trailing zeros in a floating point number.
  • Added formatEng to strutils.nim to format numbers using engineering notation.

Compiler Additions

  • Added a new --noCppExceptions switch that allows to use default exception handling (no throw or try/catch generated) when compiling to C++ code.

Language Additions

  • Nim now supports a .this pragma for more notational convenience. See automatic-self-insertions for more information.
  • Nim now supports a different using statement for more convenience. Consult using-statement for more information.
  • include statements are not restricted to top level statements anymore.

..

  • Nim now supports partial object declarations to mitigate the problems that arise when types are mutually dependent and yet should be kept in different modules.

Bugfixes

The list below has been generated based on the commits in Nim’s git repository. As such it lists only the issues which have been closed via a commit, for a full list see this link on Github.

  • Fixed “Calling generic templates with explicit generic arguments crashes compiler” (#3496)
  • Fixed “JS backend - strange utf-8 handling” (#3714)
  • Fixed “execvpe is glibc specific” (#3759)
  • Fixed “GC stack overflow with in data structures with circular references.” (#1895)
  • Fixed “Internal compiler error in genTraverseProc” (#3794)
  • Fixed “unsafeAddr fails in generic context” (#3736)
  • Fixed “Generic converters produce internal errors” (#3799)
  • Fixed “Cannot have two anonymous iterators in one proc” (#3788)
  • Fixed “pure/net.nim fails to compile with –taintMode:on on HEAD” (#3789)
  • Fixed “Using break inside iterator may produce memory/resource leak” (#3802)

  • Fixed “–out and –nimcache wrong paths” (#3871)
  • Fixed “Release 0.13.0: documentation build failure” (#3823)
  • Fixed “https post request” (#3895)
  • Fixed “writeFile regression in nimscript” (#3901)
  • Fixed “Cannot convert variables to int16 at compile time” (#3916)
  • Fixed “Error in concepts when using functions on typedesc” (#3686)
  • Fixed “Multiple generic table types with different type signatures lead to compilation errors.” (#3669)
  • Fixed “Explicit arguments with overloaded procedure?” (#3836)
  • Fixed “doc2 generates strange output for proc generated by template” (#3868)
  • Fixed “Passing const value as static[] argument to immediate macro leads to infinite memory consumption by compiler” (#3872)
  • Fixed “..< is not happy with BiggestInt from intVal” (#3767)
  • Fixed “stdtmpl filter does not support anything apart from ‘#’ metachar” (#3924)
  • Fixed “lib/pure/net: Can’t bind to ports >= 32768” (#3484)
  • Fixed “int and float assignment compatibility badly broken for generics” (#3998)
  • Fixed “Adding echo statement causes “type mismatch” error” (#3975)
  • Fixed “Dynlib error messages should be written to stderr, not stdout” (#3987)
  • Fixed “Tests regressions while using the devel branch” (#4005)

  • Fixed “Lambda lifting bug: wrong c code generation” (#3995)
  • Fixed “VM crashes in asgnComplex” (#3973)
  • Fixed “Unknown opcode opcNGetType” (#1152)
  • Fixed “& operator mutates first operand when used in compileTime proc while assigning result to seq” (#3804)
  • Fixed “'’nil’ statement is deprecated’ in macro” (#3561)
  • Fixed “vm crash when accessing seq with mitems iterator” (#3731)
  • Fixed “mitems or mpairs does not work for seq[NimNode] or array[T,NimNode] in a macro” (#3859)
  • Fixed “passing “proc ,()” to nim check causes an infinite loop” (#4036)
  • Fixed “–dynlibOverride does not work with {.push dynlib: name.}” (#3646)
  • Fixed “system.readChars fails on big len” (#3752)
  • Fixed “strutils.unindent” (#4037)
  • Fixed “Compiler’s infinite recursion in generic resolution” (#2006)
  • Fixed “Linux: readLineFromStdin calls quit(0) upon EOF” (#3159)
  • Fixed “Forum sign up not possible” (#2446)
  • Fixed “Json module - SIGSEGV if key not exists” (#3107)
  • Fixed “About asyncdispatch.await and exception” (#3964)
  • Fixed “Need testcase for JS backend to ensure closure callbacks don’t break” (#3132)
  • Fixed “Unexpected behaviour of C++ templates in conjunction with N_NIMCALL” (#4093)
  • Fixed “SIGSEGV at compile time when using a compileTime variable as counter” (#4097)
  • Fixed “Compiler crash issue on 32-bit machines only” (#4089)
  • Fixed “type mismatch: got () but expected 'outType' in mapIt" ([#4124](https://github.com/nim-lang/Nim/issues/4124))
  • Fixed “Generic type constraints broken?” (#4084)
  • Fixed “Invalid C code generated” (#3544)
  • Fixed “An exit variable in proc shadows exit function called by quit()” (#3471)
  • Fixed “ubuntu 16.04 build error” (#4144)
  • Fixed “Ambiguous identifier error should list all possible qualifiers” (#177)
  • Fixed “Parameters are not captured inside closures inside closure iterators” (#4070)
  • Fixed “$ For array crashes the compiler when assigned to const” (#4040)

  • Fixed “Default value for .importcpp enum is initialized incorrectly” (#4034)
  • Fixed “Nim doesn’t instantiate template parameter in cgen when using procedure return value in for-in loop” (#4110)
  • Fixed “Compile-time SIGSEGV when invoking procedures that cannot be evaluated at compile time from a macro” (#3956)
  • Fixed “Backtricks inside .emit pragma output incorrect name for types” (#3992)
  • Fixed “typedef is generated for .importcpp enums” (#4145)
  • Fixed “Incorrect C code generated for nnkEmpty node” (#950)
  • Fixed “Syntax error in config file appears as general exception without useful info” (#3763)
  • Fixed “Converting .importcpp enum to string doesn’t work when done inside procs” (#4147)
  • Fixed “Enum template specifiers do not work for .importcpp enums when they are used as a parameter” (#4146)
  • Fixed “Providing template specifier recursively for .importcpp type doesn’t work” (#4148)
  • Fixed “sizeof doesn’t work for generics in vm” (#4153)
  • Fixed “Creating list-like structures in a loop leaks memory indefinitely” (#3793)
  • Fixed “Creating list-like structures in a loop leaks memory indefinitely” (#3793)
  • Fixed “Enum items generated by a macro have wrong type.” (#4066)
  • Fixed “Memory leak with default GC” (#3184)
  • Fixed “Rationals Overflow Error on 32-bit machine” (#4194)

  • Fixed “osproc waitForExit() is ignoring the timeout parameter” (#4200)
  • Fixed “Regression: exception parseFloat(“-0.0”) “ (#4212)
  • Fixed “JS Codegen: Bad constant initialization order” (#4222)
  • Fixed “Term-rewriting macros gives Error: wrong number of arguments” (#4227)
  • Fixed “importcpp allowed in body of proc after push” (#4225)
  • Fixed “pragma SIGSEGV” (#4001)
  • Fixed “Restrict hints to the current project” (#2159)
  • Fixed “unlikely/likely should be no-ops for the Javascript backend” (#3882)
  • Fixed “.this pragma doesn’t work for fields and procs defined for parent type” (#4177)
  • Fixed “VM SIGSEV with compile-time Table” (#3729)
  • Fixed “Error during compilation with cpp option on FreeBSD “ (#3059)
  • Fixed “Compiler doesn’t keep type bounds” (#1713)
  • Fixed “Stdlib: future: Shortcut proc definition doesn’t support, varargs, seqs, arrays, or openarrays” (#4238)
  • Fixed “Why don’t asynchttpserver support request-body when put delete?” (#4221)
  • Fixed “Paths for includes in Nim documentation” (#2640)
  • Fixed “Compile pragma doesn’t work with relative import” (#1262)
  • Fixed “Slurp doesn’t work with relative imports” (#765)
  • Fixed “Make tilde expansion consistent” (#786)
  • Fixed “koch expects nim to be in path for tests?” (#3290)
  • Fixed “Don’t use relative imports for non relative modules (aka babel libs)” (#546)
  • Fixed ““echo” on general structs does not work” (#4236)
  • Fixed “Changing math.round() and adding math.integer()” (#3473)
  • Fixed “Mathematics module missing modf” (#4195)
  • Fixed “Passing method to macro causes seg fault” (#1611)
  • Fixed “Internal error with “discard quit”” (#3532)
  • Fixed “SIGSEGV when using object variant in compile time” (#4207)
  • Fixed “formatSize has incorrect prefix” (#4198)
  • Fixed “Add compiler parameter to generate output from source code filters” (#375)
  • Fixed “Add engineering notation to string formatting functions” (#4197)
  • Fixed “Very minor error in json documentation” (#4255)
  • Fixed “can’t compile when checking if closure == nil” (#4186)
  • Fixed “Strange code gen for procs returning arrays” (#2259)
  • Fixed “asynchttpserver may consume unbounded memory reading headers” (#3847)

  • Fixed “download page still implies master is default branch” (#4022)
  • Fixed “Use standard compiler flags in build script” (#2128)
  • Fixed “CentOS 6 (gcc-4.4.7) compilation failed (redefinition of typedef)” (#4272)
  • Fixed “doc2 has issues with httpclient” (#4278)
  • Fixed “tuples/tuple_with_nil fails without unsigned module” (#3579)

Meet our BountySource sponsors

It has now been two months since we began our fundraiser. Time to meet our current sponsors.

Nim in Action is now available!

We are proud to announce that Nim in Action, a book about the Nim programming language, is now available!

Version 0.13.0 released

Once again we are proud to announce the latest release of the Nim compiler and related tools. This release comes just 3 months after the last release!

A new version of Nimble which depends on this release, has also been released. See this forum thread for more information about the Nimble release.

This release of Nim includes over 116 bug fixes, many of which are related to closures. The lambda lifting algorithm in the compiler has been completely rewritten, and some changes have been made to the semantics of closures in Nim as a result. These changes may affect backwards compatibility and are all described in the section below.

With this release, we are one step closer to Nim version 1.0. The 1.0 release will be a big milestone for Nim, because after that version is released there will be no more breaking changes made to the language or the standard library.

That being said, the next release will likely be Nim 0.14. It will focus on improvements to the GC and concurrency. We will in particular be looking at ways to add multi-core support to async await. Standard library improvements are also on our roadmap but may not make it for Nim 0.14.

As always you can download the latest version of Nim from the download page.

Happy coding!

Changes affecting backwards compatibility

  • macros.newLit for bool now produces false/true symbols which actually work with the bool datatype.
  • When compiling to JS: Node, NodeType and Document are no longer defined. Use the types defined in dom.nim instead.
  • The check x is iterator (used for instance in concepts) was always a weird special case (you could not use x is proc) and was removed from the language.
  • Top level routines cannot have the calling convention closure anymore.
  • The redis module has been moved out of the standard library. It can now be installed via Nimble and is located here: https://github.com/nim-lang/redis
  • math.RunningStat and its associated procs have been moved from the math module to a new stats module.

Syntax changes

The parser now considers leading whitespace in front of operators to determine if an operator is used in prefix or infix position. This means that finally echo $foo is parsed as people expect, which is as echo($foo). It used to be parsed as (echo) $ (foo).

echo $ foo continues to be parsed as (echo) $ (foo).

This also means that -1 is always parsed as prefix operator so code like 0..kArraySize div 2 -1 needs to be changed to 0..kArraySize div 2 - 1.

This release also adds multi-line comments to Nim. The syntax for them is: #[ comment here ]#. For more details read the section of the manual.

Iterator changes

Implicit return type inference for iterators has been removed from the language. The following used to work:

iterator it =
  yield 7

This was a strange special case and has been removed. Now you need to write it like so which is consistent with procs:

iterator it: auto =
  yield 7

Closure changes

The semantics of closures changed: Capturing variables that are in loops do not produce a new environment. Nim closures behave like JavaScript closures now.

The following used to work as the environment creation used to be attached to the loop body:

proc outer =
  var s: seq[proc(): int {.closure.}] = @[]
  for i in 0 ..< 30:
    let ii = i
    s.add(proc(): int = return ii*ii)

This behaviour has changed in 0.13.0 and now needs to be written as:

proc outer =
  var s: seq[proc(): int {.closure.}] = @[]
  for i in 0 ..< 30:
    (proc () =
      let ii = i
      s.add(proc(): int = return ii*ii))()

The reason is that environment creations are now only performed once per proc call. This change is subtle and unfortunate, but:

  1. Affects almost no code out there.
  2. Is easier to implement and we are at a point in Nim’s development process where simple+stable wins over perfect-in-theory+unstable-in-practice.
  3. Implies programmers are more in control of where memory is allocated which is beneficial for a systems programming language.

Bugfixes

The list below has been generated based on the commits in Nim’s git repository. As such it lists only the issues which have been closed via a commit, for a full list see this link on Github.

  • Fixed “Generic arguments cannot be used in templates (raising undeclared identifier)” (#3498)
  • Fixed “multimethods: Error: internal error: cgmeth.genConv” (#3550)
  • Fixed “nimscript - SIGSEGV in except block” (#3546)
  • Fixed “Bool literals in macros do not work.” (#3541)
  • Fixed “Docs: nativesocket.html - 404” (#3582)
  • Fixed ““not nil” return types never trigger an error or warning” (#2285)
  • Fixed “No warning or error is raised even if not nil is specified “ (#3222)
  • Fixed “Incorrect fsmonitor add() filter logic” (#3611)
  • Fixed ““nimble install nimsuggest” failed” (#3622)
  • Fixed “compile time excl cause SIGSEGV” (#3639)
  • Fixed “Unable to echo unsigned ints at compile-time” (#2514)
  • Fixed “Nested closure iterator produces internal error” (#1725)
  • Fixed “C Error on walkDirRec closure” (#3636)
  • Fixed “Error in generated c code” (#3201)
  • Fixed “C Compile-time error with generic proc type.” (#2659)
  • Fixed “ICE dereferencing array pointer” (#2240)
  • Fixed “Lambda lifting crash” (#2007)
  • Fixed “Can’t reference outer variables from a closure in an iterator” (#2604)
  • Fixed “M&S collector breaks with nested for loops.” (#603)
  • Fixed “Regression: bad C codegen” (#3723)
  • Fixed “JS backend - handle bool type in case statement” (#3722)
  • Fixed “linenoise compilation with cpp” (#3720)
  • Fixed “(???,???) duplicate case label” (#3665)
  • Fixed “linenoise compilation with cpp” (#3720)
  • Fixed “Update list of backward incompatibilities for Nim 0.12.0 in the main site” (#3689)
  • Fixed “Can’t compile nimble with latest devel - codegen bug” (#3730)

Andreas Rumpf's talk at OSCON Amsterdam

In case you have missed it, here is Andreas’ Nim: An Overview talk at OSCON Amsterdam.


Version 0.12.0 released

The Nim community of developers is proud to announce the new version of the Nim compiler. This has been a long time coming as the last release has been made over 5 months ago!

This release includes some changes which affect backwards compatibility, one major change is that now the hash table [] operators now raise a KeyError exception when the key does not exist.

Some of the more exciting new features include: the ability to unpack tuples in any assignment context, the introduction of NimScript, and improvements to the type inference of lambdas.

There are of course many many many bug fixes included with this release. We are getting closer and closer to a 1.0 release and are hoping that only a few 0.x releases will be necessary before we are happy to release version 1.0.

As always you can download the latest version of Nim from the download page.

For a more detailed list of changes look below. Some of the upcoming breaking changes are also documented in this forum thread.

Changes affecting backwards compatibility

  • The regular expression modules, re and nre now depend on version 8.36 of PCRE. If you have an older version you may see a message similar to could not import: pcre_free_study output when you start your program. See this issue for more information.
  • tables.[], strtabs.[], critbits.[] now raise the KeyError exception when the key does not exist! Use the new getOrDefault instead to get the old behaviour. Compile all your code with -d:nimTableGet to get a listing of where your code uses []!
  • The rawsockets module has been renamed to nativesockets to avoid confusion with TCP/IP raw sockets, so newNativeSocket should be used instead of newRawSocket.
  • The miliseconds property of times.TimeInterval is now milliseconds. Code accessing that property is deprecated and code using miliseconds during object initialization or as a named parameter of initInterval() will need to be updated.
  • std.logging functions no longer do formatting and semantically treat their arguments just like echo does. Affected functions: log, debug, info, warn, error, fatal. Custom subtypes of Logger also need to be adjusted accordingly.
  • Floating point numbers can now look like 2d (float64) and 2f (float32) which means imports like import scene/2d/sprite do not work anymore. Instead quotes have to be used: import "scene/2d/sprite". The former code never was valid Nim.
  • The Windows API wrapper (windows.nim) is now not part of the official distribution anymore. Instead use the oldwinapi Nimble package.
  • There is now a clear distinction between --os:standalone and --gc:none. So if you use --os:standalone ensure you also use --gc:none. --os:standalone without --gc:none is now a version that doesn’t depend on any OS but includes the GC. However this version is currently untested!
  • All procedures which construct a Socket/AsyncSocket now need to specify the socket domain, type and protocol. The param name typ: SockType (in newSocket/newAsyncSocket procs) was also renamed to sockType. The param af in the connect procs was removed. This affects asyncnet, asyncdispatch, net, and rawsockets.
  • varargs[typed] and varargs[untyped] have been refined and now work as expected. However varargs[untyped] is not an alias anymore for varargs[expr]. So if your code breaks for varargs[untyped], use varargs[expr] instead. The same applies to varargs[typed] vs varargs[stmt].
  • sequtils.delete doesn’t take confusing default arguments anymore.
  • system.free was an error-prone alias to system.dealloc and has been removed.
  • macros.high never worked and the manual says high cannot be overloaded, so we removed it with no deprecation cycle.
  • To use the parallel statement you now have to use the --experimental mode.
  • Toplevel procs of calling convention closure never worked reliably and are now deprecated and will be removed from the language. Instead you have to insert type conversions like (proc (a, b: int) {.closure.})(myToplevelProc) if necessary.
  • The modules libffi, sdl, windows, zipfiles, libzip, zlib, zzip, dialogs, expat, graphics, libcurl, sphinx have been moved out of the stdlib and are Nimble packages now.
  • The constant fights between 32 and 64 bit DLLs on Windows have been put to an end: The standard distribution now ships with 32 and 64 bit versions of all the DLLs the standard library needs. This means that the following DLLs are now split into 32 and 64 versions:

    • pcre.dll: Split into pcre32.dll and pcre64.dll.
    • pdcurses.dll: Split into pdcurses32.dll and pdcurses64.dll.
    • sqlite3.dll: Split into sqlite3_32.dll and sqlite3_64.dll.
    • ssleay32.dll: Split into ssleay32.dll and ssleay64.dll.
    • libeay32.dll: Split into libeay32.dll and libeay64.dll.

    Compile with -d:nimOldDLLs to make the stdlib use the old DLL names.

  • Nim VM now treats objects as nkObjConstr nodes, and not nkPar nodes as it was previously. Macros that generate nkPar nodes when object is expected are likely to break. Macros that expect nkPar nodes to which objects are passed are likely to break as well.
  • Base methods now need to be annotated with the base pragma. This makes multi methods less error-prone to use with the effect system.
  • Nim’s parser directive #! is now #? in order to produce no conflicts with Unix’s #!.
  • An implicit return type for an iterator is now deprecated. Use auto if you want more type inference.
  • The type auto is now a “multi-bind” metatype, so the following compiles:

      proc f(x, y: auto): auto =
        result = $x & y
    
      echo f(0, "abc")
    
  • The ftpclient module is now deprecated in favour of the asyncftpclient module.
  • In sequtils.nim renamed repeat function to cycle (concatenating a sequence by itself the given times), and also introduced repeat, which repeats an element the given times.
  • The function map is moved to sequtils.nim. The inplace map version is renamed to apply.
  • The template mapIt now doesn’t require the result’s type parameter. Also the inplace mapIt is renamed to apply.
  • The compiler is now stricter with what is allowed as a case object discriminator. The following code used to compile but was not supported completely and so now fails:

      type
          DataType* {.pure.} = enum
              Char = 1,
              Int8 = 2,
              Int16 = 3,
              Int32 = 4,
              Int64 = 5,
              Float32 = 6,
              Float64 = 7
    
          DataSeq* = object
              case kind* : DataType
              of DataType.Char: charSeq* : seq[char]
              of DataType.Int8: int8Seq* : seq[int8]
              of DataType.Int16: int16Seq* : seq[int16]
              of DataType.Int32: int32Seq* : seq[int32]
              of DataType.Int64: int64Seq* : seq[int64]
              of DataType.Float32: float32Seq* : seq[float32]
              of DataType.Float64: float64Seq* : seq[float64]
    
              length* : int
    

Library Additions

  • The nre module has been added, providing a better interface to PCRE than re.
  • The expandSymlink proc has been added to the os module.
  • The tailDir proc has been added to the os module.
  • Define nimPinToCpu to make the threadpool use explicit thread affinities. This can speed up or slow down the thread pool; it’s up to you to benchmark it.
  • strutils.formatFloat and formatBiggestFloat do not depend on the C locale anymore and now take an optional decimalSep = '.' parameter.
  • Added unicode.lastRune, unicode.graphemeLen.

Compiler Additions

  • The compiler now supports a new configuration system based on NimScript.
  • The compiler finally considers symbol binding rules in templates and generics for overloaded [], []=, {}, {}= operators (issue #2599).
  • The compiler now supports a bitsize pragma for constructing bitfields.
  • Added a new --reportConceptFailures switch for better debugging of concept related type mismatches. This can also be used to debug system.compiles failures.

Language Additions

  • system.unsafeAddr can be used to access the address of a let variable or parameter for C interoperability. Since technically this makes parameters and let variables mutable, it is considered even more unsafe than the ordinary addr builtin.
  • Added macros.getImpl that can be used to access the implementation of a routine or a constant. This allows for example for user-defined inlining of function calls.
  • Tuple unpacking finally works in a non-var/let context: (x, y) = f() is allowed. Note that this doesn’t declare x and y variables, for this let (x, y) = f() still needs to be used.
  • when nimvm can now be used for compiletime versions of some code sections. Click here for details.
  • Usage of the type NimNode in a proc now implicitly annotates the proc with .compileTime. This means generics work much better for NimNode.

Bugfixes

  • Fixed “Compiler internal error on iterator it(T: typedesc[Base]) called with it(Child), where Child = object of Base” (#2662)
  • Fixed “repr() misses base object field in 2nd level derived object” (#2749)
  • Fixed “nimsuggest doesn’t work more than once on the non-main file” (#2694)
  • Fixed “JS Codegen. Passing arguments by var in certain cases leads to invalid JS.” (#2798)
  • Fixed ““check” proc in unittest.nim prevents the propagation of changes to var parameters.” (#964)
  • Fixed “Excessive letters in integer literals are not an error” (#2523)
  • Fixed “Unicode dashes as “lisp’ish” alternative to hump and snake notation” (#2811)
  • Fixed “Bad error message when trying to construct an object incorrectly” (#2584)
  • Fixed “Determination of GC safety of globals is broken “ (#2854)
  • Fixed “v2 gc crashes compiler” (#2687)
  • Fixed “Compile error using object in const array” (#2774)
  • Fixed “httpclient async requests with method httpPOST isn’t sending Content-Length header” (#2884)
  • Fixed “Streams module not working with JS backend” (#2148)
  • Fixed “Sign of certain short constants is wrong” (#1179)
  • Fixed “Symlinks to directories reported as symlinks to files” (#1985)
  • Fixed “64-bit literals broken on x86” (#2909)
  • Fixed “import broken for certain names” (#2904)
  • Fixed “Invalid UTF-8 strings in JavaScript” (#2917)
  • Fixed “[JS][Codegen] Initialising object doesn’t create unmentioned fields.”

    (#2617)

  • Fixed “Table returned from proc computed at compile time is missing keys:” (#2297)
  • Fixed “Clarify copyright status for some files” (#2949)
  • Fixed “math.nim: trigonometry: radians to degrees conversion” (#2881)
  • Fixed “xoring unsigned integers yields RangeError in certain conditions” (#2979)
  • Fixed “Directly checking equality between procs” (#2985)
  • Fixed “Compiler crashed, but there have to be meaningful error message” (#2974)
  • Fixed “repr is broken” (#2992)
  • Fixed “Ipv6 devel - add IPv6 support for asyncsockets, make AF_INET6 a default” (#2976)
  • Fixed “Compilation broken on windows” (#2996)
  • Fixed “‘u64 literal conversion compiler error” (#2731)
  • Fixed “Importing ‘impure’ libraries while using threads causes segfaults” (#2672)
  • Fixed “Uncatched exception in async procedure on raise statement” (#3014)
  • Fixed “nim doc2 fails in Mac OS X due to system.nim (possibly related to #1898)” (#3005)
  • Fixed “IndexError when rebuilding Nim on iteration 2” (#3018)
  • Fixed “Assigning large const set to variable looses some information” (#2880)
  • Fixed “Inconsistent generics behavior” (#3022)
  • Fixed “Compiler breaks on float64 division” (#3028)
  • Fixed “Confusing error message comparing string to nil “ (#2935)
  • Fixed “convert 64bit number to float on 32bit” (#1463)
  • Fixed “Type redefinition and construction will break nim check” (#3032)
  • Fixed “XmlParser fails on very large XML files without new lines” (#2429)
  • Fixed “Error parsing arguments with whitespaces” (#2874)
  • Fixed “Crash when missing one arg and used a named arg” (#2993)
  • Fixed “Wrong number of arguments in assert will break nim check” (#3044)
  • Fixed “Wrong const definition will break nim check” (#3041)
  • Fixed “Wrong set declaration will break nim check” (#3040)
  • Fixed “Compiler segfault (type section)” (#2540)
  • Fixed “Segmentation fault when compiling this code” (#3038)
  • Fixed “Kill nim i” (#2633)
  • Fixed “Nim check will break on wrong array declaration” (#3048)
  • Fixed “boolVal seems to be broken” (#3046)
  • Fixed “Nim check crashes on wrong set/array declaration inside ref object” (#3062)
  • Fixed “Nim check crashes on incorrect generic arg definition” (#3051)
  • Fixed “Nim check crashes on iterating nonexistent var” (#3053)
  • Fixed “Nim check crashes on wrong param set declaration + iteration” (#3054)
  • Fixed “Wrong sharing of static_t instantations” (#3112)
  • Fixed “Automatically generated proc conflicts with user-defined proc when .exportc.’ed” (#3134)
  • Fixed “getTypeInfo call crashes nim” (#3099)
  • Fixed “Array ptr dereference” (#2963)
  • Fixed “Internal error when repr-ing a type directly” (#3079)
  • Fixed “unknown type name ‘TNimType’ after importing typeinfo module” (#2841)
  • Fixed “Can export a template twice and from inside a block” (#1738)
  • Fixed “C Codegen: C Types are defined after their usage in certain cases” (#2823)
  • Fixed “s.high refers to the current seq instead of the old one” (#1832)
  • Fixed “Error while unmarshaling null values” (#3149)
  • Fixed “Inference of static[T] in sequences” (#3144)
  • Fixed “Argument named “closure” to proc inside template interfere with closure pragma” (#3171)
  • Fixed “Internal error with aliasing inside template” (#3158)
  • Fixed “Cardinality of sets prints unexpected value” (#3135)
  • Fixed “Nim crashes on const assignment from function returning var ref object” (#3103)
  • Fixed “repr cstring” (#3080)
  • Fixed “Nim check crashes on wrong enum declaration” (#3052)
  • Fixed “Compiler assertion when evaluating template with static[T]” (#1858)
  • Fixed “Erroneous overflow in iterators when compiler built with overflowChecks enabled” (#3140)
  • Fixed “Unicode dashes as “lisp’ish” alternative to hump and snake notation” (#2811)
  • Fixed “Calling discardable proc from a defer is an error.” (#3185)
  • Fixed “Defer statement at the end of a block produces ICE” (#3186)
  • Fixed “Call to createU fails to compile” (#3193)
  • Fixed “VM crash when accessing array’s element” (#3192)
  • Fixed “Unexpected proc invoked when different modules add procs to a type from a 3rd module” (#2664)
  • Fixed “Nim crashes on conditional declaration inside a template” (#2670)
  • Fixed “Iterator names conflict within different scopes” (#2752)
  • Fixed “VM: Cannot assign int value to ref variable” (#1329)
  • Fixed “Incorrect code generated for tagged unions with enums not starting at zero” (#3096)
  • Fixed “Compile time procs using forward declarations are silently ignored” (#3066)
  • Fixed “re binding error in generic” (#1965)
  • Fixed “os.getCreationTime is incorrect/impossible on Posix systems” (#1058)
  • Fixed “Improve error message for osproc.startProcess when command does not exist” (#2183)
  • Fixed “gctest segfaults with –gc:markandsweep on x86_64” (#2305)
  • Fixed “Coroutine changes break compilation on unsupported architectures” (#3245)
  • Fixed “Bugfix: Windows 32bit TinyCC support issue fixed” (#3237)
  • Fixed “db_mysql getValue() followed by exec() causing error” (#3220)
  • Fixed “xmltree.newEntity creates xnCData instead of xnEntity” (#3282)
  • Fixed “Methods and modules don’t work together” (#2590)
  • Fixed “String slicing not working in the vm” (#3300)
  • Fixed “internal error: evalOp(mTypeOf)” (#3230)
  • Fixed “#! source code prefix collides with Unix Shebang” (#2559)
  • Fixed “wrong codegen for constant object” (#3195)
  • Fixed “Doc comments inside procs with implicit returns don’t work” (#1528)

First Nim conference

Learn about the first Nim workshop in Kyiv.

Version 0.11.2 released

This is just a bugfix release that fixes the most pressing regressions we introduced with version 0.11.0. The way types are computed was changed significantly causing all sort of problems. Sorry for the inconvenience; we grew overconfident our large test suite would prevent these things.


Version 0.11.0 released

With this release we are one step closer to reaching version 1.0 and by extension the persistence of the Nim specification. As mentioned in the previous release notes, starting with version 1.0, we will not be introducing any more breaking changes to Nim.

The language itself is very close to 1.0, the primary area that requires more work is the standard library.

Take a look at the download page for binaries (Windows-only) and 0.11.0 snapshots of the source code. The Windows installer now also includes Aporia, Nimble and other useful tools to get you started with Nim.

What’s left to be done

The 1.0 release is expected by the end of this year. Rumors say it will be in summer 2015. What’s left:

  • Bug fixes, bug fixes, bug fixes, in particular:
    • The remaining bugs of the lambda lifting pass that is responsible to enable closures and closure iterators need to be fixed.
    • concept needs to be refined, a nice name for the feature is not enough.
    • Destructors need to be refined.
    • static[T] needs to be fixed.
    • Finish the implementation of the ‘parallel’ statement.
  • immediate templates and macros will be deprecated as these will soon be completely unnecessary, instead the typed or untyped metatypes can be used.
  • More of the standard library should be moved to Nimble packages and what’s left should use the features we have for concurrency and parallelism.

Changes affecting backwards compatibility

  • Parameter names are finally properly gensym‘ed. This can break templates though that used to rely on the fact that they are not. (Bug #1915.) This means this doesn’t compile anymore:

    
      template doIt(body: stmt) {.immediate.} =
        # this used to inject the 'str' parameter:
        proc res(str: string) =
          body
    
      doIt:
        echo str # Error: undeclared identifier: 'str'
    

    This used to inject the str parameter into the scope of the body. Declare the doIt template as immediate, dirty to get the old behaviour.

  • Tuple field names are not ignored anymore, this caused too many problems in practice so now the behaviour is as it was for version 0.9.6: If field names exist for the tuple type, they are checked.
  • logging.level and logging.handlers are no longer exported. addHandler, getHandlers, setLogFilter and getLogFilter should be used instead.
  • nim idetools has been replaced by a separate tool nimsuggest.
  • arrow like operators are not right associative anymore and are required to end with either ->, ~> or =>, not just >. Examples of operators still considered arrow like: ->, ==>, +=>. On the other hand, the following operators are now considered regular operators again: |>, -+>, etc.
  • Typeless parameters are now only allowed in templates and macros. The old way turned out to be too error-prone.
  • The ‘addr’ and ‘type’ operators are now parsed as unary function application. This means type(x).name is now parsed as (type(x)).name and not as type((x).name). Note that this also affects the AST structure; for immediate macro parameters nkCall('addr', 'x') is produced instead of nkAddr('x').
  • concept is now a keyword and is used instead of generic.
  • The inc, dec, +=, -= builtins now produce OverflowError exceptions. This means code like the following:

      var x = low(T)
      while x <= high(T):
        echo x
        inc x
    

    Needs to be replaced by something like this:

      var x = low(T).int
      while x <= high(T).int:
        echo x.T
        inc x
    
  • Negative indexing for slicing does not work anymore! Instead of a[0.. -1] you can use a[0.. ^1]. This also works with accessing a single element a[^1]. Note that we cannot detect this reliably as it is determined at runtime whether negative indexing is used! a[0.. -1] now produces the empty string/sequence.
  • The compiler now warns about code like foo +=1 which uses inconsistent spacing around binary operators. Later versions of the language will parse these as unary operators instead so that echo $foo finally can do what people expect it to do.
  • system.untyped and system.typed have been introduced as aliases for expr and stmt. The new names capture the semantics much better and most likely expr and stmt will be deprecated in favor of the new names.
  • The split method in module re has changed. It now handles the case of matches having a length of 0, and empty strings being yielded from the iterator. A notable change might be that a pattern being matched at the beginning and end of a string, will result in an empty string being produced at the start and the end of the iterator.
  • The compiler and nimsuggest now count columns starting with 1, not 0 for consistency with the rest of the world.

Language Additions

  • For empty case object branches discard can finally be used instead of nil.
  • Automatic dereferencing is now done for the first argument of a routine call if overloading resolution produces no match otherwise. This feature has to be enabled with the experimental pragma.
  • Objects that do not use inheritance nor case can be put into const sections. This means that finally this is possible and produces rather nice code:

      import tables
    
      const
        foo = {"ah": "finally", "this": "is", "possible.": "nice!"}.toTable()
    
  • Ordinary parameters can follow after a varargs parameter. This means the following is finally accepted by the compiler:

      template takesBlock(a, b: int, x: varargs[expr]; blck: stmt) =
        blck
        echo a, b
    
      takesBlock 1, 2, "some", 0.90, "random stuff":
        echo "yay"
    
  • Overloading by ‘var T’ is now finally possible:

      proc varOrConst(x: var int) = echo "var"
      proc varOrConst(x: int) = echo "const"
    
      var x: int
      varOrConst(x) # "var"
      varOrConst(45) # "const"
    
  • Array and seq indexing can now use the builtin ^ operator to access things from backwards: a[^1] is like Python’s a[-1].
  • A first version of the specification and implementation of the overloading of the assignment operator has arrived!
  • system.len for strings and sequences now returns 0 for nil.

  • A single underscore can now be used to discard values when unpacking tuples:

      let (path, _, _) = os.splitFile("path/file.ext")
    
  • marshal.$$ and marshal.to can be executed at compile-time.
  • Interoperability with C++ improved tremendously; C++’s templates and operators can be wrapped directly. See this for more information.
  • macros.getType can be used to query an AST’s type at compile-time. This enables more powerful macros, for instance currying can now be done with a macro.

Library additions

  • reversed proc added to the unicode module.
  • Added multipart param to httpclient’s post and postContent together with a newMultipartData proc.
  • Added %* operator for JSON.
  • The compiler is now available as Nimble package for c2nim.
  • Added ..^ and ..< templates to system so that the rather annoying space between .. < and .. ^ is not necessary anymore.
  • Added system.xlen for strings and sequences to get back the old len operation that doesn’t check for nil for efficiency.
  • Added sexp.nim to parse and generate sexp.

Bugfixes

  • Fixed internal compiler error when using char() in an echo call (#1788).
  • Fixed Windows cross-compilation on Linux.
  • Overload resolution now works for types distinguished only by a static[int] param (#1056).
  • Other fixes relating to generic types and static params.
  • Fixed some compiler crashes with unnamed tuples (#1774).
  • Fixed channels.tryRecv blocking (#1816).
  • Fixed generic instantiation errors with typedesc (#419).
  • Fixed generic regression where the compiler no longer detected constant expressions properly (#544).
  • Fixed internal error with generic proc using static[T] in a specific way (#1049).
  • More fixes relating to generics (#1820, #1050, #1859, #1858).
  • Fixed httpclient to properly encode queries.
  • Many fixes to the uri module.
  • Async sockets are now closed on error.
  • Fixes to httpclient’s handling of multipart data.
  • Fixed GC segfaults with asynchronous sockets (#1796).
  • Added more versions to openssl’s DLL version list (076f993).
  • Fixed shallow copy in iterators being broken (#1803).
  • nil can now be inserted into tables with the db_sqlite module (#1866).
  • Fixed “Incorrect assembler generated” (#1907)
  • Fixed “Expression templates that define macros are unusable in some contexts” (#1903)
  • Fixed “a second level generic subclass causes the compiler to crash” (#1919)
  • Fixed “nim 0.10.2 generates invalid AsyncHttpClient C code for MSVC “ (#1901)
  • Fixed “1 shl n produces wrong C code” (#1928)
  • Fixed “Internal error on tuple yield” (#1838)
  • Fixed “ICE with template” (#1915)
  • Fixed “include the tool directory in the installer as it is required by koch” (#1947)
  • Fixed “Can’t compile if file location contains spaces on Windows” (#1955)
  • Fixed “List comprehension macro only supports infix checks as guards” (#1920)
  • Fixed “wrong field names of compatible tuples in generic types” (#1910)
  • Fixed “Macros within templates no longer work as expected” (#1944)
  • Fixed “Compiling for Standalone AVR broken in 0.10.2” (#1964)
  • Fixed “Compiling for Standalone AVR broken in 0.10.2” (#1964)
  • Fixed “Code generation for mitems with tuple elements” (#1833)
  • Fixed “httpclient.HttpMethod should not be an enum” (#1962)
  • Fixed “terminal / eraseScreen() throws an OverflowError” (#1906)
  • Fixed “setControlCHook(nil) disables registered quit procs” (#1546)
  • Fixed “Unexpected idetools behaviour” (#325)
  • Fixed “Unused lifted lambda does not compile” (#1642)
  • Fixed “‘low’ and ‘high’ don’t work with cstring asguments” (#2030)
  • Fixed “Converting to int does not round in JS backend” (#1959)
  • Fixed “Internal error genRecordField 2 when adding region to pointer.” (#2039)
  • Fixed “Macros fail to compile when compiled with –os:standalone” (#2041)
  • Fixed “Reading from {.compileTime.} variables can cause code generation to fail” (#2022)
  • Fixed “Passing overloaded symbols to templates fails inside generic procedures” (#1988)
  • Fixed “Compiling iterator with object assignment in release mode causes “var not init”” (#2023)
  • Fixed “calling a large number of macros doing some computation fails” (#1989)
  • Fixed “Can’t get Koch to install nim under Windows” (#2061)
  • Fixed “Template with two stmt parameters segfaults compiler” (#2057)
  • Fixed “noSideEffect not affected by echo” (#2011)
  • Fixed “Compiling with the cpp backend ignores –passc” (#1601)
  • Fixed “Put untyped procedure parameters behind the experimental pragma” (#1956)
  • Fixed “generic regression” (#2073)
  • Fixed “generic regression” (#2073)
  • Fixed “Regression in template lookup with generics” (#2004)
  • Fixed “GC’s growObj is wrong for edge cases” (#2070)
  • Fixed “Compiler internal error when creating an array out of a typeclass” (#1131)
  • Fixed “GC’s growObj is wrong for edge cases” (#2070)
  • Fixed “Invalid Objective-C code generated when calling class method” (#2068)
  • Fixed “walkDirRec Error” (#2116)
  • Fixed “Typo in code causes compiler SIGSEGV in evalAtCompileTime” (#2113)
  • Fixed “Regression on exportc” (#2118)
  • Fixed “Error message” (#2102)
  • Fixed “hint[path] = off not working in nim.cfg” (#2103)
  • Fixed “compiler crashes when getting a tuple from a sequence of generic tuples” (#2121)
  • Fixed “nim check hangs with when” (#2123)
  • Fixed “static[T] param in nested type resolve/caching issue” (#2125)
  • Fixed “repr should display \0” (#2124)
  • Fixed “‘nim check’ never ends in case of recursive dependency “ (#2051)
  • Fixed “From macros: Error: unhandled exception: sons is not accessible” (#2167)
  • Fixed “fieldPairs doesn’t work inside templates” (#1902)
  • Fixed “fields iterator misbehavior on break statement” (#2134)
  • Fixed “Fix for compiler not building anymore since #c3244ef1ff” (#2193)
  • Fixed “JSON parser fails in cpp output mode” (#2199)
  • Fixed “macros.getType mishandles void return” (#2211)
  • Fixed “Regression involving templates instantiated within generics” (#2215)
  • Fixed ““Error: invalid type” for ‘not nil’ on generic type.” (#2216)
  • Fixed “–threads:on breaks async” (#2074)
  • Fixed “Type mismatch not always caught, can generate bad code for C backend.” (#2169)
  • Fixed “Failed C compilation when storing proc to own type in object” (#2233)
  • Fixed “Unknown line/column number in constant declaration type conversion error” (#2252)
  • Fixed “Adding {.compile.} fails if nimcache already exists.” (#2247)
  • Fixed “Two different type names generated for a single type (C backend)” (#2250)
  • Fixed “Ambiguous call when it should not be” (#2229)
  • Fixed “Make sure we can load root urls” (#2227)
  • Fixed “Failure to slice a string with an int subrange type” (#794)
  • Fixed “documentation error” (#2205)
  • Fixed “Code growth when using const” (#1940)
  • Fixed “Instances of generic types confuse overload resolution” (#2220)
  • Fixed “Compiler error when initializing sdl2’s EventType” (#2316)
  • Fixed “Parallel disjoint checking can’t handle <, items, or arrays” (#2287)
  • Fixed “Strings aren’t copied in parallel loop” (#2286)
  • Fixed “JavaScript compiler crash with tables” (#2298)
  • Fixed “Range checker too restrictive” (#1845)
  • Fixed “Failure to slice a string with an int subrange type” (#794)
  • Fixed “Remind user when compiling in debug mode” (#1868)
  • Fixed “Compiler user guide has jumbled options/commands.” (#1819)
  • Fixed “using method: 1 in a objects constructor fails when compiling” (#1791)

Version 0.10.2 released

This release marks the completion of a very important change to the project: the official renaming from Nimrod to Nim. Version 0.10.2 contains many language changes, some of which may break your existing code. For your convenience, we added a new tool called nimfix that will help you convert your existing projects so that it works with the latest version of the compiler.

Progress towards version 1.0

Although Nim is still pre-1.0, we were able to keep the number of breaking changes to a minimum so far. Starting with version 1.0, we will not introduce any breaking changes between major release versions. One of Nim’s goals is to ensure that the compiler is as efficient as possible. Take a look at the latest benchmarks, which show that Nim is consistently near the top and already nearly as fast as C and C++. Recent developments, such as the new asyncdispatch module will allow you to write efficient web server applications using non-blocking code. Nim now also has a built-in thread pool for lightweight threading through the use of spawn.

The unpopular “T” and “P” prefixes on types have been deprecated. Nim also became more expressive by weakening the distinction between statements and expressions. We also added a new and searchable forum, a new website, and our documentation generator docgen has seen major improvements. Many thanks to Nick Greenfield for the much more beautiful documentation!

What’s left to be done

The 1.0 release is actually very close. Apart from bug fixes, there are two major features missing or incomplete:

  • static[T] needs to be defined precisely and the bugs in the implementation need to be fixed.
  • Overloading of the assignment operator is required for some generic containers and needs to be implemented.

This means that fancy matrix libraries will finally start to work, which used to be a major point of pain in the language.

Nimble and other Nim tools

Outside of the language and the compiler itself many Nim tools have seen considerable improvements.

Babel the Nim package manager has been renamed to Nimble. Nimble’s purpose is the installation of packages containing libraries and/or applications written in Nim. Even though Nimble is still very young it already is very functional. It can install packages by name, it does so by accessing a packages repository which is hosted on a GitHub repo. Packages can also be installed via a Git repo URL or Mercurial repo URL. The package repository is searchable through Nimble. Anyone is free to add their own packages to the package repository by forking the nim-lang/packages repo and creating a pull request. Nimble is fully cross-platform and should be fully functional on all major operating systems. It is of course completely written in Nim.

Changelog

Changes affecting backwards compatibility

  • The language has been renamed from Nimrod to Nim. The name of the compiler changed from nimrod to nim too.
  • system.fileHandle has been renamed to system.getFileHandle to prevent name conflicts with the new type FileHandle.
  • Comments are now not part of the AST anymore, as such you cannot use them in place of discard.
  • Large parts of the stdlib got rid of the T/P type prefixes. Instead most types now simply start with an uppercased letter. The so called “partial case sensitivity” rule is now active allowing for code like var foo: Foo in more contexts.
  • String case (or any non-ordinal case) statements without ‘else’ are deprecated.
  • Recursive tuple types are not allowed anymore. Use object instead.
  • The PEGS module returns nil instead of "" when an optional capture fails to match.
  • The re module returns nil instead of "" when an optional capture fails to match.
  • The “symmetric set difference” operator (-+-) never worked and has been removed.
  • defer is a keyword now.
  • func is a keyword now.
  • The using language feature now needs to be activated via the new {.experimental.} pragma that enables experimental language features.
  • Destructors are now officially experimental.
  • Standalone except and finally statements are deprecated now. The standalone finally can be replaced with defer, standalone except requires an explicit try.
  • Operators ending in > are considered as “arrow like” and have their own priority level and are right associative. This means that the => and -> operators from the future module work better.
  • Field names in tuples are now ignored for type comparisons. This allows for greater interoperability between different modules.
  • Statement lists are not converted to an implicit do block anymore. This means the confusing nnkDo nodes when working with macros are gone for good.

Language Additions

  • The new concurrency model has been implemented including locks sections, lock levels and object field guards.
  • The parallel statement has been implemented.
  • deepCopy has been added to the language.
  • The builtin procCall can be used to get super-like functionality for multi methods.
  • There is a new pragma {.experimental.} that enables experimental language features per module, or you can enable these features on a global level with the --experimental command line option.

Compiler Additions

  • The compiler now supports mixed Objective C / C++ / C code generation: The modules that use importCpp or importObjc are compiled to C++ or Objective C code, any other module is compiled to C code. This improves interoperability.
  • There is a new parallel statement for safe fork&join parallel computing.
  • guard and lock pragmas have been implemented to support safer concurrent programming.
  • The following procs are now available at compile-time::

    math.sqrt, math.ln, math.log10, math.log2, math.exp, math.round, math.arccos, math.arcsin, math.arctan, math.arctan2, math.cos, math.cosh, math.hypot, math.sinh, math.sin, math.tan, math.tanh, math.pow, math.trunc, math.floor, math.ceil, math.fmod, os.getEnv, os.existsEnv, os.dirExists, os.fileExists, system.writeFile

  • Two backticks now produce a single backtick within an emit or asm statement.
  • There is a new tool, nimfix to help you in updating your code from Nimrod to Nim.
  • The compiler’s output has been prettified.

Library Additions

  • Added module fenv to control the handling of floating-point rounding and exceptions (overflow, division by zero, etc.).
  • system.setupForeignThreadGc can be used for better interaction with foreign libraries that create threads and run a Nim callback from these foreign threads.
  • List comprehensions have been implemented as a macro in the future module.
  • The new Async module (asyncnet) now supports SSL.
  • The smtp module now has an async implementation.
  • Added module asyncfile which implements asynchronous file reading and writing.
  • osproc.kill has been added.
  • asyncnet and asynchttpserver now support SO_REUSEADDR.

Bugfixes

  • nil and NULL are now preserved between Nim and databases in the db_* modules.
  • Fixed issue with OS module in non-unicode mode on Windows.
  • Fixed issue with x.low (#1366).
  • Fixed tuple unpacking issue inside closure iterators (#1067).
  • Fixed ENDB compilation issues.
  • Many asynchttpserver fixes.
  • Macros can now keep global state across macro calls (#903).
  • osproc fixes on Windows.
  • osproc.terminate fixed.
  • Improvements to exception handling in async procedures. (#1487).
  • try now works at compile-time.
  • Fixes T = ref T to be an illegal recursive type.
  • Self imports are now disallowed.
  • Improved effect inference.
  • Fixes for the math module on Windows.
  • User defined pragmas will now work for generics that have been instantiated in different modules.
  • Fixed queue exhaustion bug.
  • Many, many more.

New website design!

A brand new website including an improved forum is now live. All thanks go to Philip Witte and Dominik Picheta, Philip Witte for the design of the website (together with the logo) as well as the HTML and CSS code for his template, and Dominik Picheta for integrating Philip’s design with Nim’s forum. We’re sure you will agree that Philip’s design is beautiful.


Version 0.9.6 released

Note: 0.9.6 is the last release of Nimrod. The language is being renamed to Nim. Nim slightly breaks compatibility.

This is a maintenance release. The upcoming 0.10.0 release has the new features and exciting developments.

Changes affecting backwards compatibility

  • spawn now uses an elaborate self-adapting thread pool and as such has been moved into its own module. So to use it, you now have to import threadpool.
  • The symbol binding rules in generics changed: bar in foo.bar is now considered for implicit early binding.
  • c2nim moved into its own repository and is now a Babel package.
  • pas2nim moved into its own repository and is now a Babel package.
  • system.$ for floating point types now produces a human friendly string representation.
  • uri.TUrl as well as the parseurl module are now deprecated in favour of the new TUri type in the uri module.
  • The destructor pragma has been deprecated. Use the override pragma instead. The destructor’s name has to be destroy now.
  • lambda is not a keyword anymore.
  • system.defined has been split into system.defined and system.declared. You have to use --symbol to declare new conditional symbols that can be set via --define.
  • --threadanalysis:on is now the default. To make your program compile you can disable it but this is only a temporary solution as this option will disappear soon!

Compiler improvements

  • Multi method dispatching performance has been improved by a factor of 10x for pathological cases.

Language Additions

  • This version introduces the deprecated pragma statement that is used to handle the upcoming massive amount of symbol renames.
  • spawn can now wrap proc that has a return value. It then returns a data flow variable of the wrapped return type.

Library Additions

  • Added module cpuinfo.
  • Added module threadpool.
  • sequtils.distnct has been renamed to sequtils.deduplicate.
  • Added algorithm.reversed
  • Added uri.combine and uri.parseUri.
  • Some sockets procedures now support a SafeDisconn flag which causes them to handle disconnection errors and not raise them.

Version 0.9.4 released

The Nimrod development community is proud to announce the release of version 0.9.4 of the Nimrod compiler and tools. Note: This release has to be considered beta quality! Lots of new features have been implemented but unfortunately some do not fulfill our quality standards yet.

Prebuilt binaries and instructions for building from source are available on the download page.

This release includes about 1400 changes in total including various bug fixes, new languages features and standard library additions and improvements. This release brings with it support for user-defined type classes, a brand new VM for executing Nimrod code at compile-time and new symbol binding rules for clean templates.

It also introduces support for the brand new Babel package manager which has itself seen its first release recently. Many of the wrappers that were present in the standard library have been moved to separate repositories and should now be installed using Babel.

Apart from that a new experimental Asynchronous IO API has been added via the asyncdispatch and asyncnet modules. The net and rawsockets modules have also been added and they will likely replace the sockets module in the next release. The Asynchronous IO API has been designed to take advantage of Linux’s epoll and Windows’ IOCP APIs, support for BSD’s kqueue has not been implemented yet but will be in the future. The Asynchronous IO API provides both a callback interface and an interface which allows you to write code as you would if you were writing synchronous code. The latter is done through the use of an await macro which behaves similar to C#’s await. The following is a very simple chat server demonstrating Nimrod’s new async capabilities.

import asyncnet, asyncdispatch

var clients: seq[PAsyncSocket] = @[]

proc processClient(client: PAsyncSocket) {.async.} =
  while true:
    let line = await client.recvLine()
    for c in clients:
      await c.send(line & "\c\L")

proc serve() {.async.} =
  var server = newAsyncSocket()
  server.bindAddr(TPort(12345))
  server.listen()

  while true:
    let client = await server.accept()
    clients.add client

    processClient(client)

serve()
runForever()

Note that this feature has been implemented with Nimrod’s macro system and so await and async are no keywords.

Syntactic sugar for anonymous procedures has also been introduced. It too has been implemented as a macro. The following shows some simple usage of the new syntax:

import future

var s = @[1, 2, 3, 4, 5]
echo(s.map((x: int) => x * 5))

A list of changes follows, for a comprehensive list of changes take a look here.

Library Additions

  • Added macros.genSym builtin for AST generation.
  • Added macros.newLit procs for easier AST generation.
  • Added module logging.
  • Added module asyncdispatch.
  • Added module asyncnet.
  • Added module net.
  • Added module rawsockets.
  • Added module selectors.
  • Added module asynchttpserver.
  • Added support for the new asynchronous IO in the httpclient module.
  • Added a Python-inspired future module that features upcoming additions to the system module.

Changes affecting backwards compatibility

  • The scoping rules for the if statement changed for better interaction with the new syntactic construct (;).
  • OSError family of procedures has been deprecated. Procedures with the same name but which take different parameters have been introduced. These procs now require an error code to be passed to them. This error code can be retrieved using the new OSLastError proc.
  • os.parentDir now returns “” if there is no parent dir.
  • In CGI scripts stacktraces are shown to the user only if cgi.setStackTraceStdout is used.
  • The symbol binding rules for clean templates changed: bind for any symbol that’s not a parameter is now the default. mixin can be used to require instantiation scope for a symbol.
  • quoteIfContainsWhite now escapes argument in such way that it can be safely passed to shell, instead of just adding double quotes.
  • macros.dumpTree and macros.dumpLisp have been made immediate, dumpTreeImm and dumpLispImm are now deprecated.
  • The nil statement has been deprecated, use an empty discard instead.
  • sockets.select now prunes sockets that are not ready from the list of sockets given to it.
  • The noStackFrame pragma has been renamed to asmNoStackFrame to ensure you only use it when you know what you’re doing.
  • Many of the wrappers that were present in the standard library have been moved to separate repositories and should now be installed using Babel.

Compiler Additions

  • The compiler can now warn about “uninitialized” variables. (There are no real uninitialized variables in Nimrod as they are initialized to binary zero). Activate via {.warning[Uninit]:on.}.
  • The compiler now enforces the not nil constraint.
  • The compiler now supports a codegenDecl pragma for even more control over the generated code.
  • The compiler now supports a computedGoto pragma to support very fast dispatching for interpreters and the like.
  • The old evaluation engine has been replaced by a proper register based virtual machine. This fixes numerous bugs for nimrod i and for macro evaluation.
  • --gc:none produces warnings when code uses the GC.
  • A union pragma for better C interoperability is now supported.
  • A packed pragma to control the memory packing/alignment of fields in an object.
  • Arrays can be annotated to be unchecked for easier low level manipulations of memory.
  • Support for the new Babel package manager.

Language Additions

  • Arrays can now be declared with a single integer literal N instead of a range; the range is then 0..N-1.
  • Added requiresInit pragma to enforce explicit initialization.
  • Exported templates are allowed to access hidden fields.
  • The using statement enables you to more easily author domain-specific languages and libraries providing OOP-like syntactic sugar.
  • Added the possibility to override various dot operators in order to handle calls to missing procs and reads from undeclared fields at compile-time.
  • The overload resolution now supports static[T] params that must be evaluable at compile-time.
  • Support for user-defined type classes has been added.
  • The command syntax is supported in a lot more contexts.
  • Anonymous iterators are now supported and iterators can capture variables of an outer proc.
  • The experimental strongSpaces parsing mode has been implemented.
  • You can annotate pointer types with regions for increased type safety.
  • Added support for the builtin spawn for easy thread pool usage.

Tools improvements

  • c2nim can deal with a subset of C++. Use the --cpp command line option to activate.

Nimrod Featured in Dr. Dobb's Journal

Nimrod has been featured as the cover story in the February 2014 issue of Dr. Dobb’s Journal.


Andreas Rumpf's talk on Nimrod at Strange Loop 2013 is now online

Andreas Rumpf presented Nimrod: A New Approach to Metaprogramming at Strange Loop 2013. The video and slides of the talk are now available.


Version 0.9.2 released

We are pleased to announce that version 0.9.2 of the Nimrod compiler has been released. This release has attracted by far the most contributions in comparison to any other release.

This release brings with it many new features and bug fixes, a list of which can be seen later. One of the major new features is the effect system together with exception tracking which allows for checked exceptions and more, for further details check out the manual . Another major new feature is the introduction of statement list expressions, more details on these can be found here. The ability to exclude symbols from modules has also been implemented, this feature can be used like so: import module except symbol.

Thanks to all contributors!

Bugfixes

  • The old GC never collected cycles correctly. Fixed but it can cause performance regressions. However you can deactivate the cycle collector with GC_disableMarkAndSweep and run it explicitly at an appropriate time or not at all. There is also a new GC you can activate with --gc:markAndSweep which does not have this problem but is slower in general and has no realtime guarantees.
  • cast for floating point types now does the bitcast as specified in the manual. This breaks code that erroneously uses cast to convert different floating point values.
  • SCGI module’s performance has been improved greatly, it will no longer block on many concurrent requests.
  • In total fixed over 70 github issues and merged over 60 pull requests.

Library Additions

  • There is a new experimental mark&sweep GC which can be faster (or much slower) than the default GC. Enable with --gc:markAndSweep.
  • Added system.onRaise to support a condition system.
  • Added system.locals that provides access to a proc’s locals.
  • Added macros.quote for AST quasi-quoting.
  • Added system.unsafeNew to support hacky variable length objects.
  • system.fields and system.fieldPairs support object too; they used to only support tuples.
  • Added system.CurrentSourcePath returning the full file-system path of the current source file.
  • The macros module now contains lots of useful helpers for building up abstract syntax trees.

Changes affecting backwards compatibility

  • shared is a keyword now.
  • Deprecated sockets.recvLine and asyncio.recvLine, added readLine instead.
  • The way indentation is handled in the parser changed significantly. However, this affects very little (if any) real world code.
  • The expression/statement unification has been implemented. Again this only affects edge cases and no known real world code.
  • Changed the async interface of the scgi module.
  • WideStrings are now garbage collected like other string types.

Compiler Additions

  • The doc2 command does not generate output for the whole project anymore. Use the new --project switch to enable this behaviour.
  • The compiler can now warn about shadowed local variables. However, this needs to be turned on explicitly via --warning[ShadowIdent]:on.
  • The compiler now supports almost every pragma in a push pragma.
  • Generic converters have been implemented.
  • Added a highly experimental noforward pragma enabling a special compilation mode that largely eliminates the need for forward declarations.

Language Additions

  • case expressions are now supported.
  • Table constructors now mimic more closely the syntax of the case statement.
  • Nimrod can now infer the return type of a proc from its body.
  • Added a mixin declaration to affect symbol binding rules in generics.
  • Exception tracking has been added and the doc2 command annotates possible exceptions for you.
  • User defined effects (“tags”) tracking has been added and the doc2 command annotates possible tags for you.
  • Types can be annotated with the new syntax not nil to explicitly state that nil is not allowed. However currently the compiler performs no advanced static checking for this; for now it’s merely for documentation purposes.
  • An export statement has been added to the language: It can be used for symbol forwarding so client modules don’t have to import a module’s dependencies explicitly.
  • Overloading based on ASTs has been implemented.
  • Generics are now supported for multi methods.
  • Objects can be initialized via an object constructor expression.
  • There is a new syntactic construct (;) unifying expressions and statements.
  • You can now use from module import nil if you want to import the module but want to enforce fully qualified access to every symbol in module.

Notes for the future

  • The scope rules of if statements will change in 0.9.4. This affects the =~ pegs/re templates.
  • The sockets module will become a low-level wrapper of OS-specific socket functions. All the high-level features of the current sockets module will be moved to a network module.

Version 0.9.0 released

Summary

  • Unsigned integers have been added.
  • The integer type promotion rules changed.
  • The template and macro system evolved.
  • Closures have been implemented.
  • Term rewriting macros have been implemented.
  • First steps to unify expressions and statements have been taken.
  • Symbol lookup rules in generics have become stricter to catch more errors.

Bugfixes

  • Fixed a bug where the compiler would “optimize away” valid constant parts of a string concatenation.
  • Fixed a bug concerning implicit type conversions in case statements.
  • Fixed a serious code generation bug that caused algorithm.sort to produce segmentation faults.
  • Fixed ambiguity in recvLine which meant that receiving \r\L was indistinguishable from disconnections.
  • Many more bugfixes, too many to list them all.

Library Additions

  • Added the (already existing) module htmlgen to the documentation.
  • Added the (already existing) module cookies to the documentation.
  • Added system.shallow that can be used to speed up string and sequence assignments.
  • Added system.eval that can execute an anonymous block of code at compile time as if was a macro.
  • Added system.staticExec and system.gorge for compile-time execution of external programs.
  • Added system.staticRead as a synonym for system.slurp.
  • Added macros.emit that can emit an arbitrary computed string as nimrod code during compilation.
  • Added strutils.parseEnum.
  • Added json.% constructor operator.
  • The stdlib can now be avoided to a point where C code generation for 16bit micro controllers is feasible.
  • Added module oids.
  • Added module endians.
  • Added a new OpenGL wrapper that supports OpenGL up to version 4.2.
  • Added a wrapper for libsvm.
  • Added a wrapper for mongodb.
  • Added terminal.isatty.
  • Added an overload for system.items that can be used to iterate over the values of an enum.
  • Added system.TInteger and system.TNumber type classes matching any of the corresponding types available in Nimrod.
  • Added system.clamp to limit a value within an interval [a, b].
  • Added strutils.continuesWith.
  • Added system.getStackTrace.
  • Added system.|| for parallel for loop support.
  • The GC supports (soft) realtime systems via GC_setMaxPause and GC_step procs.
  • The sockets module now supports ssl through the OpenSSL library, recvLine is now much more efficient thanks to the newly implemented sockets buffering.
  • The httpclient module now supports ssl/tls.
  • Added times.format as well as many other utility functions for managing time.
  • Added system.@ for converting an openarray to a seq (it used to only support fixed length arrays).
  • Added system.compiles which can be used to check whether a type supports some operation.
  • Added strutils.format, subexes.format which use the new varargs type.
  • Added module fsmonitor.

Changes affecting backwards compatibility

  • On Windows filenames and paths are supposed to be in UTF-8. The system, os, osproc and memfiles modules use the wide string versions of the WinAPI. Use the -d:useWinAnsi switch to revert back to the old behaviour which uses the Ansi string versions.
  • static, do, interface and mixin are now keywords.
  • Templates now participate in overloading resolution which can break code that uses templates in subtle ways. Use the new immediate pragma for templates to get a template of old behaviour.
  • There is now a proper distinction in the type system between expr and PNimrodNode which unfortunately breaks the old macro system.
  • pegs.@ has been renamed to pegs.!* and pegs.@@ has been renamed to pegs.!*\ as @ operators now have different precedence.
  • The type proc (without any params or return type) is now considered a type class matching all proc types. Use proc () to get the old meaning denoting a proc expecing no arguments and returning no value.
  • Deprecated system.GC_setStrategy.
  • re.findAll and pegs.findAll don’t return captures anymore but matching substrings.
  • RTTI and thus the marshall module don’t contain the proper field names of tuples anymore. This had to be changed as the old behaviour never produced consistent results.
  • Deprecated the ssl module.
  • Deprecated nimrod pretty as it never worked good enough and has some inherent problems.
  • The integer promotion rules changed; the compiler is now less picky in some situations and more picky in other situations: In particular implicit conversions from int to int32 are now forbidden.
  • system.byte is now an alias for uint8; it used to be an alias to int8.
  • bind expressions in templates are not properly supported anymore. Use the declarative bind statement instead.
  • The default calling convention for a procedural type is now closure, for procs it remains nimcall (which is compatible to closure). Activate the warning ImplicitClosure to make the compiler list the occurrences of proc types which are affected.
  • The Nimrod type system now distinguishes openarray from varargs.
  • Templates are now hygienic. Use the dirty pragma to get the old behaviour.
  • Objects that have no ancestor are now implicitly final. Use the inheritable pragma to introduce new object roots apart from TObject.
  • Macros now receive parameters like templates do; use the callsite builtin to gain access to the invocation AST.
  • Symbol lookup rules in generics have become stricter to catch more errors.

Compiler Additions

  • Win64 is now an officially supported target.
  • The Nimrod compiler works on BSD again, but has some issues as os.getAppFilename and os.getAppDir cannot work reliably on BSD.
  • The compiler can detect and evaluate calls that can be evaluated at compile time for optimization purposes with the --implicitStatic command line option or pragma.
  • The compiler now generates marker procs that the GC can use instead of RTTI. This speeds up the GC quite a bit.
  • The compiler now includes a new advanced documentation generator via the doc2 command. This new generator uses all of the semantic passes of the compiler and can thus generate documentation for symbols hiding in macros.
  • The compiler now supports the dynlib pragma for variables.
  • The compiler now supports bycopy and byref pragmas that affect how objects/tuples are passed.
  • The embedded profiler became a stack trace profiler and has been documented.

Language Additions

  • Added explicit static sections for enforced compile time evaluation.
  • Added an alternative notation for lambdas with do.
  • addr is now treated like a prefix operator syntactically.
  • Added global pragma that can be used to introduce new global variables from within procs.
  • when expressions are now allowed just like if expressions.
  • The precedence for operators starting with @ is different now allowing for sigil-like operators.
  • Stand-alone finally and except blocks are now supported.
  • Macros and templates can now be invoked as pragmas.
  • The apostrophe in type suffixes for numerical literals is now optional.
  • Unsigned integer types have been added.
  • The integer promotion rules changed.
  • Nimrod now tracks proper intervals for range over some built-in operators.
  • In parameter lists a semicolon instead of a comma can be used to improve readability: proc divmod(a, b: int; resA, resB: var int).
  • A semicolon can now be used to have multiple simple statements on a single line: inc i; inc j.
  • bind supports overloaded symbols and operators.
  • A distinct type can now borrow from generic procs.
  • Added the pragmas gensym, inject and dirty for hygiene in templates.
  • Comments can be continued with a backslash continuation character so that comment pieces don’t have to align on the same column.
  • Enums can be annotated with pure so that their field names do not pollute the current scope.
  • A proc body can consist of an expression that has a type. This is rewritten to result = expression then.
  • Term rewriting macros (see trmacros) have been implemented but are still in alpha.

Version 0.8.14 released

Version 0.8.14 has been released!

Bugfixes

  • Fixed a serious memory corruption concerning message passing.
  • Fixed a serious bug concerning different instantiations of a generic proc.
  • Fixed a newly introduced bug where a wrong EIO exception was raised for the end of file for text files that do not end with a newline.
  • Bugfix c2nim, c2pas: the --out option has never worked properly.
  • Bugfix: forwarding of generic procs never worked.
  • Some more bugfixes for macros and compile-time evaluation.
  • The GC now takes into account interior pointers on the stack which may be introduced by aggressive C optimizers.
  • Nimrod’s native allocator/GC now works on PowerPC.
  • Lots of other bugfixes: Too many to list them all.

Changes affecting backwards compatibility

  • Removed deprecated os.AppendFileExt, os.executeShellCommand, os.iterOverEnvironment, os.pcDirectory, os.pcLinkToDirectory, os.SplitPath, os.extractDir, os.SplitFilename, os.extractFileTrunk, os.extractFileExt, osproc.executeProcess, osproc.executeCommand.
  • Removed deprecated parseopt.init, parseopt.getRestOfCommandLine.
  • Moved strutils.validEmailAddress to matchers.validEmailAddress.
  • The pointer dereference operator ^ has been removed, so that ^ can now be a user-defined operator.
  • implies is no keyword anymore.
  • The is operator is now the of operator.
  • The is operator is now used to check type equivalence in generic code.
  • The pure pragma for procs has been renamed to noStackFrame.
  • The threading API has been completely redesigned.
  • The unidecode module is now thread-safe and its interface has changed.
  • The bind expression is deprecated, use a bind declaration instead.
  • system.raiseHook is now split into system.localRaiseHook and system.globalRaiseHook to distinguish between thread local and global raise hooks.
  • Changed exception handling/error reporting for os.removeFile and os.removeDir.
  • The algorithm for searching and loading configuration files has been changed.
  • Operators now have diffent precedence rules: Assignment-like operators (like *=) are now special-cased.
  • The fields in TStream have been renamed to have an Impl suffix because they should not be used directly anymore. Wrapper procs have been created that should be used instead.
  • export is now a keyword.
  • assert is now implemented in pure Nimrod as a template; it’s easy to implement your own assertion templates with system.astToStr.

Language Additions

  • Added new is and of operators.
  • The built-in type void can be used to denote the absence of any type. This is useful in generic code.
  • Return types may be of the type var T to return an l-value.
  • The error pragma can now be used to mark symbols whose usage should trigger a compile-time error.
  • There is a new discardable pragma that can be used to mark a routine so that its result can be discarded implicitly.
  • Added a new noinit pragma to prevent automatic initialization to zero of variables.
  • Constants can now have the type seq.
  • There is a new user-definable syntactic construct a{i, ...} that has no semantics yet for built-in types and so can be overloaded to your heart’s content.
  • bind (used for symbol binding in templates and generics) is now a declarative statement.
  • Nimrod now supports single assignment variables via the let statement.
  • Iterators named items and pairs are implicitly invoked when an explicit iterator is missing.
  • The slice assignment a[i..j] = b where a is a sequence or string now supports splicing.

Compiler Additions

  • The compiler can generate C++ code for easier interfacing with C++.
  • The compiler can generate Objective C code for easier interfacing with Objective C.
  • The new pragmas importcpp and importobjc make interfacing with C++ and Objective C somewhat easier.
  • Added a new pragma incompleteStruct to deal with incomplete C struct definitions.
  • Added a --nimcache:PATH configuration option for control over the output directory for generated code.
  • The --genScript option now produces different compilation scripts which do not contain absolute paths.
  • Added --cincludes:dir, --clibdir:lib configuration options for modifying the C compiler’s header/library search path in cross-platform way.
  • Added --clib:lib configuration option for specifying additional C libraries to be linked.
  • Added --mainmodule:file configuration options for specifying the main project file. This is intended to be used in project configuration files to allow commands like nimrod c or nimrod check to be executed anywhere within the project’s directory structure.
  • Added a --app:staticlib option for creating static libraries.
  • Added a --tlsEmulation:on|off switch for control over thread local storage emulation.
  • The compiler and standard library now support a taint mode. Input strings are declared with the TaintedString string type. If the taint mode is turned on it is a distinct string type which helps to detect input validation errors.
  • The compiler now supports the compilation cache via --symbolFiles:on. This potentially speeds up compilations by an order of magnitude, but is still highly experimental!
  • Added --import:file and --include:file configuration options for specifying modules that will be automatically imported/incluced.
  • nimrod i can now optionally be given a module to execute.
  • The compiler now performs a simple alias analysis to generate better code.
  • The compiler and ENDB now support watchpoints.
  • The compiler now supports proper compile time expressions of type bool for on|off switches in pragmas. In order to not break existing code, on and off are now aliases for true and false and declared in the system module.
  • The compiler finally supports closures. This is a preliminary implementation, which does not yet support nestings deeper than 1 level and still has many known bugs.

Library Additions

  • Added system.allocShared, system.allocShared0, system.deallocShared, system.reallocShared.
  • Slicing as implemented by the system module now supports splicing.
  • Added explicit channels for thread communication.
  • Added matchers module for email address etc. matching.
  • Added strutils.unindent, strutils.countLines, strutils.replaceWord.
  • Added system.slurp for easy resource embedding.
  • Added system.running for threads.
  • Added system.programResult.
  • Added xmltree.innerText.
  • Added os.isAbsolute, os.dynLibFormat, os.isRootDir, os.parentDirs.
  • Added parseutils.interpolatedFragments.
  • Added macros.treeRepr, macros.lispRepr, macros.dumpTree, macros.dumpLisp, macros.parseExpr, macros.parseStmt, macros.getAst.
  • Added locks core module for more flexible locking support.
  • Added irc module.
  • Added ftpclient module.
  • Added memfiles module.
  • Added subexes module.
  • Added critbits module.
  • Added asyncio module.
  • Added actors module.
  • Added algorithm module for generic sort, reverse etc. operations.
  • Added osproc.startCmd, osproc.execCmdEx.
  • The osproc module now uses posix_spawn instead of fork and exec on Posix systems. Define the symbol useFork to revert to the old implementation.
  • Added intsets.assign.
  • Added system.astToStr and system.rand, system.doAssert.
  • Added system.pairs for built-in types like arrays and strings.

Version 0.8.12 released

Bugfixes

  • Bugfix: httpclient correct passes the path starting with /.
  • Bugfixes for the htmlparser module.
  • Bugfix: pegs.find did not respect start parameter.
  • Bugfix: dialogs.ChooseFilesToOpen did not work if only one file is selected.
  • Bugfix: niminst: nimrod is not default dir for every project.
  • Bugfix: Multiple yield statements in iterators did not cause local vars to be copied.
  • Bugfix: The compiler does not emit very inaccurate floating point literals anymore.
  • Bugfix: Subclasses are taken into account for try except matching.
  • Bugfix: Generics and macros are more stable. There are still known bugs left though.
  • Bugfix: Generated type information for tuples was sometimes wrong, causing random crashes.
  • Lots of other bugfixes: Too many to list them all.

Changes affecting backwards compatibility

  • Operators starting with ^ are now right-associative and have the highest priority.
  • Deprecated os.getApplicationFilename: Use os.getAppFilename instead.
  • Deprecated os.getApplicationDir: Use os.getAppDir instead.
  • Deprecated system.copy: Use substr or string slicing instead.
  • Changed and documented how generalized string literals work: The syntax module.re"abc" is now supported.
  • Changed the behaviour of strutils.%, ropes.% if both notations $# and $i are involved.
  • The pegs and re modules distinguish between replace and replacef operations.
  • The pointer dereference operation p^ is deprecated and might become ^p in later versions or be dropped entirely since it is rarely used. Use the new notation p[] in the rare cases where you need to dereference a pointer explicitly.
  • system.readFile does not return nil anymore but raises an EIO exception instead.
  • Unsound co-/contravariance for procvars has been removed.

Language Additions

  • Source code filters are now documented.
  • Added the linearScanEnd, unroll, shallow pragmas.
  • Added emit pragma for direct code generator control.
  • Case statement branches support constant sets for programming convenience.
  • Tuple unpacking is not enforced in for loops anymore.
  • The compiler now supports array, sequence and string slicing.
  • A field in an enum may be given an explicit string representation. This yields more maintainable code than using a constant array[TMyEnum, string] mapping.
  • Indices in array literals may be explicitly given, enhancing readability: [enumValueA: "a", enumValueB: "b"].
  • Added thread support via the threads core module and the --threads:on command line switch.
  • The built-in iterators system.fields and system.fieldPairs can be used to iterate over any field of a tuple. With this mechanism operations like == and hash are lifted to tuples.
  • The slice .. is now a first-class operator, allowing code like: x in 1000..100_000.

Compiler Additions

  • The compiler supports IDEs via the new group of idetools command line options.
  • The interactive mode (REPL) has been improved and documented for the first time.
  • The compiler now might use hashing for string case statements depending on the number of string literals in the case statement.

Library Additions

  • Added lists module which contains generic linked lists.
  • Added sets module which contains generic hash sets.
  • Added tables module which contains generic hash tables.
  • Added queues module which contains generic sequence based queues.
  • Added intsets module which contains a specialized int set data type.
  • Added scgi module.
  • Added smtp module.
  • Added encodings module.
  • Added re.findAll, pegs.findAll.
  • Added os.findExe.
  • Added parseutils.parseUntil and parseutils.parseWhile.
  • Added strutils.align, strutils.tokenize, strutils.wordWrap.
  • Pegs support a captured search loop operator {@}.
  • Pegs support new built-ins: \letter, \upper, \lower, \title, \white.
  • Pegs support the new built-in \skip operation.
  • Pegs support the $ and ^ anchors.
  • Additional operations were added to the complex module.
  • Added strutils.formatFloat, strutils.formatBiggestFloat.
  • Added unary < for nice looking excluding upper bounds in ranges.
  • Added math.floor.
  • Added system.reset and a version of system.open that returns a TFile and raises an exception in case of an error.
  • Added a wrapper for redis.
  • Added a wrapper for 0mq via the zmq module.
  • Added a wrapper for sphinx.
  • Added system.newStringOfCap.
  • Added system.raiseHook and system.outOfMemHook.
  • Added system.writeFile.
  • Added system.shallowCopy.
  • system.echo is guaranteed to be thread-safe.
  • Added prelude include file for scripting convenience.
  • Added typeinfo core module for access to runtime type information.
  • Added marshal module for JSON serialization.

Version 0.8.10 released

Bugfixes

  • Bugfix: Command line parsing on Windows and os.parseCmdLine now adheres to the same parsing rules as Microsoft’s C/C++ startup code.
  • Bugfix: Passing a ref pointer to the untyped pointer type is invalid.
  • Bugfix: Updated keyval example.
  • Bugfix: system.splitChunk still contained code for debug output.
  • Bugfix: dialogs.ChooseFileToSave uses STOCK_SAVE instead of STOCK_OPEN for the GTK backend.
  • Bugfix: Various bugs concerning exception handling fixed.
  • Bugfix: low(somestring) crashed the compiler.
  • Bugfix: strutils.endsWith lacked range checking.
  • Bugfix: Better detection for AMD64 on Mac OS X.

Changes affecting backwards compatibility

  • Reversed parameter order for os.copyFile and os.moveFile!!!
  • Procs not marked as procvar cannot only be passed to a procvar anymore, unless they are used in the same module.
  • Deprecated times.getStartMilsecs: Use epochTime or cpuTime instead.
  • Removed system.OpenFile.
  • Removed system.CloseFile.
  • Removed strutils.replaceStr.
  • Removed strutils.deleteStr.
  • Removed strutils.splitLinesSeq.
  • Removed strutils.splitSeq.
  • Removed strutils.toString.
  • If a DLL cannot be loaded (via the dynlib pragma) EInvalidLibrary is not raised anymore. Instead system.quit() is called. This is because raising an exception requires heap allocations. However the memory manager might be contained in the DLL that failed to load.
  • The re module (and the pcre wrapper) now depend on the pcre dll.

Additions

  • The {.compile: "file.c".} pragma uses a CRC check to see if the file needs to be recompiled.
  • Added system.reopen.
  • Added system.getCurrentException.
  • Added system.appType.
  • Added system.compileOption.
  • Added times.epochTime and times.cpuTime.
  • Implemented explicit type arguments for generics.
  • Implemented {.size: sizeof(cint).} pragma for enum types. This is useful for interfacing with C.
  • Implemented {.pragma.} pragma for user defined pragmas.
  • Implemented {.extern.} pragma for better control of name mangling.
  • The importc and exportc pragmas support format strings: proc p{.exportc: "nim_$1".} exports p as nim_p. This is useful for user defined pragmas.
  • The standard library can be built as a DLL. Generating DLLs has been improved.
  • Added expat module.
  • Added json module.
  • Added support for a Tiny C backend. Currently this only works on Linux. You need to bootstrap with -d:tinyc to enable Tiny C support. Nimrod can then execute code directly via nimrod run myfile.

Version 0.8.8 released

Bugfixes

  • The Posix version of os.copyFile has better error handling.
  • Fixed bug #502670 (underscores in identifiers).
  • Fixed a bug in the parsexml module concerning the parsing of <tag attr="value" />.
  • Fixed a bug in the parsexml module concerning the parsing of enities like &ltXX.
  • system.write(f: TFile, s: string) now works even if s contains binary zeros.
  • Fixed a bug in os.setFilePermissions for Windows.
  • An overloadable symbol can now have the same name as an imported module.
  • Fixed a serious bug in strutils.cmpIgnoreCase.
  • Fixed unicode.toUTF8.
  • The compiler now rejects '\n' (use "\n" instead).
  • times.getStartMilsecs() now works on Mac OS X.
  • Fixed a bug in pegs.match concerning start offsets.
  • Lots of other little bugfixes.

Additions

  • Added system.cstringArrayToSeq.
  • Added system.lines(f: TFile) iterator.
  • Added system.delete, system.del and system.insert for sequences.
  • Added system./ for int.
  • Exported system.newException template.
  • Added cgi.decodeData(data: string): tuple[key, value: string].
  • Added strutils.insertSep.
  • Added math.trunc.
  • Added ropes module.
  • Added sockets module.
  • Added browsers module.
  • Added httpserver module.
  • Added httpclient module.
  • Added parseutils module.
  • Added unidecode module.
  • Added xmldom module.
  • Added xmldomparser module.
  • Added xmltree module.
  • Added xmlparser module.
  • Added htmlparser module.
  • Added re module.
  • Added graphics module.
  • Added colors module.
  • Many wrappers now do not contain redundant name prefixes (like GTK_, lua). The old wrappers are still available in lib/oldwrappers. You can change your configuration file to use these.
  • Triple quoted strings allow for " in more contexts.
  • "" within raw string literals stands for a single quotation mark.
  • Arguments to openArray parameters can be left out.
  • More extensive subscript operator overloading. (To be documented.)
  • The documentation generator supports the .. raw:: html directive.
  • The Pegs module supports back references via the notation $capture_index.

Changes affecting backwards compatibility

  • Overloading of the subscript operator only works if the type does not provide a built-in one.
  • The search order for libraries which is affected by the path option has been reversed, so that the project’s path is searched before the standard library’s path.
  • The compiler does not include a Pascal parser for bootstrapping purposes any more. Instead there is a pas2nim tool that contains the old functionality.
  • The procs os.copyFile and os.moveFile have been deprecated temporarily, so that the compiler warns about their usage. Use them with named arguments only, because the parameter order will change the next version!
  • atomic and let are now keywords.
  • The \w character class for pegs now includes the digits '0'..'9'.
  • Many wrappers now do not contain redundant name prefixes (like GTK_, lua) anymore.
  • Arguments to openArray parameters can be left out.

Version 0.8.6 released

The version jump from 0.8.2 to 0.8.6 acknowledges the fact that all development of the compiler is now done in Nimrod.

Bugfixes

  • The pragmas hint[X]:off and warning[X]:off now work.
  • Method call syntax for iterators works again (for x in lines.split()).
  • Fixed a typo in removeDir for POSIX that lead to an infinite recursion.
  • The compiler now checks that module filenames are valid identifiers.
  • Empty patterns for the dynlib pragma are now possible.
  • os.parseCmdLine returned wrong results for trailing whitespace.
  • Inconsequent tuple usage (using the same tuple with and without named fields) does not crash the code generator anymore.
  • A better error message is provided when the loading of a proc within a dynamic lib fails.

Additions

  • Added system.contains for open arrays.
  • The PEG module now supports the search loop operator @.
  • Grammar/parser: SAD|IND is allowed before any kind of closing bracket. This allows for more flexible source code formatting.
  • The compiler now uses a bind table for symbol lookup within a bind context. (See manual.html#templates for details.)
  • discard """my long comment""" is now optimized away.
  • New --floatChecks: on|off switches and pragmas for better debugging of floating point operations. (See manual.html#types-pre-defined-floating-point-types for details.)
  • The manual has been improved. (Many thanks to Philippe Lhoste!)

Changes affecting backwards compatibility

  • The compiler does not skip the linking step anymore even if no file has changed.
  • os.splitFile(".xyz") now returns ("", ".xyz", "") instead of ("", "", ".xyz"). So filenames starting with a dot are handled differently.
  • strutils.split(s: string, seps: set[char]) never yields the empty string anymore. This behaviour is probably more appropriate for whitespace splitting.
  • The compiler now stops after the --version command line switch.
  • Removed support for enum inheritance in the parser; enum inheritance has never been documented anyway.
  • The msg field of system.E_base has now the type string, instead of cstring. This improves memory safety.

订阅RSS