Jaithon 3,一种语法完美的快速编程语言。
Jaithon 3, a fast programming language with the perfect syntax

原始链接: https://github.com/abhiramasonny/jaithon

Jaithon 是一种动态执行、具备垃圾回收机制并使用字节码虚拟机的编程语言。其架构灵感源自 Java,语法与设计则借鉴了 Rust 和 Python。该语言具有高度的自举性,大部分组件均由 Jaithon 自身实现,便于扩展。 该项目采用了人工智能辅助的开发工作流。尽管约 80% 的原始代码由 Claude 等工具生成,但其架构完全由人工设计。开发者将大模型视为生产力倍增器而非人类判断的替代品,确保每一行代码都经过审核与理解。 **核心特性:** * **语法:** 支持可选类型、模式匹配、代数数据类型(枚举)、特征(traits)以及延迟执行。 * **生态系统:** 包含包管理器、标准库以及诸如 `jaitensor`(支持 Metal 加速张量)和 `jaiplot` 等专用模块。 * **工具链:** 提供强大的 REPL、内置格式化工具、字节码反汇编器以及清晰详尽的错误报告系统。 * **性能:** 使用 C11 编译器构建,旨在实现快速迭代与可扩展性。 Jaithon 基于 MIT 许可证发布,代表了一种工程协作的新范式,通过结合人工系统设计与自动化实现,加速语言的演进。

Jaithon 是一门快速编程语言,由年轻开发者 Abhirama 于 2023 年发起。该语言最初只是一个简单的解释器,现已演变成一个功能丰富的自举系统,包含词法分析器、解析器、字节码生成器,以及一个具备即时(JIT)编译器、多态内联缓存和垃圾回收机制的虚拟机。 该项目的语法借鉴了 Python、Rust、Java 和 Go 等多种语言,旨在实现功能与可读性之间的“最佳”平衡。Abhirama 利用人工智能代理工具来加速开发,但他强调自己对底层架构拥有严格控制权,并确保完全理解每一行生成的代码。 该项目在 Hacker News 上引发了关于人工智能在编程中作用的热烈讨论——一些批评者将其贴上“AI 垃圾(AI slop)”的标签——同时也引发了关于内存管理、错误处理以及基于栈与基于寄存器的虚拟机之优劣的技术探讨。目前,Jaithon 针对 macOS 进行了优化,未来计划进一步提升性能并扩展功能。Abhirama 欢迎各界提供反馈并参与协作,以持续迭代该语言的核心设计。
相关文章

原文

Jaithon is a dynamically executed and garbage collected language with a bytecode VM. It takes heavy insp from the structure from Java (for its architecture) and insp for everything else from a combination of Rust & Python.

Pretty much everything (apart from the CORE primitive implementation stuff) is written in jaithon itself, making it VERY much bootstrapped and easy to extend with new features.

Most documentation within .jai and .c files is currently AI-generated to speed up development, though it is being rewritten as the language evolves. The README and most of LANGUAGE.md are hand-written, thoroughly reviewed, and are currently 100% accurate. Docstrings in the code may still be inaccurate, as they were generated by an LLM.

Additionally, around 80% of the raw code in this repository was produced with agentic coding tools (claude code). My workflow is to first design a feature or bug fix completley by hand, then use an LLM to help either finish it, integrate it with the codebase, catch additioal bugs before I push, improve performance, or correct me on bad assumptions. The resulting code is something I completley understand and something that I stand by, and something that belongs to me.

The architecture is also 100% my own, 100% human generated, and not AI assisted.

I see agent-assisted coding as the future of software engineering. It let me build Jaithon 3 far faster than I could have done alone, while still keeping a real human in the loop for the important decisions. Without agentic coding, Jaithon 3 probably wouldnt have existed, and Jaithon would have been stuck at a primal level. The entire codebase is reviewed by me and I would not consider myself a "vibecoder", or jaithon as "ai slop"; it is collaborative engineering with LLMs used as a multiplier to exponentiate my productivity.

