Live data from Hacker News

What is special about Nim?

hookrace.net

31–40 of 88 posts

Re: What is special about Nim?

#31
post #3

Great write-up! I expected this to reference a few "normal" language features like static typing, operator overloading, or generics, but instead it was a list of some really neat off-the-beaten-track features: * Run regular code at compile time * Extend the language (AST templates and macros); this can be used to add a form of list comprehensions to the language! * Add your own optimizations to the compiler! * Bind (…

As a pythonista one thing that struck me in the code fragments is zeroes and ones appearing everywhere. It looks very easy to have off by one errors. (It is very rare to have off by one errors in Python due to the way counting and ranges work.)

I don't program in Python, but I thought one of the contention points the community had was the syntax of slices and such (starting at one instead of zero, or one sire of the range being inclusive, I can't recall). If that's true, I would imagine that would encourage for some off by one errors. Then again, maybe it's not nearly as contentious as it sounded in a few comments.

Re: What is special about Nim?

#32
post #11

Earlier quoted context omitted.

The idea that thisFunction and this_function are the same might be worse than the problem they're trying to solve. I cannot unfortunately have experience with larg-ish codebases in nim to tell if this would result in an actual problem or not, but the idea that I have to scan between two possible identifiers in the code can be a source of stupid bugs in the same vein as case-insensitive identifiers. On the other hand…

That seems like a really bad idea. It means that searching for an identifier requires you to allow for the possibility that there might be any number of underscores inserted anywhere. I suppose in practice you'll rely on the fact that no one will be inserting them other than at word boundaries, but it still seems horrible. (I'd worry about ambiguities of the experts exchange / expert sex change type, too, but my gues…

Maybe you're thinking in terms of a text editor and not an IDE? With an IDE, you look for symbol references, not text with regexps. You could imagine that the IDE's search would be smart enough to know that if you look for foo_bar, it should also report occurrences of fooBar.

Either way, I still find the idea a bit weird. If the language wants to be opinionated about naming, maybe it could simply make _ illegal in an identifier or, to push it one level further, refuse to compile any identifier that is not camelCase.

Re: What is special about Nim?

#33
post #11

Earlier quoted context omitted.

The idea that thisFunction and this_function are the same might be worse than the problem they're trying to solve. I cannot unfortunately have experience with larg-ish codebases in nim to tell if this would result in an actual problem or not, but the idea that I have to scan between two possible identifiers in the code can be a source of stupid bugs in the same vein as case-insensitive identifiers. On the other hand…

That seems like a really bad idea. It means that searching for an identifier requires you to allow for the possibility that there might be any number of underscores inserted anywhere. I suppose in practice you'll rely on the fact that no one will be inserting them other than at word boundaries, but it still seems horrible. (I'd worry about ambiguities of the experts exchange / expert sex change type, too, but my gues…

The reason of this (while I agree with you) is because Nim comes with a strong interop with C/C++ so the problem is that in C and C++ there is a SnakeCase debate still open. They did that so your program can invoke c (or even nim libs) without taking care of the upcase/underscore style and use your own.

While this seems problematic they added some neat features to avoid problems with `uniqueness` of the name and so on.

One thing I wish at this point is to force the compiler to stop if this pattern is not uniform within a codebase.

Re: What is special about Nim?

#34
post #3

