News for hackers. Stuff that matters.
Re:Nim 2.0 thoughts by michaelsbradley on Saturday May 15, 2021 @11:29AM (#27166061)
Nim is partially case-insensitive:

https://nim-lang.github.io/Nim/manual.html#lexical-analysis-...

my_foo, myfoo, and myFoo are interchangeable. MyFoo is different because the first letter is capitalized.

If it's not clear, what I mean is that if you've imported a module that exports myFoo, you can refer to it in your code as my_foo, if you prefer.

Some people love this aspect of Nim, others loathe it. I don't have strong feelings about it, though one has to be mindful of it when searching through a codebase with e.g. the_silver_searcher.

Re:Nim 2.0 thoughts by khaledh on Saturday May 15, 2021 @11:34AM (#27166122)
Good to know. Although I'd argue that this is something that I'd count _against_ the language. I'm also biased against languages that allow you to do the same thing in multiple ways (hint: Scala). Code bases tend to vary according to the team's own conventions, so you have to keep adapting to whatever code base you happen to be reading.
Re:Nim 2.0 thoughts by tubbyjr on Saturday May 15, 2021 @12:38PM (#27166702)
Your bias is your own problem. There's clearly a solution that allows you to use snake_case and those that potentially import your library to seamlessly use all exports as camelCase, yet you're still bothered by that. It's nonsensical, Nim literally came up with the absolute most elegant solution to this.
Re:Nim 2.0 thoughts by funny_falcon on Monday May 17, 2021 @09:40AM (#27183243)
Nope. Its solution is "we made things uglier therefore you can mangle them in a way you like".

Strong convention is much better than pleasure of everyone.

Re:Nim 2.0 thoughts by planetis on Monday May 17, 2021 @12:42PM (#27185424)
> we made things uglier

That's unfounded, please try it at least once in the playground play.nim-lang.org/. To me it's very cool that wrapped C libs with identifiers like ATOMIC_RELEASE can be written as AtomicRelease without any trouble.

Re:Nim 2.0 thoughts by sp33der89 on Saturday May 15, 2021 @11:52AM (#27166295)
I get what you're at with the multiple ways to do stuff, but in Nim it actually makes it more consistent (imo).

If my codebase enforces camelCase and a library uses snake_case, then I can still use that library using camelCase, and Nim has nimgrep to make this easier all the way.

Re:Nim 2.0 thoughts by planetis on Saturday May 15, 2021 @11:39AM (#27166169)
--styleCheck:on to enforce the style every identifier is declared in your code base.
Re:Nim 2.0 thoughts by DangitBobby on Saturday May 15, 2021 @04:46PM (#27168864)
Me too. I do a lot of grepping on codebases and this seems like it could bite me at some point. But it is a very interesting approach to solving the naming convention problem.
Re:Nim 2.0 thoughts by dragonwriter on Saturday May 15, 2021 @11:42AM (#27166209)
> I'm also biased against languages that allow you to do the same thing in multiple ways

So you oppose languages supporting both recursion and iteration?

Re:Nim 2.0 thoughts by khaledh on Saturday May 15, 2021 @12:08PM (#27166438)
recursion vs. iteration, inheritance vs. composition, interfaces vs. abstract classes, etc. are design choices that depend on the problem being solved. Language syntax is different; it's an opinion of the language designer which gives the language its distinctive style, and IMO shouldn't have much leeway in expressing the same thing in multiple ways. It's what gives the language its identity.

For example, here's how you can iterate over a list in scala to print each element:

    List(1, 2, 3).foreach(element => println(element))
    List(1, 2, 3) foreach { element => println(element) }
    List(1, 2, 3).foreach(println(_))
    List(1, 2, 3).foreach { println(_) }
    List(1, 2, 3).foreach { println _ }
    List(1, 2, 3).foreach(println)
    List(1, 2, 3) foreach (println)
    List(1, 2, 3) foreach { println }
    List(1, 2, 3) foreach println
Re:Nim 2.0 thoughts by jjnoakes on Saturday May 15, 2021 @12:45PM (#27166760)
I'm having trouble contrasting that to the many ways I can add 2 and 3, and this doesn't bother me:

    x = 2 + 3
    x = 3 + 2
    x = (2 + 3)
    x = (3 + 2)
    x = 2; x += 3
    x = 3; x += 2
    x = 2; x = x + 3
    x = 3; x = x + 2
Re:Nim 2.0 thoughts by dragonwriter on Saturday May 15, 2021 @01:23PM (#27167093)
> recursion vs. iteration, inheritance vs. composition, interfaces vs. abstract classes, etc. are design choices that depend on the problem being solved.

Recursion and inheritance are interchangeable (in fact, either can be implemented as syntax sugar over the other); while some people find one or the other more natural for a particular problem, there is considerable disagreement among people over which is more natural for which problems. In practice people choose between them based on personal preference and what the language they are using favors (e.g., you probably [0] don’t use recursion unless it is of fairly tightly bounded depth in a language like Python that doesn’t optimize tail calls.

> Language syntax is different; it's an opinion of the language designer which gives the language its distinctive style, and IMO shouldn't have much leeway in expressing the same thing in multiple ways.

As noted, recursion vs. iteration is exactly a syntax-preference decision, and one on which some languages are highly opinionated (Python) forming an important part of their distinctive style, while others are not.

[0] though you could use a tail call optimization decorator

Re:Nim 2.0 thoughts by funny_falcon on Monday May 17, 2021 @09:45AM (#27183296)
> Recursion and inheritance are interchangeable (in fact, either can be implemented as syntax sugar over the other)

Did you mean Recursion and Iteration?

Some recursion could be translated into iteration only if there is stack managed by hands. It decreases readability significantly.

Simplest example: Ackermann function.

And it works both way: some algorithms are better read as iteration.

Re:Nim 2.0 thoughts by dunefox on Saturday May 15, 2021 @03:25PM (#27168108)
> my_foo, myfoo, and myFoo are interchangeable. MyFoo is different because the first letter is capitalized.

God, that's horrible.

Re:Nim 2.0 thoughts by jb1991 on Saturday May 15, 2021 @11:36AM (#27166144)
>my_foo, myFoo, and myFoo are interchangeable.

I'm confused, two of those are myFoo, so I hope they are interchangeable!

Re:Nim 2.0 thoughts by dragonwriter on Saturday May 15, 2021 @11:40AM (#27166182)
I think it intended my_foo, myFoo, and myfoo.
Re:Nim 2.0 thoughts by michaelsbradley on Saturday May 15, 2021 @11:40AM (#27166183)
Fixed. The second or third one should have been all lowercase.