git clone https://github.com/abhiramasonny/jaithon
cd jaithon
make                        # builds ./jaithon
make test                   # this is optional, but it runs the benchmarks and tests and stuff
./scripts/install.sh        # also optional, it installs itself to /usr/local

The reqs to run jaithon are a C11 compiler and make, readline is used for the REPL if present. On macOS the Metal and Cocoa frameworks enable the GUI and GPU modules, however everything else builds and runs without them.

jaithon run program.jai     # run a file
jaithon                     # REPL
jaithon check src/          # type-check without running
jaithon fmt .               # canonical formatter, no options
jaithon test                # discover and run tests
jaithon doc --out docs/api  # generate API documentation
jaithon disasm program.jai  # bytecode listing

The REPL keeps its bindings across lines, continues an unfinished input on a ... prompt, and takes meta-commands. :help lists every one of them.

# let is immutable but var is not and const is compile time
let name = "Jaithon"
var count = 0
const MAX = 1 << 16

# types are optional, but they are checked if they are present
let ratio: float = 0.5
let names: list[str] = []
let lookup: dict[str, int] = {}
let maybe: int? = null           # T? is T | null

if names.len() > 0 { print(names[0]) }
print(maybe ?? -1)

# loops and ranges
for i in 0..10 { count += i }
'outer: for row in grid {
    for cell in row {
        if cell == target { break 'outer }
    }
}

# pattern matching
let kind = match code {
    200           => "ok",
    301 | 302     => "redirect",
    400..=499     => "client error",
    n if n >= 500 => "server error",
    _             => "unknown",
}

enum Shape {
    Circle(radius: float),
    Rect(w: float, h: float),
}

fn area(s: Shape) -> float {
    return match s {
        Shape.Circle(r)  => math.PI * r ** 2,
        Shape.Rect(w, h) => w * h,
    }
}

# traits are interfaces with default methods, and they are types.
trait Printable {
    fn to_str(self) -> str
    fn describe(self) -> str { return f"<{self.to_str()}>" }
}

# Errors are classes
fn load(path: str) -> str {
    let file = io.open(path, "r")
    defer { file.close() }
    return file.read()
}

# comphressons and lazy iterators.
let squares = [x ** 2 for x in 0..10 if x % 2 == 0]
let first_ten = iter(source).map(parse).filter(is_valid).take(10).collect()

more idepth file -> LANGUAGE.md.

Also you can checkout the examples directory.

Libraries that can ship outside the Jaithon standard library can be found under packages/. Each package owns its source, tests, version, and dependency manifest. Jaithon finds workspace packages from a checkout and from an installed share/jaithon/packages directory.

jaiplot is a library for Matplotlib-style figures and axes with file and window backends.

jaitensor provides Metal-resident float32 tensors and a Keras-style API. It includes common tensor math, format-independent datasets, dense models, ReLU/sigmoid/tanh/softmax activations, momentum SGD, Adam, validation, prediction, and JSON weight files. The examples cover MNIST and a nonlinear spiral classifier.

Every error is in this format, so hopefully its easy to debug

error[E0301]: cannot assign to immutable binding `x`
  --> examples/demo.jai:7:5
   |
 5 | let x = 1
   |     - `x` declared immutable here
 ...
 7 |     x = 2
   |     ^^^^^ assignment to immutable binding
   |
help: change the declaration to `var x = 1`

These are what the codes mean:

Code Area
E00xx lexical
E01xx syntax
E02xx names
E03xx bindings
E04xx types
E05xx match
E06xx functions
E07xx classes
E08xx modules

source --> lexer --> parser --> resolver --> type checker --> codegen --> VM
            |         │           │              │               │         │
          tokens     AST      symbols +      types +          bytecode   values
                               slots          casts           + caches   + GC
make debug            # -O0 -g, assertions on
make check            # type-check the whole tree
make test             # full suite
make bootstrap        # differential front-end verification
jaithon fmt --check . # formatting gate

MIT. See LICENSE.

Created by Abhirama Sonny.

联系我们 contact @ memedata.com