Great write-up! I expected this to reference a few "normal" language features like static typing, operator overloading, or generics, but instead it was a list of some really neat off-the-beaten-track features: * Run regular code at compile time * Extend the language (AST templates and macros); this can be used to add a form of list comprehensions to the language! * Add your own optimizations to the compiler! * Bind (…

As a pythonista one thing that struck me in the code fragments is zeroes and ones appearing everywhere. It looks very easy to have off by one errors. (It is very rare to have off by one errors in Python due to the way counting and ranges work.)

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 .. result.high:
Or:

  proc createCRCTable(): array[256, CRC32] =
    for i, v in result: # index, value
Or define your own indices iterator:

  iterator indices(x) =
    for i in x.low .. x.high:
      yield i

  proc createCRCTable(): array[256, CRC32] =
    for i in result.indices:
I think I should propose adding indices to the standard library.

Re: What is special about Nim?

#35
A little OT: Courtesy of the Reddit discussion of the OP, a reference to the discussion on Wikipedia about Nim, or rather, the discussion to delete its Wikipedia entry:

https://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletio...

At what point does a language become noteworthy enough for a site that contains full entries for side characters in non-canonical Star Wars novels?

Re: What is special about Nim?

#36
post #11

Earlier quoted context omitted.

That seems like a really bad idea. It means that searching for an identifier requires you to allow for the possibility that there might be any number of underscores inserted anywhere. I suppose in practice you'll rely on the fact that no one will be inserting them other than at word boundaries, but it still seems horrible. (I'd worry about ambiguities of the experts exchange / expert sex change type, too, but my gues…

Maybe you're thinking in terms of a text editor and not an IDE? With an IDE, you look for symbol references, not text with regexps. You could imagine that the IDE's search would be smart enough to know that if you look for foo_bar, it should also report occurrences of fooBar. Either way, I still find the idea a bit weird. If the language wants to be opinionated about naming, maybe it could simply make _ illegal in an…

I was thinking of both. An IDE is worse unless it's actually targetted specifically at Nim, because its code for finding symbol references surely won't know about Nim's underscore-blindness.

(But I'm not much of an IDE-user myself. Perhaps modern IDEs have enough hooks that you really can control this stuff?)

Re: What is special about Nim?

#37
post #35

A little OT: Courtesy of the Reddit discussion of the OP, a reference to the discussion on Wikipedia about Nim, or rather, the discussion to delete its Wikipedia entry: https://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletio... At what point does a language become noteworthy enough for a site that contains full entries for side characters in non-canonical Star Wars novels?

Honestly, I thing a dozen Nim users should band together and register at Wikipedia to turn the vote the next time someone tries to delete the article. If the deletionists come with formalistic arguments, just synthesize a few articles on sites that fulfill their WP:RELIABLE criteria. There's got to be somebody working for a commercial (read: non-blog) website who doesn't like deletionism and would post a small article on Nim (or any other topic suffering from the same problem) just to stick it to them.

Re: What is special about Nim?

#38
post #35

A little OT: Courtesy of the Reddit discussion of the OP, a reference to the discussion on Wikipedia about Nim, or rather, the discussion to delete its Wikipedia entry: https://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletio... At what point does a language become noteworthy enough for a site that contains full entries for side characters in non-canonical Star Wars novels?

Honestly, I thing a dozen Nim users should band together and register at Wikipedia to turn the vote the next time someone tries to delete the article. If the deletionists come with formalistic arguments, just synthesize a few articles on sites that fulfill their WP:RELIABLE criteria. There's got to be somebody working for a commercial (read: non-blog) website who doesn't like deletionism and would post a small articl…

If somebody on HN has a website like that and would be willing to do this then we would really love to hear from that person!

Re: What is special about Nim?

#39
I copy/pasted the code in the article and compiled each one. I am getting very different ratios compared to the ones you posted:

tmp$cc -Wall -O2 test.c -o test && time ./test

real 0m1.041s user 0m0.998s sys 0m0.029s

nim-0.10.2$./bin/nim --opt:speed c test.nim && time ./test

real 0m1.943s user 0m1.894s sys 0m0.036s

Re: What is special about Nim?

#40
post #35

A little OT: Courtesy of the Reddit discussion of the OP, a reference to the discussion on Wikipedia about Nim, or rather, the discussion to delete its Wikipedia entry: https://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletio... At what point does a language become noteworthy enough for a site that contains full entries for side characters in non-canonical Star Wars novels?

Honestly, I thing a dozen Nim users should band together and register at Wikipedia to turn the vote the next time someone tries to delete the article. If the deletionists come with formalistic arguments, just synthesize a few articles on sites that fulfill their WP:RELIABLE criteria. There's got to be somebody working for a commercial (read: non-blog) website who doesn't like deletionism and would post a small articl…

Wikipedia is, for some things, severely broken.

Your post will be seen by some wikipedians as a violation of some policy or other. (Off the top of my head there's sock puppeting http://en.wikipedia.org/wiki/Wikipedia:Sock_puppetry "Do not ask your friends to create accounts to support you.")

Post reply on HN