I have tried this in C before but it didn't turn out right... I think the problem was not interpolating the pre-offset midpoint, ended up with ragid square waves. Anyways in Python you can create and write image files with import PIL but don't know how to create images in Nim yet.
As per Nim's install page, there's no longer a reason to compile Nim by hand. It always provided binaries for Windows. The best and easiest way to install and update Nim on Unix / MacOS is the choosenim tool. There are also nightly builds for Linux, Windows, and MacOS. It's up-to-date in the default package registry for FreeBSD, [NetBSD](http:// pkgsrc.se/lang/nim), etc.
It isn't one of the releases on the main website, but Nim is available for Android too. If you have the Termux command line terminal app installed then you can do apt install nim.
Nim is like one of those languages you see on Rosetta Code and always wanted to try. I understand Go, Rust, D and Nim are all intended as alternatives to C++ (Zig fancies itself a replacement for vanilla C).
The problem I have is the official tutorials don't really teach well, they are more like promotions to showcase features to experienced developers... You would have to hunker down and get used to the syntax and stuff to be comfortable with it. In the real world true beginners (pajeets or not) take a Java class and struggle to master for loops to draw ASCII patterns.
The standard library is pretty big, not as big as the C++ template library but it has a lot of features! Lots of data structures... Pretty interesting stuff you could study, but it isn't really documented well from a user perspective. :/
Parts of the website are autogenerated using a documentation tool, technically documented but no usage examples and the references are difficult to read... It comes with a package manager (most packages are hosted on GitHub or BitBucket and it downloads and compiles source), but many packages turn out to be Nim bindings to C code, and are not well documented... I understand both Nim and D communities have that issue.
Isn't there a more gentle intro? Like I tried to do a few Euler Project problems, and while Nim syntax is pretty clean looking it took awhile to declare a 64-bit integer in order to calculate larger Fibbonacci numbers... It's pretty easy actually but you have to learn everything from the beginning over again.
Yup, there are several ways to target Android in addition to Termux. Other examples: dali (not copyfree), nimx, nimes (just uses sdl2). This old forum thread could still be useful.
I understand Go, Rust, D and Nim are all intended as alternatives to C++
Performance overhead compared to C. Rust usually comes second to C, D / Nim fight for third place, and Go is further behind. But Nim has a secret weapon that others don't: it can use a proprietary native code generator backend (ex. Intel's ICC) to get ahead of D and Rust!
Having manual memory management (ex. C/C++, Ada, Rust), GC by default that you can disable (Nim, D, Go), or mandatory GC (Swift?, Java?).
VM reliance. I don't think languages that default to JVM / .NET can be considered system languages, even if they have a "native" variant. All those native variants I've seen so far (Scala Native, Kotlin Native, etc) are far behind the VM variants.
Every time I look at this language and try to do a code doodle it never works... The syntax looks clean but I can never guess how to do things correctly.
Like, what if I want to print "*" 19 times in a row, or rather create a string that long? In Python you can multiply a string for concatenated repetition but Nim doesn't do that. Okay, I'll just write a loop and concatenate characters to a string... I keep guessing the wrong syntax to do that!
Has anybody else out there used this language? How do you get past the extreme-beginner stage when you don't know how to do anything.
Every time I look at this language and try to do a code doodle it never works... The syntax looks clean but I can never guess how to do things correctly.
Good things do require some effort. If you just know Python, learning any language that comes close to the speed of C will involve new concepts and require practice. A lot of things you're learning aren't specific to Nim and would also be useful for any statically typed, feature-rich, (ultra)modern programming language. Nim does compare very favorably to C/C++, Rust, D, Haskell, etc in ease of learning. It does have hard parts and lots of advanced features (ex. metaprogramming, effects, turning off GC, etc) that you can (at least) initially avoid.
Like, what if I want to print "*" 19 times in a row, or rather create a string that long? In Python you can multiply a string for concatenated repetition but Nim doesn't do that.
Of course it does.
The language developer decided that let s = "*".repeat 19 (also need import strutils prior) is the better default behavior for Nim's standard library. Nim's way is clearer, as you can tell exactly what's happening. Reducing the number of characters to do something doesn't always make the language better.
But if you really want Python's print("x" * 19) to work, all you have to do is importpylib (after getting it with nimble install pylib command). Additional libraries make Nim more like Python, Kotlin, Perl, etc.
How do you get past the extreme-beginner stage when you don't know how to do anything.
Practice, practice, practice. Reading other people's code also helps.
It will also get easier when the language & standard library reaches version 1.0 stability, and there will be no breaking changes and more focus on documentation.
Earlier I learnt Nim just for myself. Thanks for sharing these essential details which I didn’t know. I hope that Nim is the next major programming language, that will take the world by storm, and that in several years, there will be lots of work that needs to be done in Nim.
Despite the fact that today I'm already working in a successful software engineering company, I still find time to learn Nim. It is absolutely worth learning.
9 comments
0 u/rcb [OP] 27 May 2019 02:53
There is a little something I would like to try but haven't learned enough yet.
https://voat.co/v/Algorithms/328557 -> https://web.archive.org/web/20160211133100/http://gameprogrammer.com/fractal.html
I have tried this in C before but it didn't turn out right... I think the problem was not interpolating the pre-offset midpoint, ended up with ragid square waves. Anyways in Python you can create and write image files with
import PILbut don't know how to create images in Nim yet.0 u/libman 27 May 2019 14:37
I'm very glad to see Nim getting attention here!
As per Nim's install page, there's no longer a reason to compile Nim by hand. It always provided binaries for Windows. The best and easiest way to install and update Nim on Unix / MacOS is the choosenim tool. There are also nightly builds for Linux, Windows, and MacOS. It's up-to-date in the default package registry for FreeBSD, [NetBSD](http:// pkgsrc.se/lang/nim), etc.
0 u/rcb [OP] 27 May 2019 15:50
It isn't one of the releases on the main website, but Nim is available for Android too. If you have the Termux command line terminal app installed then you can do
apt install nim.Nim is like one of those languages you see on Rosetta Code and always wanted to try. I understand Go, Rust, D and Nim are all intended as alternatives to C++ (Zig fancies itself a replacement for vanilla C).
The problem I have is the official tutorials don't really teach well, they are more like promotions to showcase features to experienced developers... You would have to hunker down and get used to the syntax and stuff to be comfortable with it. In the real world true beginners (pajeets or not) take a Java class and struggle to master
forloops to draw ASCII patterns.The standard library is pretty big, not as big as the C++ template library but it has a lot of features! Lots of data structures... Pretty interesting stuff you could study, but it isn't really documented well from a user perspective. :/
Parts of the website are autogenerated using a documentation tool, technically documented but no usage examples and the references are difficult to read... It comes with a package manager (most packages are hosted on GitHub or BitBucket and it downloads and compiles source), but many packages turn out to be Nim bindings to C code, and are not well documented... I understand both Nim and D communities have that issue.
Isn't there a more gentle intro? Like I tried to do a few Euler Project problems, and while Nim syntax is pretty clean looking it took awhile to declare a 64-bit integer in order to calculate larger Fibbonacci numbers... It's pretty easy actually but you have to learn everything from the beginning over again.
0 u/libman 28 May 2019 19:09
Yup, there are several ways to target Android in addition to Termux. Other examples: dali (not copyfree), nimx, nimes (just uses sdl2). This old forum thread could still be useful.
They are all systems languages. They can be further categorized by:
Performance overhead compared to C. Rust usually comes second to C, D / Nim fight for third place, and Go is further behind. But Nim has a secret weapon that others don't: it can use a proprietary native code generator backend (ex. Intel's ICC) to get ahead of D and Rust!
Having manual memory management (ex. C/C++, Ada, Rust), GC by default that you can disable (Nim, D, Go), or mandatory GC (Swift?, Java?).
VM reliance. I don't think languages that default to JVM / .NET can be considered system languages, even if they have a "native" variant. All those native variants I've seen so far (Scala Native, Kotlin Native, etc) are far behind the VM variants.
0 u/rcb [OP] 27 May 2019 23:13
Every time I look at this language and try to do a code doodle it never works... The syntax looks clean but I can never guess how to do things correctly.
https://hookrace.net/blog/what-is-special-about-nim/
Like, what if I want to print
"*"19 times in a row, or rather create a string that long? In Python you can multiply a string for concatenated repetition but Nim doesn't do that. Okay, I'll just write a loop and concatenate characters to a string... I keep guessing the wrong syntax to do that!Has anybody else out there used this language? How do you get past the extreme-beginner stage when you don't know how to do anything.
0 u/libman 28 May 2019 17:16
Good things do require some effort. If you just know Python, learning any language that comes close to the speed of C will involve new concepts and require practice. A lot of things you're learning aren't specific to Nim and would also be useful for any statically typed, feature-rich, (ultra)modern programming language. Nim does compare very favorably to C/C++, Rust, D, Haskell, etc in ease of learning. It does have hard parts and lots of advanced features (ex. metaprogramming, effects, turning off GC, etc) that you can (at least) initially avoid.
Further recommended reading / watching:
Nim for Python Programmers
Awesome Nim - curated list of libraries
Nim for VScode - currently the best supported Nim IDE (along with (neo)vim). Static typing makes real time suggestions more useful than Python.
Nim YouTube video playlist
Nim In Action book
Of course it does.
The language developer decided that
let s = "*".repeat 19(also needimport strutilsprior) is the better default behavior for Nim's standard library. Nim's way is clearer, as you can tell exactly what's happening. Reducing the number of characters to do something doesn't always make the language better.But if you really want Python's
print("x" * 19)to work, all you have to do isimportpylib (after getting it withnimble install pylibcommand). Additional libraries make Nim more like Python, Kotlin, Perl, etc.Practice, practice, practice. Reading other people's code also helps.
It will also get easier when the language & standard library reaches version 1.0 stability, and there will be no breaking changes and more focus on documentation.
0 u/SubhumanDeplorable 13 Jun 2019 17:05
Why did we need all these fing variations if damn languages? They all do the same shit.
0 u/Bessalitskykh 22 Jul 2019 11:04
Earlier I learnt Nim just for myself. Thanks for sharing these essential details which I didn’t know. I hope that Nim is the next major programming language, that will take the world by storm, and that in several years, there will be lots of work that needs to be done in Nim.
0 u/Bessalitskykh 22 Jul 2019 11:06
Despite the fact that today I'm already working in a successful software engineering company, I still find time to learn Nim. It is absolutely worth learning.