Tour of Lux · chapter 8 of 8
Energy as an observable
The part that makes Lux, Lux.
energy.total() reads the meter from inside the program — cost is a first-class observable, queryable mid-run like any other value. In this sandbox it's modeled from evaluation steps (~1 nJ each, and labeled as a model); on real hardware the same call reports measured joules from the attached sensor source.Once cost is observable, comparing implementations is just code. Both functions below compute the same sum — one walks a loop, one uses the closed form. The receipt difference is the lesson, and it's the whole thesis of Lux in five lines: most compute can be a lookup or a formula, and the meter proves it.