Nix (language): Difference between revisions

imported>Makefu
No edit summary
imported>Ixxie
No edit summary
Line 10: Line 10:


== Language Paradigms ==
== Language Paradigms ==
=== lazy evaluation ===
 
=== Lazy ===


Not all expressions in nixpkgs will be evaluated and instantiated as nix performs evaluation only when needed for a finished output. In the following example <code>abort</code> will never be triggered as the variable it belogs to is unused:
Not all expressions in nixpkgs will be evaluated and instantiated as nix performs evaluation only when needed for a finished output. In the following example <code>abort</code> will never be triggered as the variable it belogs to is unused:
Line 21: Line 22:
</syntaxHighlight>
</syntaxHighlight>


=== functional paradigm ===
=== Functional ===
Functional Programming is a style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. It is a declarative programming paradigm, which means programming is done with expressions or declarations instead of statements.
Functional Programming is a style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. It is a declarative programming paradigm, which means programming is done with expressions or declarations instead of statements.


see also: [https://en.wikipedia.org/wiki/Functional_programming]
see also: [https://en.wikipedia.org/wiki/Functional_programming]


=== purity ===
=== Pure ===


A pure function is a function where the return value is only determined by its input values, without observable side effects. In Nix, all build operations try to be as pure as possible to achieve reproducible builds. This means that wherever you build the packages as few side effects as possible should have an impact onto the build.
A pure function is a function where the return value is only determined by its input values, without observable side effects. In Nix, all build operations try to be as pure as possible to achieve reproducible builds. This means that wherever you build the packages as few side effects as possible should have an impact onto the build.