Skip to content

zorp-corp/jock-lang

Repository files navigation

Jock, a friendly and practical programming language

This is a developer preview of Jock, a friendly programming language that compiles to the Nock instruction set architecture.

This repo contains the Jock base language, tutorial materials, and language unit tests.

Resources

Jock

The Jock compiler is written in Hoon and runs on the NockApp architecture, part of Nockchain.

Jock code results in Nock which can be run on any Nock VM (NockVM, Vere).

Nock

Nock serves as the instruction set architecture for Nockchain, Nock ZKVM, and Urbit, among other projects. The Nock ISA is a minimalist combinator calculus. All computations are reduced to a set of twelve opcodes that are easy to reason about and make proofs about.

NockApp

The NockApp framework consists of NockVM, a runtime VM interpreter for Nock, the NockApp Rust framework, and hoonc, which builds Nock programs from Jock or Hoon into executable standalones.

Setup

  1. Download and build hoonc, a NockApp compiler which forms part of Nockchain.

    make install-hoonc
  2. In a separate location, download the Jock language repo (this repo).

  3. Copy hoonc from nockchain/target/release to the root of jock-lang.

    cp nockchain/target/release/hoonc jock-lang/

jockc Jock Compiler

If you are developing Jock code, you should use the Jock compiler tool jockc.

  1. Build the Jock compiler and command-line execution environment:

    make jockc
  2. Copy jockc from ./target/release to the root of jock-lang.

    cp ./target/release/jockc .
  3. Run a Jock program directly using its path:

    ./jockc ./common/hoon/try/hello-world --import-dir ./common/hoon/jib

    See available demos:

    ls common/hoon/try

    Supply a path for library imports:

    ./jockc ./common/hoon/try/import --import-dir ./common/hoon/jib
  4. Run a demo with its name and any arguments:

    ./jockc ./common/hoon/try/hello-world --import-dir ./common/hoon/jib
    ./jockc ./common/hoon/try/fib 10 --import-dir ./common/hoon/jib

    The demo will output several pieces of information:

    1. %parse, the tokenization.
    2. %jeam, the Jock abstract syntax tree (AST).
    3. %mint, the compiled Nock (which will be rather long; output is currently slow).
    4. %jype, the Jock result type.
    5. %nock, the evaluated Nock result, as an atom (unsigned decimal value).

    For a tutorial like hello-world, the Nock text will be printed as the numeric equivalent of the hexadecimal for the time being.

    (Rust logs from hoonc tend to be obnoxiously verbose; to make them more concise, use MINIMAL_LOG_FORMAT=true as a command-line environment variable, e.g. MINIMAL_LOG_FORMAT=true ./jockc fib 10. You can also run the same minified log format with make run fib 10.)

  5. Add a new demo by saving Jock code in /common/hoon/try and running it by name.

    If you modify the Hoon code located in /crates/jockc/hoon/lib or /common/hoon/try, run make jockc before running the new code.

    If you modify the Rust code in /crates/jockc/main.rs, run make jockc.

jockt Jock Test Framework

If you are developing Jock itself, you should use the Jock testing tool jockt to verify behavior.

  1. Build the Jock testing tool:

    make jockt
  2. Copy jockt from target/release to the root of jock-lang.

    cp ./target/release/jockt .
  3. Run a Jock program using its internal index:

    ./jockt exec 5 --import-dir ./common/hoon/jib

    These are listed in /hoon/lib/test-jock.hoon.

    The demo will output several pieces of information:

    1. %parse, the tokenization.
    2. %jeam, the Jock abstract syntax tree (AST).
    3. %mint, the compiled Nock (which will be rather long).
    4. %jype, the Jock result type.
    5. %nock, the evaluated Nock result, as an atom.

    Alternatively, run all codes:

    ./jockt exec-all --import-dir ./common/hoon/jib
  4. Run a Jock program with all tests:

    ./jockt test 5 --import-dir ./common/hoon/jib

    These indices are identical to those obtained in the previous step from /hoon/lib/test-jock.hoon.

    Alternatively, run all tests (slow):

    ./target/release/jockt test-all --import-dir ./common/hoon/jib

Releases

About

A simple scripting language that compiles to Nock.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors 7