Live data from Hacker News

Typing Nix

tweag.io

91–100 of 128 posts

Re: Typing Nix

#91
post #63

Earlier quoted context omitted.

Yes, when the commas are at the beginning of the line they are really obvious. I have used commas-first style in JavaScript, and it definitely reduced the amount of times I forgot a comma. I wonder if people's aversion to commas first has something to do with the fact that commas have a very familiar use in ordinary writing, and there they always follow a word. It is very common to see BNF grammars written with leadi…

My aversion has to do with the fact that the first element doesn't have one. The irregularity is annoying not just aesthetically, but also if you want to swap lines around, etc.

But there's always a line without a comma -- comma-last has it on the last line instead of the first. So you can have the same line-swapping problem in either arrangement. Comma first just makes it easier to spot.

Re: Typing Nix

#92
post #91

Earlier quoted context omitted.

My aversion has to do with the fact that the first element doesn't have one. The irregularity is annoying not just aesthetically, but also if you want to swap lines around, etc.

But there's always a line without a comma -- comma-last has it on the last line instead of the first. So you can have the same line-swapping problem in either arrangement. Comma first just makes it easier to spot.

But there's always a line without a comma -- comma-last has it on the last line instead of the first.

Not if the language allows trailing commas on the last line, like Python and Go do.

Re: Typing Nix

#93
post #90

I'm pleasantly surprised to see so many Nix enthusiasts milling around in this thread and I'd like to encourage people to step up and do their part in helping improve and maintain nixpkgs. It's really not that hard, and it's the main area I would say Nix could do with some improvement. Adopt a package today!

I tried doing some non-trivial contributions, and unfortunately there's currently some degree of a problem where there are not enough people actively revieving contributions and having enough authority in the project to be able to merge with confidence. Is it maybe not enough sponsorship for the project, compared to its popularity? Or does it not have a person with enough organisational experience in non-profits?

Re: Typing Nix

#94

There's also Guix in case anyone is interested. It uses Guile/Scheme for everything instead of Haskell.

I think that all the efforts to fix or re-implement the Nix language have vindicated Ludovic, the Guix maintainer, who chose an existing general-purpose language instead.

But Scheme is untyped too AFAIK - isn't it? So it'd require the same degree of "fixing" as long as we're talking about the discussed article.

Re: Typing Nix

#95
post #60

Earlier quoted context omitted.

Go solves this problem by permitting foo := Foo{ x: 10, y: 24, }

Also Perl, Python, Javascript and Rust.

JavaScript doesn't (didn't?) let you put a trailing comma in function parameter lists, annoyingly.

Re: Typing Nix

#96
post #70

Earlier quoted context omitted.

Very strongly agreed. Syntactically significant whitespace is the source of so many preventable errors that I believe it's simply not worth the aesthetic improvements.

There is no significant whitespace in what I am offering; just semicolon inference at newlines (like in modern Javascript).

Keep in mind that I am being simultaneously irreverent while also expressing how I feel about these two debates (semicolons and significant whitespace).

I'm someone who has worked in a large variety of languages, including Python (significant whitespace) and Javascript (no significant whitespace).

First: semicolon inference in Javascript is an abomination :). If the language says that whitespace is not significant, then using newlines to infer where semicolons maybe should be... is inconsistent with the statement "whitespace is insignificant".

Second: when I learned Python, I was coming from a primarily Perl and C background. The significant whitespace wasn't a big deal at all because that's how I indent my code anyway. And I would argue (and do in code reviews) that any code that is not indented properly is incorrect because it is extraordinarily misleading to a reader.

So, yeah, for any given programming language, I couldn't care less if whitespace is significant or not, or whether there's semicolons at the end of lines, but god damnit don't go half way on either of those. Indent your code as if whitespace is significant (because it IS to whoever's trying to decipher it later), and stick semicolons at the end of your lines whether or not some stupid inference rule will stick them there for you if you forget.

And as a final rant, "modern Javascript" didn't introduce semicolon inference; it's been there for a long time and was put there to try to lower the barrier for newbies. It wasn't put there because it's a great design decision.

Re: Typing Nix

#97
post #55
post #36

Earlier quoted context omitted.

I love the Nix language and I generally distrust aesthetic feelings about programming languages. Neither SML nor Haskell are optimized for expressing deeply nested records with many string literals, for example. The multiline interpolated strings in Nix are extremely much better than in SML or Haskell. The way records and arrays are written is great: SML and Haskell both suffer from the tedious problem of using separ…

> If you can make a better surface syntax ... http://gnu.org/s/guix Lisp is pretty good at lists. The only important language is the derivation language sent to the daemon. Nix spends so much time building up inputs... for shell scripts. I always felt like they would have been so much more successful if they chose some other, more popular language to generate derivation.

Is it possible to write a guix package that includes code which redefines the package object?

Re: Typing Nix

#99

Earlier quoted context omitted.

There is no significant whitespace in what I am offering; just semicolon inference at newlines (like in modern Javascript).

Keep in mind that I am being simultaneously irreverent while also expressing how I feel about these two debates (semicolons and significant whitespace). I'm someone who has worked in a large variety of languages, including Python (significant whitespace) and Javascript (no significant whitespace). First: semicolon inference in Javascript is an abomination :). If the language says that whitespace is not significant, t…

I come from Scala, and there semicolon inference works flawlessly. Why do you consider it to be an abomination in Javascript? (Except this famous corner case with continued line, almost never encountered in practice).

Re: Typing Nix

#100
post #86

Earlier quoted context omitted.

It makes git diffs inaccurate compared to trailing commas.

How so?

Inserting a new element with comma-first changes 2 lines:

   - { old-one
   + { new-one
   + , old-one
While trailing commas allow you to insert an element anywhere with just one line addition.

This doesn't break anything, but it makes looking at "git blame" so much easier.

Post reply on HN