[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-74696":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":15,"forks30d":15,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":24,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":34,"readmeContent":35,"aiSummary":36,"trendingCount":15,"starSnapshotCount":15,"syncStatus":37,"lastSyncTime":38,"discoverSource":39},74696,"zenc","zenc-lang\u002Fzenc","zenc-lang","Write like a high-level language, run like C.","https:\u002F\u002Fwww.zenc-lang.org\u002F",null,"C",4295,216,41,0,3,13,64,12,29.01,"MIT License",false,"main",true,[26,27,28,29,30,31,32,33],"c","compiler","lsp","open-source","programming-languages","repl","transpiler","zen-c","2026-06-12 02:03:27","\u003Cdiv align=\"center\">\n  \u003Cp>\n    \u003Ca href=\"README.md\">English\u003C\u002Fa> •\n    \u003Ca href=\"translations\u002FREADME_DE.md\">Deutsch\u003C\u002Fa> •\n    \u003Ca href=\"translations\u002FREADME_RU.md\">Русский\u003C\u002Fa> •\n    \u003Ca href=\"translations\u002FREADME_ZH_CN.md\">简体中文\u003C\u002Fa> •\n    \u003Ca href=\"translations\u002FREADME_ZH_TW.md\">繁體中文\u003C\u002Fa> •\n    \u003Ca href=\"translations\u002FREADME_ES.md\">Español\u003C\u002Fa> •\n    \u003Ca href=\"translations\u002FREADME_IT.md\">Italiano\u003C\u002Fa> •\n    \u003Ca href=\"translations\u002FREADME_PT_BR.md\">Português Brasileiro\u003C\u002Fa>\n  \u003C\u002Fp>\n\u003C\u002Fdiv>\n\n\u003Cdiv align=\"center\">\n  \u003Ch1>Zen C\u003C\u002Fh1>\n  \u003Ch3>Modern Ergonomics. Zero Overhead. Pure C.\u003C\u002Fh3>\n  \u003Cbr>\n  \u003Cp>\n    \u003Ca href=\"#\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fbuild-passing-brightgreen\" alt=\"Build Status\">\u003C\u002Fa>\n    \u003Ca href=\"#\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-blue\" alt=\"License\">\u003C\u002Fa>\n    \u003Ca href=\"#\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fv\u002Frelease\u002Fzenc-lang\u002Fzenc?label=version&color=orange\" alt=\"Version\">\u003C\u002Fa>\n    \u003Ca href=\"#\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fplatform-linux%20%7C%20windows%20%7C%20macos-lightgrey\" alt=\"Platform\">\u003C\u002Fa>\n  \u003C\u002Fp>\n  \u003Cp>\u003Cem>Write like a high-level language, run like C.\u003C\u002Fem>\u003C\u002Fp>\n\u003C\u002Fdiv>\n\n\u003Chr>\n\n\u003Cdiv align=\"center\">\n  \u003Cp>\n    \u003Cb>\u003Ca href=\"#overview\">Overview\u003C\u002Fa>\u003C\u002Fb> •\n    \u003Cb>\u003Ca href=\"#community\">Community\u003C\u002Fa>\u003C\u002Fb> •\n    \u003Cb>\u003Ca href=\"#quick-start\">Quick Start\u003C\u002Fa>\u003C\u002Fb> •\n    \u003Cb>\u003Ca href=\"#ecosystem\">Ecosystem\u003C\u002Fa>\u003C\u002Fb> •\n    \u003Cb>\u003Ca href=\"#language-reference\">Language Reference\u003C\u002Fa>\u003C\u002Fb> •\n    \u003Cb>\u003Ca href=\"#standard-library\">Standard Library\u003C\u002Fa>\u003C\u002Fb> •\n    \u003Cb>\u003Ca href=\"#tooling\">Toolchain\u003C\u002Fa>\u003C\u002Fb>\n  \u003C\u002Fp>\n\u003C\u002Fdiv>\n\n---\n\n## Overview\n\n**Zen C** is a modern systems programming language that compiles to human-readable `GNU C`\u002F`C11`. It provides a rich feature set including type inference, pattern matching, generics, traits, async\u002Fawait, and manual memory management with RAII capabilities, all while maintaining 100% C ABI compatibility.\n\n## Community\n\nJoin the discussion, share demos, ask questions, or report bugs in the official Zen C Discord server!\n\n- Discord: [Join here](https:\u002F\u002Fdiscord.com\u002Finvite\u002Fq6wEsCmkJP)\n- RFCs: [Propose features](https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Frfcs)\n\n## Ecosystem\n\nThe Zen C project consists of several repositories. Below you can find the primary ones:\n\n| Repository | Description | Status |\n| :--- | :--- | :--- |\n| **[zenc](https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Fzenc)** | The core Zen C compiler (`zc`), CLI, and Standard Library. | Active Development |\n| **[docs](https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Fdocs)** | The official documentation and language specification. | Active |\n| **[rfcs](https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Frfcs)** | The Request for Comments (RFC) repository. Shape the future of the language. | Active |\n| **[vscode-zenc](https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Fvscode-zenc)** | Official VS Code extension (Syntax Highlighting, Snippets). | Alpha |\n| **[www](https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Fwww)** | Source code for `zenc-lang.org`. | Active |\n| **[awesome-zenc](https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Fawesome-zenc)** | A curated list of awesome Zen C examples | Growing |\n| **[zenc.vim](https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Fzenc.vim)** | Official Vim\u002FNeovim plugin (Syntax, Indentation). | Active |\n\n## Showcase\n\nCheck out these projects built with Zen C:\n\n- **[ZC-pong-3ds](https:\u002F\u002Fgithub.com\u002F5quirre1\u002FZC-pong-3ds)**: A Pong clone for the Nintendo 3DS.\n- **[zen-c-parin](https:\u002F\u002Fgithub.com\u002FKapendev\u002Fzen-c-parin)**: A basic example using Zen C with Parin.\n- **[almond](https:\u002F\u002Fgit.sr.ht\u002F~leanghok\u002Falmond)**: A minimal web browser written in Zen C.\n\n---\n\n## Index\n\n\u003Ctable align=\"center\">\n  \u003Ctr>\n    \u003Cth width=\"50%\">General\u003C\u002Fth>\n    \u003Cth width=\"50%\">Language Reference\u003C\u002Fth>\n  \u003C\u002Ftr>\n  \u003Ctr>\n    \u003Ctd valign=\"top\">\n      \u003Cul>\n        \u003Cli>\u003Ca href=\"#overview\">Overview\u003C\u002Fa>\u003C\u002Fli>\n        \u003Cli>\u003Ca href=\"#community\">Community\u003C\u002Fa>\u003C\u002Fli>\n        \u003Cli>\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Frfcs\">RFCs\u003C\u002Fa>\u003C\u002Fli>\n        \u003Cli>\u003Ca href=\"#quick-start\">Quick Start\u003C\u002Fa>\u003C\u002Fli>\n        \u003Cli>\u003Ca href=\"#ecosystem\">Ecosystem\u003C\u002Fa>\u003C\u002Fli>\n        \u003Cli>\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Fdocs\">Documentation\u003C\u002Fa>\u003C\u002Fli>\n        \u003Cli>\u003Ca href=\"#standard-library\">Standard Library\u003C\u002Fa>\u003C\u002Fli>\n        \u003Cli>\u003Ca href=\"#tooling\">Tooling\u003C\u002Fa>\n          \u003Cul>\n            \u003Cli>\u003Ca href=\"#language-server-protocol-lsp\">LSP\u003C\u002Fa>\u003C\u002Fli>\n            \u003Cli>\u003Ca href=\"#debugging-zen-c\">Debugging\u003C\u002Fa>\u003C\u002Fli>\n          \u003C\u002Ful>\n        \u003C\u002Fli>\n        \u003Cli>\u003Ca href=\"#compiler-support--compatibility\">Compiler Support & Compatibility\u003C\u002Fa>\u003C\u002Fli>\n        \u003Cli>\u003Ca href=\"#contributing\">Contributing\u003C\u002Fa>\u003C\u002Fli>\n        \u003Cli>\u003Ca href=\"#attributions\">Attributions\u003C\u002Fa>\u003C\u002Fli>\n      \u003C\u002Ful>\n    \u003C\u002Ftd>\n    \u003Ctd valign=\"top\">\n      \u003Cp>\u003Ca href=\"https:\u002F\u002Fdocs.zenc-lang.org\u002Ftour\u002F\">\u003Cb>Browse the Language Reference\u003C\u002Fb>\u003C\u002Fa>\u003C\u002Fp>\n    \u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n\n---\n\n## Quick Start\n\n### Installation\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Fzenc.git\ncd zenc\nmake clean # remove old build files\nmake\nsudo make install\n```\n\n#### Development Targets\n\n```bash\nmake format       # Auto-format all source files with clang-format\nmake format-check # Verify formatting without changing files\nmake lint         # Run format-check + shellcheck on test scripts\nmake bench        # Run performance benchmarks\nmake WERROR=1     # Build with -Werror (warnings as errors)\n```\n\n### Windows\n\nZen C has full native support for Windows (x86_64). You can build using the provided batch script with GCC (MinGW):\n\n```cmd\nbuild.bat\n```\n\nThis will build the compiler (`zc.exe`). Networking, Filesystem, and Process operations are fully supported via the Platform Abstraction Layer (PAL).\n\nAlternatively, you can use `make` if you have a Unix-like environment (MSYS2, Cygwin, git-bash).\n\n### Portable Build (APE)\n\nZen C can be compiled as an **Actually Portable Executable (APE)** using [Cosmopolitan Libc](https:\u002F\u002Fgithub.com\u002Fjart\u002Fcosmopolitan). This produces a single binary (`.com`) that runs natively on Linux, macOS, Windows, FreeBSD, OpenBSD, and NetBSD on both x86_64 and aarch64 architectures.\n\n**Prerequisites:**\n- `cosmocc` toolchain (must be in your PATH)\n\n**Build & Install:**\n```bash\nmake ape\nsudo env \"PATH=$PATH\" make install-ape\n```\n\n**Artifacts:**\n- `out\u002Fbin\u002Fzc.com`: The portable Zen-C compiler. Includes the standard library embedded within the executable.\n- `out\u002Fbin\u002Fzc-boot.com`: A self-contained bootstrap installer for setting up new Zen-C projects.\n\n**Usage:**\n```bash\n# Run on any supported OS\n.\u002Fout\u002Fbin\u002Fzc.com build hello.zc -o hello\n```\n\n### Usage\n\n```bash\n# Compile and run\nzc run hello.zc\n\n# Build executable\nzc build hello.zc -o hello\n\n# Interactive Shell\nzc repl\n\n# Documentation (Recursive)\nzc doc main.zc\n\n# Documentation (Single file, no check)\nzc doc --no-recursive-doc --no-check main.zc\n\n# Show Zen Facts\nzc build hello.zc --zen\n```\n\n### Environment Variables\n\nYou can set `ZC_ROOT` to specify the location of the Standard Library (standard imports like `import \"std\u002Fvec.zc\"`). This allows you to run `zc` from any directory.\n\n```bash\nexport ZC_ROOT=\u002Fpath\u002Fto\u002FZen-C\n```\n\n---\n\n## Language Reference\n\nSee the official [Language Reference](https:\u002F\u002Fdocs.zenc-lang.org\u002Ftour\u002F01-variables-constants\u002F) for more details.\n\n## Standard Library\n\nZen C includes a standard library (`std`) covering essential functionality.\n\n[Browse the Standard Library Documentation](docs\u002Fstd\u002FREADME.md)\n\n### Key Modules\n\n\u003Cdetails>\n\u003Csummary>Click to see all Standard Library modules\u003C\u002Fsummary>\n\n| Module | Description | Docs |\n| :--- | :--- | :--- |\n| **`std\u002Fbigfloat.zc`** | Arbitrary-precision floating-point arithmetic. | [Docs](docs\u002Fstd\u002Fbigfloat.md) |\n| **`std\u002Fbigint.zc`** | Arbitrary-precision integer `BigInt`. | [Docs](docs\u002Fstd\u002Fbigint.md) |\n| **`std\u002Fbits.zc`** | Low-level bitwise operations (`rotl`, `rotr`). | [Docs](docs\u002Fstd\u002Fbits.md) |\n| **`std\u002Fcomplex.zc`** | Complex Number Arithmetic `Complex`. | [Docs](docs\u002Fstd\u002Fcomplex.md) |\n| **`std\u002Fvec.zc`** | Growable dynamic array `Vec\u003CT>`. | [Docs](docs\u002Fstd\u002Fvec.md) |\n| **`std\u002Fstring.zc`** | Heap-allocated `String` type with UTF-8 support. | [Docs](docs\u002Fstd\u002Fstring.md) |\n| **`std\u002Fqueue.zc`** | FIFO queue (Ring Buffer). | [Docs](docs\u002Fstd\u002Fqueue.md) |\n| **`std\u002Fmap.zc`** | Generic Hash Map `Map\u003CV>`. | [Docs](docs\u002Fstd\u002Fmap.md) |\n| **`std\u002Ffs.zc`** | File system operations. | [Docs](docs\u002Fstd\u002Ffs.md) |\n| **`std\u002Fio.zc`** | Standard Input\u002FOutput (`print`\u002F`println`). | [Docs](docs\u002Fstd\u002Fio.md) |\n| **`std\u002Foption.zc`** | Optional values (`Some`\u002F`None`). | [Docs](docs\u002Fstd\u002Foption.md) |\n| **`std\u002Fresult.zc`** | Error handling (`Ok`\u002F`Err`). | [Docs](docs\u002Fstd\u002Fresult.md) |\n| **`std\u002Fpath.zc`** | Cross-platform path manipulation. | [Docs](docs\u002Fstd\u002Fpath.md) |\n| **`std\u002Fenv.zc`** | Process environment variables. | [Docs](docs\u002Fstd\u002Fenv.md) |\n| **`std\u002Fnet\u002F`** | TCP, UDP, HTTP, DNS, URL. | [Docs](docs\u002Fstd\u002Fnet.md) |\n| **`std\u002Fthread.zc`** | Threads and Synchronization. | [Docs](docs\u002Fstd\u002Fthread.md) |\n| **`std\u002Ftime.zc`** | Time measurement and sleep. | [Docs](docs\u002Fstd\u002Ftime.md) |\n| **`std\u002Fjson.zc`** | JSON parsing and serialization. | [Docs](docs\u002Fstd\u002Fjson.md) |\n| **`std\u002Fstack.zc`** | LIFO Stack `Stack\u003CT>`. | [Docs](docs\u002Fstd\u002Fstack.md) |\n| **`std\u002Fset.zc`** | Generic Hash Set `Set\u003CT>`. | [Docs](docs\u002Fstd\u002Fset.md) |\n| **`std\u002Fprocess.zc`** | Process execution and management. | [Docs](docs\u002Fstd\u002Fprocess.md) |\n| **`std\u002Fregex.zc`** | Regular Expressions (TRE based). | [Docs](docs\u002Fstd\u002Fregex.md) |\n| **`std\u002Fsimd.zc`** | Native SIMD vector types. | [Docs](docs\u002Fstd\u002Fsimd.md) |\n\n\u003C\u002Fdetails>\n\n### 18. Unit Testing Framework\n\nZen C features a built-in testing framework with **per-test isolation**, **named output**, and **non-fatal assertions**.\n\n#### Syntax\nA `test` block contains a descriptive name and a body of code to execute. Tests do not require a `main` function to run.\n\n```zc\ntest \"descriptive name\" {\n    let a = 3;\n    assert(a > 0, \"a should be positive\");\n}\n```\n\n#### Running Tests\n```bash\nzc run my_file.zc\n```\n\nOutput shows each test by name:\n```\n  TEST: descriptive name ... OK\n  TEST: another test ... FAIL\n\n1 test(s) failed\n```\n\n#### Assertions\n| Function | Behavior |\n|:---|:---|\n| `assert(cond, msg)` | Records failure, continues to next test (no longer aborts) |\n| `expect(cond, msg)` | Non-fatal — records failure but continues within the same test |\n\nUse `assert` for critical checks that should stop the current test, and `expect` when you want to verify multiple conditions without short-circuiting:\n\n```zc\ntest \"example\" {\n    expect(result != null, \"result should not be null\");\n    expect(result.code == 200, \"status should be 200\");\n    \u002F\u002F both run even if the first fails\n}\n```\n\n#### Exit Code\nThe binary exits with the number of failed tests (0 = all passed).\n\n---\n\n## Tooling\n\nZen C provides a built-in Language Server and REPL to enhance the development experience. It is also debuggable with LLDB.\n\n### Language Server (LSP)\n\nThe Zen C Language Server (LSP) supports standard LSP features for editor integration, providing:\n\n*   **Go to Definition**\n*   **Find References**\n*   **Hover Information**\n*   **Completion** (Function\u002FStruct names, Dot-completion for methods\u002Ffields)\n*   **Document Symbols** (Outline)\n*   **Signature Help**\n*   **Diagnostics** (Syntax\u002FSemantic errors)\n\nTo start the language server (typically configured in your editor's LSP settings):\n\n```bash\nzc lsp\n```\n\nIt communicates via standard I\u002FO (JSON-RPC 2.0).\n\n### REPL\n\nThe Read-Eval-Print Loop allows you to experiment with Zen C code interactively using modern **In-Process JIT Compilation** (powered by LibTCC).\n\n```bash\nzc repl\n```\n\n#### Features\n\n*   **JIT Execution**: Code is compiled in-memory and executed directly within the REPL process for lightning-fast feedback.\n\n*   **Interactive Coding**: Type expressions or statements for immediate evaluation.\n*   **Persistent History**: Commands are saved to `~\u002F.zprep_history`.\n*   **Startup Script**: Auto-loads commands from `~\u002F.zprep_init.zc`.\n\n#### Commands\n\n| Command | Description |\n|:---|:---|\n| `:help` | Show available commands. |\n| `:reset` | Clear current session history (variables\u002Ffunctions). |\n| `:vars` | Show active variables. |\n| `:funcs` | Show user-defined functions. |\n| `:structs` | Show user-defined structs. |\n| `:imports` | Show active imports. |\n| `:history` | Show session input history. |\n| `:type \u003Cexpr>` | Show the type of an expression. |\n| `:c \u003Cstmt>` | Show the generated C code for a statement. |\n| `:time \u003Cexpr>` | Benchmark an expression (runs 1000 iterations). |\n| `:edit [n]` | Edit command `n` (default: last) in `$EDITOR`. |\n| `:save \u003Cfile>` | Save the current session to a `.zc` file. |\n| `:load \u003Cfile>` | Load and execute a `.zc` file into the session. |\n| `:watch \u003Cexpr>` | Watch an expression (re-evaluated after every entry). |\n| `:unwatch \u003Cn>` | Remove a watch. |\n| `:undo` | Remove the last command from the session. |\n| `:delete \u003Cn>` | Remove command at index `n`. |\n| `:clear` | Clear the screen. |\n| `:quit` | Exit the REPL. |\n| `! \u003Ccmd>` | Run a shell command (e.g. `!ls`). |\n\n---\n\n\n### Language Server Protocol (LSP)\n\nZen C includes a built-in Language Server for editor integration.\n\n- **[Installation & Setup Guide](docs\u002FLSP.md)**\n- **Supported Editors**: VS Code, Neovim, Vim ([zenc.vim](https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Fzenc.vim)), Zed, and any LSP-capable editor.\n\nUse `zc lsp` to start the server.\n\n### Debugging Zen C\n\nZen C programs can be debugged using standard C debuggers like **LLDB** or **GDB**.\n\n#### Visual Studio Code\n\nFor the best experience in VS Code, install the official [Zen C extension](https:\u002F\u002Fmarketplace.visualstudio.com\u002Fitems?itemName=Z-libs.zenc). For debugging, you can use the **C\u002FC++** (by Microsoft) or **CodeLLDB** extension.\n\nAdd these configurations to your `.vscode` directory to enable one-click debugging:\n\n**`tasks.json`** (Build Task):\n```json\n{\n    \"label\": \"Zen C: Build Debug\",\n    \"type\": \"shell\",\n    \"command\": \"zc\",\n    \"args\": [ \"${file}\", \"-g\", \"-o\", \"${fileDirname}\u002Fapp\", \"-O0\" ],\n    \"group\": { \"kind\": \"build\", \"isDefault\": true }\n}\n```\n\n**`launch.json`** (Debugger):\n```json\n{\n    \"name\": \"Zen C: Debug (LLDB)\",\n    \"type\": \"lldb\",\n    \"request\": \"launch\",\n    \"program\": \"${fileDirname}\u002Fapp\",\n    \"preLaunchTask\": \"Zen C: Build Debug\"\n}\n```\n\n## Compiler Support & Compatibility\n\nZen C is designed to work with most C11 compilers. Some features rely on GNU C extensions, but these often work in other compilers. Use the `--cc` flag to switch backends.\n\n```bash\nzc run app.zc --cc clang\nzc run app.zc --cc zig\n```\n\n### Test Suite Status\n\n\u003Cdetails>\n\u003Csummary>Click to view Compiler Support details\u003C\u002Fsummary>\n\n| Compiler | Pass Rate | Supported Features | Known Limitations |\n|:---|:---:|:---|:---|\n| **GCC** | **100% (Full)** | All Features | None. |\n| **Clang** | **100% (Full)** | All Features | None. |\n| **Zig** | **100% (Full)** | All Features | None. Uses `zig cc` as a drop-in C compiler. |\n| **TCC** | **98% (High)** | Structs, Generics, Traits, Pattern Matching | No Intel ASM, No `__attribute__((constructor))`. |\n\n\u003C\u002Fdetails>\n\n> [!WARNING]\n> **COMPILER BUILD WARNING:** While **Zig CC** works excellently as a backend for your Zen C programs, building the *Zen C compiler itself* with it may verify but produce an unstable binary that fails tests. We recommend building the compiler with **GCC** or **Clang** and using Zig only as a backend for your operational code.\n\n### MISRA C:2012 Compliance Testing\n\nThe Zen C test suite includes verification against MISRA C:2012 guidelines. \n\n> [!IMPORTANT]\n> **MISRA Disclaimer**\n> This project is completely independent and holds no affiliation, official endorsement, or corporate connection with MISRA (Motor Industry Software Reliability Association). \n> \n> Due to strict copyright restrictions, test cases only list directives by their numeric identifiers and avoid publishing internal specifications. Users needing primary documentation are encouraged to acquire authentic guideline materials from the [Official MISRA portal](https:\u002F\u002Fwww.misra.org.uk\u002F).\n\n### Building with Zig\n\nZig's `zig cc` command provides a drop-in replacement for GCC\u002FClang with excellent cross-compilation support. To use Zig:\n\n```bash\n# Compile and run a Zen C program with Zig\nzc run app.zc --cc zig\n\n# Build the Zen C compiler itself with Zig\nmake zig\n```\n\n### Output Backends\n\nZen C supports multiple output backends via the `--backend` flag. Each backend produces a different target format:\n\n| Backend | Flag | Extension | Description |\n|:---|:---|:---:|:---|\n| **C** | `--backend c` | `.c` | Default — GNU C11 |\n| **C++** | `--backend cpp` | `.cpp` | C++11 compatible (also available as `--cpp`) |\n| **CUDA** | `--backend cuda` | `.cu` | NVIDIA CUDA C++ (also available as `--cuda`) |\n| **Objective-C** | `--backend objc` | `.m` | Objective-C (also available as `--objc`) |\n| **JSON** | `--backend json` | `.json` | Machine-readable AST for tooling |\n| **AST dump** | `--backend ast-dump` | `.ast` | Human-readable AST tree (debugging) |\n| **Lisp** | `--backend lisp` | `.lisp` | Transpile to Common Lisp (`sbcl --script`) |\n| **Graphviz** | `--backend dot` | `.dot` | Visual AST graph (`dot -Tpng ast.dot -o ast.png`) |\n\nBackend-specific options can be set with `--backend-opt`:\n\n```bash\n# Pretty-print JSON output\nzc transpile file.zc --backend json --backend-opt pretty\n\n# Show full raw content (no truncation)\nzc transpile file.zc --backend lisp --backend-opt full-content\n\n# OR use convenience aliases:\nzc transpile file.zc --backend json --json-pretty\nzc transpile file.zc --backend lisp --backend-full-content\n```\n\nAll backend options are self-documented — unknown `--` flags are checked against registered backend aliases automatically.\n\n### C++ Interop\n\nZen C can generate C++-compatible code with the `--backend cpp` flag (`--cpp` for short), allowing seamless integration with C++ libraries.\n\n```bash\n# Direct compilation with g++\nzc app.zc --backend cpp\n\n# Or transpile for manual build\nzc transpile app.zc --backend cpp\ng++ out.cpp my_cpp_lib.o -o app\n```\n\n#### Using C++ in Zen C\n\nInclude C++ headers and use raw blocks for C++ code:\n\n```zc\ninclude \u003Cvector>\ninclude \u003Ciostream>\n\nraw {\n    std::vector\u003Cint> make_vec(int a, int b) {\n        return {a, b};\n    }\n}\n\nfn main() {\n    let v = make_vec(1, 2);\n    raw { std::cout \u003C\u003C \"Size: \" \u003C\u003C v.size() \u003C\u003C std::endl; }\n}\n```\n\n> [!NOTE]\n> The `--cpp` flag switches the backend to `g++` and emits C++-compatible code (uses `auto` instead of `__auto_type`, function overloads instead of `_Generic`, and explicit casts for `void*`).\n\n#### CUDA Interop\n\nZen C supports GPU programming by transpiling to **CUDA C++** via the `--backend cuda` flag (`--cuda` for short). This allows you to leverage powerful C++ features (templates, constexpr) within your kernels while maintaining Zen C's ergonomic syntax.\n\n```bash\n# Direct compilation with nvcc\nzc run app.zc --backend cuda\n\n# Or transpile for manual build\nzc transpile app.zc --backend cuda -o app.cu\nnvcc app.cu -o app\n```\n\n#### CUDA-Specific Attributes\n\n| Attribute | CUDA Equivalent | Description |\n|:---|:---|:---|\n| `@global` | `__global__` | Kernel function (runs on GPU, called from host) |\n| `@device` | `__device__` | Device function (runs on GPU, called from GPU) |\n| `@host` | `__host__` | Host function (explicit CPU-only) |\n\n#### Kernel Launch Syntax\n\nZen C provides a clean `launch` statement for invoking CUDA kernels:\n\n```zc\nlaunch kernel_name(args) with {\n    grid: num_blocks,\n    block: threads_per_block,\n    shared_mem: 1024,  \u002F\u002F Optional\n    stream: my_stream   \u002F\u002F Optional\n};\n```\n\nThis transpiles to: `kernel_name\u003C\u003C\u003Cgrid, block, shared, stream>>>(args);`\n\n#### Writing CUDA Kernels\n\nUse Zen C function syntax with `@global` and the `launch` statement:\n\n```zc\nimport \"std\u002Fcuda.zc\"\n\n@global\nfn add_kernel(a: float*, b: float*, c: float*, n: int) {\n    let i = thread_id();\n    if i \u003C n {\n        c[i] = a[i] + b[i];\n    }\n}\n\nfn main() {\n    def N = 1024;\n    let d_a = cuda_alloc\u003Cfloat>(N);\n    let d_b = cuda_alloc\u003Cfloat>(N); \n    let d_c = cuda_alloc\u003Cfloat>(N);\n    defer cuda_free(d_a);\n    defer cuda_free(d_b);\n    defer cuda_free(d_c);\n\n    \u002F\u002F ... init data ...\n    \n    launch add_kernel(d_a, d_b, d_c, N) with {\n        grid: (N + 255) \u002F 256,\n        block: 256\n    };\n    \n    cuda_sync();\n}\n```\n\n#### Standard Library (`std\u002Fcuda.zc`)\nZen C provides a standard library for common CUDA operations to reduce `raw` blocks:\n\n```zc\nimport \"std\u002Fcuda.zc\"\n\n\u002F\u002F Memory management\nlet d_ptr = cuda_alloc\u003Cfloat>(1024);\ncuda_copy_to_device(d_ptr, h_ptr, 1024 * sizeof(float));\ndefer cuda_free(d_ptr);\n\n\u002F\u002F Synchronization\ncuda_sync();\n\n\u002F\u002F Thread Indexing (use inside kernels)\nlet i = thread_id(); \u002F\u002F Global index\nlet bid = block_id();\nlet tid = local_id();\n```\n\n\n> [!NOTE]\n> **Note:** The `--cuda` flag sets `nvcc` as the compiler and implies `--cpp` mode. Requires the NVIDIA CUDA Toolkit.\n\n### C23 Support\n\nZen C supports modern C23 features when using a compatible backend compiler (GCC 14+, Clang 14+, TCC (partial)).\n\n- **`auto`**: Zen C automatically maps type inference to standard C23 `auto` if `__STDC_VERSION__ >= 202300L`.\n- **`_BitInt(N)`**: Use `iN` and `uN` types (e.g., `i256`, `u12`, `i24`) to access C23 arbitrary-width integers.\n\n### Objective-C Interop\n\nZen C can compile to Objective-C (`.m`) using the `--backend objc` flag (`--objc` for short), allowing you to use Objective-C frameworks (like Cocoa\u002FFoundation) and syntax.\n\n```bash\n# Compile with clang (or gcc\u002Fgnustep)\nzc app.zc --backend objc --cc clang\n```\n\n#### Using Objective-C in Zen C\n\nUse `include` for headers and `raw` blocks for Objective-C syntax (`@interface`, `[...]`, `@\"\"`).\n\n```zc\n\u002F\u002F> macos: framework: Foundation\n\u002F\u002F> linux: cflags: -fconstant-string-class=NSConstantString -D_NATIVE_OBJC_EXCEPTIONS\n\u002F\u002F> linux: link: -lgnustep-base -lobjc\n\ninclude \u003CFoundation\u002FFoundation.h>\n\nfn main() {\n    raw {\n        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];\n        NSLog(@\"Hello from Objective-C!\");\n        [pool drain];\n    }\n    println \"Zen C works too!\";\n}\n```\n\n> [!NOTE]\n> **Note:** Zen C string interpolation works with Objective-C objects (`id`) by calling `debugDescription` or `description`.\n\n---\n\n### Public API (Embedding)\n\nZen C can be used as a C library via the public headers in `src\u002Fpublic\u002F*.h`. These headers compile without `-DZC_ALLOW_INTERNAL` and provide a stable API for embedding the compiler in your own tools:\n\n```c\n#include \u003Czc_core.h>\n#include \u003Czc_driver.h>\n#include \u003Czc_diag.h>\n\nint main(void) {\n    ZenCompiler compiler = {0};\n    compiler.config.input_file = \"source.zc\";\n    return driver_run(&compiler);\n}\n```\n\n**Compile with:**\n\n```bash\ncc -I src\u002Fpublic -I src -I src\u002Futils my_tool.c -o my_tool\n```\n\n**After install (`make install`):**\n\n```bash\ncc -I \u002Fusr\u002Flocal\u002Finclude\u002Fzenc my_tool.c -o my_tool\n```\n\nThe public API covers:\n- **`zc_core.h`** — `CompilerConfig`, `ZenCompiler`, `ASTNode`, `Type` types, parser entry points, type introspection helpers\n- **`zc_driver.h`** — `driver_run()`, `driver_compile()` (full pipeline orchestration)\n- **`zc_codegen.h`** — `codegen_node()`, `emit_preamble()`, `format_expression_as_c()`\n- **`zc_analysis.h`** — `check_program()`, `check_moves_only()`, `resolve_alias()`\n- **`zc_diag.h`** — `zerror_at()`, `zwarn_at()`, `zpanic_at()`, diagnostic reporting\n- **`zc_utils.h`** — `Emitter` (output buffer), `load_file()`, `z_resolve_path()`\n\nInstall with `sudo make install` to deploy headers, the binary, man pages, and standard library.\n\n---\n\n## Contributing\n \n We welcome contributions! Whether it's fixing bugs, adding documentation, or proposing new features.\n \n Please see [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines on how to contribute, run tests, and submit pull requests.\n\n---\n \n ## Security\n \n For security reporting instructions, please see [SECURITY.md](SECURITY.md).\n \n ---\n \n ## Attributions\n\nThis project uses third-party libraries. Full license texts can be found in the `LICENSES\u002F` directory.\n\n*   **[cJSON](https:\u002F\u002Fgithub.com\u002FDaveGamble\u002FcJSON)** (MIT License): Used for JSON parsing and generation in the Language Server.\n*   **[zc-ape](https:\u002F\u002Fgithub.com\u002FOEvgeny\u002Fzc-ape)** (MIT License): The original Actually Portable Executable port of Zen-C by [Eugene Olonov](https:\u002F\u002Fgithub.com\u002FOEvgeny).\n*   **[Cosmopolitan Libc](https:\u002F\u002Fgithub.com\u002Fjart\u002Fcosmopolitan)** (ISC License): The foundational library that makes APE possible.\n*   **[TRE](https:\u002F\u002Fgithub.com\u002Flaurikari\u002Ftre)** (BSD License): Used for the regular expression engine in the standard library.\n*   **[zenc.vim](https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Fzenc.vim)** (MIT License): The official Vim\u002FNeovim plugin, primarily authored by **[davidscholberg](https:\u002F\u002Fgithub.com\u002Fdavidscholberg)**.\n*   **[TinyCC](https:\u002F\u002Fgithub.com\u002FTinyCC\u002Ftinycc)** (LGPL License): The foundational JIT engine used for the high-performance REPL evaluation.\n\n---\n\n\u003Cdiv align=\"center\">\n  \u003Cp>\n    Copyright © 2026 Zen C Programming Language.\u003Cbr>\n    Start your journey today.\n  \u003C\u002Fp>\n  \u003Cp>\n    \u003Ca href=\"https:\u002F\u002Fdiscord.com\u002Finvite\u002Fq6wEsCmkJP\">Discord\u003C\u002Fa> •\n    \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Fzenc\">GitHub\u003C\u002Fa> •\n    \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Fdocs\">Documentation\u003C\u002Fa> •\n    \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Fawesome-zenc\">Examples\u003C\u002Fa> •\n    \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fzenc-lang\u002Frfcs\">RFCs\u003C\u002Fa> •\n    \u003Ca href=\"CONTRIBUTING.md\">Contribute\u003C\u002Fa>\n  \u003C\u002Fp>\n\u003C\u002Fdiv>\n","Zen C 是一种现代系统编程语言，它能够以高级语言的风格编写代码，同时编译成可读性强的GNU C\u002FC11。其核心功能包括类型推断、模式匹配、泛型、特性（traits）、异步\u002F等待支持以及带有RAII能力的手动内存管理，这些都保持了与C语言ABI的完全兼容性。该项目采用MIT许可证开放源码，并提供了丰富的工具链支持，如官方文档、RFC提案机制和VS Code插件等。Zen C适用于需要高性能且对C生态系统有依赖的应用场景，如嵌入式开发、操作系统组件或是任何要求直接控制硬件资源的项目。",2,"2026-06-11 03:50:28","high_star"]