TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Nim Programming Language Tutorial

136 pointsby j-bover 10 years ago

8 comments

beagle3over 10 years ago
I&#x27;ve just read through the Nim manual. On the surface, it looks as simple as Python - but it is ridiculously deep when you look at all the template, macro, term rewriters, etc.<p>Whether or not you can make use of it without being aware of all those things remains to be seen. I suspect the answer is mostly yes, i.e. that one can use the nim ecosystem effectively without knowing all of that. (my answer for C++ would be &quot;mostly no&quot; - you need to really know everything about all the dark corners of the language to use the ecosystem effectively).<p>I&#x27;m trying to think of a good way to implement automatic reference counting with copy-on-write, e.g. for big arrays, but haven&#x27;t come up with one yet. Could a Nim veteran kindly point me in the idiomatic direction?
评论 #8811401 未加载
评论 #8811323 未加载
评论 #8814684 未加载
fiatjafover 10 years ago
For those wanting a quick grasp of the language, here&#x27;s Nim in action:<p>- against Python: <a href="http://rosetta.alhur.es/compare/Python/Nimrod/#" rel="nofollow">http:&#x2F;&#x2F;rosetta.alhur.es&#x2F;compare&#x2F;Python&#x2F;Nimrod&#x2F;#</a><p>- against Ruby: <a href="http://rosetta.alhur.es/compare/ruby/Nimrod/#" rel="nofollow">http:&#x2F;&#x2F;rosetta.alhur.es&#x2F;compare&#x2F;ruby&#x2F;Nimrod&#x2F;#</a>
评论 #8812872 未加载
kartikkumarover 10 years ago
I&#x27;m intrigued by Nim after browsing through some of the basic tutorials. Looks quite straightforward to get started. As with other languages I look at, for my use-cases it&#x27;s important for me to understand0 if scientific packages are available and if there&#x27;s a &quot;scientific computing ecosystem&quot;.<p>I had a look through the `packages.json` [1] listing for Nimble [2] and couldn&#x27;t really spot the maths packages that I&#x27;d need, e.g., numerical integration, optimization, linear algebra. Given that I can&#x27;t find any of those, I&#x27;m guessing there aren&#x27;t any physics packages either e.g., Newtonian mechanics, physical constants etc. Maybe maths libraries are available as ports to e.g., Eigen, NLOPT etc.?<p>Can anyone that is more familiar with the community comment on the potential of Nim as a language for scientific computing, in contrast to e.g., Julia?<p>[1] <a href="https://github.com/nim-lang/packages/blob/master/packages.json" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nim-lang&#x2F;packages&#x2F;blob&#x2F;master&#x2F;packages.js...</a><p>[2] <a href="https://github.com/nimrod-code/nimble" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nimrod-code&#x2F;nimble</a><p>[3] <a href="http://eigen.tuxfamily.org/index.php?title=Main_Page" rel="nofollow">http:&#x2F;&#x2F;eigen.tuxfamily.org&#x2F;index.php?title=Main_Page</a><p>[4] <a href="http://ab-initio.mit.edu/wiki/index.php/NLopt" rel="nofollow">http:&#x2F;&#x2F;ab-initio.mit.edu&#x2F;wiki&#x2F;index.php&#x2F;NLopt</a><p>EDIT: Fixed typos
评论 #8811012 未加载
baroslover 10 years ago
I&#x27;m quite surprised that Nim&#x27;s strings are null-terminated, <i>and</i> have a length field. According to a forum article[1], it is mainly due to the C interoperability.<p>I understand that FFI is kinda important for system languages, but isn&#x27;t it giving up too much to disallow null characters in the middle of a string? Null-terminated strings generally work well, but there have been some corner cases that made me annoyed. (Such as PHP&#x27;s preg_* functions)<p>[1] <a href="http://forum.nimrod-lang.org/t/125" rel="nofollow">http:&#x2F;&#x2F;forum.nimrod-lang.org&#x2F;t&#x2F;125</a>
评论 #8810810 未加载
评论 #8810957 未加载
Tloewaldover 10 years ago
Nice tutorial pitched just right for me. Looks a lot like Iron Python iirc. I like that you can start writing old school interactive command line apps so easily -- great for starting out and in the absence of solid gui tools.
wildmXranatover 10 years ago
I just spent an hour going through Nim related webpages by users who write in it. This is a good find, thanks.
评论 #8810647 未加载
jzelinskieover 10 years ago
Is that german quote from something other than Rammstein lyrics?
davexunitover 10 years ago
I don&#x27;t see anything particulary special here. The metaprogramming features are quite weak. The macro system is very primitive. The number types seem to be lacking, too. I don&#x27;t see anything about bignums, rationals, or complex numbers.
评论 #8811431 未加载
评论 #8811458 未加载