Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
def-
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
21 ms
·
181.
▲
by
def-
12y ago
Usually you don't create a struct yourself, but use c2nim to wrap it, like I did here: http://hookrace.net/blog/what-makes-nim-practical/#wrapping-... When you look at the resulting Nim wrapper, here's w
182.
▲
On Rust and Nim
(andreaferretti.github.io)
7 points
by
def-
12y ago
|
0 comments
183.
▲
by
def-
12y ago
This is all I found: http://nim-lang.org/manual.html#parallel-statement
184.
▲
by
def-
12y ago
proc a = var x = 10 proc b = echo x b() a() Comes pretty close, the struct is further up: https://gist.github.com/def-/c496cd42774617fd0271#file-nestc...
185.
▲
by
def-
12y ago
That's on its way!
186.
▲
by
def-
12y ago
That means if programs written in C work on your OS, so do the ones in Nim.
187.
▲
by
def-
12y ago
That's something nim-idetools can do once it works properly: http://nim-lang.org/idetools.html
188.
▲
by
def-
12y ago
> - Significant whitespace, but tabs are forbidden Here's the reasoning: https://github.com/Araq/Nim/wiki/Whitespace-FAQ#tabs-vs-spac... If you still want tabs you can add this at the top of your file
189.
▲
by
def-
12y ago
User defined type classes can be used for this, but they're still experimental: http://nim-lang.org/manual.html#user-defined-type-classes
190.
▲
by
def-
12y ago
As unwind suggested, they just get transformed down to global functions with unique names. Here's the actual C code generated: https://gist.github.com/def-/0fe87bf1d35102c62d3b#file-nest-...
191.
▲
by
def-
12y ago
Nested functions like this?: proc a = proc b = proc c = proc d = echo "Hello World" d() c() b() a() Works fine.
192.
▲
by
def-
12y ago
Why would you say it's not competing with D and Rust? Performance-wise Nim should be in the same ball-park, and you can do systems programming in it. For me Nim is a universal language which I can use for almost anything.
193.
▲
by
def-
12y ago
Oops, I thought I checked all links. Thank you!
194.
▲
What makes Nim practical?
(hookrace.net)
154 points
by
def-
12y ago
|
130 comments
195.
▲
by
def-
12y ago
http://hookrace.net/blog/what-is-special-about-nim/
196.
▲
by
def-
12y ago
Well, there is a REPL, but it's not that great: $ nim i >>> for i in 0..10: ... echo "Hello World"[0..i] ... H He Hel Hell Hello Hello Hello W Hello Wo Hello W
197.
▲
by
def-
12y ago
Term rewriting templates are only supposed to be optimizations, not change the semantics. They happen on the AST, so the pattern matches are on the AST as well. You won't get the actual values of any variables, they aren't even kn
198.
▲
by
def-
12y ago
$ gcc -O2 -std=c99 -lm -o c c.c $ time ./c ./c 2.49s user 0.07s system 99% cpu 2.567 total $ nim -d:release c nim $ time ./nim ./nim 2.47s user 0.07s system 99% cpu 2.538 total Yes, --opt:speed is slo
199.
▲
by
def-
12y ago
I guess you could use fewer magic numbers if you want, for example instead of: proc createCRCTable(): array[256, CRC32] = for i in 0..255: You can write: proc createCRCTable(): array[256, CRC32] = for i in result.low .. r
200.
▲
by
def-
12y ago
I prefer to have a consistent code base, then I can use the internal tools of my editor, which are not aware of Nim's identifier rules.
201.
▲
by
def-
12y ago
> -For "You should then add ~/.nimble/bin to your $PATH" it took me quite a while to figure I had to enter "ln -s ~/.nimble/bin/nimble /usr/local/bin/" in my Mac's ter
202.
▲
by
def-
12y ago
I would consider it bad style to abuse the case-insensitivity like that. It can be used for good too, for example if you have a bunch of different naming conventions in the libraries you use: proc some_lib_function(x: int) = echo "
203.
▲
by
def-
12y ago
And the first release with the new name was just a few days ago: https://news.ycombinator.com/item?id=8809215
204.
▲
by
def-
12y ago
Thanks, that's great!
205.
▲
by
def-
12y ago
The compiler isn't completely stable yet. Often I ran into problems combining multiple features, when I filled up Nim's Rosetta Code entries: https://github.com/def-/nim-unsorted http://rosettacode
206.
▲
What is special about Nim?
(hookrace.net)
269 points
by
def-
12y ago
|
84 comments
207.
▲
by
def-
12y ago
No, since it's written by Araq, the creator of Nim.
208.
▲
by
def-
12y ago
https://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletio... > Lacks reliable independent secondary sources to establish notability as required by WP:GNG. Every source is WP:PRIMARY. Every one of them. Googling t
209.
▲
by
def-
12y ago
Wow, that's really cool! Never seen that before. (I implemented many of the Rosetta Code tasks in Nim)
210.
▲
by
def-
12y ago
I think that should be type refCounted[T] = object val: T refs: int You could try a destructor for the object: http://nim-lang.org/manual.html#destructors
More ›