Nix language alternatives

if you could have an alternative two way representation of your nix files, what would it look like?
After years of using nix I’m still finding myself sometimes puzzled by the language.

so I’ve been researching ways to operate and expose ‘nix-space’ – the underlying mathematical lattice &language through reversible mechanical transformations.

take a look at this early demo:

the demo supports

  • realtime bidirectional transformation into python-ish, guix-ish and haskell-ish alternatives
  • nested shell syntax parsing/highlighting
  • mechanical, fast, correct
  • it’s been tested against most of the language + a fuzzer + most nix files on github (~2M total)
3 Likes

I’m NOT one of those people who says syntax doesn’t matter, but I don’t see what’s wrong with nix syntax. Can you say more about what you don’t like?

Anyway, I love your reversible transformations!

1 Like

I’m one of the people that think nix syntax isn’t that bad, it looks like JSON after all.

The only thing that I don’t like is function definition and function calling syntax. For that I wish it was a bit more traditional (like JavaScript for example)

If I was the one designing the language today, it would look almost identical to TypeScript with all imperative stuff removed and lazyness built in.

Especially the Type system of TypeScript is so nice and powerful, it would be nice to have this in Nix.

Also, I’d like the module system added as a first class system to the language as Eelco described it a long time ago.

2 Likes

Nix might be awful, but adding whitespace sensitivity and random keywords into the language doesn’t solve any problems for me.

With that said, if this is just an educational tool that helps someone “get it”, I’m all for it.

2 Likes

mapybara: … Can you say more about what you don’t like …

mainly readability. I have a hard time reading understanding and debugging.
a good % of the nix corpus is actually just nested shell, but the shell isn’t mechanically tied and analyzed.

but more generically: nix is this beautiful, clean pure functional crystal, and I love it, and it’s been dressed in elaborate curly {setting}. with llms + autoformalization we can now easily change the look of it without comprising safety.

e.g: an org could migrate from a bazel corpus to nix while keeping most existing build files relatively unchanged – but simply creating a mapping.

VanCoding: …only thing that I don’t like is function definition and function calling syntax…

take a look at the nixy example I linked above, e.g test with this.

addSet = { a, b }: a + b; # nix

def addSet(a, b):         # nixy
  (a + b) 

waffle8946: …adding whitespace sensitivity and random keywords into the language doesn’t solve any problems for me…

we could also remove keywords. make them more verbose on demand or less verbose. Historically there’s many reasons for alternative syntaxes sharing ast: OCaml/Reason, Hy/Python, CoffeeScript/Javascript.

the cool bit is the shared substrate we run on, not the exact formatting of our braces

1 Like