Live data from Hacker News

What makes Nim practical?

hookrace.net

61–70 of 132 posts

Re: What makes Nim practical?

#61
post #57
post #18

Earlier quoted context omitted.

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-...

What about variables nested within these functions then? Is scope enforced? i.e. you can reach back to variable aa in function a() from nested d() but can't reach variable dd in d() from a()?

I assume so? That would be a static check of the nim code.

Re: What makes Nim practical?

#62
post #58

Nim has some good ideas but I can't get over the syntax: - Significant whitespace, but tabs are forbidden - No block comments, save for `discard """ ... """` - Identifiers are case and underscore-insensitive (FOO_BAR === fooBar === fo_ob_ar)

> - Identifiers are case and underscore-insensitive (FOO_BAR === fooBar === fo_ob_ar) In the language design stages who in the world thought this would be a good idea? Even PHP doesn't do that.

Let's be realistic. If you have somebody naming variables:

foo_bar = blah

foobar = blah

fooBar = blah

That's someone you really don't want to be coding anywhere near, because it leads to really, really confusing code. So nim is just enforcing not being able to do it it as a language.

Re: What makes Nim practical?

#63
post #9
post #5

I just realized something: Nim is like a faster Python or a better Go lang It's not really competing in quite the same space as say, D or Rust. It's like a statically typed scripting language.

Care elaborating on why is it a better Golang?

Just about everything is better than Go. Nim, Rust, OCaml, Haskell... Did you read the submission? And for further enlightenment, the link to the previous post on the blog about what makes Nim special? Here's a link to a rant comparing Go and Rust, which includes some links of its own highlighting further issues with Go: http://www.quora.com/How-do-Go-and-Rust-languages-compare

Re: What makes Nim practical?

#64
post #58

Nim has some good ideas but I can't get over the syntax: - Significant whitespace, but tabs are forbidden - No block comments, save for `discard """ ... """` - Identifiers are case and underscore-insensitive (FOO_BAR === fooBar === fo_ob_ar)

> - Identifiers are case and underscore-insensitive (FOO_BAR === fooBar === fo_ob_ar) In the language design stages who in the world thought this would be a good idea? Even PHP doesn't do that.

The idea here -as far as I'm aware- is to allow for different coding styles without having to wrap another library. One author preferring camel case while another library uses underscore, lowercase naming?

For a new language, I feel like one could have just forced one style unto the users, but that's just me talking.

Re: What makes Nim practical?

#66
post #62
post #58

Earlier quoted context omitted.

> - Identifiers are case and underscore-insensitive (FOO_BAR === fooBar === fo_ob_ar) In the language design stages who in the world thought this would be a good idea? Even PHP doesn't do that.

Let's be realistic. If you have somebody naming variables: foo_bar = blah foobar = blah fooBar = blah That's someone you really don't want to be coding anywhere near, because it leads to really, really confusing code. So nim is just enforcing not being able to do it it as a language.

It still means you can't reliably grep code for an identifier. Strikes me as a really stupid wart in an otherwise great language.

go format is a much better solution to the same problem.

Re: What makes Nim practical?

#69
post #62
post #58

Earlier quoted context omitted.

> - Identifiers are case and underscore-insensitive (FOO_BAR === fooBar === fo_ob_ar) In the language design stages who in the world thought this would be a good idea? Even PHP doesn't do that.

Let's be realistic. If you have somebody naming variables: foo_bar = blah foobar = blah fooBar = blah That's someone you really don't want to be coding anywhere near, because it leads to really, really confusing code. So nim is just enforcing not being able to do it it as a language.

I agree, but the problem is that you don't ever want to do this whether those are three different variables (or is that two?) or whether all are alternative forms of the same case/underscore insensitive name. Nim is going out it's way to make the syntax you have about legal (will all of these equivalent), which strikes me as a bad move.

The best case for usability is that this "feature" never used, which makes it an odd design choice. The worst case is that the feature is used frequently, there is no clear language norm, visually scanning for variables is harder, search and replace requires dedicated tools, and subtle bugs abound. Far better (in my personal opinion) to make identifiers case sensitive and enforce consistency with style guidelines and code "prettifiers".

The current Nim approach is being called cs:partial (case sensitive partial) and makes the first letter case sensitive but all others insensitive. This like an awkward compromise, and needlessly complicated. The best proposal I've seen suggests making "_x" equivalant to "X" (underscore is an alias for "next letter is capital"). But I don't see it as better than case insensitive plus strong code conventions.

Post reply on HN