@QuixiAI: With 编程语言取得了重大里程碑。PCRE2 已集成。正则表达式已整合。隐式 main 函数,单行命令已实现…
摘要
With 编程语言通过集成 PCRE2 支持正则表达式并实现隐式 main 函数,达到了一个重要里程碑。该更新支持单行命令,并包含具有内置 LSP 支持的自托管编译器。
查看缓存全文
缓存时间: 2026/05/10 16:28
The With Programming Language has hit a major milestone. PCRE2 is in. Regular expressions integrated. Implicit main, one-liners implemented. $ printf ‘[INFO] boot\n[WARN] slow query\n[ERROR] db timeout\n’ | with -n ’if line =~ /^[(?ERROR|WARN)]\s+(?.*)/: print(f"{nr}: {$level} {$msg}")' 2: WARN slow query 3: ERROR db timeout --- # withlang-dev/with Source: https://github.com/withlang-dev/with # With With 是一种系统级编程语言,拥有自举编译器。编译器由 With 语言编写并编译自身。仓库中包含一个冻结的 Zig 引导编译器 (`bootstrap/`) 作为历史遗留物——它在构建流程中不再使用。 ## 依赖要求 - LLVM 工具链(默认:`/usr/local/llvm`,可通过 `LLVM_PREFIX` 覆盖) - PATH 中可用 clang(用于链接用户程序) - Zig(可选,用于交叉编译) ## 构建 Makefile 是主要的构建接口。常规开发应通过 `make` 进行,而不是通过临时 shell 脚本。自举链如下: ``text seed → stage1 → stage2 → stage3 `` 常用目标: ``sh make stage1 # 仅构建 stage1 make stage2 # 仅构建 stage2 make build # stage2 的别名,同时刷新 out/bin/with make stage3 # 仅构建 stage3 make fixpoint # 验证 stage2 == stage3 make test # 使用 stage2 运行自举套件和 CLI 回归测试 make smoke # 快速编译器冒烟检查 `` 种子编译器从 `WITH` 环境变量、PATH 上的 `with` 或下载的种子二进制文件中解析: ``sh make build # 使用 PATH 上的 `with` make seed && make build # 从 GitHub Releases 下载种子 WITH=~/other/with make build # 使用显式二进制文件 `` `src/main` 是本地的已下载种子二进制文件。它被 gitignore 忽略,绝不能提交或推送。`out/bin/with-stage2` 是工作区中规范构建的编译器,而 `out/bin/with` 是它的副本,方便使用。`make fixpoint` 从 stage2 构建 stage3 并验证它们是否字节级一致。 ## 安装 ``sh make install-user # 安装到 ~/.local/bin/with make install PREFIX=HOME/.local # 显式本地前缀安装 sudo make install # 安装到 /usr/local/bin/with `make build` 不会安装到你的 PATH 中。安装是一个单独的步骤。对于 fish shell:sh fish_add_path -g ~/.local/bin ## 使用 基本命令:sh with check examples/hello.w with build examples/hello.w ./examples/hello with run examples/hello.w 调试/转储命令:sh with check –dump-tokens examples/hello.w with check –dump-ast examples/hello.w with check –dump-resolved examples/hello.w with check –dump-typed examples/hello.w with check –dump-mir examples/hello.w with check –dump-async-mir examples/hello.w C 代码输出路径:sh with build –emit-c examples/hello.w -o hello.c cc -I runtime hello.c runtime/with_runtime.c runtime/helpers.c runtime/fiber.c runtime/fiber_asm_aarch64.s -o hello ## 测试 自举测试套件和 CLI 回归测试:sh make test 固定点验证(stage2 == stage3):sh make fixpoint ## 编辑器支持 编译器包含内置的语言服务器:`with lsp`。它提供诊断、跳转到定义、悬停提示和保存时格式化功能。 ### VSCode 从 `with-vscode/` 安装扩展:sh cd with-vscode npm install npx tsc -p ./ 然后打开 VSCode,运行 **Extensions: Install from VSIX**(或按 F1),或者符号链接扩展目录:sh ln -s “(pwd)/with-vscode" ~/.vscode/extensions/with-lang `` 重启 VSCode。带有 `.w` 扩展名的文件会自动获得语法高亮和 LSP 功能。如果 `with` 不在 PATH 中,请在设置中配置编译器路径: ``json { "with.lsp.path": "/path/to/with" } `` ### Neovim 使用内置 LSP 客户端(需要 Neovim 0.5+): ``lua -- ~/.config/nvim/init.lua (或 ftplugin/with.lua) vim.api.nvim_create_autocmd('FileType', { pattern = 'with', callback = function() vim.lsp.start({ name = 'with-lsp', cmd = { 'with', 'lsp' }, root_dir = vim.fs.dirname(vim.fs.find({ 'with.toml' }, { upward = true })[1]), }) end, }) vim.filetype.add({ extension = { w = 'with' } }) `` ### Vim 使用 vim-lsp(https://github.com/prabirshrestha/vim-lsp): ``vim " ~/.vimrc au User lsp_setup call lsp#register_server({ \ 'name': 'with-lsp', \ 'cmd': ['with', 'lsp'], \ 'allowlist': ['with'], \ }) au BufRead,BufNewFile *.w set filetype=with `` 使用 coc.nvim(https://github.com/neoclide/coc.nvim),添加到 `coc-settings.json`: ``json { "languageserver": { "with": { "command": "with", "args": ["lsp"], "filetypes": ["with"] } } } `` ### Emacs 使用 lsp-mode(https://github.com/emacs-lsp/lsp-mode): ``elisp ;; ~/.emacs.d/init.el 或 ~/.emacs (define-derived-mode with-mode prog-mode "With" "Major mode for the With language." (setq-local comment-start "// ")) (add-to-list 'auto-mode-alist '("\\.w\\'" . with-mode)) (with-eval-after-load 'lsp-mode (add-to-list 'lsp-language-id-configuration '(with-mode . "with")) (lsp-register-client (make-lsp-client :new-connection (lsp-stdio-connection '("with" "lsp")) :activation-fn (lsp-activate-on "with") :server-id 'with-lsp))) (add-hook 'with-mode-hook #'lsp) `` 使用 eglot(https://github.com/joaotavora/eglot)(内置于 Emacs 29+): ``elisp (define-derived-mode with-mode prog-mode "With" (setq-local comment-start "// ")) (add-to-list 'auto-mode-alist '("\\.w\\'" . with-mode)) (with-eval-after-load 'eglot (add-to-list 'eglot-server-programs '(with-mode . ("with" "lsp")))) (add-hook 'with-mode-hook #'eglot-ensure) `` ### Zed 添加到你的 Zed 配置(`~/.config/zed/settings.json`): ``json { "lsp": { "with-lsp": { "binary": { "path": "with", "arguments": ["lsp"] } } }, "languages": { "With": { "language_servers": ["with-lsp"] } }, "file_types": { "With": ["w"] } } `` ### Helix 添加到 `~/.config/helix/languages.toml`: ``toml [[language]] name = "with" scope = "source.with" file-types = ["w"] comment-token = "//" indent = { tab-width = 4, unit = " " } language-servers = ["with-lsp"] [language-server.with-lsp] command = "with" args = ["lsp"] `` ## 仓库结构 ``text src/ 自举编译器 (.w) src/main 本地种子二进制文件 (被 gitignore 忽略;通过 `make seed` 下载) src/compiler/ 编译优先架构的端口层 runtime/ C 运行时源码 (.c, .h, .s) lib/std/ 标准库 (.w) test/cases/ 行为测试 out/ 所有构建输出 (被 gitignore 忽略) bin/ 编译器二进制文件 lib/ 编译后的运行时对象 (.o), LLVM 链接配置 log/ 构建日志 bootstrap/ 历史性的 Zig 引导编译器 (已冻结,未使用) `` ## 故障排除 - 在 `/usr/local` 下出现 `install: ... Operation not permitted`:使用 `make install-user`、`PREFIX=HOME/.local,或运行 sudo make install。 - no LLVM bridge available:在 /usr/local/llvm安装 LLVM 或设置LLVM_PREFIX。编译器静态链接 LLVM —— 运行时不需要动态库。 - 只需重建分阶段编译器:仅 stage2 使用 make stage2,或进行 stage2 加上 stage3 验证使用 make fixpoint。 - 需要直接重建编译器阶段:使用 make stage1、make stage2或make stage3`。
相似文章
@karpathy:最火的新编程语言是英语
评论大型语言模型和AI如何使英语成为一门有效的编程语言,反映了编程任务向自然语言界面转变的趋势。
@badlogicgames:pibot 现在完全本地运行,使用 parakeet 进行语音转文字(STT),qwen3-tts 进行文字转语音(TTS),以及 Qwen 3.6 作为本地的多模态大语言模型……
pibot 现已完全本地化,采用 Parakeet 进行语音转文字(STT),Qwen3-tts 进行文字转语音(TTS),并通过 llama.cpp 使用 Qwen 3.6 作为本地多模态大语言模型,推理引擎基于 Rust/mlx-c,实现了零 Python 依赖。
@julien_c: 耶!
Rémi 分享说,他现在在笔记本电脑上使用 Qwen3.6-27B 直接在命令行中输入纯英文,突出展示了这款实用的人工智能工具在命令行交互中的应用。
QBE - 编译器后端:版本 1.3
QBE 1.3 是一个重要的编译器后端版本,新增了 7000 行代码,引入了一种新的 IL 匹配算法,针对 coremark 基准测试进行了优化(性能从 gcc -O2 的 40% 提升到超过 63%),支持 Windows ABI 和位置无关代码生成。
@hwchase17:代码解释器是一个轻量级的代码执行环境,让你可以:- RLMs - 程序化工具调用 - 更多!w…
Harrison Chase 发布了一个名为 code interpreter 的轻量级代码执行环境,它支持 RLMs 和程序化工具调用,无需启动完整的沙箱,更多用例将陆续公布。