How jank-lang/jank works
Main Components
• Compiler & Runtime Core:
– Domain: The “compiler+runtime” directory is the heart of the system. It includes CMake build files, source code (both C++ and jank), header files for language internals (e.g., parsing, analysis, code generation, error reporting, runtime, JIT, and interop).
– Sub-components: Show elements such as a Lexical Analyzer, Parser, AST/IR Generator, Semantic Analyzer (with symbol resolution and type management), Code Generation (LLVM integration) and Runtime system (handling native performance, GC, etc.).
• Frontend/Tooling Integration:
– clojure-cli, lein-jank, and nrepl-server directories provide interfaces/integration with popular Clojure tooling ecosystems. Represent these components as “CLI frontends/integrators” that bridge user source code with the jank compiler.
– Include connections to the REPL and interactive components.
• Standard Library & Data Libraries:
– Include components like “jank.data.bencode” that indicate libraries written in jank (or interfacing via C++) to handle specific data formats (e.g., bencode).
• Test Infrastructure:
– There are extensive test suites distributed in subdirectories under “compiler+runtime/test”, “clojure-cli/test-project”, and similar paths (also in “compiler+runtime/test/bash”, “compiler+runtime/test/cpp”) that should be represented as a separate component validating various facets (e.g., language forms, compiler passes, error handling, integration tests).
• Build & Utility Scripts:
– The “bin” directories and scripts (like “check_everything.clj”, “build.yml” in GitHub workflows, and various build scripts in “compiler+runtime/bin”) show that the project uses automated builds, linting, CI, and formatting tools. They form the ancillary infrastructure for continuous integration and deployment.
• Third-Party Dependencies:
– The “third-party” directories inside “compiler+runtime” indicate integrations with external libraries (e.g., Boost, CLI11, ftux, etc.). These should be noted separately to indicate external dependency management.
Relationships and Interactions
• Runtime Interaction: From Code Generation output, show graphs leading into the “Runtime System” that executes the compiled code.
Architectural Patterns and Design Principles
• Layered Architecture: Clearly differentiate the compilation pipeline layers (front-end, analysis/transformation, code generation, runtime) and separate tooling/integration layers.
• Modularity: Notice that each of the language components (compiler, CLI integrations, tests) are decoupled to allow independent development and testing.
• Build Automation & Integration: The usage of CMake for the compiler and the CI workflows (GitHub Actions, Travis) reflect continuous integration principles.
Relevant Technologies & Frameworks
• LLVM: Emphasize that code generation culminates in LLVM IR and native binary generation.
• C++: The runtime system and interop components are written in C++ (as seen in “include/cpp” and “src/cpp” paths).
• Clojure: Since jank is a Clojure dialect, indicate its compatibility and similarities with Clojure, especially in how the source language (jank) is processed.