Total Pageviews

Showing posts with label zig. Show all posts
Showing posts with label zig. Show all posts

Tuesday, 13 January 2026

编程语言Zig离开GitHub:微软AI狂热下的开发者表达反抗




编程语言Zig近日宣布全面迁移至开源平台Codeberg,彻底告别GitHub。这一决定直指微软旗下GitHub对AI工具的过度投入,导致其核心代码托管服务品质下滑。

导火索

事件的导火索可追溯至2025年4月。开发者AlekseiNikiforovIBM在GitHub提交了一个关于safe_sleep.sh脚本无限挂起的错误报告。该脚本原应用于安全暂停GitHub Actions运行器的执行,但在高负载环境下会出现严重故障。

Zig核心开发人员Matthew Lugg指出:“这个脚本的缺陷显而易见:如果进程没有在特定的一秒间隔内被调度,它就会永远旋转下去,占用100%的CPU资源”。这一问题导致Zig的CI运行器机器上出现多个已运行数百小时的进程, silently地使两个运行器服务宕机数周。

尽管修复程序于2025年8月20日被合并,但相关的错误报告直到12月1日才被关闭,整整拖延了八个月。更令人担忧的是,另一个CPU使用率问题至今仍未解决。
领导层表态:AI或离开

Zig软件基金会主席Andrew Kelly直言不讳地批评了GitHub的现状。他特别引用了GitHub首席执行官“拥抱AI或离开”的言论,认为这直接导致了GitHub Actions开始实施“氛围调度”——看似随机选择要运行的作业。Kelly称:“结合其他错误和无法手动干预的问题,我们的CI系统积压严重,甚至连主分支提交都无法得到检查”。尽管他后来为帖文的激烈语气道歉,但迁移决定已经做出。
业界响应

Zig并非唯一对GitHub表示不满的项目。Dillo浏览器项目创建者Rodrigo Arias Mallo也在周末宣布计划离开GitHub,理由包括对JavaScript的过度依赖、服务拒绝能力、可用性下降,以及“对LLM和生成式AI的过度关注正在摧毁开放网络”。

Answer.AI和Fast.AI联合创始人Jeremy Howard在社交媒体上表示,用户关于GitHub Actions维护状况不佳的说法似乎是有道理的。他指出:“我无法理解这样一个非凡的、令人震惊的事件集合如何在任何正常运作的组织中发生”。

代码托管商业反思

微软CEO萨提亚·纳德拉在2025财年第三季度财报电话会议上透露,GitHub Copilot用户已超过1500万,同比增长超过4倍。早在2024年第四季度,GitHub就报告了20亿美元的年收入运行率,其中Copilot订阅贡献了约40%的年收入增长。

然而Codeberg作为非营利性Git托管服务,自1月份以来支持会员数量翻倍,从600多名增加到1200多名。这一增长反映了开发社区对纯粹代码托管服务的需求正在上升。

消息来源:https://www.theregister.com/2025/12/02/zig_quits_github_microsoft_ai_obsession/

Tuesday, 25 February 2025

开源的终端模拟器-Ghostty

 

Ghostty是一款跨平台的开源终端模拟器项目。基于Zig 编写,支持 GPU 加速,在 Linux 和 macOS 上都使用了各自平台的 GUI 构建,macOS 是基于 SwiftUI,而 Linux 是基于 GTK。项目遵守MIT开源协议,作者称目前有许多出色的终端模拟器可用,但在速度、功能或原生 UI 之间各有千秋,无法做到平衡。Ghostty 提供速度、功能或 UI。三个类别都具有竞争力,试图达到平衡。

功能特色:

    跨平台:支持 macOS 和 Linux。
    窗口、标签和拆分:支持多个窗口,每个窗口都有自己的标签和拆分,所有这些都使用原生 UI 组件呈现。
    GPU 加速渲染:macOS 上使用 Metal,Linux 上使用 OpenGL 进行终端屏幕渲染。
    主题:内置数百个主题,可以使用一行配置进行选择,并能根据系统明/暗模式自动切换,用户也可以创建自己的主题。
    连字:可以正确渲染具有连字的字体,并支持启用或禁用特定的字体功能。
    字形聚类:多代码点表情符号(如标志、肤色)被正确渲染为单个字符。
    Kitty 图形协议:允许终端应用程序直接在终端中渲染图像。
    macOS 平台原生特性:
        快速终端:从菜单栏下方动画显示,可快速访问。
        原生标签、拆分等:使用原生的 macOS 组件。
        代理图标:在标题栏中拖动代理图标以移动或访问终端会话文件。
        快速查看:使用三指轻点或 Force Touch 来查看定义、网络搜索等。
        安全键盘输入:自动检测密码提示或手动启用安全键盘输入来保护密码

源代码:https://github.com/ghostty-org/ghostty

