News for hackers. Stuff that matters.
Re:This Month with Nim: March 2023 by skerit on Thursday April 06, 2023 @04:23PM (#35473867)
What's up with all the 2-space indentations?
Re:This Month with Nim: March 2023 by tmountain on Thursday April 06, 2023 @04:47PM (#35474174)
To help save space on our 80 column CRT monitors? /s
Re:This Month with Nim: March 2023 by elcritch on Thursday April 06, 2023 @06:09PM (#35475215)
You jest, but I do like to save space. If possible I like to have 2-3 editor columns which works well with Nim.

This lets me have context of having a test file in one column, some code in another, and the core types in another say.

Re:This Month with Nim: March 2023 by 000ooo000 on Thursday April 06, 2023 @08:20PM (#35476419)
Prettier (JS code formatter) defaults to 80 cols and by golly does it butcher code.
Re:This Month with Nim: March 2023 by bobbylarrybobby on Thursday April 06, 2023 @04:59PM (#35474348)
I wonder why they used spaces at all. If they had used tabs, you could at least override the width with a userstyle extension using https://developer.mozilla.org/en-US/docs/web/css/tab-size
Re:This Month with Nim: March 2023 by otherme123 on Thursday April 06, 2023 @05:32PM (#35474804)
From NEP1:

Spacing and Whitespace Conventions

Lines should be no longer than 80 characters. Limiting the amount of information present on each line makes for more readable code - the reader has smaller chunks to process.

Two spaces should be used for indentation of blocks; tabstops are not allowed (the compiler enforces this). Using spaces means that the appearance of code is more consistent across editors. Unlike spaces, tabstop width varies across editors, and not all editors provide means of changing this width.

Re:This Month with Nim: March 2023 by 000ooo000 on Thursday April 06, 2023 @08:24PM (#35476451)
Their rationale for enforcing spaces over tabs is nonsense, particularly after you dive through their GH issues, find where this is discussed, and see the true reason is implementation simplicity.
Re:This Month with Nim: March 2023 by otherme123 on Friday April 07, 2023 @09:52AM (#35481554)
Implementation simplicity also sounds good to me. BTW, it's discussed in the manual:

Nim's standard grammar describes an indentation sensitive language. This means that all the control structures are recognized by indentation. Indentation consists only of spaces; tabulators are not allowed.

The indentation handling is implemented as follows: The lexer annotates the following token with the preceding number of spaces; indentation is not a separate token. This trick allows parsing of Nim with only 1 token of lookahead.

Re:This Month with Nim: March 2023 by elcritch on Monday April 10, 2023 @05:01AM (#35510447)
Only allowing spaces was a good decision. It was supposedly inspired by a quote from Guido bin Rossum that if he could redo it he’d only allow spaces in Python, or something along those lines.

It eliminates lots of issues mixing code that has tabs or spaces like in Python. I’ve never had to worry about a lingering tab.

Re:This Month with Nim: March 2023 by tangus on Thursday April 06, 2023 @06:32PM (#35475421)
What's the problem?
Re:This Month with Nim: March 2023 by schemescape on Thursday April 06, 2023 @06:38PM (#35475469)
I think Deno also standardized on two spaces for indents and I find that’s not enough to be able to quickly identify the structure of code at a glance.

Is Nim requiring this at build time? If so, that would be an odd choice for a language that goes out of its way to let people call functions, capitalize variables, and manage memory however they want.

Re:This Month with Nim: March 2023 by 000ooo000 on Thursday April 06, 2023 @08:19PM (#35476407)
You can name your symbols a_b_c, ABC, abc, or aBc - it's all the same! Tabs for whitespace though..? Don't be stupid
Re:This Month with Nim: March 2023 by ElegantBeef on Thursday April 06, 2023 @08:47PM (#35476643)
Well there is a practical reason that in a whitespace significant language you do not want to mix indentation types. I personally prefer tabs for the user customization, but the actual reasoning that generally speaking it was(is?) hard to get tabs to render as you want in a multitude of environments whereas spaces always render as is.

Quick someone reset the inane "Days since mentioning style insensitivity".

Re:This Month with Nim: March 2023 by 000ooo000 on Thursday April 06, 2023 @09:12PM (#35476821)
Would it be silly to suggest that a joke about a counter for "Days since mentioning style insensitivity" might point to a legitimate gripe many folk have with the language?
Re:This Month with Nim: March 2023 by xigoi on Friday April 07, 2023 @05:55AM (#35479934)
It's not a “legitimate gripe” if you can safely ignore it and it won't affect you (as long as you use a consistent naming style).
Re:This Month with Nim: March 2023 by otherme123 on Friday April 07, 2023 @10:00AM (#35481636)
My new hobby is replying on every Rust post pushing to replace :: with another symbol. Barely use Rust, don't plan to, but it sounds funny to annoy them on the smallest bikeshed I can find.
Re:This Month with Nim: March 2023 by pietroppeter on Thursday April 06, 2023 @11:48PM (#35477823)
Re:This Month with Nim: March 2023 by ElegantBeef on Thursday April 06, 2023 @08:43PM (#35476615)
Indent size is up to the programmer.