I've been translating various versions of the SSoZ I did in C++ in 2014 to Nim. 
Here are a few of my observations as a newbie.

1) Nim is much less noisy to write code in, with much less syntactical 
requirements to worry about (curly braces for if|for statements, etc).

2) Once I figured it out, it's a (just) little bit easier to satisfy integer 
type unification for doing math. But why can't you just add an **int** to an 
**uint** without having to manually explicitly cast the numbers. Can't the 
compiler figure this out?

3) Nim executables are either approxiamently 4|5x (with clang) or 6|7x (with 
gcc) larger than for C++ for some programs, though I can make them smaller 
using **strip** on them.

4) However, the Nim executables produce faster runtimes, and run to completion 
in some cases (for Nth Primes for example) where the comparable C++ throws a 
runtime Segfault error for the same inputs.

5) Nim is definitely easier to learn than C++ (because of the lower syntatic 
noise and more robust language paradigms, such as with **for** loops, etc), if 
you already know how to program (it's easier to figure out). Being young and 
growing (not 1.0 yet) it doesn't have the level of documentation you can find 
for C++, nor example code, etc, but the new book will help with that. I would 
highly recommend, and urge, a significant effort be put into creating as much 
(good, helpful, relevant) documentation as possible, especially to answer all 
the low level newbie questions, to attract people who want to try using Nim for 
really serious stuff.

6) The Nim installation procedure on the website failed to intall Nim on a 
number of distros (KDE Neon, LinuxMint, Kubuntu, PCLinuxOS) I tried. Even 
though the Ubuntu derivatives have Nim in their repos it's version 0.12 (not 
latest 0.17). Please provide instructions that will work, and/or create an 
AppImage, Snap, etc package to make installation universally simple.

Below are the gists source code for my Nim translations of the original C++ 
implementations of the Segmented Sieve of Zakiya (SSoZ) using the P5 prime 
generator in each instance (I've done version with P7 too). These are 
sequential implementation. The main reason I'm interested in Nim is the 
potential to (easierly) implement these in parallel (than with C++, Rust, 
Julia, Python, etc). I've rearchitectured the memory model to make it parallel 
friendly, and now just need to figure out how to play with Nim pointers (and 
whatever else) to accomplish this.

All in all, I see alot of potential for Nim as it matures.

Gist files of Nim code of SSoZ versions, transated from C++.

**ssozp5.nim**

Find the primes <= N, using sequential implementation of SSoZ with P5 prime 
generator.

[https://gist.github.com/jzakiya/94670e6144735eb0041919f633d6011c](https://gist.github.com/jzakiya/94670e6144735eb0041919f633d6011c)

**nthprime_ssozp5.nim**

Find nth primes, using sequential implementation of SSoZ with P5 prime 
generator.

[https://gist.github.com/jzakiya/aff4f2e38f9b0f833955b4cc391de3d4](https://gist.github.com/jzakiya/aff4f2e38f9b0f833955b4cc391de3d4)

**twinprimes_ssozp5.nim**

[https://gist.github.com/jzakiya/776b7aae3126168b4cad90de9adc4961](https://gist.github.com/jzakiya/776b7aae3126168b4cad90de9adc4961)

Find twin primes <= N, using sequential implementation of SSoZ with P5 prime 
generator.

Reply via email to