3 ms·
You can use pretty much any Turing complete language to achieve this constraint, as long as its inputs and execution are deterministic. The language itself does
by CyberShadow 5y ago
You can use pretty much any Turing complete language to achieve this constraint, as long as its inputs and execution are deterministic. The language itself doesn't have to be purely functional.
- Filligree 5y agoThe obvious choice is Haskell. It's a pity they didn't use that.
- ImprobableTruth 5y ago... and how do you ensure that it's execution is deterministic?
- CyberShadow 5y agoMost programming languages are already generally deterministic. Pick any programming language. Now, remove access to I/O (except standard input and output), networking, time, random number generators, threads, OS syscalls, etc. Given an input, the program will always generate the same output, i.e. it is deterministic. However, the program is still allowed to have global mutable state; the state is just encapsulated to the program's memory and execution time. A trivial example is Brainfuck. It is most certainly not a functional programming language, but it is deterministic.
- lmm 5y ago> Pick any programming language. Now, remove access to I/O (except standard input and output), networking, time, random number generators, threads, OS syscalls, etc. The devil is in the details, and if you miss even one case then the problems are just as bad as if you hadn't bothered at all. For example, comparing two URLs in Java is not deterministic. For another example, iterating through a set in Python will give you the elements in a different order on 32- versus 64-bit systems. In practice it's just not practical to retrofit deterministic behaviour onto a language that was not designed for it. Even your "trivial example" isn't; Brainfuck does not standardize overflow behaviour and so the same program may behave differently on different systems.
- CyberShadow 5y ago> For example, comparing two URLs in Java is not deterministic. Well, it does network access, so it would excluded. > For another example, iterating through a set in Python will give you the elements in a different order on 32- versus 64-bit systems. This is a good counter-point. > Brainfuck does not standardize overflow behaviour and so the same program may behave differently on different systems. Different implementations of Nix might have the same issue in some places. In this case, whether the language is fully defined is orthogonal to whether its behavior is deterministic; here, a particular implementation will continue to be as such. As far as I know, Nix doesn't have a formal specification; it is defined by its reference implementation.
- zaarn 5y agoDeterministic execution simply requires you remove sources of non-determinism. This is not to be confused with defined vs undefined behaviour, like a program behaving different on another machine. As long as it's behaviour remains constant over all executions in the same input environment (where architecture, for example, is part of the input), it is entirely fine. After all you need to be non-constant over architecture, since you need to download the correct binaries for 32-bit and 64-bit architectures.
- soraminazuki 5y agoIt’s mostly about using the right tool for the right job. The Nix language is used for large scale configuration, not scripting. Anything that requires scripting is offloaded to Bash. As a result of that, Nix resembles JSON but with variables and lambdas to make writing complex configurations easier. The competitor of the Nix language is not Bash or Python, it’s JSON and YAML.
- stelonix 5y agoA friend uses YAML in that way. Each entry is valid JS code. The result is you have a mixed declarative-imperative configuration language. It's very powerful and I have found a few uses too. The best part is that the evaluator is at most 30 lines of code.