nordlow/compiler-benchmark

[feature request] Add Nim language

ringabout opened this issue ยท 7 comments

Hi, could you add Nim language?

Nim is a system language using automatic reference counting with destructors and move semantics to manage memory. It supports C/C++/JS backends. Nim has a powerful macro system which allows direct manipulation of the AST, offering nearly unlimited opportunities.

The website:
https://nim-lang.org

The Github repo:
https://github.com/nim-lang/Nim

Installation:
https://nim-lang.org/install.html

debug build: nim c --gc:arc app.nim
release build: nim c --gc:arc -d:release app.nim
check?: nim check app.nim

Sample code:

proc add_long_n0_h0(x: int): int =
  return x + 15440

proc add_long_n0(x: int): int =
  return x + add_long_n0_h0(x) + 95485

proc add_long_n1_h0(x: int): int =
  return x + 37523

proc add_long_n1(x: int): int =
  return x + add_long_n1_h0(x) + 92492

proc add_long_n2_h0(x: int): int =
  return x + 39239

proc add_long_n2(x: int): int =
  return x + add_long_n2_h0(x) + 12248


var long_sum = 0;
long_sum += add_long_n0(0)
long_sum += add_long_n1(1)
long_sum += add_long_n2(2)

I'll try.

Hi, could you add Nim language?
debug build: nim c --gc:arc app.nim
release build: nim c --gc:arc -d:release app.nim
check?: nim check app.nim

You can give master a try now.

I've added support for check and debug builds support. Feel free to modify and propose pull requests as you wish. compiler-benchmark currenly only tests debug build performance.

There are lots of flags here and I don't know what to enable by default so go ahead you and propose whatever you prefer at https://nim-lang.org/docs/nimc.html

The flag --gc:arc doesn't work on nim version 1.0.6 packaged with Ubuntu 20.04 but works with version 1.2.6 packaged on Ubuntu 21.04. Is there a different betweeen --gc:arc and --gc:refc? I'm gonna use --gc:refc for now because it works on Ubuntu 20.04.

Is there a different betweeen --gc:arc and --gc:refc

refc is the default memory management method. arc is introduced since 1.2.x.

You can give master a try now.

Nice, thanks!

@nordlow 1.0.6 and even 1.2 are quite old releases, it's really preferable to have 1.4

Yeah as @Yardanico suggested, can you use curl(choosenim) to install latest Nim?

curl https://nim-lang.org/choosenim/init.sh -sSf | sh

https://www.osradar.com/nim-programming-language-ubuntu-debian

BTW system is imported implicit, so it is unnecessary to import it.

thanks!