As part of the process of learning Nim, I've ported my game Gravitate (a variation of TileFall or the SameGame), to Nim.
I used the NiGui library, so no third party .so's or .dll's are needed.
Although I've tried to make the most of Nim and to be as idiomatic as possible, I'm sure there's room for improvement. So I hope that some Nim experts will review the source and give me feedback -- or just edited .nim files -- to help me improve my code. (For example, in the game.nim file's start() function it takes me 4 lines to choose 4 unique random colors from a sequence of 17; surely it can be done in less code?)
There are two archives available from the game's home page. The direct downloads (both including 64-bit executables and full source code <1 KLOC) are Windows and Linux.
Things I couldn't do because either I can't figure out how or because NiGui doesn't support them:
Despite the above, given how small and convenient NiGui is, and how it can be used to create stand-alone GUI executables, I think it is a superb library.
And I'm also enjoying learning Nim very much!
it takes me 4 lines to choose 4 unique random colors from a sequence of 17;
shuffle() should do the trick, not only in Nim:
import sequtils, random, sugar
var a = toSeq(1 .. 17).outplace(shuffle())[0 .. 3]
echo a
The other points you miss in NiGui -- well we have at least one lib which would support that :-)
If you are really interested in someone improving or reading your game source code, then you may put the code on your github account. I think it is a great example for NiGUI.
I can't find outplace (at least not in 1.0.4 or 'latest' on the Nim playground). However, I'll have another go with shuffle which I already use elsewhere.
I'm sure there are other Nim libs that support NiGui's missing features -- but don't all of them depend on SDL or OpenGL or other third party libs?
As for github, I have an a/c there to contribute, but I don't put my own projects there. My gravitate packages include the full source.
Outplace is new in devel, but I wrote "shuffle does the trick". I only used outplace in the example to generate the mutable test array from the range.
And note that NiGui depends on GTK on Linux, so your earlier statement "pure Nim, no depencies" is only valid for windows. There are some GUI libs which do not need SDL or OpenGL. GTK3 needs GTK3 of course. And wNim runs on windows only. First I considered making a GTK3 version of your game, may take a few hours over Christmas. But the game idea is too boring, and I have to do really many other stuff, sorry.
Are you considering writing a Nim book? Saw your Python and Go books.
shuffle() is in-place but it did save me one line:
var colors = gameColors # gameColors is a const seq[Color]
shuffle(colors)
colors = colors[0 ..< game.maxColors]
It is true that NiGui uses Gtk on Linux, but Gtk is pretty well always on desktop/laptop systems even KDE ones, since there're bound to be apps that depend on it.
Nim could certainly do with a really good book -- I'd certainly like to read one.
(I've dipped into Nim in Action, but I felt it was too close to the docs, the main examples didn't appeal to me, and it isn't Nim 1.0.)
As for writing a Nim book: (1) I'd need to have done a lot more Nim programming -- which I'm in the process of doing; (2) I'd need to have at least one core dev willing to read and give feedback on all the examples and on the text -- over a 12-18 month period; (3) I'd need to interest my -- or another -- publisher; (4) I'd need to feel motivated to spend at least a year working on a book that's likely to sell only a few thousand copies and so be a labor of love rather than economically viable. So I'm hoping someone else does it:-)
to sell only a few thousand copies
Good joke! To sell 100 with current Nim community size may be possible, maybe 200 with a chinese translation. A free book may have indeed 1k readers. My guess is that manning sold some hundreds of NimInActions indeed, but that was when Nim was new and had some hype, in 2015. And they sold them for only 20$. Now many people know already Nim, so they may not want to buy a book. And we have a lot of free resources now.