Configs2026年7月21日·1 分钟阅读

Janet — Lightweight Embeddable Programming Language

A functional and imperative Lisp dialect designed for embedding, scripting, system automation, and rapid prototyping with a tiny footprint.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Janet Overview
直接安装命令
npx -y tokrepo@latest install b2d4d7b0-84e1-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

Janet is a small, portable, dynamically typed programming language inspired by Clojure, Lua, and Python. It is designed for embedding into C/C++ applications, writing build scripts, system automation, and rapid prototyping. The entire runtime compiles to a single C file with no external dependencies.

What Janet Does

  • Provides a Lisp-like language with familiar syntax for functional and imperative programming
  • Embeds into C/C++ applications as a single-file library with a clean C API
  • Includes a built-in module system, package manager (jpm), and PEG-based parser combinator
  • Offers fibers and channels for lightweight concurrency without OS threads
  • Compiles scripts to bytecode for faster loading and optional ahead-of-time compilation

Architecture Overview

Janet compiles source code into bytecode that runs on a custom register-based virtual machine written in ANSI C. The runtime includes a mark-and-sweep garbage collector, a module loader, and an event loop for asynchronous I/O. The entire core is a single C file (~15K lines) with no dependencies beyond libc, making cross-compilation and embedding straightforward.

Self-Hosting & Configuration

  • Install via Homebrew, package managers, or compile from source with make && sudo make install
  • Use jpm (Janet Project Manager) to manage dependencies and build projects
  • Embed by including janet.c and janet.h in your C project — no separate library needed
  • Configure the module search path via JANET_PATH environment variable
  • Pre-compile scripts to images with janet -c script.janet script.jimage for faster startup

Key Features

  • Tiny runtime (~300 KB binary) suitable for resource-constrained environments
  • PEG module for parsing grammars directly in Janet without external parser generators
  • First-class fibers enabling cooperative multitasking and coroutine-based workflows
  • Built-in networking, file I/O, and OS interaction for system scripting
  • Comprehensive standard library covering data structures, regex, JSON, and more

Comparison with Similar Tools

  • Lua — Similar embedding niche; Janet offers richer data structures and a more modern standard library
  • Guile/Scheme — More traditional Lisp; Janet is smaller and simpler to embed
  • Python — Larger ecosystem; Janet is 100x smaller for embedding use cases
  • Fennel — Lisp that transpiles to Lua; Janet has its own VM and does not depend on Lua

FAQ

Q: Is Janet a Lisp? A: Janet is Lisp-inspired with s-expression syntax but adds features from Clojure and Python. It uses brackets for arrays and braces for tables.

Q: How do I add packages? A: Use jpm install package-name. Packages are listed in the Janet package index.

Q: Can Janet replace Lua for game scripting? A: Yes. Janet's embedding API is similar to Lua's, and several game projects use Janet for scripting.

Q: What platforms does Janet support? A: Janet runs on Linux, macOS, Windows, BSDs, and has been ported to embedded systems and WebAssembly.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产