官网:https://ghostty.org/

Saturday, 12 February 2022

zig, A general-purpose programming language

 

A general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.

https://ziglang.org/

Documentation

If you are looking at this README file in a source tree, please refer to the Release Notes, Language Reference, or Standard Library Documentation corresponding to the version of Zig that you are using by following the appropriate link on the download page.

Otherwise, you're looking at a release of Zig, and you can find documentation here:

  • doc/langref.html
  • doc/std/index.html

Installation

A Zig installation is composed of two things:

  1. The Zig executable
  2. The lib/ directory

At runtime, the executable searches up the file system for the lib/ directory, relative to itself:

  • lib/
  • lib/zig/
  • ../lib/
  • ../lib/zig/
  • (and so on)

In other words, you can unpack a release of Zig anywhere, and then begin using it immediately. There is no need to install it globally, although this mechanism supports that use case too (i.e. /usr/bin/zig and /usr/lib/zig/).

Building from Source

Ensure you have the required dependencies:

  • CMake >= 3.5
  • System C/C++ Toolchain
  • LLVM, Clang, LLD development libraries == 17.x

Then it is the standard CMake build process:

mkdir build
cd build
cmake ..
make install

For more options, tips, and troubleshooting, please see the Building Zig From Source page on the wiki.

Building from Source without LLVM

In this case, the only system dependency is a C compiler.

cc -o bootstrap bootstrap.c
./bootstrap

This produces a zig2 executable in the current working directory. This is a "stage2" build of the compiler, without LLVM extensions, and is therefore lacking these features:

However, a compiler built this way does provide a C backend, which may be useful for creating system packages of Zig projects using the system C toolchain. In such case, LLVM is not needed!

Contributing

Donate monthly.

Zig is Free and Open Source Software. We welcome bug reports and patches from everyone. However, keep in mind that Zig governance is BDFN (Benevolent Dictator For Now) which means that Andrew Kelley has final say on the design and implementation of everything.

One of the best ways you can contribute to Zig is to start using it for an open-source personal project.

This leads to discovering bugs and helps flesh out use cases, which lead to further design iterations of Zig. Importantly, each issue found this way comes with real world motivations, making it straightforward to explain the reasoning behind proposals and feature requests.

You will be taken much more seriously on the issue tracker if you have a personal project that uses Zig.

The issue label Contributor Friendly exists to help you find issues that are limited in scope and/or knowledge of Zig internals.

Please note that issues labeled Proposal but do not also have the Accepted label are still under consideration, and efforts to implement such a proposal have a high risk of being wasted. If you are interested in a proposal which is still under consideration, please express your interest in the issue tracker, providing extra insights and considerations that others have not yet expressed. The most highly regarded argument in such a discussion is a real world use case.

For more tips, please see the Contributing page on the wiki.

Community

The Zig community is decentralized. Anyone is free to start and maintain their own space for Zig users to gather. There is no concept of "official" or "unofficial". Each gathering place has its own moderators and rules. Users are encouraged to be aware of the social structures of the spaces they inhabit, and work purposefully to facilitate spaces that align with their values.

Please see the Community wiki page for a public listing of social spaces.

from https://github.com/ziglang/zig

 ------------------------------------------------

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.

https://ziglang.org/

A general-purpose programming language and toolchain for maintaining robustoptimal, and reusable software.

Resources

Installation

from https://github.com/ziglang/zig
----------------------------------------------
 
https://github.com/ziglang/zig/wiki/Building-Zig-From-Source
----------------------------------------------------------------------------
 

A toolkit for building command lines programs in Zig.

zigcli.liujiacai.net/

Zigcli

https://img.shields.io/github/stars/jiacai2050/zigcli.svg https://img.shields.io/github/license/jiacai2050/zigcli.svg https://github.com/jiacai2050/loc/actions/workflows/CI.yml/badge.svg https://github.com/jiacai2050/loc/actions/workflows/binary.yml/badge.svg https://img.shields.io/badge/zig%20version-0.12.0-blue.svg

Zigcli is a toolkit for building command lines programs in Zig.

This package provides:

Modules
Zig modules to help developers build their awesome cli programs. Currently there are:
  • simargs, which is used to parse arguments
  • pretty-table, which is used to print aligned and formatted tables
Programs
Practical command line programs which can be used directly. Currently there are:
  • loc, lines of code.
  • tree, list contents of directories in a tree-like format.
  • yes, output a string repeatedly until killed.
  • repeat, repeat a command until it succeeds.
  • pidof, like pidof, but for macOS.
  • night-shift, control Night Shift in macOS.
  • dark-mode, control dark mode in macOS.

Install

Programs

Prebuilt binaries can be found in CI’s artifacts, or you can build from source:

git clone https://github.com/jiacai2050/zigcli

