Live data from Hacker News

Nim: Scripting Ease in a Compiled Language

junglecoder.com

121–130 of 169 posts

Re: Nim: Scripting Ease in a Compiled Language

#121
post #102

Earlier quoted context omitted.

Oh, but that's OK. You can just have inform and in_form. Except you can't because Nim also ignores underscores in identifiers. Gotta make sure there is literally no way to disambiguate cases like this! (I _want_ to like Nim but this single decision seems to me so spectacularly bad that it's a non-starter.)

Sounds like you're agreeing with me?

Yup. (And saying it's _even worse_ than what you describe.)

Re: Nim: Scripting Ease in a Compiled Language

#122

I've been considering getting into Nim for a while now as something more lightweight/terse to write thin CLI utilities in. I'm glad to hear that it's performing well for this usecase. It's a very attractive alternative to Rust for it's simplicity and terseness. I still haven't gotten around to picking it up though, these days I just use QuickJS for anything that needs to be reasonably portable and thin. Maybe next si…

I would highly recommend it. Setup is incredibly easy (VSCode has great plugins for it), the language is simple to read/write and compiled Nim is very fast with small binaries. I also really like nimfmt to keep my code tidy so I don't need to worry about it. Nim compiles VERY quickly and errors seem to be easy to comprehend. It's definitely one of my go-to languages for most of my projects.

Re: Nim: Scripting Ease in a Compiled Language

#123

Earlier quoted context omitted.

Nim is actually case sensitive on the first character only, so your list of identifiers are not all equivalent. Just thought I'd point that out for correctness sake.

Oh, thank you for the correction, and sorry for the misinformation! In any case (pun intended?) it's the underscore insensitivity that makes it difficult to use standard search tools.

> it's the underscore insensitivity that makes it difficult to use standard search tools.

I personally don't like the feature, but what do you find difficult about using /my_?[vV]ariable/ to search for any of myvariable, my_variable or myVariable?

Re: Nim: Scripting Ease in a Compiled Language

#124

One thing I find annoying about Nim is the case insensitivity [0]. There was no strong reason for this "feature" and literally no mainstream language does it. Moreover it makes code search a pain. [0] https://nim-lang.org/docs/manual.html#lexical-analysis-ident...

Disallowing these case/underscore variants from referring to differing values could be quite ok -- even a plus-- if (but only if) an additional rule is added to disallow any variations of the declaration-time casing for a variable within the same scope to prevent the need for bespoke grepping tools and discourage arbitrary variations. If that restriction was added one could argue that this improves code readability (…

Even with such a rule, you would still run into problems if you want to grep for a token that's used in some application but declared in a separate library.

Re: Nim: Scripting Ease in a Compiled Language

#125
post #86

Earlier quoted context omitted.

I use Nim in production. I been using it for more than 1 year in production. I like it. For me, it started out as a faster python that prevents typos. But it has really grown on me. I really like that I can share libs on server (compiling to c) and client side (compiling to plain javascript). Basically any C library is also a Nim library with a tiny wrapper. That's a huge ecosystem! I also like how Nim can integrate…

I have some code duplication between android, iOS and a webapp / PWA. How realistic is it to look at something like nim for codesharing?

Not the parent poster but I'd say it's very realistic. I've written a few applications that target both JS (web browser) and binary (server) and it works very well. One example of this is https://picheta.me/snake/.

I'm also working on a game that I haven't quite moved to iOS/Android yet, but that is my plan. So far targeting the desktop with SDL and HTML5/Canvas with the JS backend works very well.

Re: Nim: Scripting Ease in a Compiled Language

#126
post #116

Earlier quoted context omitted.

For me, I'm seeing compile times averaging around 5-10 seconds, with outlier builds taking up to 40 seconds if the files in question aren't cached. It feels faster than Go, but I think part of that is down to Nim's compile output being verbose by default.

Nim's compilation is much faster than Go.

As someone that compared both a while back (and a biased Nim core developer) I don't think this claim is true. Go is really fast at compilation, but honestly Nim is good enough.

Re: Nim: Scripting Ease in a Compiled Language

#127
post #102

Earlier quoted context omitted.

> Its difficult to read and understand code that does things like myvalue = myValue. I think they made the right tradeoff They could enforce case consistency instead of case insensitivity if that's the problem they're trying to solve, though. Although, even then, consider that variables like 'inform' and 'inForm' might not mean the same thing...

Oh, but that's OK. You can just have inform and in_form. Except you can't because Nim also ignores underscores in identifiers. Gotta make sure there is literally no way to disambiguate cases like this! (I _want_ to like Nim but this single decision seems to me so spectacularly bad that it's a non-starter.)

You can also just pick a different name, which is something you should probably do anyway in this case.

Re: Nim: Scripting Ease in a Compiled Language

#128
post #114

One thing I find annoying about Nim is the case insensitivity [0]. There was no strong reason for this "feature" and literally no mainstream language does it. Moreover it makes code search a pain. [0] https://nim-lang.org/docs/manual.html#lexical-analysis-ident...

It's shocking how people whine about case insensitivity without bothering to try using Nim for a while. Case insensitivity is a feature and it's meant to allow easy interfacing with C. And it also encourages clean code. With other languages you can have variables called "startdate", "start_date" and "startDate" in the same scope leading to bugs - especially when using completion in an editor - and poor readability. I…

> In Nim the compiler tells you that you are redefining the same variable in 3 different places and you can go and give them more meaningful names.

If this is the goal, there are many alternative ways to solve this problem, making the language case insensitive is a pretty big hammer.

Re: Nim: Scripting Ease in a Compiled Language

#129

Earlier quoted context omitted.

great! then I don't really understand nim's case insensitivity rules

Only the first char is case sensitive. The rest is case and underline insensitive;

Oh, my god! How do people reach this kind of ideas?

Re: Nim: Scripting Ease in a Compiled Language

#130

One thing I find annoying about Nim is the case insensitivity [0]. There was no strong reason for this "feature" and literally no mainstream language does it. Moreover it makes code search a pain. [0] https://nim-lang.org/docs/manual.html#lexical-analysis-ident...

Main reason for this feature is that Nim is big as a glue language. Many C/C++ libraries don't have consistent naming conventions between them. I don't want my code to look like a patch work of `__APICALL__(system_call.inspectSomething())` I just want it to look like Nim code: `apiCall(systemCall.inspectSomething())`. This is just a consistent standard on how to turn names in one style into another style backed into…

    apiCall = __APICALL__
done
Post reply on HN