[English](LICENSING.md) | [Português](LICENSING.pt_BR.md) # Kof Licensing **Last updated:** September 12, 2026 **Version:** 0.4.0-beta (7 targets; free-list + pthread spawn + FP XMM) --- ## 1. Kof Source Code The source code of the Kof project — including compiler, tools, backends and other repository components — is distributed under the **GNU General Public License v3.0** (GPLv3). This means that anyone may use, modify and distribute Kof's source code, as long as they respect the terms of the GPLv3. The `LICENSE` file at the repository root contains the full text of the GPLv3. --- ## 2. JDK embedded in the official distribution (0.2.6-beta, JDK 21) The official Kof package ships an **OpenJDK Eclipse Temurin 21** (Adoptium binaries, Tooling API Level 21), distributed under the **GPLv2 with Classpath Exception**. The embedded JDK is a component separate from Kof's source code, packaged only in the distribution (not in the repository), and keeps its own license. Kof does not modify the embedded JDK; the launcher (`bin/kof`/`bin/kof.bat`, Windows SIGPIPE fix 08/27) only locates and executes it. `scripts/package.sh` generates the dist layout + tar.gz/zip + SHA256SUMS, `release.yml` uses 2 jobs (`test-and-bump` exports the SHA of the bump commit → `package-and-release` checks out the bump commit + version sanity check) with per-platform releases (linux-x86_64/macos-arm64/windows-x86_64). --- ## 2.1 Compiler (0.2.6-beta) The Kof compiler (modules `kof-compiler` 793 tests + `kof-script` 8 + `kof-c-compiler` 5 = 806, `VERSION` 0.2.6-beta) is GPLv3. It contains: - Lexer / Parser (`case String s` + `Point(x,y)` + `String?`) - AST / `Type.java` (`String?` nullable) - Type system / SymbolTable - Semantic analysis (`CompilerDriver.java:243` import `a.b.C` fix) - IR (backend-agnostic + `KofDebugInfo`) - Backends: `JvmBackend` (ASM V21 + web ws/sse + cache + http retry/circuit), `NativeBackend` (x86_64 free-list + pthread spawn + FP XMM; `native.risc`/`native.arm` toolchain + qemu), `JsBackend` (GraalJS + `Java HttpClient` interop), `KofScript` (`let`→`KofScriptGlobals`), `KofCcompiler` (`kof_c`), `KofFormatter` (`kof fmt`) - Code generation + `Optimizer` (constant folding etc.) Using the Kof compiler to compile your code does NOT make your code GPLv3. --- ## 3. Runtime The Kof runtime has two implementations: ### JVM Runtime The JVM backend delegates to the JVM's facilities (java.lang.String, native arrays, GC, etc.). The JVM runtime is the JVM itself — there is no Kof-specific code being incorporated into the executable. ### Native Runtime The Native backend generates runtime functions in assembly during compilation (0.2.6-beta: free-list `kof_free_head` with `mmap` reuse + `spawn`/`await` via `pthread_create`/`pthread_join` with a thread-safe allocator (futex) + real FP in XMM + JSON objects/arrays). These functions are: - `kof_alloc` / `kof_free_head` — allocation with `mmap` reuse (mark-sweep GC pending) - `kof_print`, `kof_println`, `kof_print_int`, `kof_int_to_string` — output - `kof_string_*`, `kof_array_*`, `kof_list_*` (`map/filter/reduce`), `kof_map_*` — collections - JSON objects/records + `Int/Long/Bool/String/Double` arrays (08/31) - `pthread_create` + `pthread_join` trampoline (spawn/await, 08/31) - `kof_cache_*` (get/set/ttl/delete/clear, 08/30) - `kof_db_mysql_scramble` — MySQL auth scramble SHA-1 (wire protocol WIP, 08/31) - `kof_panic`, `kof_null_error`, `kof_bounds_error` — error handling **Important:** These functions are **generated by the compiler** during the compilation process. They are not distributed as a precompiled library. They are incorporated into the final executable as part of the compilation process. Under the GPLv3, a compiler's output is NOT automatically GPLv3. The runtime functions are generated by the compiler and are part of the compilation output. Therefore, they are NOT automatically GPLv3. --- ## 4. Standard Library Currently there is no separate standard library. String and array operations are implemented as runtime functions generated by the compiler. In the future, if a standard library is created, it should be licensed separately if it is necessary to allow proprietary software. --- ## 5. Code written by users Programs written in Kof belong to their respective authors. **Writing a program in Kof does NOT automatically turn that program into GPLv3 code.** The author of the Kof program retains the right to choose the license of their own software. --- ## 6. Proprietary software Proprietary software written in Kof is allowed. The author may: - Keep the source code closed - Distribute only the binary - Use any license compatible with the dependencies As long as the software is not incorporating components that impose another incompatible obligation. --- ## 7. Binary distribution ### JVM Target The JVM executable (`.class` or `.jar`) contains JVM bytecode. The runtime is the JVM itself. There is no Kof code being incorporated. ### Native Target The native executable contains: - Compiled user code - Runtime functions generated by the compiler - Generated assembly The runtime functions are generated by the compiler and are part of the compilation process. They are NOT distributed as a separate library. --- ## 8. Third-party dependencies The Kof compiler uses the following dependencies: - **ASM** (org.objectweb.asm) — for JVM bytecode generation ASM is used only by the JVM backend and is not incorporated into the final executable of the Native target. Programs written in Kof may have their own dependencies, which must be licensed according to the terms of each dependency. --- ## 9. What Kof's GPLv3 covers Kof's GPLv3 covers: - Compiler source code - Command-line tools - Backends - Project documentation - Tests --- ## 10. What it does NOT cover Kof's GPLv3 does NOT cover: - Programs written in Kof by users - Software produced with the Kof compiler - Binaries generated for the JVM or Native target --- ## 11. Practical examples ### Example 1: Proprietary company ``` empresa/ sistema.kf main.kf ``` The company may keep the code proprietary. Using the Kof compiler does not obligate the company to open its source code. ### Example 2: Open source project The author may choose GPL, MIT, Apache-2.0, or any other license, respecting the licenses of the dependencies incorporated into their software. ### Example 3: Closed commercial application It may be proprietary, as long as the application is not incorporating components that impose another obligation incompatible with the chosen license. ### Example 4: Kof library If someone creates a library in Kof and wants to distribute it as open source, they may choose GPL, MIT, Apache-2.0, etc. If they want to distribute it as proprietary, they may do so. --- ## 12. Analogy with traditional compilers Just as: - Programs compiled with GCC are not automatically GPLv3 - Programs compiled with Clang are not automatically Apache 2.0 - Programs compiled with javac are not automatically GPL Programs compiled with Kof are NOT automatically GPLv3. The compiler is a tool. The code produced with the tool belongs to the author. --- ## 13. Points requiring attention 1. **Third-party dependencies**: If the Kof software incorporates third-party libraries with specific licenses, the author must respect those licenses. 2. **Native runtime**: The runtime functions are generated by the compiler and incorporated into the executable. They are minimalistic and do not constitute a significant separate work. 3. **Future**: If a standard library is created and distributed separately, it may have a different license. This will be documented explicitly. --- ## 14. Contact For questions about licensing, consult the project repository or open an issue.