Then build with

make build

To build zigcli locally, Zig master is required, which can be downloaded here.

from  https://github.com/jiacai2050/zigcli

(https://codeberg.org/jiacai2050/zigcli)

------------------------------------------------------

zigcc 

A util script that aims to ease use zig cc to compile C/C++/Rust/Go programs.

Why

In most cases, we can use following command to use Zig for compile

CC='zig cc' CXX='zig c++' ...

However in real world, there are many issues this way, such as:

So this project was born, it will

  • Convert target between Zig and Rust/Go
  • Ignore link args when zig cc throw errors, hopefully this will make compile successfully, WIP.

Install

Download zigcc file, give it executable permission, and create two soft links zigcxx, zigcargo to it.

curl -Lo zigcc https://github.com/jiacai2050/zig-cc/raw/main/zigcc
chmod +x zigcc
ln -s zigcc zigcxx
ln -s zigcc zigcargo

Then use like this

CC=zigcc CXX=zigcxx ...

zigcargo can used to replace cargo, it will automatically set

  • CC CARGO_TARGET_<triple>_LINKER to zigcc
  • CXX to zigcxx

Use in GitHub Action

Adding a step to your workflow like this:

- uses: jiacai2050/zigcc@v1
  with:
    zig-version: master

Then you can invoke zigcc zigcxx zigcargo in following steps.

Config

There some are env variable to config zigcc:

  • ZIGCC_FLAGS, space separated flags, pass to zig cc. An example is set this to -fno-sanitize=undefined to disable sanitize since they may break your programs. See Catching undefined behavior with zig cc
  • ZIGCC_BLACKLIST_FLAGS, space separated flags, used to filter flags zig cc don’t support, such as -Wl,-dylib otherwise you could see errors below
    = note: error: unsupported linker arg: -dylib
        
ZIGCC_LOG Set to 1 enable verbose logs.

from https://github.com/jiacai2050/zigcc 

(https://codeberg.org/jiacai2050/zigcc)

---------------------------------------------------

https://github.com/ziglibs/repository

--------------------------------------------------

zig学习资料

由于 Zig 目前还处于快速迭代,因此最权威的资料无疑是官方的 Zig Language Reference,遇到语言的细节问题,基本都可以在这里找到答案。其次是社区的一些高质量教程,例如:

学习 Zig
该系列教程最初由 Karl Seguin 编写,该教程行文流畅,讲述的脉络由浅入深,深入浅出,是入门 Zig 非常不错的选择
Zig 语言圣经
一套完整的 Zig 教程
ziglings/exercises
Learn the Zig programming language by fixing tiny broken programs.
Zig Cookbook
A collection of simple Zig programs that demonstrate good practices to accomplish common programming tasks
zigcc/zig-idioms
Common idioms used in Zig
zigcc/awesome-zig
A collection of some awesome public Zig programming language projects.
 
from https://ziglang.cc/ 
(https://github.com/zigcc,    Zig Chinese Community, Zig 语言中文社区
---------------------------------------------------------------------------------

How build systems run

Different with Rust, there is no rustc-like zigc to compile build.zig, then how does build.zig works?

The answer is sub-process. When you build a fresh project, zig build will first compile build.zig to a binary, then run this binary to execute specific chosen steps.

The build binary sub-process to other Zig sub-commands to finish their jobs, such as zig build-exe for CompileStep.

build_runner.zig contains the main entry for the build binary, build.zig is imported using const root = @import("@build"), it requires four arguments when start:

  • Zig executable
  • directory where build.zig locates
  • Local cache directory(optional)
  • Global cache directory(optional)

We can manually invoke the build binary like this:


$ find . -name build
./zig-cache/o/0c7d271c608c27670403b31835132c7d/build
$ ./zig-cache/o/0c7d271c608c27670403b31835132c7d/build $(which zig) $(pwd) .cache .glocal-cache
$ zig-out/bin/demo
All your codebase are belong to us.
Run `zig build test` to run the tests.

So when you have bugs in build.zig, you first need to find where the build binary is, then run it in gdb/lldb with args above.

Conclusion

A fully featured build system is necessary to keep developers productive, but flexibility come at a cost of misuse, so design a good build system is hard.

Zig's build system is based on the language itself, developers don't need to learn a new language to write their build(CMake, I'm looking at you!). And Zig provides a declarative API to construct steps' DAG, lots of pre-defined steps to finish common task, powerful as will as practical.

Besides build system, package manager in Zig is in rapid development. With those, developer can build old/complex C/C++ projects in just one command: zig build. Some early adopters:

  • pcre2, Perl-Compatible Regular Expressions
  • llama.cpp, Port of Facebook's LLaMA model in C/C++
  • raylib, A simple and easy-to-use library to enjoy videogames programming

Discussions on Lobsters and Reddit