const addr: u32 = 0x10;
const mask: u32 = 0xF;
if (addr & mask == 0) {}
В Си парсится как:
if (addr & (mask == 0)) {}
// @as(u32, 0)В Zig парсится как:
if ((addr & mask) == 0) {}
// @as(bool, true)✍5👍2
Язык Zig (канал)
const addr: u32 = 0x10; const mask: u32 = 0xF; if (addr & mask == 0) {} В Си парсится как: if (addr & (mask == 0)) {} // @as(u32, 0) В Zig парсится как: if ((addr & mask) == 0) {} // @as(bool, true)
Если вдруг будете портировать код с Си на Zig или наоборот, обычно люди скобки пишут (и Clang предупреждение даёт), но иногда вот так оставляют.
Язык Zig (канал)
const addr: u32 = 0x10; const mask: u32 = 0xF; if (addr & mask == 0) {} В Си парсится как: if (addr & (mask == 0)) {} // @as(u32, 0) В Zig парсится как: if ((addr & mask) == 0) {} // @as(bool, true)
В Си изначально не было and оператора (&&), был только bitwise and (&), который использовался для обоих случаев:
Уже потом они добавили операторы && и ||, и поставили им те же приоритеты, что у bitwise (== идет раньше, чем & и &&), для упрощения портирования
if (a == b & c == d)
// имелось в виду:
if (a == b && c == d)
Уже потом они добавили операторы && и ||, и поставили им те же приоритеты, что у bitwise (== идет раньше, чем & и &&), для упрощения портирования
В Zig (и куче других языков) эти операторы были с самого начала, поэтому правила приоритетов можно было сразу поставить более интуитивные, с четким разделением "обязанностей":
addr & mask == 0
// В Си парсится как:
addr & (mask == 0)
// Потому что в старых Си (до появления &&)
// могло иметься ввиду:
addr && (mask == 0)
// В Zig сразу ясно, что это
// побитовая операция с логичным приоритетом:
(addr & mask) == 0
Forwarded from Zig reporter
Язык Zig (канал)
https://ziglang.org/news/2024-financials/ Финансовый отчёт за 2023 + призывают пожертвовать ещё) #upstream
Для сравнения, отчет в прошлом году за 2023:
Sure. In general, we're finally nearing the end of language stabilization phase of the roadmap (although there are still a few breaking language changes planned). The next phase will be standard library stabilization. The first step of that will be minimization of the standard library, aggressively deleting what is deemed unnecessary. Then it will be auditing, then it will completeness additions, in collaboration with Zig communities and ecosystem.
Before, when the language was younger, any additions to the std lib were welcomed as they helped test pilot the language. Now, the std lib is big enough and the ecosystem is big enough that there are other better ways to test pilot the language.
https://github.com/ziglang/zig/issues/20491#issuecomment-3315245540
#upstream
🤔1
Язык Zig (канал)
Sure. In general, we're finally nearing the end of language stabilization phase of the roadmap (although there are still a few breaking language changes planned). The next phase will be standard library stabilization. The first step of that will be minimization…
DeepL:
Конечно. В целом, мы наконец-то приближаемся к завершению этапа стабилизации языка в рамках дорожной карты (хотя еще запланировано несколько серьезных изменений в языке). Следующим этапом будет стабилизация стандартной библиотеки. Первым шагом будет минимизация стандартной библиотеки, агрессивное удаление всего, что считается ненужным. Затем будет проведена аудит, а затем добавлены дополнения в сотрудничестве с сообществом Zig и экосистемой.
Раньше, когда язык был моложе, любые дополнения к стандартной библиотеке приветствовались, поскольку они помогали тестировать язык. Сейчас стандартная библиотека достаточно велика, а экосистема достаточно большая, чтобы использовать другие, более эффективные способы тестирования языка.
🕊1👀1
Язык Zig (канал)
add basic compile-time detection for stack escape violations закрыт правда... #upstream
forbid trivial local address returned from functions
Проверка проще, но ошибка теперь раньше появляется
#upstream
Проверка проще, но ошибка теперь раньше появляется
#upstream
GitHub
forbid trivial local address returned from functions by andrewrk · Pull Request #25333 · ziglang/zig
progress towards #25312 (I amended the proposal to include more cases)
Upgrade Guide
fn foo() *i32 {
var x: i32 = 1234;
return &x;
}
test.zig:3:13: error: returning address of expir...
Upgrade Guide
fn foo() *i32 {
var x: i32 = 1234;
return &x;
}
test.zig:3:13: error: returning address of expir...
Старый вариант от jedisct1 мне больше нравился, потому что в новом от Эндрю проверку легко обойти:
fn returnStackPointer() *i32 {
var stack_allocation: i32 = 1234;
const ptr = &stack_allocation;
return ptr;
}Forwarded from mak
https://github.com/ziglang/zig/pull/25351
парочка новых функций и переименований в std.mem
парочка новых функций и переименований в std.mem
GitHub
std.mem: introduce cut functions; rename "index of" to "find" by andrewrk · Pull Request #25351 · ziglang/zig
Introduce cut functions: cut, cutPrefix, cutSuffix, cutScalar, cutLast, cutLastScalar
Moving towards our function naming convention of having one word per concept and constructing function names ...
Moving towards our function naming convention of having one word per concept and constructing function names ...
🤗3❤1
Forwarded from Andrei Kolesnikov
Там это, книжка для zig нарисовалась
Manning Publications
Systems Programming with Zig - Garrison Hinson-Hasty
Zig delivers performance, reliability, and complex integration in systems programming in a simple, modern package.
Zig hits the sweet spot for systems programming. This new programming language is high-performance, low-level, ultra-reliable, and perfectly…
Zig hits the sweet spot for systems programming. This new programming language is high-performance, low-level, ultra-reliable, and perfectly…
👍4🕊1
Forwarded from Andrei Kolesnikov
Пока пишется, какие-то главы доступны онлайн, хотят закончить к весне 2026го
Forwarded from Андрей Краевский
GitHub
std: Introduce `Io` Interface by andrewrk · Pull Request #25592 · ziglang/zig
This patchset adds std.Io and provides two implementations for it:
std.Io.Threaded - based on a thread pool.
-fno-single-threaded - supports concurrency and cancellation.
-fsingle-threaded - does...
std.Io.Threaded - based on a thread pool.
-fno-single-threaded - supports concurrency and cancellation.
-fsingle-threaded - does...
🎉7
Очередной async для Zig:
https://lalinsky.com/2025/10/26/zio-async-io-for-zig.html
https://github.com/lalinsky/zio
#блоги #библиотеки
https://lalinsky.com/2025/10/26/zio-async-io-for-zig.html
https://github.com/lalinsky/zio
#блоги #библиотеки
Lukáš Lalinský
How I turned Zig into my favorite language to write network programs in
I’ve been watching the Zig language for a while now, given that it was created for writing audio software (low-level, no allocations, real time). I never paid too much attention though, it seemed a little weird to me and I didn’t see the real need. Then I…
Forwarded from Андрей Краевский
Новый доклад про Async https://youtu.be/mdOxIc0HM04
YouTube
Zig's New Async I/O - Andrew & Zig Core Team
Andrew is the President and Lead Developer of Zig Software Foundation. In his talk at Zigtoberfest 2025 he showcases the upcoming Async I/O for the #Zig programming language.
If you like Zig, consider sponsoring the Zig Software Foundation: https://ziglang.org/zsf/…
If you like Zig, consider sponsoring the Zig Software Foundation: https://ziglang.org/zsf/…