Hackers News

Tree Calculus captures the essence of computation


  • Intensional

    Tree Calculus can perform program analysis without quotation:
    The ability to reflect on programs is built right into the reduction rules. This means that anything from type checking to compilation and optimization can happen from within programs and without additional external tools (
    ๐Ÿš€demo, ๐Ÿš€fusion demo).
    In particular, this supports arbitrary type systems and truly gradual typing or verification: Static vs dynamic checks are one and the same function call, just at different points in time (๐Ÿš€demo).

    Furthermore, intensionality allows compiling and deploying programs (or elaborate combinations like tier splitting) right from the program itself. This makes for all-powerful REPLs; translated to Python, imagine using nothing but a Jupyter Notebook for an entire product lifecycle, from prototyping to productionization.


  • Powerful

    Tree Calculus is Turing-complete and intensional (๐Ÿš€demo).
    Combined with its trivial abstract syntax, it becomes easy to serialize any value, including programs (๐Ÿš€demo).

    But furthermore, there is in fact no distinction between a program and its encoding.
    Such distinctions complicate descriptions and formal proofs of the Halting Problem, whereas with Tree Calculus as the substrate, Halting Problem formulations become more straightforward (๐Ÿš€demo).

    Despite its simplicity, Tree Calculus is not a Turing tarpit. Data encodings and algorithms are asymptotically optimal. In practice:
    Typical functions to manipliate lists (map, filter, concat, fold, โ€ฆ) are binary trees with a few hundred nodes (๐Ÿš€demo).
    The compiler used in all demos is also written in Tree Calculus, not particularly optimized, yet quite efficient.


  • Concise

    The abstract syntax of Tree Calculus is trivial: Values are unlabeled binary trees.
    The reduction rules act on trees of higher degree, until they are binary.
    (Bonus for readers familiar with ฮป-calculus: Recursive functions have normal form/are values in Tree Calculus.)
    The definition is compact, precise and imports no other โ€œwell knownโ€ definitions or standards,
    such as JSON, UTF8, twoโ€™s complement integers, IEEE floats or their respective arithmetic operations, which have tricky corner cases.

    However, arbitrary concepts like that can be bootstrapped in Tree Calculus swiftly and explicitly (๐Ÿš€demo).
    This makes Tree Calculus a great language for modeling and formal specifications,
    but also very suitable for education: There are no incumbent towers of abstraction, but they can be introduced and modeled incrementally.


  • Portable

    The syntax and semantics of Tree Calculus are minimal and self-contained,
    relying on no platform-specific concepts or abstractions.
    As a result, it is trivial to write interpreters on any platform or in any programming language (๐Ÿš€demo).
    Such interpreters are effectively safe by construction, since the reduction rules are simple (resulting in little code) and pure (no inherent access to the environment or resources).

    The ability to bootstrap the full power of Tree Calculus anywhere makes it an
    excellent configuration as code language in a heterogeneous system.
    Developers could write Tree Calculus programs that generate, say, JSON,
    and use an interpreter (that is tiny compared to a JSON parser) to materialize
    the configuration anywhere (๐Ÿš€demo).
    This article describes how Meta uses Python for a similar purpose.

  • admin

    The realistic wildlife fine art paintings and prints of Jacquie Vaux begin with a deep appreciation of wildlife and the environment. Jacquie Vaux grew up in the Pacific Northwest, soon developed an appreciation for nature by observing the native wildlife of the area. Encouraged by her grandmother, she began painting the creatures she loves and has continued for the past four decades. Now a resident of Ft. Collins, CO she is an avid hiker, but always carries her camera, and is ready to capture a nature or wildlife image, to use as a reference for her fine art paintings.

    Related Articles

    Leave a Reply