News for hackers. Stuff that matters.
Re:I missed Nim (2014) by 3pt14159 on Thursday January 21, 2016 @02:33PM (#10947663)
Nim is great. It is fast and it works everywhere that C works or JavaScript works since it transpiles to either (and then compiles if transpiling to C). It is super fucking fast (usually faster than C) and it feels like it has none of the limitations that you normally find out there.

That being said, there are a couple of issues.

1. Like Crystal, Nim still doesn't have HTTPS for its webserver, and with both, the default instructions are insecure. (Download this thing and run it in your shell, pay no attention to any MITM that can trivially root your machine).

2. The community is really pro, but the arguments are too tiring. We had a huge argument over the equivalent of Ruby's chomp. Everyone is so afraid of bloat in the standard lib (which I don't really understand, since I've never found myself wanting less string methods).

3. While the syntax is way better than Rust, Go, et al. It borrows some annoyingness from Python where it could have looked to Ruby for better guidance. For example, sort vs sorted. Sorted is the safer operation in Python. It returns a new sorted list. Now what normally happens in the real world is that programmers make the safe version first and later make the fast version. But imagine that the first version was called "sort" and it returned a new array, how are you to transition to a fast sort and a safe sorted? Error prone patching. Ruby's array.sort vs array.sort! is much better during transition, more legible, just all around better. It means less mangling around and it means that 99.9% of the time you know the method you're calling is safe if it doesn't have the bang after it.

4. There is still some instability here and there when you try to do cute things. I can't remember exactly what it was, but something along the lines of passing channels over channels segfaulted. This leaves you a little concerned about just how much abstraction you build up.

That being said, I fucking love Nim. It's so fun to write, it's super fast, it's quite legible, and you can do literally anything. It's had shared objects (dlls) since I started using it, so Ruby <-> Nim is possible and fun. It's very debugable and once it hits 1.0 and gets more mainstream use I'm sure it's going to be a really popular language.

Re:I missed Nim (2014) by scardine on Thursday January 21, 2016 @03:03PM (#10947891)
The deal breaker for me is the variable name normalization:

userName == user_name == username == uS_eR_aN_mE

It used to be totally case insensitive now it is case sensitive for the first letter. Underscores are ignored: two identifiers are considered equal if the following algorithm returns true:

    proc sameIdentifier(a, b: string): bool =
      a[0] == b[0] and
        a.replace(re"_|–", "").toLower == b.replace(re"_|–", "").toLower
For me it is a capital violation of the "principle of least astonishment".
Re:I missed Nim (2014) by 3pt14159 on Thursday January 21, 2016 @03:31PM (#10948084)
I actually love this. It makes it easy to write code in either a JS context (where you want camel case) or Ruby(ish) context. I really don't see how this is a deal breaker. It's one of the first things you learn when you start with Nim and I've never had a problem with it.

To me this is kinda akin to the people that complain about the magic in Rails or that Ruby includes so many things by default (like rand or sleep) without working on a couple of projects first. Those really aren't the problems that slow you down in Ruby and this isn't really something that is an issue in practice.

Re:I missed Nim (2014) by lqdc13 on Thursday January 21, 2016 @07:38PM (#10949821)
it's a huge problem because in many cases you have no idea that you are reusing a variable, because in every other language you wouldn't be reusing a variable.

This plus the crazy global name space pollution. If you import something, everything is imported from that module. I have no idea what to name things because everything collides with everything else.

In Python, things are simple. Classes are 'CapitalCase' and functions are 'lower_case'. If I did the same thing in nim, they would collide. Also, in Python it is considered a terrible idea to do

    from some_module import *
in Nim, it is the way things are done. Although, they are alternative methods that don't do this.

also, the weird

    var
        a, b = 0
Perhaps you get used to it with time. But still namespace collision is always a problem for me especially when working with others' libs.

However, it is currently the most painless way to write fast code and integrate with Python, which says a lot.

Edit: Looks like first letter matters now, so ignore that part of the comment.

Re:I missed Nim (2014) by 3pt14159 on Thursday January 21, 2016 @09:21PM (#10950333)
I've never had a namespace collision problem. Not when reusing or when importing. When was the last time you used Nim?
Re:I missed Nim (2014) by lqdc13 on Friday January 22, 2016 @12:40AM (#10950983)
Yesterday. But I ran into the issue last week.

I was reusing "paramStr" variable. This is a built in in the os module. I defined "param_str" in my module. Then wrote another module that was using the first one. Then realized I was overwriting an OS module function.

I actually have no idea how such collisions are handled. What if I import another module that overwrites the OS module? What if a 3rd party lib uses some variable that another 3rd party lib also defined?

A whole set of problems would be gone if such importing was looked down upon. I mean it is exactly the same situation in Python (but not exacerbated by the name canonicalization), and people realized a long time ago that doing this is not a good idea.

Re:I missed Nim (2014) by robochat42 on Friday January 22, 2016 @03:08AM (#10951424)
Coming from python, I'm also surprised by the way Nim imports but I realised that it's not the same sitution because nim uses unified function call (ufc) syntax to implement its method calls. Methods are functions that due to the UFC sugar can be used as methods and so everything needs to be imported from a module in order that methods are visible to the calling scope. This works better than you might expect since the correct function normally gets called due to static typing. Of course this doesn't fix variable name collisions. I'd need to program more in nim though to decide how much of a problem this is.
Re:I missed Nim (2014) by robochat42 on Monday February 01, 2016 @06:47AM (#11011202)
Having looked at the tutorial, I can see now that variable name collisions (i.e. if defined in two imported modules) are caught as errors by the compiler. Also only deliberately exposed symbols get imported into the namespace which reduces the namespace overlap considerably.
Re:I missed Nim (2014) by cma on Saturday January 23, 2016 @10:11AM (#10958588)
It destroys the ability to search. You have to use a crazy regex to search for all instances of a variable.
Re:I missed Nim (2014) by Mikeb85 on Thursday January 21, 2016 @03:19PM (#10947998)
Because it's such a deal breaker that you can't have "userName" and "user_name" in the same scope. This was brought up in the other thread, and it's just as silly now. Rejecting an absurd naming scheme is a feature.
Re:I missed Nim (2014) by dom96 on Thursday January 21, 2016 @05:20PM (#10948937)
For those who would like to read the previous thread: https://news.ycombinator.com/item?id=10931800
Re:I missed Nim (2014) by david-given on Thursday January 21, 2016 @05:05PM (#10948811)
Urgh. I wish languages wouldn't do this. Things which look different should be different.

At least it's case sensitive for the first letter, which means that the traditional lowercase-for-identifiers, capitalised-for-types naming scheme works.

I've tried programming in Ada, which has case insensitive identifiers; it was deeply painful.

Edit: Plus, of course, case sensitivity is locale dependent. Are I and i the same letter? Not if you're Turkish. (Upper case i is İ; lower case I is ı.)

Yes, this matters. http://www.theinquirer.net/inquirer/news/1017243/cellphone-l...

Re:I missed Nim (2014) by dom96 on Thursday January 21, 2016 @05:22PM (#10948967)
I would be interested to hear your experiences with Ada, what in particular made case insensitive identifiers painful. Can you give some examples?
Re:I missed Nim (2014) by throwaway999888 on Thursday January 21, 2016 @07:30PM (#10949782)
So uppercase Turkish `ı` is the same as ASCII `I`?.

Go and Haskell also have some special (unconventional) treatment of capital letters, which probably make them biased towards the English language.

Re:I missed Nim (2014) by lifthrasiir on Thursday January 21, 2016 @07:44PM (#10949862)
Yes. And uppercase Turkish `i` (which is same to ASCII `i`) is not ASCII `I` but Turkish `İ`. Obviously this behavior is very locale-specific.

> Go and Haskell also have some special (unconventional) treatment of capital letters, which probably make them biased towards the English language.

In Ruby an identifier is considered to start with an uppercase letter when it really starts with an uppercase letter or underscore; that probably is the best compromise for unicase scripts including CJK scripts.

Re:I missed Nim (2014) by throwaway999888 on Thursday January 21, 2016 @08:38PM (#10950138)
It's a weird language bug. I wish English (and my own tongue) was as consistent with the dots as Turkish is. ;)
Re:I missed Nim (2014) by krupan on Thursday January 21, 2016 @04:07PM (#10948360)
How does the garbage collection work when transpiling to c?
Re:I missed Nim (2014) by PeCaN on Thursday January 21, 2016 @06:54PM (#10949562)
Probably just has a conservative Boehm-ish GC. Their website is a bit sparse on the GC details from what I can tell, but anything else would be rather surprising.
Re:I missed Nim (2014) by nickpsecurity on Friday January 22, 2016 @01:47AM (#10951192)
A bit more interesting:

"The basic algorithm is Deferred Reference Counting with cycle detection. # This is achieved by combining a Deutsch-Bobrow garbage collector # together with Christoper's partial mark-sweep garbage collector. # # Special care has been taken to avoid recursion as far as possible to avoid # stack overflows when traversing deep datastructures. It is well-suited # for soft real time applications (like games)."

Re:I missed Nim (2014) by tonyg on Thursday January 21, 2016 @10:38PM (#10950597)
The garbage collector looks to be written in Nim: https://github.com/nim-lang/Nim/blob/devel/lib/system/gc.nim
Re:I missed Nim (2014) by gokr on Tuesday January 26, 2016 @10:36AM (#10973885)
In fact, there are five (!) different GCs you can try:

--gc:refc|v2|markAndSweep|boehm|go|none