Live data from Hacker News

Typing Nix

tweag.io

81–90 of 128 posts

Re: Typing Nix

#81
post #6

I love Nix. NixOS is my primary development operating system. However, the Nix language itself is syntactically ugly , and this proposal makes it even uglier. Parentheses, sigils and special characters (esp. semicolons) are line noise — the less of it the better. Why they wouldn't take the most (syntactically) beautiful functional programming language out there — Standard ML? It would work perfectly for such a task.…

This is why I'm very much interested in Guix and GuixSD, which use Guile Scheme. Unfortunately I don't think they have an officially-supported story for running on the server, yet, or an equivalent to NixOps.

Re: Typing Nix

#82
post #76
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…

So, JavaScript? The records literals are JSON, which is the most popular syntax for this at the moment anyways.

I tend to write JavaScript that looks a bit like Nix... but in general, the imperative constructs aren't suitable to the lazy evaluation strategy of Nix.

Re: Typing Nix

#83
post #76
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…

So, JavaScript? The records literals are JSON, which is the most popular syntax for this at the moment anyways.

No, Nix syntax is much nicer than Javascript. Consider, for example, the similarity between a let expression and an attribute set (NOT JSON by the way):

  let
    foo = 42;
    bar = "a string";
  in {
    baz = "deja";
    quux = "vu";
  }
Javascript:

  const foo = 42;
  const bar = "a string";
  return {
    baz: "similar",
    quux: "but different"
  };
You find this kind of thing all over the place. Nix is a much smaller and simpler language syntactically, and more pleasant to write.

Re: Typing Nix

#84

Earlier quoted context omitted.

I could not agree with you more! I use nix daily, and every time I go to edit it a nix file a voice in the back of my head says, "you should really start that Haskell to Nix compiler you've been thinking about." [edit] ha! just notice the next comment talking about hnix. Great minds... :)

Wow, I'm doing the opposite where I'm staring at all these other DSLs and configuration files and have to hold myself back from writing a bunch of nix to autogenerate them from.

Haha same here, I've been considering writing Nix expressions for window manager configurations for quite some time now, but some config files are so complex that it would take ages.

Re: Typing Nix

#85
post #83
post #76

Earlier quoted context omitted.

So, JavaScript? The records literals are JSON, which is the most popular syntax for this at the moment anyways.

No, Nix syntax is much nicer than Javascript. Consider, for example, the similarity between a let expression and an attribute set (NOT JSON by the way): let foo = 42; bar = "a string"; in { baz = "deja"; quux = "vu"; } Javascript: const foo = 42; const bar = "a string"; return { baz: "similar", quux: "but different" }; You find this kind of thing all over the place. Nix is a much smaller and simpler language syntacti…

Also, recursive definitions using "rec" which become nasty in JavaScript.

Re: Typing Nix

#87
post #60

Earlier quoted context omitted.

> comma-first syntax oooh but this is one of those trivial things that I really liked in my brief days of using Haskell, and that has sometimes carried over to my C++, e.g. in initializer lists. I find it super useful because everything lines up nicely, and from the point of view of version control you don't have to edit the previous line to change '}' to ',' when adding a new line.

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

Python does this, too.

Re: Typing Nix

#88
post #60

Earlier quoted context omitted.

> comma-first syntax oooh but this is one of those trivial things that I really liked in my brief days of using Haskell, and that has sometimes carried over to my C++, e.g. in initializer lists. I find it super useful because everything lines up nicely, and from the point of view of version control you don't have to edit the previous line to change '}' to ',' when adding a new line.

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

Also Perl, Python, Javascript and Rust.

Re: Typing Nix

#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!
Post reply on HN