3 ms·
Isn't that the process of compilation?
by melony 5y ago
Isn't that the process of compilation?
- chriswarbo 5y ago"Compilation" usually describes translation from one language to another (e.g. C to machine code). In contrast, beta-reduction rewrites expressions in the same language. It's a "reduction" since it brings expressions closer and closer to their "normal form" (i.e. a halted program); although some expressions have no normal form (they run forever, i.e. the Halting Problem). In Javascript syntax, the following expression is not in "normal form": (function(x) { return x + 5; })(42) If we apply beta-reduction to it, we get back the function body, with occurrences of 'x' substituted by '42': 42 + 5 That expression can no longer be beta-reduced; it is "beta-normal". Lambda calculus only uses beta-reduction (although there are "alpha" and "eta" replacements, which are more like refactorings). However, Javascript has more reduction rules than just beta-reduction; in this case we can use its numerical operations, to reduce the expression further: 47 That is in normal form for Javascript; i.e. the program has halted. Note that it's not "compilation", since we stayed in the same language at all times, just replacing one expression with an equivalent expression.