avatar_url stringlengths 47 116 ⌀ | name stringlengths 1 46 | full_name stringlengths 7 60 | created_at stringdate 2016-04-01 08:17:56 2025-05-20 11:38:17 | description stringlengths 0 387 ⌀ | default_branch stringclasses 44
values | open_issues int64 0 4.93k | stargazers_count int64 0 78.2k | forks_count int64 0 3.09k | watchers_count int64 0 78.2k | tags_url stringlengths 0 94 | license stringclasses 27
values | topics listlengths 1 20 | size int64 0 4.82M | fork bool 2
classes | updated_at stringdate 2018-11-13 14:41:18 2025-05-22 08:23:54 | has_build_zig bool 2
classes | has_build_zig_zon bool 2
classes | zig_minimum_version stringclasses 50
values | repo_from stringclasses 3
values | dependencies listlengths 0 38 | readme_content stringlengths 0 437k | dependents listlengths 0 21 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
https://avatars.githubusercontent.com/u/8539353?v=4 | whale | fencl/whale | 2023-02-12T11:31:07Z | VP8L (Lossless WebP) Decoder | main | 0 | 10 | 0 | 10 | https://api.github.com/repos/fencl/whale/tags | BSL-1.0 | [
"c",
"cpp",
"decoder",
"format",
"image",
"vp8l",
"webp",
"zig"
] | 79 | false | 2025-05-05T07:49:01Z | false | false | unknown | github | [] | Whale
Simple <strong>VP8L</strong> bit stream decoder written in both <strong>C</strong> (or <strong>C++</strong>, both valid) and <strong>Zig</strong>.
<em>VP8L</em> is a image format used by the WebP format in lossless mode.
WebP decoders usually support both lossless and lossy mode, which makes them significantly bigger than necessary if you only want lossless. So Whale does only the absolute minimum to parse <em>VP8L</em> bit stream and output RGBA pixel array.
Usage
Use the function
```c
void <em>whale_decode(
void </em>user_data,
<code>// interface
unsigned long (*stream) (unsigned char n, void *user_data),
void* (*alloc) (unsigned long n, void *user_data),
void (*free) (void *block, void *user_data),
// output
unsigned *width,
unsigned *height
</code>
);
```
to decode VP8L bit stream.
Stream function takes argument <strong>n</strong> and returns an integer with <strong>n</strong> least-significant bits set to n bits from bit stream. For example, if <strong>n</strong> is 5 and next bits in the stream are -> 1 1 1 0 1 ... the function will return <code>0b00...0010111</code>
Function will return an array of pixels in scan-line order, each pixel represented by 4 bytes first being red, second green, third blue and forth alpha component. So the result is <code>RGBARGBARGBA...</code> No padding or alignment is added between pixels or lines. This array is allocated using interface <code>alloc</code> function and the caller is responsible for freeing it.
Compilation
There is no need for build system and so no build system or script is provided. Just add <code>whale.c</code> in your sources and <code>whale.h</code> in your include directories.
Example
<code>example.c</code> uses Whale as header-only library (see below). To compile the example, run
<code>gcc example.c -o webp2tga</code>
or whatever equivalent command your favorite c/c++ compiler use.
To compile in visual studio, just add the <code>example.c</code> file to a project and compile.
Header-only
<code>whale.c</code> can be used as a header-only library.
```c
include "whale.c"
<code>``
Whale is written to be valid c and c++ code so it can be included into both.
However</code>whale.c<code>can only be included in single source file as no guards or</code>IMPLEMENTATION<code>macros are present and this would result in multiple definitions of</code>whale_decode` symbol.
All symbols in <code>whale.c</code> are prefixed using <code>vp8l_</code> prefix and are static (except <code>whale_decode</code>).
Configuration
If you know for sure that you are only decoding specific set of images which doesn't use one or more of four transforms used by VP8L, you can disable the transform by defining one of 4 macros:
<code>WHALE_DISABLE_PREDICTOR_TRANSFORM</code>
<code>WHALE_DISABLE_COLOR_TRANSFORM</code>
<code>WHALE_DISABLE_SUBTRACT_GREEN_TRANSFORM</code>
<code>WHALE_DISABLE_INDEX_TRANSFORM</code>
Zig
Repository contains <code>whale.zig</code> file which contains whale decoder rewritten in Zig. This version works more-less the same as the C version, just more Zig-ified. See comments in the source code.
The code is currently compatible with <strong>0.13-dev</strong> version of the Zig compiler. Let's see how long it is going to take before some breaking change comes.
Remarks
This library has no error codes, asserts or any runtime checks whatsoever. The input stream has to be correct otherwise your program will output garbage or more likely crash.
License
```
Copyright (c) 2023 Matej Fencl
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
``` | [] |
https://avatars.githubusercontent.com/u/499599?v=4 | jstring.zig | liyu1981/jstring.zig | 2024-01-19T10:58:50Z | a reusable string lib for myself with all familiar methods methods can find in javascript string | main | 4 | 10 | 1 | 10 | https://api.github.com/repos/liyu1981/jstring.zig/tags | - | [
"jstring",
"zig",
"zig-package"
] | 6,092 | false | 2025-03-17T17:39:42Z | true | true | unknown | github | [] | <code>jstring.zig</code>
Target: create a reusable string lib for myself with all familiar methods methods can find in javascript string.
Reason:
<ol>
<li>string is important we all know, so a good string lib will be very useful.</li>
<li>javascript string is (in my opinion) the most battle tested string library out there, strike a good balance
between features and complexity.</li>
</ol>
The javascript string specs and methods this file use as reference can be found at
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
All methods except those marked as deprecated (such as anchor, big, blink etc) are implemented, in zig way.
integration with PCRE2 regex
One highlight of <code>jstring.zig</code> is that it integrates with <a>PCRE2</a> to provide <code>match</code>, <code>match_all</code> and more just like the familar feeling of javascript string.
here are some examples of how regex can be used
<code>zig
var str1 = try JStringUnmanaged.newFromSlice(arena.allocator(), "hello,hello,world");
var results = try str1.splitByRegex(arena.allocator(), "l+", 0, 0);
try testing.expectEqual(results.len, 1);
try testing.expect(results[0].eqlSlice("hello,hello,world"));
results = try str1.splitByRegex(arena.allocator(), "l+", 0, -1);
try testing.expectEqual(results.len, 4);
try testing.expect(results[0].eqlSlice("he"));
try testing.expect(results[1].eqlSlice("o,he"));
try testing.expect(results[2].eqlSlice("o,wor"));
try testing.expect(results[3].eqlSlice("d"));</code>
usage
<code>bash
zig fetch --save https://github.com/liyu1981/jstring.zig/archive/refs/tags/0.1.1.tar.gz</code>
check <code>example</code> folder for a sample project
```zig
const std = @import("std");
const jstring = @import("jstring");
pub fn main() !u8 {
var your_name = brk: {
var jstr = try jstring.JString.newFromSlice(std.heap.page_allocator, "name is: zig");
defer jstr.deinit();
const m = try jstr.match("name is: (?.+)", 0, true, 0, 0);
if (m.matchSucceed()) {
const r = m.getGroupResultByName("name");
break :brk try jstr.slice(
@as(isize, @intCast(r.?.start)),
@as(isize, @intCast(r.?.start + r.?.len)),
);
}
unreachable;
};
defer your_name.deinit();
<code>try std.io.getStdOut().writer().print("\nhello, {s}\n", .{your_name});
return 0;
</code>
}
```
in order to run this example from the <code>git clone</code> repo, you will need
<code>bash
cd <jstirng_repo>/examples
zig fetch --save ../ # to update your local zig cache about jstring
zig build run</code>
<code>build.zig</code>
when use <code>jstring.zig</code> in your project, as it integrates with <code>PCRE2</code>, will need to link your project to <code>libpcre-8</code>. <code>jstring.zig</code> provide a build time function to easy this process.
<code>zig
// in your build.zig
const jstring_build = @import("jstring");
...
const jstring_dep = b.dependency("jstring", .{});
exe.addModule("jstring", jstring_dep.module("jstring"));
jstring_build.linkPCRE(exe, jstring_dep);</code>
again, check <code>example</code> folder for the usage
performance
<code>jstring.zig</code> is built with performance in mind. Though <code>benchmark</code> is still in developing, but the initial result of allocate/free 1M random size of strings shows a <em>~70%</em> advantage comparing to c++/20's <code>std::string</code>.
<code>bash
benchmark % ./zig-out/bin/benchmark
|zig create/release: | [ooooo] | avg= 16464000ns | min= 14400000ns | max= 20975000ns |
|cpp create/release: | [ooooo] | avg= 56735400ns | min= 56137000ns | max= 57090000ns |</code>
(<code>jstring.zig</code> is built with <code>-Doptimize=ReleaseFast</code>, and <code>cpp</code> is built with <code>-std=c++20 -O2</code>)
check current benchmark method <a>here</a>
docs
check the auto generated zig docs <a>here</a>
tests
<code>jstring</code> is rigorously tested.
<code>bash
./script/pcre_test.sh src/jstring.zig</code>
to run all tests.
or check kcov report <a>here</a>: the current level is 100%.
license
MIT License :) | [] |
https://avatars.githubusercontent.com/u/99132213?v=4 | zig-csv | DISTREAT/zig-csv | 2023-05-18T19:02:55Z | A library for parsing, creating, and manipulating CSV data. | master | 2 | 10 | 4 | 10 | https://api.github.com/repos/DISTREAT/zig-csv/tags | LGPL-3.0 | [
"csv",
"zig",
"zig-lib",
"zig-library",
"zig-package"
] | 16,003 | false | 2025-04-27T01:40:11Z | true | true | 0.14.0 | github | [] | zig-csv
A library for parsing, creating, and manipulating CSV data.
Features
<ul>
<li>avoiding memory leaks</li>
<li>flexible and simplistic API</li>
</ul>
Example
```zig
const std = @import("std");
const csv = @import("zig-csv");
const allocator = std.heap.allocator;
// parse CSV data
var table = csv.Table.init(allocator, csv.Settings.default());
defer table.deinit();
try table.parse(
\id,animal,shorthand
\0,dog,d
\1,cat,c
\2,pig,p
);
// print all animals
const column_indexes_animal = try table.findColumnIndexesByKey(allocator, "animal");
defer allocator.free(column_indexes_animal);
var animals = table.getColumnByIndex(column_indexes_animal[0]);
while (animals.next()) |animal| {
std.debug.print("{s}", .{animal.value});
}
// replace a value
const column_indexes_id = try table.findColumnIndexesByKey(allocator, "id");
defer allocator.free(column_indexes_id);
const row_indexes_id_2 = try table.findRowIndexesByValue(allocator, column_indexes_id[0], "2");
defer allocator.free(row_indexes_id_2);
try table.replaceValue(row_indexes_id_2[0], column_indexes_animal[0], "porcupine");
// delete a column
try table.deleteColumnByIndex(column_indexes_id[0]);
// export back to CSV
const exported = try table.exportCSV(allocator);
defer allocator.free(exported);
```
<em>More examples can be found in <code>src/tests.zig</code>.</em>
Docs
The documentation is created in the directory <code>docs/</code> when running <code>zig build</code>.
<a>Documentation</a> | [] |
https://avatars.githubusercontent.com/u/8206?v=4 | retrobob | iury/retrobob | 2024-02-02T03:39:22Z | retrobob is a retro gaming emulator that runs directly on your browser. Super Nintendo, NES/Famicom, Gameboy and Gameboy Color are currently supported, with more systems to come. | master | 0 | 10 | 0 | 10 | https://api.github.com/repos/iury/retrobob/tags | MIT | [
"emulator",
"gameboy",
"gameboy-color",
"nes",
"snes",
"webassembly",
"zig"
] | 4,188 | false | 2025-02-11T17:56:28Z | false | false | unknown | github | [] | Overview
<strong>retrobob</strong> is a retro gaming emulator made by <a>iury</a> that runs directly on your browser.
Super Nintendo, NES/Famicom, Gameboy and Gameboy Color are currently supported, with more systems to come.
You can also <a>download</a> it as a native executable for stable FPS and better audio quality.
Don't have a ROM to test it? Try <a>Super Tilt Bro</a>, a free game made by sgadrat.
Links
<a>Live demo</a>
Warning
You'll most likely lose your savestates after version releases. So, if you are playing for real then I recommend
<a>downloading</a> the executable and saving locally. As we're under active
development, no compatibility is guaranteed between different versions.
Compiling
You'll need <a>pnpm</a>, <a>zig 0.12</a>,
and <a>emscripten</a> installed,
active and with the cache generated (compile a hello world using emcc).
Then, it is as simple as:
<code>git submodule update --init --recursive
pnpm install
cd packages/ui
pnpm dev
</code>
You can also run the emulator directly as a native executable, without the browser:
<code>cd packages/engine
zig build run --release=fast
</code>
Controls
A gamepad (Xbox/PS) or keyboard:
| System | Action | Key |
| -------------------------- | :-------------------: | ---------- |
| Global | | |
| | Fullscreen | F11 |
| | Save state | F1 |
| | Load state | F4 |
| | Reset | F3 |
| | Pause / resume | Space |
| | D-pad | Arrow keys |
| | Select | Q |
| | Start | W or Enter |
| <em>Super Nintendo</em> | |
| | Y | A |
| | X | S |
| | B | Z |
| | A | X |
| | L | D |
| | R | C |
| <em>NES / Famicom / GB / GBC</em> | |
| | B | Z or A |
| | A | X or S |
| <em>Gameboy (monochrome)</em> | |
| | Toggle color palettes | T |
Supported Systems
SNES
<ul>
<li>Most commercial games are playable if they don't <a>require a coprocessor</a>.</li>
<li>All background modes are implemented, including Mode 7 (+ExtBG).</li>
<li>NTSC/PAL, 224p/239p + interlacing, pseudo hires (SETINI) and true hires (mode 5/6) are supported.</li>
<li>Offset per tile (on mode 2, 4 and 6) is implemented.</li>
<li>All PPU features, including mosaic, color windows and color math are implemented.</li>
</ul>
Known Issues
<ul>
<li>You may experience random glitches and crashes due to emulation inaccuracies.</li>
<li>A few games are unplayable, notably all Donkey Kong Country games and various Square and Enix JRPGs.</li>
</ul>
GB / GBC
<ul>
<li>Most commercial games should work.</li>
<li>MBCs implemented: ROM, MBC1, MBC2, MBC3 (+RTC) and MBC5.</li>
<li>Games in monochrome will use a color palette like playing on a GBC hardware by default but you can toggle it by pressing T.</li>
</ul>
Known Issues
<ul>
<li>Super Mario Bros. Deluxe (slowdowns and glitches)</li>
</ul>
NES / Famicom
<ul>
<li>Most commercial games should work.</li>
<li>Mappers implemented: NROM, CNROM, UxROM, AxROM, MMC1, MMC2 and MMC3.</li>
</ul>
Known Issues
<ul>
<li>Castlevania 3 (MMC5 mapper is not implemented)</li>
<li>Batman: Return of the Joker (FME-7 mapper is not implemented)</li>
<li>Battletoads and BT&DD (random crashes)</li>
</ul> | [] |
https://avatars.githubusercontent.com/u/42881610?v=4 | ncdu-zig | konosubakonoakua/ncdu-zig | 2023-11-13T12:50:47Z | [folk] disk usage analyzer with an ncurses interface | main | 0 | 10 | 0 | 10 | https://api.github.com/repos/konosubakonoakua/ncdu-zig/tags | - | [
"cli",
"disk",
"disk-usage",
"linux",
"ncurses",
"tool",
"tui",
"zig"
] | 172 | false | 2025-05-21T16:17:35Z | true | false | unknown | github | [] |
ncdu-zig
Description
Ncdu is a disk usage analyzer with an ncurses interface. It is designed to find
space hogs on a remote server where you don't have an entire graphical setup
available, but it is a useful tool even on regular desktop systems. Ncdu aims
to be fast, simple and easy to use, and should be able to run in any minimal
POSIX-like environment with ncurses installed.
See the <a>ncdu 2 release announcement</a> for
information about the differences between this Zig implementation (2.x) and the
C version (1.x).
Requirements
<ul>
<li>Zig 0.14</li>
<li>Some sort of POSIX-like OS</li>
<li>ncurses</li>
<li>libzstd</li>
</ul>
Install
You can use the Zig build system if you're familiar with that.
There's also a handy Makefile that supports the typical targets, e.g.:
<code>make
sudo make install PREFIX=/usr</code>
Caution
<blockquote>
<span class="bg-green-100 text-green-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-green-900 dark:text-green-300">IMPORTANT</span>
This repo is upload from https://dev.yorhel.nl/ncdu, maybe diverged from the origin.
</blockquote>
Similar projects
<ul>
<li><a>Duc</a> - Multiple user interfaces.</li>
<li><a>gt5</a> - Quite similar to ncdu, but a different approach.</li>
<li><a>gdu</a> - Go disk usage analyzer inspired by ncdu.</li>
<li><a>dua</a> - Rust disk usage analyzer with a CLI.</li>
<li><a>diskonaut</a> - Rust disk usage analyzer with a TUI.</li>
<li><a>godu</a> - Another Go disk usage analyzer, with a slightly different browser UI.</li>
<li><a>tdu</a> - Go command-line tool with ncdu JSON export.</li>
<li><a>TreeSize</a> - GTK, using a treeview.</li>
<li><a>Baobab</a> - GTK, using pie-charts, a treeview and a treemap. Comes with GNOME.</li>
<li><a>GdMap</a> - GTK, with a treemap display.</li>
<li><a>Filelight</a> - KDE, using pie-charts.</li>
<li><a>QDirStat</a> - Qt, with a treemap display.</li>
<li><a>K4DirStat</a> - Qt, treemap.</li>
<li><a>xdiskusage</a> - FLTK, with a treemap display.</li>
<li><a>fsv</a> - 3D visualization.</li>
</ul> | [] |
https://avatars.githubusercontent.com/u/47771011?v=4 | ziglm | karlobratko/ziglm | 2023-09-24T16:28:08Z | ZiGLM - Zig language implementation of OpenGL Mathematics (GLM) library | master | 7 | 9 | 7 | 9 | https://api.github.com/repos/karlobratko/ziglm/tags | MIT | [
"glm",
"graphics",
"opengl",
"zig"
] | 86 | false | 2024-11-13T22:33:34Z | true | false | unknown | github | [] | ZiGLM
Zig language implementation of OpenGL Mathematics (GLM) library.
ZiGLM is a Zig language mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specification.
<strong><em>ZiGLM library is currently under heavy development, so expect changes and frequent updates.</em></strong>
1. Design approach
Every functionality which is bound to some structure is implemented with mixin pattern.
Every method is bound to specific mixin which in compile time checks type which is stored in structure and provides only methods for that type. This is implemented by using compile time checks inside mixin methods which on failed check return empty struct, and on match return struct with methods. These structs are then embedded in main mixin using <code>usingnamespace</code> keyword. This not only gives us type safety, but totally disables usage of methods which are not intended for that type.
Except for type checking this pattern gives us ability to check for other compile time parameters also, and provide specialised methods for those properties of type, e.g. cross product method, which should be only accessible to 3-dimensional vectors of any numeric type.
This pattern can get a little bit messy, but with quality naming conventions and mixin method ordering we are able to create reusable and manageable code.
2. Features
ZiGLM currently provides vector structure implementation. Every available function is named according to GLSL shading language standard. In addition to the standard functions, functions have been added that make creation and comparison of vectors easier.
3. Example
```zig
const glm = @import("ziglm");
const Vec3f = glm.Vec3(f32);
const vector = Vec3f.new(4.2, 1.5, 2.8);
const normalized = vector.normalize();
const to_reflect = Vec3f.new(3.2, 2.1, -1.5);
const refl = to_reflect.reflect(normalized);
```
4. License
This project is licensed under the <strong>MIT</strong> license - see the <a>LICENSE.md</a> file for details. | [] |
https://avatars.githubusercontent.com/u/69054152?v=4 | zarg | d4c7/zarg | 2023-07-11T17:53:54Z | [WIP] zarg is a minimalist and efficient command-line parsing library written in Zig | main | 0 | 9 | 0 | 9 | https://api.github.com/repos/d4c7/zarg/tags | - | [
"cli",
"command-line",
"command-line-parser",
"zig",
"zig-package"
] | 208 | false | 2025-03-26T16:39:41Z | true | true | 0.13.0 | github | [] |
zarg
zarg (former zig-argueando) is a minimalist and efficient command-line parsing library written in Zig. It is designed to offer a convenient way of parsing command-line arguments in a simple yet powerful manner. With zarg, you can easily set options, flags, and positional arguments for your command-line applications.
Version 0.0.1 for zig 0.3.0
<code>WARNING: THIS IS A WORK IN PROGRESS, YOU SHOULD EXPECT BREAKING CHANGES AND BUGS</code>
Features
<ul>
<li>Parses command-line arguments into an autogenerated struct</li>
<li>Automatic generation of usage and help text including headers, footers, types...</li>
<li>Support for flags, options, and positional arguments</li>
<li>Support for multi-option arguments</li>
<li>You can define the separator between options and arguments</li>
<li>Provides built-in support for basic and complex argument types, including enums and JSON</li>
<li>Offers the ability to define and use custom argument types</li>
<li>Includes default validators for arguments, reducing the boilerplate code</li>
<li>Enables users to define and use custom validation rules for arguments</li>
<li>Choose between halting at the first encountered problem or collecting all problems</li>
<li>Highly customizable and easy to use</li>
<li>Lightweight with no dependencies</li>
<li>Leverages Zig's powerful compile-time feature <strong>as much as possible</strong></li>
<li>Autocomplete support</li>
</ul>
Documentation
<a>Un analizador de línea de comandos en Zig 🔧 (Parte I)</a>
<a>Un analizador de línea de comandos en Zig 🔧 (Parte II)</a>
Install
To use zarg in your project, you need to add the dependency to your <code>build.zig.zon</code>:
<code>bash
$ zig fetch --save git+https://github.com/d4c7/zarg</code>
Then you could add the module to to your <code>build.zig</code> file:
```zig
const zarg = b.dependency("zarg", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("zarg", zarg.module("zarg"));
```
Usage
Define a struct that defines the command-line arguments, help texts, headers and types you want to parse:
<code>zig
const clp = comptime zarg.CommandLineParser.init(.{
.header=
\\ ______ _ _ __ __ _
\\ |_ / _` | '__/ _` |
\\ / / (_| | | | (_| |
\\ /___\__,_|_| \__, |
\\ |___/
,.params = &[_]zarg.Param{
help(.{ .long = "help", .short = "h", .help = "Shows this help." }),
flag(.{ .long = "version", .help = "Output version information and exit." }),
flag(.{ .long = "verbose", .short = "v", .help = "Enable verbose output." }),
option(.{ .long = "port", .short = "p", .parser = "TCP_PORT", .default = "1234", .help = "Listening Port." }),
option(.{ .long = "host", .short = "H", .parser = "TCP_HOST", .default = "localhost", .help = "Host name" }),
positional(.{ .parser = "DIR", .default = ".", .check = &Check.Dir(.{ .mode = .read_only }).f }),
},
.desc = "This command starts an HTTP Server and serves static content from directory DIR.",
.footer = "More info: <https://d4c7.github.io/zig-zagueando/>.",
});</code>
The field <code>params</code> in the struct defines the option and positional arguments.
Then, in your <code>main</code> function, use the <code>parse</code> function to parse the command-line arguments:
```zig
var s = clp.parseArgs(allocator);
defer s.deinit();
if (s.helpRequested()) {
try s.printHelp(std.io.getStdErr().writer());
return;
}
if (s.hasProblems()) {
try s.printProblems(std.io.getStdErr().writer(), .all_problems);
return;
}
std.debug.print("dir: {s}\n", .{s.arg.positional});
std.debug.print("port: {d}\n", .{s.arg.port});
std.debug.print("host: {s}\n", .{s.arg.host});
```
Output sample
```txt
$ sample --help
|<em> / </em><code>| '__/ _</code> |
/ / (<em>| | | | (</em>| |
/<strong><em>_</em>,<em>|</em>| __, |
|</strong>_/
Usage: sample [(-h|--help)] [--version] [(-v|--verbose)] [(-p|--port)=TCP_PORT] [(-H|--host)=TCP_HOST] [DIR]
This command starts an HTTP Server and serves static content from directory DIR.
-h, --help Shows this help.
--version Output version information and exit.
-v, --verbose Enable verbose output.
-p, --port=TCP_PORT Listening Port.
Default value: 1234
-H, --host=TCP_HOST Host name
Default value: localhost
TCP_PORT TCP port value between 0 and 65535. Use port 0 to dynamically assign a port
Can use base prefix (0x,0o,0b).
TCP_HOST TCP host name or IP.
DIR Directory
More info: <a>https://d4c7.github.io/zig-zagueando/</a>.
```
Detailed error reporting with <code>all_problems</code> mode:
<code>txt
$ zig-out/bin/sample_complete -c=black -k -p 70000 -vv
sample_complete:
* Unsupported value 'black' of type COLOR for option 'c': InvalidEnum (-c=black) at arg #1
* Unrecognized option 'k' (-k) at arg #2
* Unsupported value '70000' of type TCP_PORT for option 'p': Overflow (70000) at arg #4
* Unexpected repeated flag 'v' (-vv) at arg #5
* Expected between 1 and 5 Directory's, but found 0
* Expected --alloc_opt
* Expected 1 --array1a1's, but found 0
* Expected between 1 and 2 --array1a2's, but found 0
* Expected 1 --array1aN's, but found 0
Try 'zig-out/bin/sample_complete --help' for more information.</code>
View more examples in the <a><code>examples</code></a> folder.
You can build the samples using:
<code>zig build examples</code>
Misc
Run tests
<code>zig test src/tests.zig</code>
Generate a coverture report
Require <code>kcov</code> installed
<code>zig build cover</code>
View the report
<code>firefox zig-out/coverture/index.html</code>
Note: Since the Zig compiler exclusively compiles functions that are explicitly called or referenced and comptime can lead to substantial portions of code not being included in the runtime the coverage results only reflect the extent to which the utilized functions are covered.
Autocomplete
You can provide easily an autocompleter for a zarg command line parser.
How it works
To enable autocompletion, a command is compiled that analyzes the command line and suggests completion options based on the cursor position in that line. This command also allows installing a lightweight autocompletion script for a specific shell, which will call the autocompletion command for the heavy processing.
You can integreate in the same command or using a separate one, which is the recommended way.
The autocompleter analizes your provided CommandlineParser and suggest completions for:
<ul>
<li>Short option names</li>
<li>Long option names</li>
<li>Option argument types</li>
<li>Positional argument types</li>
</ul>
The built-in supported argument types are:
- FILE: autocomplete with a file
- DIR: autocomplete with a directory
- ENUM: autocomplete with enum values
You could define your own parser with custom autocomplete behaviour.
How to use autocomplete
In order to generate an autocompleter command for a custom CommandlineParser use the following code:
```zig
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
defer _ = gpa.deinit();
<code>try zarg.Autocomplete.__main(my_clp, allocator);
</code>
}
```
Autocomplete sample
A complete sample is provided:
```
zig build examples
export PATH=zig-out/bin/:$PATH
source <(sample_autocomplete_completer install -s bash -t sample_autocomplete)
or output to /etc/bash_completion.d/
sample_autocomplete --
```
Road map
<ul>
<li>Fix and complete </li>
<li>Reorganize code</li>
<li>Data structures simplification</li>
<li>Params comptime smart param indexing </li>
<li>Documentation</li>
<li>Add missing basic parsers</li>
<li>Much more tests</li>
<li>Help structure rethink</li>
<li>Color support for help with custom styles</li>
<li>Upgrade to zig 0.14.0 (maintain branch per main zig version)</li>
</ul>
Caution
<strong>Please note that zarg is a work in progress being developed and tested</strong>. If you are using a different Zig compiler version, we cannot guarantee that the library will work as expected. Before reporting any issues, please make sure you are using the recommended Zig compiler version. It is always a good practice to use the same compiler version that a library or application was developed with to avoid any compatibility issues. We are continuously working on providing support for newer versions of the Zig compiler. Please stay tuned for updates.
Contribution
We welcome all contributions! Please feel free to submit a PR or create an issue if you encounter any problem or have a feature request.
License
zarg is licensed under the EUPL-1.2 license and MIT. Please check the <a><code>LICENSES</code></a> folder for more details. | [] |
https://avatars.githubusercontent.com/u/206480?v=4 | benchmark.zig | karlseguin/benchmark.zig | 2023-10-27T12:51:47Z | Simple Benchmarking for Zig | master | 0 | 9 | 1 | 9 | https://api.github.com/repos/karlseguin/benchmark.zig/tags | MPL-2.0 | [
"benchmarking",
"zig",
"zig-library"
] | 11 | false | 2025-05-07T21:14:24Z | true | true | unknown | github | [] | Simple Benchmarking for Zig
This module is a single file, you can either import it using Zig modules, or simply copy and paste benchmark.zig into your project.
```zig
const std = @import("std");
const benchmark = @import("benchmark");
const Allocator = std.mem.Allocator;
pub fn main() !void {
(try benchmark.run(indexOfScalar)).print("indexOScalar");
(try benchmark.run(indexOfPosLinear)).print("indexOfPosLinear");
}
fn indexOfScalar(_: Allocator, timer: *std.time.Timer) !void {
// you can do expensive setup, and then call:
timer.reset();
// to exclude the setup from the measurement
const input = "it's over 9000!!";
std.mem.doNotOptimizeAway(std.mem.indexOfScalar(u8, input, '!'));
}
fn indexOfPosLinear(_: Allocator, _timer: *std.time.Timer) !void {
const input = "it's over 9000!!";
std.mem.doNotOptimizeAway(std.mem.indexOfPosLinear(u8, input, 0, "!"));
}
```
Will output:
```text
indexOScalar
16051047 iterations 62.02ns per iterations
0 bytes per iteration
worst: 292ns median: 42ns stddev: 21.63ns
indexOfPosLinear
6822614 iterations 145.41ns per iterations
0 bytes per iteration
worst: 375ns median: 125ns stddev: 22.82ns
```
If allocations are made using the provided allocator, the number of bytes requested will be captured and reported. The provided timer can be <code>reset()</code> should the benchmark need to do setup work that should not be measured.
The <code>runC</code> function will pass an arbitrary context to the benchmark function:
```zig
const Context = struct {
input: []const u8,
needle: u8,
};
fn indexOfScalar(<em>: Allocator, context: Context, </em>: *std.time.Timer) !void {
std.mem.doNotOptimizeAway(std.mem.indexOfScalar(u8, context.input, context.needle));
}
pub fn main() !void {
const context = Context{.input = "it's over 9000!!", .needle = '!'};
(try benchmark.runC(context, indexOfScalar)).print("indexOScalar");
}
```
Result
<code>run</code> and <code>runC</code> return <code>benchmark.Result</code>. The <code>Result</code> is a little odd: some of the data reflects the total run of the benchmark, and other data is based on samples. This is done in the name of performance.
Fields
<ul>
<li><code>total</code> - total time in nanoseconds that the benchmark took</li>
<li><code>iterations</code> - total number of benchmark iterations</li>
<li><code>requested_bytes</code> - total number of requested bytes to the allocator</li>
</ul>
print(self: Result, name: []const u8) void
Uses <code>std.log.debug</code> to display statistics.
samples(self: Result) []const u64
Returns ordered timing, in nanosecond, for the sampled values. The samples is currently made up of the last <code>benchmark.SAMPLE_SIZE</code> values.
worst(self: Result) u64
Returns the worst result (i.e. the last value in <code>result.sample()</code>).
mean(self: Result) f64
Returns the mean of the samples.
median(self: Result) u64
Returns the median of the samples.
stdDev(self: Result) f64
Returns the standard deviation of the samples | [] |
https://avatars.githubusercontent.com/u/124872?v=4 | zig-bounded-array | jedisct1/zig-bounded-array | 2023-11-22T17:18:28Z | BoundedArray module for Zig. | main | 0 | 9 | 0 | 9 | https://api.github.com/repos/jedisct1/zig-bounded-array/tags | MIT | [
"array",
"arrayvec",
"bounded",
"boundedarray",
"tinyvec",
"zig",
"zig-lib",
"zig-package",
"ziglang"
] | 10 | false | 2025-02-22T18:59:02Z | true | true | unknown | github | [] | BoundedArray for Zig
A <code>BoundedArray</code> is a structure containing a fixed-size array, as well as the length currently being used.
It can be used as a variable-length array that can be freely resized up to the size of the backing array.
If you're looking for a Zig equivalent to Rust's super useful <code>ArrayVec</code>, this is it.
It is useful to pass around small arrays whose exact size is only known at runtime, but whose maximum size is known at comptime, without requiring an <code>Allocator</code>.
Bounded arrays are easier and safer to use than maintaining buffers and active lengths separately, or involving structures that include pointers.
They can also be safely copied like any value, as they don't use any internal pointers.
<code>zig
var actual_size = 32;
var a = try BoundedArray(u8, 64).init(actual_size);
var slice = a.slice(); // a slice of the 64-byte array
var a_clone = a; // creates a copy - the structure doesn't use any internal pointers</code>
Update: archived.
The main point of that fork was to keep the length being a <code>usize</code>,
because returning a different type was a footgun (adding lengths, in
particular, could easily trigger an overflow).
However, that change was eventually
<a>reverted</a>,
so applications should just go back to using the type from the standard library. | [] |
https://avatars.githubusercontent.com/u/35909?v=4 | zig-language-extras | ianic/zig-language-extras | 2023-06-26T16:57:46Z | Zig Language Extras VSCode extension | main | 4 | 9 | 4 | 9 | https://api.github.com/repos/ianic/zig-language-extras/tags | MIT | [
"vscode-extension",
"zig"
] | 83 | false | 2025-03-21T01:33:31Z | false | false | unknown | github | [] | Zig Language Extras
This extension adds few
<a>commands</a>
for Zig development:
* Zig extras: Run single test
* Zig extras: Run file tests
* Zig extras: Test workspace
* Zig extras: Build workspace
* Zig extras: Debug test
* Zig extras: Debug binary
It also displays code lenses above tests to run or debug single test, and code
lens at the first line of the file to run all tests.
It depends on several extensions:
<ul>
<li><a>Zig Language</a>
for location of Zig binary</li>
<li><a>Native Debug</a> for
debugging on Linux</li>
<li><a>CodeLLDB</a>
for debugging on MacOS</li>
<li><a>C/C++</a> for debugging on Windows</li>
</ul>
The main reason I decided to make this is to create fine vscode problems
description from zig command output. When running tests there can be few
different versions of the output. Build can fail, test can fail, assert can be
risen while running the test. All of those have different output and it is hard
to make single regexp which will work for all. So I make it more procedural way
by analyzing zig command output line by line.
Most of the commands are expecting folder structure built with 'zig init-exe' or
'zig init-lib'. With build.zig in the root and files under src. Folder with the
build.zig is expected to be root of the vscode workspace.
Testing
'Test workspace' runs <code>zig build test</code> in the root of the workspace so depends
on tests definition in your build.zig
'Run file tests' runs all tests in the current file <code>zig test {file_name}</code>.
'Run single tests' tries to find test name from the current position. It first
searches up from the current position to find name of the test. If not found
then it searches down. If you are positioned in the test, that will run that
test. If you are in the code and the tests are below you code this will find
first test.
If you need to use additional test command arguments set <code>testArgs</code> variable in workspace config.
For example in a project which depends on zlib I'm using this config:
<code>json
{
"zig-language-extras.testArgs": "--deps zlib=zlib --mod zlib::../zig-zlib/src/main.zig --library z",
}</code>
Building
'Build workspace' command runs <code>zig build</code> in the root of the workspace.
Debugging
There are two debugging commands.
'Debug test' builds binary for the test (binary location: zig-out/debug/test)
and starts debugger on that binary. Put a breakpoint in you test before running
command.
'Debug binary' first builds workspace and then starts binary zig-out/bin/{name}.
If current file is in src folder name is set to the folder name above src folder
which is expected to be root of your workspace. If the current file is in some
other folder then the name of the current file is used as name of the binary
except if that file is named main.zig then folder name of that file is used as
expected binary name.
You can modify debugger via settings: <code>"zig-language-extras.debugType": "type"</code>. Type refers to the specific <code>"type"</code> field that you would use in the launch.json file.
The default debugger types for each platform are as follows:
- "lldb" for darwin platform
- "cppvsdbg" for win32 platform
- "gdb" for other platforms
Keybinding tip
When adding keybinding you can restrict usage on Zig language files:
<code>jsonc
// Zig extras: Run file tests
{
"key": "ctrl+j t",
"command": "zig-language-extras.runFileTests",
"when": "editorLangId == 'zig'"
},
// Zig extras: Run single test
{
"key": "ctrl+j s",
"command": "zig-language-extras.runSingleTest",
"when": "editorLangId == 'zig'"
},</code>
Extension development
Zig command output parser is in <a>src/parser.ts</a> and the
corresponding tests in the <a>src/test/suite/parser.test.ts</a>.
Parser test cases are in files located in
src/test/suite/testdata. Each case in .txt file has
corresponding expected parser output in _expected.json file. Parser test loads
all txt files and expects to get parsing result as in expected file.
Parser has no dependency on vscode so it is possible to test without running vscode:
<code>sh
mocha -ui tdd out/test/suite/parser.test.js</code>
Credits
Code lenses implementation is taken from Jarred-Sumner's <a>pull
request</a> to original
vscode-zig extension.
| [] |
https://avatars.githubusercontent.com/u/135145066?v=4 | prettytable-zig | dying-will-bullet/prettytable-zig | 2023-05-15T13:26:10Z | :butter: Display tabular data in a visually appealing ASCII table format. | master | 0 | 9 | 3 | 9 | https://api.github.com/repos/dying-will-bullet/prettytable-zig/tags | MIT | [
"ascii-art",
"prettytable",
"tabular-data",
"zig",
"ziglang"
] | 82 | false | 2025-03-24T16:24:25Z | true | true | unknown | github | [] |
prettytable-zig
<blockquote>
A formatted and aligned table printer library for Zig.
This library is an implementation of <a>prettytable</a> in the Zig programming language.
</blockquote>
<a></a>
<strong>NOTE: Minimum Supported Zig Version: 0.12.0-dev.1773+8a8fd47d2. Any suggestions or feedback are welcome.</strong>
Table of Contents
<ul>
<li><a>Features</a></li>
<li><a>Getting Started</a></li>
<li><a>Row Operations</a></li>
<li><a>Modify cell data</a></li>
<li><a>Alignment</a></li>
<li><a>Read from file/stream/...</a></li>
<li><a>Get the table as string(bytes)</a></li>
<li><a>Change print format</a></li>
<li><a>Change cell style</a></li>
<li><a>API</a></li>
<li><a>LICENSE</a></li>
</ul>
Features
<ul>
<li>Automatic alignment</li>
<li>Customizable border</li>
<li>Color and style</li>
</ul>
Getting Started
Let's start with an example. All example code can be found in the <code>examples</code> directory.
```zig
const std = @import("std");
const pt = @import("prettytable");
pub fn main() !void {
var table = pt.Table.init(std.heap.page_allocator);
defer table.deinit();
<code>try table.setTitle(&.{
"City", "Country", "Longitude", "Latitude", " Temperature", "Humidity",
});
try table.addRows(&.{
&.{ "Caconda", "AO", "15.06", "-13.73", "26.15", "35" },
&.{ "Diamantino", "BR", "-56.44", "-14.4", "29.4", "74" },
&.{ "Hirara", "JP", "125.28", "24.8", "21.77", "100" },
&.{ "Abha", "SA", "42.5", "18.22", "14.03", "100" },
});
try table.printstd();
</code>
}
```
Output:
<code>+---------------+---------+-----------+----------+--------------+----------+
| City | Country | Longitude | Latitude | Temperature | Humidity |
+===============+=========+===========+==========+==============+==========+
| Prince Rupert | CA | -130.32 | 54.32 | 7.0 | 87 |
+---------------+---------+-----------+----------+--------------+----------+
| Caconda | AO | 15.06 | -13.73 | 26.15 | 35 |
+---------------+---------+-----------+----------+--------------+----------+
| Diamantino | BR | -56.44 | -14.4 | 29.4 | 74 |
+---------------+---------+-----------+----------+--------------+----------+
| Hirara | JP | 125.28 | 24.8 | 21.77 | 100 |
+---------------+---------+-----------+----------+--------------+----------+
| Abha | SA | 42.5 | 18.22 | 14.03 | 100 |
+---------------+---------+-----------+----------+--------------+----------+</code>
Row Operations
Add a row to the table.
```zig
try table.addRow(
&[_][]const u8{ "Kaseda", "JP", "130.32", "31.42", "13.37", "100" },
);
```
Insert a row.
<code>zig
try table.insertRow(
0,
&[_][]const u8{ "Kaseda", "JP", "130.32", "31.42", "13.37", "100" },
);</code>
Remove a row from the table.
<code>zig
table.removeRow(0);</code>
Modify cell data
<code>zig
try table.setCell(0, 5, "100");</code>
Alignment
The table is aligned to the left by default. You can change the alignment of the entire table.
<code>zig
// table.setAlign(Alignment.left);
// table.setAlign(Alignment.center);
table.setAlign(Alignment.right);</code>
Or you can change the alignment of a specific column.
```zig
table.setColumnAlign(1, Alignment.right);
```
Read from file/stream/...
You can use the <code>readFrom</code> function to read data from <code>Reader</code> and construct a table.
One scenario is to read data from a CSV file.
```zig
var data =
\name, id, favorite food
\beau, 2, cereal
\abbey, 3, pizza
\
;
<code>var s = std.io.fixedBufferStream(data);
var reader = s.reader();
var table = Table.init(std.heap.page_allocator);
defer table.deinit();
var read_buf: [1024]u8 = undefined;
try table.readFrom(reader, &read_buf, ",", true);
try table.printstd();
</code>
```
Get the table as string(bytes)
```zig
var buf = std.ArrayList(u8).init(std.heap.page_allocator);
defer buf.deinit();
<code>var out = buf.writer();
_ = try table.print(out);
// buf.items is the bytes of table
</code>
```
Change print format
<code>zig
table.setFormat(pt.FORMAT_BORDERS_ONLY);</code>
Output:
<code>+---------------------------------------------------------------------+
| City Country Longitude Latitude Temperature Humidity |
+=====================================================================+
| Prince Rupert CA -130.32 54.32 7.0 87 |
| Caconda AO 15.06 -13.73 26.15 35 |
| Diamantino BR -56.44 -14.4 29.4 74 |
| Hirara JP 125.28 24.8 21.77 100 |
| Abha SA 42.5 18.22 14.03 100 |
+---------------------------------------------------------------------+</code>
Change cell style
It supports bold, italic, underline styles, and can also set colors.
Color list:
<ul>
<li><code>black</code></li>
<li><code>red</code></li>
<li><code>green</code></li>
<li><code>yellow</code></li>
<li><code>blue</code></li>
<li><code>magenta</code></li>
<li><code>cyan</code></li>
<li><code>white</code></li>
</ul>
If the above names are capitalized, such as <code>RED</code>, it indicates a bright color.
```zig
try table.setCellStyle(0, 0, .{ .bold = true, .fg = .yellow });
try table.setCellStyle(0, 1, .{ .bold = true, .fg = .red });
try table.setCellStyle(0, 2, .{ .bold = true, .fg = .magenta });
<code>try table.setCellStyle(1, 0, .{ .fg = .black, .bg = .cyan });
try table.setCellStyle(1, 1, .{ .fg = .black, .bg = .blue });
try table.setCellStyle(1, 2, .{ .fg = .black, .bg = .white });
</code>
```
Output:
API
<a>Online Docs</a>
LICENSE
MIT | [] |
https://avatars.githubusercontent.com/u/8235638?v=4 | 3d-zig-game | AlxHnr/3d-zig-game | 2023-02-19T22:03:37Z | Deterministic, multi-threaded 3d demo written from scratch | master | 0 | 9 | 0 | 9 | https://api.github.com/repos/AlxHnr/3d-zig-game/tags | MIT | [
"billboard",
"crowds",
"deterministic",
"fixedpoint",
"flocking",
"flowfield",
"game-engine",
"instancing",
"multithreading",
"opengl",
"parallelism",
"pathfinding",
"sdl2",
"spatial-hash-grid",
"zig"
] | 1,369 | false | 2025-05-09T06:06:05Z | true | false | unknown | github | [] | <a></a>
Building and running the game
Install the required dependencies, example for Fedora:
<code>sh
sudo dnf install SDL2-devel SDL2_image-devel</code>
Install zig 0.14.0 and run <code>zig build run</code> inside the projects directory. The game is considerably
faster when built with optimizations: <code>zig build run -Doptimize=ReleaseFast</code>.
Controls
<ul>
<li><strong>arrow keys</strong> - Move</li>
<li><strong>space + arrow keys</strong> - Strafe</li>
<li><strong>right ctrl + arrow keys</strong> - Rotate slowly</li>
<li><strong>t</strong> - Toggle top-down view</li>
<li><strong>f</strong> - Toggle flow-field (path-finding info, zoom with mousewheel)</li>
<li><strong>F2</strong> - Save map to disk</li>
<li><strong>F5</strong> - Reload map from disk</li>
<li><strong>left mouse button</strong> - Start/stop placing object</li>
<li><strong>mouse wheel</strong> - Zoom in/out</li>
<li><strong>right mouse button + mouse wheel</strong> - Cycle trough placeable objects</li>
<li><strong>middle mouse button</strong> - Cycle trough object types</li>
<li><strong>delete</strong> - Toggle delete/insert mode</li>
</ul> | [] |
https://avatars.githubusercontent.com/u/26017543?v=4 | much-todo | typio/much-todo | 2023-07-03T05:43:57Z | Notes web app from scratch :zap::camel: | main | 1 | 9 | 0 | 9 | https://api.github.com/repos/typio/much-todo/tags | - | [
"dream",
"http-server",
"ocaml",
"webapp",
"zig"
] | 85 | false | 2025-05-18T08:10:03Z | false | false | unknown | github | [] |
Much Todo About Nothing
<a><em>Much Todo About Nothing</em></a> will be a modern, feature-rich note-taking / todo list web application.
Live at <a>muchtodo.app</a>. (<em>unless it crashed</em>)
Using the <strong>HOT JazZ</strong> stack
<strong>H</strong>TML + <strong>O</strong>Caml + <strong>T</strong>ypeScript + <strong>J</strong>SON + <strong>a</strong>nd + <strong>z</strong>ippy + <strong>Z</strong>ig
<ul>
<li>Frontend 👉 HTML/TypeScript</li>
<li>Backend App 👉 OCaml/JSON</li>
<li>Backend Web Server 👉 Zig</li>
</ul> | [] |
https://avatars.githubusercontent.com/u/6756180?v=4 | lean4-zig | kassane/lean4-zig | 2023-08-28T14:59:12Z | Zig bindings for Lean4 | main | 1 | 9 | 2 | 9 | https://api.github.com/repos/kassane/lean4-zig/tags | Apache-2.0 | [
"ffi-bindings",
"lean",
"lean-language",
"lean4",
"zig",
"ziglang"
] | 60 | false | 2025-04-30T20:10:14Z | true | false | unknown | github | [] | lean4-zig
Zig bindings for Lean4's C API.
Functions and comments manually translated from those in the <a><code>lean.h</code> header</a> provided with Lean 4
Required
<ul>
<li><a>zig</a> v0.12.0 or master</li>
<li><a>lean4</a> v4.4.0 or nightly</li>
</ul>
How to run
<ul>
<li><strong>FFI</strong>
```bash</li>
</ul>
default: reverse ffi (zig lib => lean4 app)
$> zig build zffi
output: 3
```
<ul>
<li><strong>Reverse-FFI</strong>
```bash</li>
</ul>
default: reverse ffi (lean4 lib => zig app)
$> zig build rffi
output: 6
``` | [] |
https://avatars.githubusercontent.com/u/26017543?v=4 | entreepy | typio/entreepy | 2023-02-10T10:22:44Z | Text compression tool ⚡ | main | 2 | 9 | 0 | 9 | https://api.github.com/repos/typio/entreepy/tags | GPL-3.0 | [
"compression",
"entropy-coding",
"huffman",
"text-compression",
"zig"
] | 106 | false | 2024-10-19T23:28:12Z | true | true | 0.12.0 | github | [] | entreepy
<a></a>
====
<blockquote>
Text compression tool :zap:
</blockquote>
The name is entropy coding + binary trees.
Usage
```
Entreepy - Text compression tool
Usage: entreepy [options] [command] [file] [command options]
Options:
-h, --help show help
-p, --print print decompressed text to stdout
-t, --test test/dry run, does not write to file
-d, --debug print huffman code dictionary and performance times to stdout
Commands:
c compress a file
d decompress a file
Command Options:
-o, --output output file (default: [file].et or decoded_[file])
Examples:
entreepy -d c text.txt -o text.txt.et
entreepy -ptd d text.txt.et -o decoded_text.txt
```
Input file must be < 1 terabyte. Be sure to use the same version of the program to decompress as compress.
Performance
I use a decode map which is keyed by the integer value of the code and stores a subarray of letters with matching code integer value - that is, the letters that correspond to codes with the same integer value - indexed by length minus one. For example, the map might include the following entries:
<code>{ 2: [_, a (10), e (010), ...], 13: [_, _, _, _, z (01101), ...] }.</code>
By utilizing this decode map, decoding can be performed much more quickly than by traversing a binary tree.
Performance on MacBook Air M2, 8 GB RAM - v1.0.0
| File | Original File Size | Compressed Size | Compression Time | Decompression Time |
| ---- | :----------------: | :-------------: | :--------------: | :----------------: |
| <a>Macbeth, Act V, Scene V</a> | 477 bytes | 374 bytes | 600μs | 3.2ms |
| <a>A Midsummer Night's Dream</a> | ~ 112 KB | ~ 68 KB | 6.7ms | 262ms |
| <a>The Complete Works of Shakespeare</a> | ~ 5.2 MB | ~ 3.0 MB | 111ms | 11.8s |
Next I'll add block based parallel decoding. After that I'm interested in exploring additional compression techniques; to support non-text file formats.
Compressed File Format
Uses the <code>.et</code> file format, identified by the magic number <code>e7 c0 de</code>.
```bf
| magic number -> 3 bytes |
| file format version -> 1 byte |
| length of dictionary - 1 -> 1 byte |
| length of body -> 4 bytes |
for n symbols
| symbol -> 1 byte |
| symbol code length -> 1 byte |
| symbol code -> m bits |
| packed big-endian bitstream of codes | starting on new byte
``` | [] |
https://avatars.githubusercontent.com/u/51416554?v=4 | zlog | hendriknielaender/zlog | 2023-10-25T16:26:18Z | 🪵 structured logging library for zig | main | 12 | 9 | 1 | 9 | https://api.github.com/repos/hendriknielaender/zlog/tags | MIT | [
"async",
"file-logger",
"json",
"lib",
"library",
"logging",
"network-logs",
"structured-logging",
"zig",
"zig-lib",
"zig-library",
"zig-package",
"ziglang"
] | 366 | false | 2025-02-20T11:58:05Z | true | false | unknown | github | [] | <blockquote>
<span class="bg-yellow-100 text-yellow-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-yellow-900 dark:text-yellow-300">WARNING</span>
Still work in progress.
</blockquote>
zlog - High-Performance Logging in Zig
<a></a>
<a></a>
zlog is a high-performance, extensible logging library for Zig, designed to offer both simplicity and power in logging for system-level applications. Inspired by the best features of modern loggers and tailored for the Zig ecosystem, <code>zlog</code> brings structured, efficient, and flexible logging to your development toolkit.
Key Features
<ul>
<li><strong>High Performance</strong>: Minimizes overhead, ensuring logging doesn't slow down your application.</li>
<li><strong>Asynchronous Logging</strong>: Non-blocking logging to maintain application performance.</li>
<li><strong>Structured Logging</strong>: Supports JSON and other structured formats for clear, queryable logs.</li>
<li><strong>Customizable Log Levels</strong>: Tailor log levels to fit your application's needs.</li>
<li><strong>Redaction Capabilities</strong>: Securely redact sensitive information from your logs.</li>
<li><strong>Extensible Architecture</strong>: Plug in additional handlers for specialized logging (e.g., file, network).</li>
<li><strong>Cross-Platform Compatibility</strong>: Consistent functionality across different platforms.</li>
<li><strong>Intuitive API</strong>: A simple, clear API that aligns with Zig's philosophy.</li>
</ul>
Getting Started
Installation
<ol>
<li>
Declare zlog as a dependency in <code>build.zig.zon</code>:
<code>diff
.{
.name = "my-project",
.version = "1.0.0",
.paths = .{""},
.dependencies = .{
+ .zlog = .{
+ .url = "https://github.com/hendriknielaender/zlog/archive/<COMMIT>.tar.gz",
+ },
},
}</code>
</li>
<li>
Add it to your <code>build.zig</code>:
```diff
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
<ul>
<li>const opts = .{ .target = target, .optimize = optimize };</li>
<li>
const zlog_module = b.dependency("zlog", opts).module("zlog");
const exe = b.addExecutable(.{
.name = "test",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
+ exe.addModule("zlog", zlog_module);
exe.install();
...
}
```
</li>
</ul>
</li>
<li>
Get zlog package hash:
<code>$ zig build
my-project/build.zig.zon:6:20: error: url field is missing corresponding hash field
.url = "https://github.com/hendriknielaender/zlog/archive/<COMMIT>.tar.gz",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: expected .hash = "<HASH>",</code>
</li>
<li>
Update <code>build.zig.zon</code> package hash value:
<code>diff
.{
.name = "my-project",
.version = "1.0.0",
.paths = .{""},
.dependencies = .{
.zlog = .{
.url = "https://github.com/hendriknielaender/zlog/archive/<COMMIT>.tar.gz",
+ .hash = "<HASH>",
},
},
}</code>
</li>
</ol>
Basic Usage
```zig
const zlog = @import("zlog");
// Set up your logger
var logger = zlog.Logger.init(allocator, zlog.Level.Info, zlog.OutputFormat.JSON, handler);
```
Here is a basic usage example of zlog:
```zig
// Simple logging
logger.log("This is an info log message");
// Asynchronous logging
logger.asyncLog("This is an error log message");
```
Structured Logging
<code>zig
// Log with structured data
logger.info("Test message", &[_]kv.KeyValue{
kv.KeyValue{ .key = "key1", .value = kv.Value{ .String = "value1" } },
kv.KeyValue{ .key = "key2", .value = kv.Value{ .Int = 42 } },
kv.KeyValue{ .key = "key3", .value = kv.Value{ .Float = 3.14 } },
});</code>
Contributing
The main purpose of this repository is to continue to evolve zlog, making it faster and more efficient. We are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving zBench.
Contributing Guide
Read our <a>contributing guide</a> to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to zlog.
License
zlog is <a>MIT licensed</a>. | [] |
https://avatars.githubusercontent.com/u/43641633?v=4 | bsn | sno2/bsn | 2023-11-21T03:39:48Z | An implementation of the Bussin esoteric language | main | 0 | 8 | 0 | 8 | https://api.github.com/repos/sno2/bsn/tags | MIT | [
"esoteric-language",
"interpreter",
"programming-language",
"zig"
] | 5,048 | false | 2025-01-16T00:26:37Z | true | false | unknown | github | [] |
An implementation of @face-hh 's
<a>Bussin esoteric language</a> written in Zig
with a custom bytecode virtual machine and component-based mark and sweep
garbage collector.
Playground
The playground is available at https://trybsn.vercel.app. It is the easiest way
to play around with this interpreter.
Known Issues
<ul>
<li>The playground does not maintain extra newlines when transforming between the
BS and BSX formats.</li>
<li>The playground is not interactive. We currently run programs and display the
output from <code>println</code> calls at the end of the program. Although, after the
<a>self-hosted Zig compiler implements async again</a>,
I will use it to add streaming IO.</li>
<li>Printing circular objects causes stack overflows.
```
lit a be {} rn
a.a be a</li>
</ul>
"Stack overflow"
waffle(a)
<code>- Parsing errors can have incorrect formatting in some cases.
- Functions do not support capturing locals, but globals do work.</code>
bruh foo() {
lit a be 24
<code> bruh bar() {
a
}
bar
</code>
}
"This will fail because it does not know about 'a'"
foo()()
```
- All other TODOs in the code.
License
<a>MIT</a> | [] |
https://avatars.githubusercontent.com/u/3848910?v=4 | zigcc | jiacai2050/zigcc | 2024-02-05T13:17:43Z | Util scripts aimed at simplifying the use of zig cc for compiling C, C++, Rust, and Go programs. | main | 0 | 8 | 1 | 8 | https://api.github.com/repos/jiacai2050/zigcc/tags | MIT | [
"compile",
"go",
"golang",
"rust",
"rustlang",
"zig",
"ziglang"
] | 50 | false | 2025-04-17T03:37:43Z | false | false | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/82351204?v=4 | ray-tracer-challenge | SinclaM/ray-tracer-challenge | 2023-06-10T19:33:43Z | A simple ray tracer to experiment with Zig | main | 0 | 8 | 0 | 8 | https://api.github.com/repos/SinclaM/ray-tracer-challenge/tags | MIT | [
"ray-tracer",
"ray-tracer-challenge",
"ray-tracing",
"raytracerchallenge",
"raytracing",
"zig"
] | 112,304 | false | 2025-04-28T06:52:34Z | true | true | unknown | github | [
{
"commit": "3c4f73a45bccc48cda4319a629a45d2469d8e24e.tar.gz",
"name": "zigimg",
"tar_url": "https://github.com/SinclaM/zigimg/archive/3c4f73a45bccc48cda4319a629a45d2469d8e24e.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/SinclaM/zigimg"
}
] | Ray Tracer Challenge
This project is a simple <a>Zig</a> implementation of the ray tracer described in
<a>The Ray Tracer Challenge</a>.
You can find an interactive demo of this ray tracer online at <a>sinclam.github.io/ray-tracer-challenge</a>.
Status
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 1 - Tuples, Points, and Vectors
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 2 - Drawing on a Canvas
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 3 - Matrices
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 4 - Matrix Transformations
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 5 - Ray-Sphere Intersections
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 6 - Light and Shading
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 7 - Making a Scene
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 8 - Shadows
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 9 - Planes
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 10 - Patterns
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 11 - Reflection and Refraction
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 12 - Cubes
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 13 - Cylinders
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 14 - Groups
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 15 - Triangles
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Chapter 16 - Constructive Solid Geometry (CSG)
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Chapter 17 - Next Steps
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> A1 - Rendering the Cover Image
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Bonus Chapter - Rendering soft shadows
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Bonus Chapter - Bounding boxes and hierarchies
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Bonus Chapter - Texture mapping
Examples
Fresnel
Patterns
Reflection and Refraction
Cubes
Groups
Teapot
Teapot model from <a>https://groups.csail.mit.edu/graphics/classes/6.837/F03/models/teapot.obj</a>.
Dragons
Dragon model from <a>http://raytracerchallenge.com/bonus/assets/dragon.zip</a>.
Nefertiti
Nefertiti bust model from <a>https://github.com/alecjacobson/common-3d-test-models/blob/master/data/nefertiti.obj</a>.
Constructive Solid Geometry
Earth
Earth texture from <a>https://planetpixelemporium.com/earth.html</a>.
Skybox
Lancellotti Chapel texture from <a>http://www.humus.name/index.php?page=Textures</a>.
Building from source
To build for native:
<code>bash
zig build -Doptimize=ReleaseFast</code>
To target the web (populating <code>www/</code> with the all the site's files):
<code>bash
zig build --sysroot [emsdk]/upstream/emscripten -Dtarget=wasm32-emscripten -Dcpu=generic+bulk_memory+atomics+simd128 -Doptimize=ReleaseFast
&& sed -i'' -e 's/_emscripten_return_address,/() => {},/g' www/ray-tracer-challenge.js</code>
Performance profiling
Although the ray tracer is not (yet) heavily optimized (e.g. it does not yet leverage Zig's SIMD builtins),
it is still very fast—faster in fact on a single thread than almost every other Ray Tracer Challenge implementation
on multiple threads I've compared with. And there is still significant room for optimization.
The optimizations I do make are largely informed by profilers. When built for native, the binary can be profiled with
<code>valgrind --tool=callgrind</code> and the results inspected with <code>qcachegrind</code>, which works well enough. Unfortunately,
<a>Valgrind's troubled state on macOS</a>,
combined with <a>Zig's incomplete Valgrind support</a>, means profiling is not
always simple. For example, I've seen Valgrind erroneously run into <code>SIGILL</code> and the like. Using <code>std.heap.raw_c_allocator</code>
on native seems to fix most of these issues.
The ray tracer currently runs about 2x slower on WebAssembly than on native, which is reasonable. I use Firefox's
"performance" tab in the developer tools for profiling on the web.
I also use <a>hyperfine</a> for benchmarking.
Benchmarks
Below are some benchmarks for scenes that can be found on the website. These benchmarks are not rigorously controlled
and averaged, but rather a general overview of speeds for various scenes. They may also change depending significantly
between Zig compiler versions. For example, I noticed a perfromance regression of up to 25% going from 0.11.0 to the
WIP 0.12.0 (perhaps related to <a>this similar issue</a>). The best way to
get a feel for the performance is to try things out yourself!
All benchmarks were done on a 2019 MacBook Pro (2.6Ghz, 6-Core Intel i7; 16GB RAM; macOS 12.6.7). WASM specific benchmarks
were done on Firefox 117 using 6 web workers (the maximum number of web workers Firefox will run in parallel, even on my
12 logical CPU system 🤷♂️). Native runs used 12 threads.
The 'WASM Preheated' category refers to renders done with the scene pre-built (scene description already parsed, objects
and bounding boxes already made, textures already loaded, etc.), which is supported on the site through the arrow key
camera movememnt. This preheating is irrelevant for simple scenes, but gives massive speedups for scenes that load
textures or construct BVHs.
Also note that renders on the website are periodically polled for completion. Renders may actually
complete up to 100ms before the reported time, which affects the benchmarks for very short renders.
| Scene | Resolution | Native | WASM | WASM Preheated |
| --------------------------- | -------------- | ----------- | ---------- | ------------------ |
| Cover Scene | 1280x1280 | 1.413 s | 2.408 s | 2.299 s |
| Cubes | 600x300 | 0.225 s | 0.418 s | 0.407 s |
| Cylinders | 800x400 | 0.111 s | 0.221 s | 0.109 s |
| Reflection and Refraction | 400x200 | 0.113 s | 0.213 s | 0.205 s |
| Fresnel | 600x600 | 0.283 s | 0.429 s | 0.411 s |
| Groups | 600x200 | 0.091 s | 0.217 s | 0.202 s |
| Teapot | 250x150 | 0.175 s | 0.413 s | 0.210 s |
| Dragons | 500x200 | 6.957 s | 12.663 s | 2.492 s |
| Nefertiti | 300x500 | 4.827 s | 6.358 s | 3.036 s |
| Constructive Solid Geometry | 1280x720 | 0.267s | 1.920 s | 1.792 s |
| Earth | 800x400 | 0.095 s | 0.212 s | 0.103 s |
| Skybox | 800x400 | 1.466 s | 1.531 s | 0.102 s |
| Raytracer REPL Default | 1280x720 | 0.210 s | 0.220 s | 0.209 s |
Other implementations
There are many great implementations of the Ray Tracer Challenge. At many points throughout the project, I referred to others
to verify my implementation, draw inspiration, or compare performance. I recommend you check out the following ray tracers:
<ul>
<li><a>graytracer</a>: fully-implemented, easy to setup, performant.</li>
<li><a>The Raytracer Challenge REPL</a>: online demo with amazing site design.</li>
<li><a>RayTracerCPU</a>: very fast, helpful online demo.</li>
</ul>
Known limitations
The website for this project uses the <code>SharedArrayBuffer</code> type, which requires certain HTTP headers to be set, something that GitHub Pages does not support. To get around this, I use
<a>coi-serviceworker</a>, which has the disadvantage of not working in
Private/Incognito sessions.
Some devices (mobile phones in particular) may not have enough memory to render some of the scenes on the website, especially the "Skybox" scene. | [] |
https://avatars.githubusercontent.com/u/20196976?v=4 | PokeBin | malaow3/PokeBin | 2024-01-24T02:45:51Z | A web-app for sharing and saving competitive Pokemon sets | main | 4 | 8 | 1 | 8 | https://api.github.com/repos/malaow3/PokeBin/tags | MIT | [
"solidjs",
"zig",
"ziglang"
] | 1,151,731 | false | 2025-05-19T19:49:28Z | true | true | 0.14.0 | github | [
{
"commit": "5bf1b4e877ae52cbbec127e30a4885bc95e87dd8",
"name": "zlog",
"tar_url": "https://github.com/max-legrand/zlog/archive/5bf1b4e877ae52cbbec127e30a4885bc95e87dd8.tar.gz",
"type": "remote",
"url": "https://github.com/max-legrand/zlog"
},
{
"commit": "master",
"name": "httpz",
... | PokeBin
Table of Contents
<ul>
<li><a>What is PokeBin?</a></li>
<li><a>How the sausage is made</a></li>
<li><a>How to use</a></li>
<li><a>Roadmap</a></li>
<li><a>Contributing</a></li>
</ul>
What is PokeBin?
PokeBin is a portmanteau of "Pokemon" and "Pastebin". More generally, it's a website that aims
to allow you to share Pokemon spreads & sets with anyone. While there isn't official integration with Pokemon Showdown, it is possible to use PokeBin
via the PokeBin Extension. See <a>here</a> for more information.
How the sausage is made
PokeBin is composed of a two main components:
<ul>
<li>The server code (backend)</li>
<li>The client code (frontend)</li>
</ul>
Pokemon data
There are a few pieces that are required to make PokeBin somewhat useful.
<ul>
<li>Pokemon information (types, species, forms, move data). This information comes curtosey of <a>PokeApi</a>
which is a wonderful project and I highly recommend you check them out!</li>
<li>Pokemon images. Again, these come from <a>PokeApi</a>.</li>
<li>Item information and sprites. This comes from <a>Pokemon Showdown</a>. The data is in a JS file by default, so
I put together a small script to convert it to JSON.</li>
</ul>
Web server
The web server is built with Zig (specifically using <a>http.zig</a>). Initially the client
was written in Rust, but after working with Zig on other projects, I've really liked the language and
found that I'd be able to achieve similar performance with faster compile times and more reusability through WASM.
Web client
The web client is built with SolidJS. Additionally I use WASM for data-intensive operations such as encryption and decryption or pastes.
Database
Both encrypted and decrypted pastes are stored in a PostgreSQL database.
How to use
First, make sure you have all the prerequisites completed.
<ul>
<li>Basic understanding of Git / command line familiarity</li>
<li>Zig installed</li>
<li>PSQL installed</li>
<li>Brotli CLI installed for compressing files</li>
<li>Docker installed (If on WSL you will need <a>Docker Desktop</a>)</li>
<li>Your Javascript package manager of choice (for this example, I'll be using <a>Bun</a>)</li>
</ul>
If you want to run PokeBin localy, you'll need to follow the following steps:
<ol>
<li>Clone the repo</li>
<li>
You will need to create a .env file. Inside that file you'll need to define two environment variables.
</li>
<li>
DB_HOST: The url of your database.
</li>
<li>DB_USER: Username for the database</li>
<li>DB_PORT: Port for the database, default is 5432</li>
<li>
DB_PASS: Password for the database
</li>
<li>
Install the web dependencies by running <code>cd web; bun install</code>
</li>
<li>Build the web files by running <code>bun run build</code></li>
<li>Cd back to the root of the repo by running <code>cd ..</code></li>
<li>Start the program. Run <code>docker compose up</code></li>
</ol>
Contributing
I believe open source is one of the most amazing parts of software! Being able to contribute to a tool you use to make it better, fix a bug, or add a new feature is incredibly rewarding.
If you want to contribute, feel free to fork the repo and send a PR with your changes!
Unfortunately, there isn't a strict set of tests / linting guidelines. I might be a bit picky on a review, but over time I hope to get the repo to a state where
contributing is easy and there is enough feedback baked into the tests/linting/static analysis that if things pass it should have no problem getting merged!
Notes
This project is not affiliated with, maintained, authorized, endorsed, or sponsored by the Pokémon Company, Nintendo, or any of its affiliates or subsidiaries.
All Pokémon images, names, and related media are intellectual property of their respective owners. This application is intended for educational, development,
and informational purposes only.
The use of any trademarks, copyright materials, or intellectual property by this project is done under fair use or with permission, and does not imply
any association with or endorsement by their respective owners. This project does not claim any ownership over any of the Pokémon franchise materials used within.
If you are the rightful owner of any content used in this project and believe that your copyright has been infringed, please contact us directly
to discuss the removal of such content or any other concerns. | [] |
https://avatars.githubusercontent.com/u/99076655?v=4 | hello-algo-rust | coderonion/hello-algo-rust | 2023-07-08T07:42:45Z | Rust codes for the famous public project 《Hello, Algorithm》|《 Hello,算法 》 about data structures and algorithms. | main | 0 | 8 | 1 | 8 | https://api.github.com/repos/coderonion/hello-algo-rust/tags | - | [
"algorithms",
"algrothm",
"data-structures",
"data-structures-and-algorithms",
"dsa",
"dynamic-programming",
"graph",
"hello-algo",
"linked-list",
"rust",
"search",
"sort",
"zig",
"ziglang"
] | 38 | false | 2025-05-22T02:53:38Z | false | false | unknown | github | [] | Hello-Algo-Rust
<ul>
<li><a><strong>Rust</strong></a> programming language codes for the famous public project <a>krahets/hello-algo</a> about data structures and algorithms.</li>
<li>Go read this great open access e-book now -> <a> hello-algo.com |《Hello, Algorithm》|《 Hello,算法 》</a>.</li>
</ul> | [] |
https://avatars.githubusercontent.com/u/7308253?v=4 | minim | heysokam/minim | 2023-09-20T17:14:10Z | ᛟ Minim | Programming Language | master | 0 | 7 | 0 | 7 | https://api.github.com/repos/heysokam/minim/tags | LGPL-3.0 | [
"c",
"nim-like",
"zig"
] | 854 | false | 2025-05-19T21:45:41Z | true | false | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/1552770?v=4 | flow-themes | neurocyte/flow-themes | 2024-02-07T17:16:10Z | Themes compiler for Flow Control, the text editor | master | 0 | 7 | 5 | 7 | https://api.github.com/repos/neurocyte/flow-themes/tags | MIT | [
"zig",
"zig-package"
] | 82 | false | 2025-05-03T22:20:41Z | true | true | unknown | github | [
{
"commit": "983c9bd674d2aedd9edb6f18b2d62c31a2f9eae7.tar.gz",
"name": "theme_1984",
"tar_url": "https://github.com/juanmnl/vs-1984/archive/983c9bd674d2aedd9edb6f18b2d62c31a2f9eae7.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/juanmnl/vs-1984"
},
{
"commit": "542ecdfcff52c... | flow-themes
Themes compiler for Flow-Control, the text editor
Requirements
<ul>
<li>zig 0.13</li>
<li>hjson (installed in your PATH)</li>
</ul>
Build
<code>zig build</code>
This will download and compile all the themes and create a zig module
in <code>zig-out</code> that can be referenced as a dependency from another project's
<code>build.zig.zon</code>. | [] |
https://avatars.githubusercontent.com/u/9482395?v=4 | zig-action-cache | Hanaasagi/zig-action-cache | 2023-05-09T15:14:13Z | GitHub action cache for zig project | master | 9 | 7 | 1 | 7 | https://api.github.com/repos/Hanaasagi/zig-action-cache/tags | MIT | [
"ci",
"github-actions",
"zig"
] | 1,549 | false | 2025-02-21T19:31:36Z | false | false | unknown | github | [] | GitHub Action Cache For Zig
An out-of-the-box GitHub Action that automatically caches dependencies and compiled artifacts for a Zig project.
How it works
Firstly, it calculates a key based on the following states:
<ul>
<li>The version of <code>zig</code> and the output information of <code>zig env</code>.</li>
<li>Environment variables during compilation, which can be configured through the <code>env-vars</code> parameter in YAML.</li>
<li>The file hashes of <code>build.zig</code> and <code>deps.zig</code>.</li>
<li>Automatic detection of whether a package manager is used and file hash calculation for <code>gyro.zzz</code> or <code>zig.mod</code>.</li>
<li>User-configured keys, as shown in the configuration file below.</li>
</ul>
Then it checks the history to see if there is a build workflow with the same key. If a match is found, it will restore the cache from the previous build.
What directories will it cache?
<ul>
<li><code>global_cache_dir</code> in <code>zig env</code></li>
<li><code>zig-cache</code></li>
<li>If you're using a package manager and there is a lock file, then directories such as <code>.gyro/</code> or <code>.zigmod/</code> will be cached.</li>
</ul>
Example
```YAML
name: CI
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
workflow_dispatch:
jobs:
test:
name: Tests on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.10.1
- uses: Hanaasagi/zig-action-cache@master # Or Hanaasagi/zig-action-cache@v1
with:
# description: 'The prefix cache key, this can be changed to start a new cache manually.'
# required: false
# default: 'zig-cache-step-0'
prefix-key: ""
<code> # description: 'A cache key that is used instead of the automatic `job`-based key, and is stable over multiple jobs.'
# required: false
# default: ""
shared-key: ""
# description: 'An additional cache key that is added alongside the automatic `job`-based cache key and can be used to further differentiate jobs.'
# required: false
# default: ""
key: ""
# description: 'Additional environment variables to include in the cache key, separated by spaces.'
# required: false
# default: ""
env-vars: ""
# description: 'Additional non workspace directories to be cached, separated by newlines.'
# required: false
# default: ""
cache-directories: ""
# description: 'Cache even if the build fails. Defaults to false.'
# required: false
# default: 'false'
cache-on-failure: true
- name: Build
run: zig build
- name: Run Tests
run: zig build test
</code>
```
<em>Please feel free to report bugs or open pull requests.</em> | [] |
https://avatars.githubusercontent.com/u/87582318?v=4 | giza | koenigskraut/giza | 2023-09-01T09:40:06Z | Zig binding for cairo/pango | master | 1 | 7 | 3 | 7 | https://api.github.com/repos/koenigskraut/giza/tags | - | [
"cairo",
"pango",
"zig"
] | 1,270 | false | 2025-02-26T12:51:35Z | true | true | unknown | github | [] | giza
An attempt to make a binding for the popular <a>cairo</a> and <a>pango</a> graphics libraries with some idiomatic Zig elements (and some that will make true Zig enjoyers' skin crawl).
Many thanks to <a>jackdbd</a> for his <a>implementation</a> of similar binding.
Zig version is 0.11.0.
Quick start
<ol>
<li>
Add giza as a dependency in your build.zig.zon as follows:
<code>diff
.{
.name = "your-project",
.version = "1.0.0",
.dependencies = .{
+ .giza = .{
+ .url = "https://github.com/koenigskraut/giza/archive/refs/tags/0.1.0.tar.gz",
+ .hash = "12202e1b6ae20694324cef241beacaa745ee9e2611cda002830bb0ee681791970ffd",
+ },
},
}</code>
</li>
<li>
In your build.zig add giza as a dependency and attach its modules to your project:
```diff
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
<ul>
<li>const opts = .{ .target = target, .optimize = optimize };</li>
<li>const dep = b.dependency("giza", opts);
+</li>
<li>const cairo_module = dep.module("cairo");</li>
<li>const pango_module = dep.module("pango");</li>
<li>
const pangocairo_module = dep.module("pangocairo");
const exe = b.addExecutable(.{
.name = "test",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
+ exe.addModule("cairo", cairo_module);
+ exe.addModule("pango", pango_module);
+ exe.addModule("pangocairo", pangocairo_module);
+ exe.linkSystemLibrary("pangocairo"); // if you need both cairo and pango, use this
exe.install();
...
}
```
</li>
</ul>
</li>
</ol>
Then you can check cairo website for reference, <a>samples</a> section in particular. You will find ports of these snippets to Zig along with some other examples in giza <a>examples</a>.
Killer features
There are just the two of them, but what are these two!
Safety checks
<strong>cairo</strong> sometimes returns allocated objects with user-managed lifetime, take for example:
<code>zig
const surface = try cairo.ImageSurface.create(.argb32, 600, 400); // cairo.ImageSurface with alpha 600x400px</code>
<code>surface</code> is owned by user and should be destroyed at some point with <code>surface.destroy()</code>. It can be done nicely with Zig <code>defer</code> pattern:
<code>zig
const surface = try cairo.ImageSurface.create(.argb32, 600, 400);
defer surface.destroy();</code>
But what if we can't do this? Let's see some example:
```zig
const cairo = @import("cairo");
test "safety" {
const surface = try cairo.ImageSurface.create(.argb32, 600, 400);
_ = surface; // surface should be destroyed somewhere else, but we forgot
}
<code>Run it:</code>bash
$ zig build test
run test: error: [giza] (err): Leak detected! ImageSurface@1cc4470 leaked:
/some/path/to/safety_test.zig:4:50: 0x235821 in test.safety (test)
const surface = try cairo.ImageSurface.create(.argb32, 600, 400);
^
...
Build Summary: 1/3 steps succeeded; 1 failed; 1/1 tests passed (disable with --summary none)
test transitive failure
└─ run test failure
```
Yes, <strong>giza</strong> detected a leak, printed stacktrace and panicked at return of the program, just like if it was a native Zig allocator leak!
Since we are linking libc anyway, I just interject some pointer counting in <code>create()</code>/<code>.reference()</code>/<code>.destroy()</code> functions and check for leaks with <code>atexit()</code> at the end. This happens only in debug and shouldn't be a performance issue then.
<code>opaque</code> types
We have a C object, but what we want is a native one. Popular pattern: pointer to C object is stored as a field of the native struct/class and passed under the hood to C functions. That's fine, but can we do better?
Thanks to Zig's easy C interop, in <strong>giza</strong> there is no such pattern. All C objects behave like native ones. What are advantages and should you care? Let's see.
Every function in <strong>giza</strong>, that returns object with <code>.status()</code> method <strong>and</strong> could set it into an error state, checks its status and raises error immediately. It's not always the intended behavoir: <strong>cairo</strong> safely allows errors to propagate in these cases, plus it's overhead.
So for example let's create <code>ImageSurface</code> unsafely and manage it manually:
```zig
const std = @import("std");
const cairo = @import("cairo");
const c = @cImport(@cInclude("cairo.h"));
test "interop 1" {
const surface_c = c.cairo_image_surface_create_from_png("does_not_exist.png").?; // cairo usually don't return null objects
defer c.cairo_surface_destroy(surface_c);
<code>const image: *cairo.ImageSurface = @ptrCast(surface_c);
try std.testing.expect(image.status() == .FileNotFound);
</code>
}
<code>We can use prepared C functions from `cairo` module to avoid pointer casting:</code>zig
test "interop 2" {
const image = cairo_image_surface_create_from_png("does_not_exist.png").?;
defer cairo.c.cairo_surface_destroy(image);
try std.testing.expect(image.status() == .FileNotFound);
}
<code>**giza**'s matrix functions return matrices by value:</code>zig
var m = cairo.Matrix.identity();
<code>`m` is `cairo.Matrix` which is an `extern struct` of 6 `f64` fields. But if you want, you can use underlying C function directly:</code>zig
const cairo = @import("cairo");
const c = @cImport(@cInlude("cairo.h"));
test "interop 3" {
var m: cairo.Matrix = undefined;
c.cairo_matrix_init_identity(@ptrCast(&m));
...
}
<code>or with `giza`'s prepared `extern fn`s:</code>zig
test "interop 4" {
var m: cairo.Matrix = undefined;
cairo.c.cairo_matrix_init_identity(&m);
...
}
<code>``
Every C object in **giza** is a valid Zig</code>opaque<code>/</code>extern struct<code>/</code>enum`, so you can call C functions with them like nothing yourself!
Coverage and progress
Cairo is somewhat covered (info <a>here</a>), current progress is 80.6% regarding <strong>cairo</strong> its functionality, <strong><em>but</em></strong> it should work already. The only missing parts are font support for FreeType/Windows etc. and real devices (other than script one). If you only need cairo to write some PNG/PDF/SVG files, that is already covered: see <a>examples</a>. Further progress is planned, but that would require using header files, which this wrapping has avoided so far, so we'll see.
Pango support is really lacking for now, but there is basic support (see <a>this</a> and <a>this</a>). | [] |
https://avatars.githubusercontent.com/u/102905510?v=4 | JNICLoader | nuym/JNICLoader | 2023-07-27T05:35:09Z | The Loader For Jnic | master | 0 | 7 | 0 | 7 | https://api.github.com/repos/nuym/JNICLoader/tags | - | [
"java",
"jni",
"jnic",
"loader",
"obfuscator",
"zig"
] | 26 | false | 2024-10-03T23:37:54Z | false | false | unknown | github | [] | JNICLoader
<ul>
<li>This is a sample jnic loader,finally i made it.</li>
<li>it can load data.dat that press by zig</li>
<li><a>Some code from radioegor146</a></li>
</ul> | [] |
https://avatars.githubusercontent.com/u/11492844?v=4 | eBPF-energy-monitor | fjebaker/eBPF-energy-monitor | 2023-11-11T12:04:28Z | Monitoring energy usage with eBPF at process level granularity. | main | 1 | 7 | 0 | 7 | https://api.github.com/repos/fjebaker/eBPF-energy-monitor/tags | GPL-3.0 | [
"bpf",
"ebpf",
"energy-consumption",
"energy-monitor",
"zig"
] | 180 | false | 2025-03-18T16:09:06Z | true | false | unknown | github | [] | eBPF Energy Monitor
<em>Proof of concept code to monitor process specific energy levels using eBPF</em>
Example
Setup
<strong>Note</strong>: this code is designed to currently <em>only work on my machine</em>. For example, the number of CPUs are hard-coded. That is to say, it will likely execute on your machine too, but will require adjustment to reflect your hardware topology.
<ul>
<li>Requirements: eBPF needs to be enabled on your kernel, and the <code>libbpf</code> package must be installed on the system (e.g. via distro package manager).</li>
</ul>
<code>bash
zig build -Doptimize=ReleaseSafe</code>
The above will build the (stripped) eBPF program to <code>zig-out/c-bpf.o</code> for inspection, but also embeds the binary in the userland executable for easy use. See the build file for details.
Due to the nature of eBPF syscalls, the program must be executed as root. It will then gather data and at the end of execution write the output to a <code>data.json</code> file.
<code>bash
sudo ./zig-out/bin/emon</code>
As it executes, the program will display execution times and energy usages of each core / CPU depending on configured granularity.
The data file may be given to the analysis script in <code>analysis/analysis.jl</code> in order to create a plot like the above, showing the top 10 energy consuming processes per CPU, along with the total energy consumed by that CPU.
```
Top 5:
PID 0: 987113 ( 99%) 996122 ( 99%) 983130 ( 98%) 989343 ( 99%)
PID 2646: 0 ( 0%) 93 ( 0%) 4897 ( 0%) 3388 ( 0%)
PID 578679: 0 ( 0%) 0 ( 0%) 4658 ( 0%) 0 ( 0%)
PID 4055: 4481 ( 0%) 0 ( 0%) 0 ( 0%) 0 ( 0%)
PID 577994: 3594 ( 0%) 0 ( 0%) 0 ( 0%) 0 ( 0%)
Total number of procs: 82
Tot (us) : 999937 1002248 1000084 1002199
Energy (uj) : 3045158 3050103
```
How it works
The eBPF code latches on to the scheduler switches in order to record how long each process spent in the CPU, and stores this data in a per-CPU hashmap.
The userland code then periodically aggregates the contents of the hashmap. There are naturally timing issues here: in the time it takes to read the hashmap, more data will have been added to the hashmap from the eBPF program. Currently, nothing is done to check this other than that the entries are themselves then stored in a hashmap, such that if any PID data is read twice, the sum of the occupation times is taken.
For each PID on each CPU core, we calculate the occupation fraction, which is the fraction of time the core spent executing that PID.
Over the same interval, we read the Intel(R) RAPL sysfs to calculate the energy usage of each CPU socket. The assumption then is that the energy usage of each process will be proportional to the total execution time in the same interval, which means we calculate the energy usage of a given process in a given CPU as
$$
E_{\text{pid}, \text{cpu}} = \left(
\frac{\sum_{i \in\text{cores}} t_{\text{pid},i}}
{\sum_{i \in\text{cores}} T_{i}}
\right) E_{\text{cpu}}
$$
where $t_{\text{pid},i}$ is the exeuction time for the process with PID in core $i$, and $T_i$ is the recorded time interval of the $i^\text{th}$ CPU.
Uncertainty
There are obvious assumptions at play here. Additionally, there are a handful of synchronization issues that ought to be discusses:
- We check that the total time recorded over the sum of all PIDs for each core is approximately (to within $\sim 2\%$) equal to the userland recording interval. This is merely a sanity check done by the user reading the output, and no way enforced in the code.
- This latency error may be reduced by increasing the sampling interval to minimze the concurrency overlap of userland reading and eBPF writing.
Related work
<ul>
<li>I learned about <a>DEEP-mon</a> whilst working on this which helped guide the design of this PoC.</li>
</ul> | [] |
https://avatars.githubusercontent.com/u/85104110?v=4 | zig-ipc | pseudocc/zig-ipc | 2024-02-08T11:46:16Z | Zig shared memory IPC example (POSIX) | main | 1 | 7 | 1 | 7 | https://api.github.com/repos/pseudocc/zig-ipc/tags | MIT | [
"ipc",
"shared-memory",
"zig"
] | 4 | false | 2025-05-04T18:40:48Z | true | false | unknown | github | [] | ZIG-IPC
Zig code example to use shared memory among processes, only works on POSIX.
How it works?
<ol>
<li>
Use <code>shm_open</code> and <code>mmap</code> to create a shared memory block.
</li>
<li>
Use <code>atomic</code> operations to manage a boolean value (busy).
<code>zig
pub inline fn lock(self: *Self, comptime value: bool) void {
while (true) {
_ = @cmpxchgStrong(bool, &self.ptr.busy, !value, value, .SeqCst, .SeqCst) orelse break;
}
}</code>
Updates on the rest memory block requires <code>busy</code> to be <code>false</code>, and
set to <code>true</code> before the update.
</li>
</ol>
Run this example
Build and start the server. Press CTRL+C to exit.
<code>sh
zig build # compiles against v0.11.0
zig-out/bin/ipc-server</code>
Start the client in another terminal.
<code>sh
zig-out/bin/ipc-client</code>
Example output
Server process:
<code>pseudoc $ zig-out/bin/ipc-server
Sorting(3): { 6, 80, 68 }
Sorted(3): { 6, 68, 80 }
Sorting(4): { 6, 68, 80, 87 }
Sorted(4): { 6, 68, 80, 87 }
Sorting(5): { 6, 68, 80, 87, 63 }
Sorted(5): { 6, 63, 68, 80, 87 }
Sorting(6): { 6, 63, 68, 80, 87, 3 }
Sorted(6): { 3, 6, 63, 68, 80, 87 }
Sorting(7): { 3, 6, 63, 68, 80, 87, 86 }
Sorted(7): { 3, 6, 63, 68, 80, 86, 87 }
Sorting(8): { 3, 6, 63, 68, 80, 86, 87, 33 }
Sorted(8): { 3, 6, 33, 63, 68, 80, 86, 87 }
Sorting(9): { 3, 6, 33, 63, 68, 80, 86, 87, 0 }
Sorted(9): { 0, 3, 6, 33, 63, 68, 80, 86, 87 }
Sorting(10): { 0, 3, 6, 33, 63, 68, 80, 86, 87, 13 }
Sorted(10): { 0, 3, 6, 13, 33, 63, 68, 80, 86, 87 }
Sorting(11): { 0, 3, 6, 13, 33, 63, 68, 80, 86, 87, 11 }
Sorted(11): { 0, 3, 6, 11, 13, 33, 63, 68, 80, 86, 87 }
Sorting(12): { 0, 3, 6, 11, 13, 33, 63, 68, 80, 86, 87, 70 }
Sorted(12): { 0, 3, 6, 11, 13, 33, 63, 68, 70, 80, 86, 87 }
Sorting(13): { 0, 3, 6, 11, 13, 33, 63, 68, 70, 80, 86, 87, 25 }
Sorted(13): { 0, 3, 6, 11, 13, 25, 33, 63, 68, 70, 80, 86, 87 }</code>
Client process:
<code>pseudoc $ zig-out/bin/ipc-client
Filled(3): { 6, 80, 68 }
Appended(1): 87
Appended(2): 63
Appended(3): 3
Appended(4): 86
Appended(5): 33
Appended(6): 0
Appended(7): 13
Appended(8): 11
Appended(9): 70
Appended(10): 25</code>
References
<a>Atomic Ordering</a>
<a>C POSIX IPC example</a> | [] |
https://avatars.githubusercontent.com/u/54114156?v=4 | wasm-sliding-puzzle | castholm/wasm-sliding-puzzle | 2023-05-13T21:54:29Z | Very simple interactive web app written in Zig and TypeScript | master | 0 | 7 | 0 | 7 | https://api.github.com/repos/castholm/wasm-sliding-puzzle/tags | MIT | [
"esbuild",
"example-project",
"sliding-puzzle-game",
"typescript",
"webassembly",
"zig"
] | 46 | false | 2024-10-25T08:34:09Z | true | false | unknown | github | [] | wasm-sliding-puzzle
Very simple example project showcasing how to write a simple interactive web app in Zig and TypeScript.
<a>Online demo</a>
Zig source code is compiled to WebAssembly using the <a>Zig compiler</a>. TypeScript "glue code" is
compiled to JavaScript and bundled using <a>esbuild</a> (CSS is also bundled using esbuild). All
build steps are orchestrated using <code>zig build</code>.
Everything is implemented "vanilla" using stock Web APIs without any frameworks or runtime dependencies.
If you're familiar with traditional web technology and you're curious about Zig and WebAssembly but don't know where to
start I hope this might serve as a useful starting point for small experiments. Likewise, if you're already comfortable
with Zig but don't know how to get your code running in browsers this might be a helpful reference.
Building/running
Requires a recent nightly master build of the <a>Zig compiler</a> (last tested
with 0.12.0-dev.1595+70d8baaec) and <a>npm</a> (or some
other equivalent package manager).
After cloning this repo but before doing anything else, run <code>npm install</code> from the repository's root directory to
install esbuild and the TypeScript compiler.
Then, run <code>zig build run</code> to build and bundle everything and launch a local dev server that serves the results.
By default, <code>zig build</code> will instruct esbuild to output JavaScript/CSS source maps. Passing a release optimization
option like <code>-Doptimize=ReleaseSmall</code> will (in addition to optimizing the WebAssembly output) instruct esbuild to minify
all JavaScript/CSS output.
Web output targets the most recent set of browser features and assumes you're using a modern web browser.
Please open an issue if the project no longer builds with the most recent version of the Zig compiler and I'll try to
update it as soon as possible. | [] |
https://avatars.githubusercontent.com/u/558581?v=4 | zig-neural-networks | MadLittleMods/zig-neural-networks | 2023-11-01T20:10:38Z | A from scratch neural network library in Zig | main | 4 | 7 | 1 | 7 | https://api.github.com/repos/MadLittleMods/zig-neural-networks/tags | - | [
"deep-learning",
"machine-learning",
"ml",
"mnist",
"mnist-handwriting-recognition",
"neural-network",
"zig"
] | 115 | false | 2025-03-17T13:39:53Z | true | true | unknown | github | [
{
"commit": "05e1fed50e6e1632ece62cf056eb0ab114d53d5c.tar.gz",
"name": "zshuffle",
"tar_url": "https://github.com/hmusgrave/zshuffle/archive/05e1fed50e6e1632ece62cf056eb0ab114d53d5c.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/hmusgrave/zshuffle"
}
] | Zig neural networks library
This is meant to be a understandable, annotated, from scratch, neural network library in
Zig.
To add some buzzword details, it's a multi-layer perceptron (MLP) with backpropagation
and stochastic gradient descent (SGD). Optional momentum, ...
Performance-wise, it should be just fine for your small application-specific purposes.
This library currently avoids the pesky vector/matrix libraries which can make it hard
to follow what exactly is being multiplied together (just uses flat arrays) when you're
trying to wrap your head around the concepts. If we ever decide to use one of
vector/matrix library, I plan to keep around the "slow" variants of the forward/backward
methods alongside the optimized versions.
This is heavily inspired by my <a>first neural network
implementation</a> which was based
on <a>Sebastian Lague's video</a> and now this
library implementation makes things a bit simpler to understand (at least math-wise) by
following a pattern from <a>Omar Aflak's (The Independent Code)
video</a> where activation functions are just
another layer in the network. See the <a><em>developer notes</em></a> for more
details.
Or if you're curious about how the math equations/formulas are derived, check out the
<a><em>developer notes</em></a> for more details.
Example Use Cases
The motivating use case for this library is to use it in a simple OCR task to recognize
the ammo counter digits in a game UI. But neural networks can be used for a vast set of
tasks. Here are some examples:
<ol>
<li>Presence and body tracking throughout a building by looking at phase/amplitude of
WiFi signals</li>
<li>Stud finder like the <a>Walabot</a> to detect and identify objects
behind walls</li>
<li><a>Detect emergency vehicle
sirens</a>
and alert when one is approaching so you can pull over.</li>
<li>Active suspension system for a bike/vehicle to adjust the suspension in real-time
based on the force feedback from the terrain, rider weight, etc.</li>
<li>Acoustic snooping of someone typing on a keyboard (eavesdropping/side-channel attacks)</li>
<li>Gesture recognition on a touch device</li>
</ol>
(if you have any ideas for more compelling use cases, feel free to open an PR!)
Installation
Tested with Zig 0.11.0
Compatible with the Zig package manager. Just define it as a dependency in your
<code>build.zig.zon</code> file.
<code>build.zig.zon</code>
<code>zig
.{
.name = "my-foo-project",
.version = "0.0.0",
.dependencies = .{
.@"zig-neural-networks" = .{
.url = "https://github.com/madlittlemods/zig-neural-networks/archive/<some-commit-hash-abcde>.tar.gz",
.hash = "1220416f31bac21c9f69c2493110064324b2ba9e0257ce0db16fb4f94657124d7abc",
},
},
}</code>
<code>build.zig</code>
<code>zig
const neural_networks_pkg = b.dependency("zig-neural-networks", .{
.target = target,
.optimize = optimize,
});
const neural_networks_mod = neural_networks_pkg.module("zig-neural-networks");
// Make the `zig-neural-networks` module available to be imported via `@import("zig-neural-networks")`
exe.addModule("zig-neural-networks", neural_networks_mod);
exe_tests.addModule("zig-neural-networks", neural_networks_mod);</code>
Examples
MNIST OCR digit recognition
Setup: Download and extract the MNIST dataset from http://yann.lecun.com/exdb/mnist/ to
a data directory in the mnist example project, <code>examples/mnist/data/</code>. Here is a
copy-paste command you can run:
```sh
Make a data/ directory
mkdir examples/mnist/data/ &&
Move to the data/ directory
cd examples/mnist/data/ &&
Download the MNIST dataset
curl -O http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz &&
curl -O http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz &&
curl -O http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz &&
curl -O http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz &&
Unzip the files
gunzip *.gz &&
Move back to the root of the project
cd ../../../
```
Then run the example:
With the MNIST OCR example, on my machine, I can complete 1 epoch of training in ~1
minute which gets to 94% accuracy and creeps to 97% after a few more epochs (60k
training images, 10k test images):
<code>sh
$ zig build run-mnist
debug: Created normalized data points. Training on 60000 data points, testing on 10000
debug: Here is what the first training data point looks like:
┌──────────┐
│ Label: 5 │
┌────────────────────────────────────────────────────────┐
│ │
│ │
│ │
│ │
│ │
│ ░░░░░░░░▒▒▓▓▓▓░░▓▓████▒▒ │
│ ░░░░▒▒▓▓▓▓████████████▓▓██████▒▒ │
│ ░░████████████████████▒▒▒▒▒▒░░░░ │
│ ░░██████████████▓▓████ │
│ ▒▒▓▓▒▒██████░░ ░░▓▓ │
│ ░░░░▓▓██▒▒ │
│ ▓▓██▓▓░░ │
│ ░░▓▓██▒▒ │
│ ░░████▓▓▒▒░░ │
│ ▒▒██████▒▒░░ │
│ ░░▓▓████▓▓░░ │
│ ░░▒▒████▓▓ │
│ ██████▒▒ │
│ ░░▓▓▓▓██████░░ │
│ ░░▓▓██████████▓▓ │
│ ░░▒▒████████████▒▒ │
│ ░░▒▒████████████▒▒░░ │
│ ░░▓▓████████████▒▒░░ │
│ ░░▓▓████████████▓▓░░ │
│ ▓▓████████▓▓▓▓░░ │
│ │
│ │
│ │
└────────────────────────────────────────────────────────┘
debug: epoch 0 batch 0 3s -> cost 331.64265899045563, accuracy with 100 test points 0.11
debug: epoch 0 batch 5 4s -> cost 242.16033395427667, accuracy with 100 test points 0.56
debug: epoch 0 batch 10 5s -> cost 155.62913461977217, accuracy with 100 test points 0.7
debug: epoch 0 batch 15 5s -> cost 118.45908401769115, accuracy with 100 test points 0.75
[...]</code>
Simple animal example
This is a small dataset that I made up to test the neural network. There are only 2
arbitrary features (x and y) where the labeled data points (fish and goat) occupy
distinct parts of the graph. Since there are only 2 input features (which means 2
dimensions), we can easily graph the neural network's decision/classification boundary.
It's a good way to visualize the neural network and see how it evolves while training.
This example produces an image called <code>simple_xy_animal_graph.ppm</code> every 1,000 epochs
showing the decision/classification boundary.
<code>sh
$ zig build run-xy_animal_example</code>
Barebones XOR example
There is also a barebones XOR example (only 4 possible data points) which just trains a neural
network to act like a XOR ("exclusive or") gate.
<code>sh
$ zig build run-xor</code>
Boundary graph

Using custom layer types
Perhaps you want to implement and use a custom dropout layer, skip layer, or
<a>convolutional/reshape</a> layer. Since the
<code>Layer</code> type is just an interface, you can implement your own layer types in Zig and
pass them to the neural network.
<a><code>examples/mnist/main_custom.zig</code></a>
<code>sh
$ zig build run-mnist_custom</code>
Saving and loading (serialize/deserialize)
You can save and load a <code>NeuralNetwork</code> with the standard Zig <code>std.json</code> methods.
This is useful so you can save all of your training progress and load it back up later
to continue training or to use the network to predict/classify data in your real
application.
```zig
var neural_network = neural_networks.NeuralNetwork.initFromLayers(
// ...
);
defer neural_network.deinit(allocator);
// Serialize the neural network
const serialized_neural_network = try std.json.stringifyAlloc(
allocator,
neural_network,
.{ .whitespace = .indent_2 },
);
defer allocator.free(serialized_neural_network);
// Deserialize the neural network
const parsed_neural_network = try std.json.parseFromSlice(
NeuralNetwork,
allocator,
serialized_neural_network,
.{},
);
defer parsed_neural_network.deinit();
const deserialized_neural_network = parsed_neural_network.value;
// Use <code>deserialized_neural_network</code> as desired
```
You can also see how this works in each of the examples where they save the state of the
<code>NeuralNetwork</code> out to a checkpoint file as it trains.
The MNIST example even has some resume training functionality to parse/load/deserialize
the JSON checkpoint file back to a <code>NeuralNetwork</code> to use: <code>zig build run-mnist --
--resume-training-from-last-checkpoint</code>
Logging
In order to adjust the log level that the Zig neural network library prints out, define
a public <code>std_options.log_scope_levels</code> declaration in the root file (where ever main
is), like the following. This library writes to the <code>.zig_neural_networks</code> scope.
<code>main.zig</code>
```zig
pub const std_options = struct {
pub const log_level = .debug;
<code>pub const log_scope_levels = &[_]std.log.ScopeLevel{
.{ .scope = .zig_neural_networks, .level = .debug },
.{ .scope = .library_foo, .level = .warn },
.{ .scope = .library_bar, .level = .info },
};
</code>
};
// ...
```
Tests
Alongside normal tests to ensure the neural network can learn, predict, and classify
data points, the codebase also has gradient checks to ensure that the backpropagation
algorithm is working correctly and slope checks to ensure that the activation and cost
functions and derivatives are accurate and correlated.
```sh
$ zig build test
Run a subset of tests
$ zig build test -Dtest-filter="Gradient check"
``` | [] |
https://avatars.githubusercontent.com/u/6756180?v=4 | wolfssl | kassane/wolfssl | 2023-06-04T15:27:00Z | WolfSSL library - Using Zig Build | zig-pkg | 1 | 7 | 2 | 7 | https://api.github.com/repos/kassane/wolfssl/tags | GPL-2.0 | [
"c-library",
"cryptography",
"fips",
"ssl",
"tls",
"wolfssl",
"wolfssl-library",
"zig",
"zig-package"
] | 760,144 | true | 2025-05-14T01:17:20Z | true | true | unknown | github | [] | *** Description ***
The wolfSSL embedded SSL library (formerly CyaSSL) is a lightweight SSL/TLS
library written in ANSI C and targeted for embedded, RTOS, and
resource-constrained environments - primarily because of its small size, speed,
and feature set. It is commonly used in standard operating environments as well
because of its royalty-free pricing and excellent cross platform support.
wolfSSL supports industry standards up to the current TLS 1.3 and DTLS 1.3
levels, is up to 20 times smaller than OpenSSL, and offers progressive ciphers
such as ChaCha20, Curve25519, and Blake2b. User benchmarking and feedback
reports dramatically better performance when using wolfSSL over OpenSSL.
wolfSSL is powered by the wolfCrypt library. Two versions of the wolfCrypt
cryptography library have been FIPS 140-2 validated (Certificate #2425 and
certificate #3389). For additional information, visit the wolfCrypt FIPS FAQ
(https://www.wolfssl.com/license/fips/) or contact fips@wolfssl.com
*** Why choose wolfSSL? ***
There are many reasons to choose wolfSSL as your embedded SSL solution. Some of
the top reasons include size (typical footprint sizes range from 20-100 kB),
support for the newest standards (SSL 3.0, TLS 1.0, TLS 1.1, TLS 1.2, TLS 1.3,
DTLS 1.0, DTLS 1.2, and DTLS 1.3), current and progressive cipher support
(including stream ciphers), multi-platform, royalty free, and an OpenSSL
compatibility API to ease porting into existing applications which have
previously used the OpenSSL package. For a complete feature list, see chapter 4
of the wolfSSL manual. (https://www.wolfssl.com/docs/wolfssl-manual/ch4/)
*** Notes, Please read ***
Note 1)
wolfSSL as of 3.6.6 no longer enables SSLv3 by default. wolfSSL also no longer
supports static key cipher suites with PSK, RSA, or ECDH. This means if you
plan to use TLS cipher suites you must enable DH (DH is on by default), or
enable ECC (ECC is on by default), or you must enable static key cipher suites
with
<code>WOLFSSL_STATIC_DH
WOLFSSL_STATIC_RSA
or
WOLFSSL_STATIC_PSK
</code>
though static key cipher suites are deprecated and will be removed from future
versions of TLS. They also lower your security by removing PFS.
When compiling ssl.c, wolfSSL will now issue a compiler error if no cipher
suites are available. You can remove this error by defining
WOLFSSL_ALLOW_NO_SUITES in the event that you desire that, i.e., you're not
using TLS cipher suites.
Note 2)
wolfSSL takes a different approach to certificate verification than OpenSSL
does. The default policy for the client is to verify the server, this means
that if you don't load CAs to verify the server you'll get a connect error,
no signer error to confirm failure (-188).
If you want to mimic OpenSSL behavior of having SSL_connect succeed even if
verifying the server fails and reducing security you can do this by calling:
<code>wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
</code>
before calling wolfSSL_new();. Though it's not recommended.
Note 3)
The enum values SHA, SHA256, SHA384, SHA512 are no longer available when
wolfSSL is built with --enable-opensslextra (OPENSSL_EXTRA) or with the macro
NO_OLD_SHA_NAMES. These names get mapped to the OpenSSL API for a single call
hash function. Instead the name WC_SHA, WC_SHA256, WC_SHA384 and WC_SHA512
should be used for the enum name.
*** end Notes ***
wolfSSL Release 5.8.0 (Apr 24, 2025)
Release 5.8.0 has been developed according to wolfSSL's development and QA
process (see link below) and successfully passed the quality criteria.
https://www.wolfssl.com/about/wolfssl-software-development-process-quality-assurance
NOTE: * --enable-heapmath is deprecated
PR stands for Pull Request, and PR references a GitHub pull request
number where the code change was added.
New Feature Additions
<ul>
<li>Algorithm registration in the Linux kernel module for all supported FIPS AES,
SHA, HMAC, ECDSA, ECDH, and RSA modes, key sizes, and digest sizes.</li>
<li>Implemented various fixes to support building for Open Watcom including OS/2
support and Open Watcom 1.9 compatibility (PR 8505, 8484)</li>
<li>Added support for STM32H7S (tested on NUCLEO-H7S3L8) (PR 8488)</li>
<li>Added support for STM32WBA (PR 8550)</li>
<li>Added Extended Master Secret Generation Callback to the --enable-pkcallbacks
build (PR 8303)</li>
<li>Implement AES-CTS (configure flag --enable-aescts) in wolfCrypt (PR 8594)</li>
<li>Added support for libimobiledevice commit 860ffb (PR 8373)</li>
<li>Initial ASCON hash256 and AEAD128 support based on NIST SP 800-232 IPD
(PR 8307)</li>
<li>Added blinding option when using a Curve25519 private key by defining the
macro WOLFSSL_CURVE25519_BLINDING (PR 8392)</li>
</ul>
Linux Kernel Module
<ul>
<li>Production-ready LKCAPI registration for cbc(aes), cfb(aes), gcm(aes),
rfc4106 (gcm(aes)), ctr(aes), ofb(aes), and ecb(aes), ECDSA with P192, P256,
P384, and P521 curves, ECDH with P192, P256, and P384 curves, and RSA with
bare and PKCS1 padding</li>
<li>Various fixes for LKCAPI wrapper for AES-CBC and AES-CFB (PR 8534, 8552)</li>
<li>Adds support for the legacy one-shot AES-GCM back end (PR 8614, 8567) for
compatibility with FIPS 140-3 Cert #4718.</li>
<li>On kernel >=6.8, for CONFIG_FORTIFY_SOURCE, use 5-arg fortify_panic() override
macro (PR 8654)</li>
<li>Update calls to scatterwalk_map() and scatterwalk_unmap() for linux commit
7450ebd29c (merged for Linux 6.15) (PR 8667)</li>
<li>Inhibit LINUXKM_LKCAPI_REGISTER_ECDH on kernel <5.13 (PR 8673)</li>
<li>Fix for uninitialized build error with fedora (PR 8569)</li>
<li>Register ecdsa, ecdh, and rsa for use with linux kernel crypto (PR 8637, 8663,
8646)</li>
<li>Added force zero shared secret buffer, and clear of old key with ecdh
(PR 8685)</li>
<li>Update fips-check.sh script to pickup XTS streaming support on aarch64 and
disable XTS-384 as an allowed use in FIPS mode (PR 8509, 8546)</li>
</ul>
Enhancements and Optimizations
Security & Cryptography
<ul>
<li>Add constant-time implementation improvements for encoding functions. We thank
Zhiyuan and Gilles for sharing a new constant-time analysis tool (CT-LLVM) and
reporting several non-constant-time implementations. (PR 8396, 8617)</li>
<li>Additional support for PKCS7 verify and decode with indefinite lengths
(PR 8520, 834, 8645)</li>
<li>Add more PQC hybrid key exchange algorithms such as support for combinations
with X25519 and X448 enabling compatibility with the PQC key exchange support
in Chromium browsers and Mozilla Firefox (PR 7821)</li>
<li>Add short-circuit comparisons to DH key validation for RFC 7919 parameters
(PR 8335)</li>
<li>Improve FIPS compatibility with various build configurations for more resource
constrained builds (PR 8370)</li>
<li>Added option to disable ECC public key order checking (PR 8581)</li>
<li>Allow critical alt and basic constraints extensions (PR 8542)</li>
<li>New codepoint for MLDSA to help with interoperability (PR 8393)</li>
<li>Add support for parsing trusted PEM certs having the header
“BEGIN_TRUSTED_CERT” (PR 8400)</li>
<li>Add support for parsing only of DoD certificate policy and Comodo Ltd PKI OIDs
(PR 8599, 8686)</li>
<li>Update ssl code in <code>src/*.c</code> to be consistent with wolfcrypt/src/asn.c
handling of ML_DSA vs Dilithium and add dual alg. test (PR 8360, 8425)</li>
</ul>
Build System, Configuration, CI & Protocols
<ul>
<li>Internal refactor for include of config.h and when building with
BUILDING_WOLFSSL macro. This refactor will give a warning of “deprecated
function” when trying to improperly use an internal API of wolfSSL in an
external application. (PR 8640, 8647, 8660, 8662, 8664)</li>
<li>Add WOLFSSL_CLU option to CMakeLists.txt (PR 8548)</li>
<li>Add CMake and Zephyr support for XMSS and LMS (PR 8494)</li>
<li>Added GitHub CI for CMake builds (PR 8439)</li>
<li>Added necessary macros when building wolfTPM Zephyr with wolfSSL (PR 8382)</li>
<li>Add MSYS2 build continuous integration test (PR 8504)</li>
<li>Update DevKitPro doc to list calico dependency with build commands (PR 8607)</li>
<li>Conversion compiler warning fixes and additional continuous integration test
added (PR 8538)</li>
<li>Enable DTLS 1.3 by default in --enable-jni builds (PR 8481)</li>
<li>Enabled TLS 1.3 middlebox compatibility by default for --enable-jni builds
(PR 8526)</li>
</ul>
Performance Improvements
<ul>
<li>Performance improvements AES-GCM and HMAC (in/out hash copy) (PR 8429)</li>
<li>LMS fixes and improvements adding API to get Key ID from raw private key,
change to identifiers to match standard, and fix for when
WOLFSSL_LMS_MAX_LEVELS is 1 (PR 8390, 8684, 8613, 8623)</li>
<li>ML-KEM/Kyber improvements and fixes; no malloc builds, small memory usage,
performance improvement, fix for big-endian (PR 8397, 8412, 8436, 8467, 8619,
8622, 8588)</li>
<li>Performance improvements for AES-GCM and when doing multiple HMAC operations
(PR 8445)</li>
</ul>
Assembly and Platform-Specific Enhancements
<ul>
<li>Poly1305 arm assembly changes adding ARM32 NEON implementation and fix for
Aarch64 use (PR 8344, 8561, 8671)</li>
<li>Aarch64 assembly enhancement to use more CPU features, fix for FreeBSD/OpenBSD
(PR 8325, 8348)</li>
<li>Only perform ARM assembly CPUID checks if support was enabled at build time
(PR 8566)</li>
<li>Optimizations for ARM32 assembly instructions on platforms less than ARMv7
(PR 8395)</li>
<li>Improve MSVC feature detection for static assert macros (PR 8440)</li>
<li>Improve Espressif make and CMake for ESP8266 and ESP32 series (PR 8402)</li>
<li>Espressif updates for Kconfig, ESP32P4 and adding a sample user_settings.h
(PR 8422, PR 8641)</li>
</ul>
OpenSSL Compatibility Layer
<ul>
<li>Modification to the push/pop to/from in OpenSSL compatibility layer. This is
a pretty major API change in the OpenSSL compatibility stack functions.
Previously the API would push/pop from the beginning of the list but now they
operate on the tail of the list. This matters when using the sk_value with
index values. (PR 8616)</li>
<li>OpenSSL Compat Layer: OCSP response improvements (PR 8408, 8498)</li>
<li>Expand the OpenSSL compatibility layer to include an implementation of
BN_CTX_get (PR 8388)</li>
</ul>
API Additions and Modifications
<ul>
<li>Refactor Hpke to allow multiple uses of a context instead of just one shot
mode (PR 6805)</li>
<li>Add support for PSK client callback with Ada and use with Alire (thanks
@mgrojo, PR 8332, 8606)</li>
<li>Change wolfSSL_CTX_GenerateEchConfig to generate multiple configs and add
functions wolfSSL_CTX_SetEchConfigs and wolfSSL_CTX_SetEchConfigsBase64 to
rotate the server's echConfigs (PR 8556)</li>
<li>Added the public API wc_PkcsPad to do PKCS padding (PR 8502)</li>
<li>Add NULL_CIPHER_TYPE support to wolfSSL_EVP_CipherUpdate (PR 8518)</li>
<li>Update Kyber APIs to ML-KEM APIs (PR 8536)</li>
<li>Add option to disallow automatic use of "default" devId using the macro
WC_NO_DEFAULT_DEVID (PR 8555)</li>
<li>Detect unknown key format on ProcessBufferTryDecode() and handle RSA-PSSk
format (PR 8630)</li>
</ul>
Porting and Language Support
<ul>
<li>Update Python port to support version 3.12.6 (PR 8345)</li>
<li>New additions for MAXQ with wolfPKCS11 (PR 8343)</li>
<li>Port to ntp 4.2.8p17 additions (PR 8324)</li>
<li>Add version 0.9.14 to tested libvncserver builds (PR 8337)</li>
</ul>
General Improvements and Cleanups
<ul>
<li>Cleanups for STM32 AES GCM (PR 8584)</li>
<li>Improvements to isascii() and the CMake key log option (PR 8596)</li>
<li>Arduino documentation updates, comments and spelling corrections (PR 8381,
8384, 8514)</li>
<li>Expanding builds with WOLFSSL_NO_REALLOC for use with --enable-opensslall and
--enable-all builds (PR 8369, 8371)</li>
</ul>
Fixes
<ul>
<li>Fix a use after free caused by an early free on error in the X509 store
(PR 8449)</li>
<li>Fix to account for existing PKCS8 header with
wolfSSL_PEM_write_PKCS8PrivateKey (PR 8612)</li>
<li>Fixed failing CMake build issue when standard threads support is not found in
the system (PR 8485)</li>
<li>Fix segmentation fault in SHA-512 implementation for AVX512 targets built with
gcc -march=native -O2 (PR 8329)</li>
<li>Fix Windows socket API compatibility warning with mingw32 build (PR 8424)</li>
<li>Fix potential null pointer increments in cipher list parsing (PR 8420)</li>
<li>Fix for possible stack buffer overflow read with wolfSSL_SMIME_write_PKCS7.
Thanks to the team at Code Intelligence for the report. (PR 8466)</li>
<li>Fix AES ECB implementation for Aarch64 ARM assembly (PR 8379)</li>
<li>Fixed building with VS2008 and .NET 3.5 (PR 8621)</li>
<li>Fixed possible error case memory leaks in CRL and EVP_Sign_Final (PR 8447)</li>
<li>Fixed SSL_set_mtu compatibility function return code (PR 8330)</li>
<li>Fixed Renesas RX TSIP (PR 8595)</li>
<li>Fixed ECC non-blocking tests (PR 8533)</li>
<li>Fixed CMake on MINGW and MSYS (PR 8377)</li>
<li>Fixed Watcom compiler and added new CI test (PR 8391)</li>
<li>Fixed STM32 PKA ECC 521-bit support (PR 8450)</li>
<li>Fixed STM32 PKA with P521 and shared secret (PR 8601)</li>
<li>Fixed crypto callback macro guards with <code>DEBUG_CRYPTOCB</code> (PR 8602)</li>
<li>Fix outlen return for RSA private decrypt with WOLF_CRYPTO_CB_RSA_PAD
(PR 8575)</li>
<li>Additional sanity check on r and s lengths in DecodeECC_DSA_Sig_Bin (PR 8350)</li>
<li>Fix compat. layer ASN1_TIME_diff to accept NULL output params (PR 8407)</li>
<li>Fix CMake lean_tls build (PR 8460)</li>
<li>Fix for QUIC callback failure (PR 8475)</li>
<li>Fix missing alert types in AlertTypeToString for print out with debugging
enabled (PR 8572)</li>
<li>Fixes for MSVS build issues with PQC configure (PR 8568)</li>
<li>Fix for SE050 port and minor improvements (PR 8431, 8437)</li>
<li>Fix for missing rewind function in zephyr and add missing files for compiling
with assembly optimizations (PR 8531, 8541)</li>
<li>Fix for quic_record_append to return the correct code (PR 8340, 8358)</li>
<li>Fixes for Bind 9.18.28 port (PR 8331)</li>
<li>Fix to adhere more closely with RFC8446 Appendix D and set haveEMS when
negotiating TLS 1.3 (PR 8487)</li>
<li>Fix to properly check for signature_algorithms from the client in a TLS 1.3
server (PR 8356)</li>
<li>Fix for when BIO data is less than seq buffer size. Thanks to the team at Code
Intelligence for the report (PR 8426)</li>
<li>ARM32/Thumb2 fixes for WOLFSSL_NO_VAR_ASSIGN_REG and td4 variable declarations
(PR 8590, 8635)</li>
<li>Fix for Intel AVX1/SSE2 assembly to not use vzeroupper instructions unless ymm
or zmm registers are used (PR 8479)</li>
<li>Entropy MemUse fix for when block size less than update bits (PR 8675)</li>
</ul>
For additional vulnerability information visit the vulnerability page at:
https://www.wolfssl.com/docs/security-vulnerabilities/
See INSTALL file for build instructions.
More info can be found on-line at: https://wolfssl.com/wolfSSL/Docs.html
*** Resources ***
<a>wolfSSL Website</a>
<a>wolfSSL Wiki</a>
<a>FIPS FAQ</a>
<a>wolfSSL Documents</a>
<a>wolfSSL Manual</a>
[wolfSSL API Reference]
(https://wolfssl.com/wolfSSL/Docs-wolfssl-manual-17-wolfssl-api-reference.html)
[wolfCrypt API Reference]
(https://wolfssl.com/wolfSSL/Docs-wolfssl-manual-18-wolfcrypt-api-reference.html)
<a>TLS 1.3</a>
[wolfSSL Vulnerabilities]
(https://www.wolfssl.com/docs/security-vulnerabilities/)
Additional wolfSSL Examples](https://github.com/wolfssl/wolfssl-examples) | [] |
https://avatars.githubusercontent.com/u/134004172?v=4 | .github | zig-ethereum/.github | 2023-05-29T05:18:52Z | zig tools for ethereum | main | 0 | 6 | 0 | 6 | https://api.github.com/repos/zig-ethereum/.github/tags | MIT | [
"zig"
] | 7 | false | 2023-10-11T04:13:26Z | false | false | unknown | github | [] | zig-ethereum
zig tools for ethereum
Learn more at our website: https://github.com/zig-ethereum. | [] |
https://avatars.githubusercontent.com/u/5464072?v=4 | zig-tokenize | nektro/zig-tokenize | 2023-02-28T04:22:15Z | A data-oriented-design built tokenizer | main | 0 | 6 | 0 | 6 | https://api.github.com/repos/nektro/zig-tokenize/tags | - | [
"zig",
"zig-package"
] | 6 | false | 2024-06-22T18:27:07Z | false | false | unknown | github | [] | zig-tokenize
A data-oriented-design built tokenizer | [] |
https://avatars.githubusercontent.com/u/2242?v=4 | zig-envy | softprops/zig-envy | 2023-11-19T06:18:44Z | parse env variables into zig structs | main | 1 | 6 | 0 | 6 | https://api.github.com/repos/softprops/zig-envy/tags | MIT | [
"environment-variables",
"zig",
"zig-package",
"zigdex-lib"
] | 35 | false | 2024-07-14T07:45:09Z | true | true | 0.13.0 | github | [] |
envy
deserialize environment variables into typesafe structs
<a></a> <a></a>
🍬 features
<ul>
<li>fail fast on faulty application configuration</li>
<li>supports parsable std lib types out of the box</li>
<li>fail at compile time for unsupported field types</li>
</ul>
examples
```zig
const std = @import("std");
const envy = @import("envy");
const Config = struct {
foo: u16,
bar: bool,
baz: []const u8,
boom: ?u64
};
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();
<code>const config = envy.parse(Config, allocator, .{}) catch |err| {
std.debug.print("error parsing config from env: {any}", err);
return;
};
std.debug.println("config {any}", .{ config });
</code>
}
```
📼 installing
Create a new exec project with <code>zig init-exe</code>. Copy the echo handler example above into <code>src/main.zig</code>
Create a <code>build.zig.zon</code> file to declare a dependency
<blockquote>
.zon short for "zig object notation" files are essentially zig structs. <code>build.zig.zon</code> is zigs native package manager convention for where to declare dependencies
</blockquote>
Starting in zig <code>0.12.0</code>, you can use
<code>sh
zig fetch --save https://github.com/softprops/zig-envy/archive/refs/tags/v0.2.1.tar.gz</code>
to manually add it as follows
<code>diff
.{
.name = "my-app",
.version = "0.1.0",
.dependencies = .{
+ // 👇 declare dep properties
+ .envy = .{
+ // 👇 uri to download
+ .url = "https://github.com/softprops/zig-envy/archive/refs/tags/v0.2.1.tar.gz",
+ // 👇 hash verification
+ .hash = "{current-hash}",
+ },
},
.paths = .{""},
}</code>
<blockquote>
the hash below may vary. you can also depend any tag with <code>https://github.com/softprops/zig-envy/archive/refs/tags/v{version}.tar.gz</code> or current main with <code>https://github.com/softprops/zig-envy/archive/refs/heads/main/main.tar.gz</code>. to resolve a hash omit it and let zig tell you the expected value.
</blockquote>
Add the following in your <code>build.zig</code> file
```diff
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
<code>const optimize = b.standardOptimizeOption(.{});
</code>
<ul>
<li>// 👇 de-reference envy dep from build.zig.zon</li>
<li>const envy = b.dependency("envy", .{</li>
<li>.target = target,</li>
<li>.optimize = optimize,</li>
<li>}).module("envy");
var exe = b.addExecutable(.{
.name = "your-exe",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});</li>
<li>// 👇 add the envy module to executable</li>
<li>
exe.root_module.addImport("envy", envy);
b.installArtifact(exe);
}
```
</li>
</ul>
🥹 for budding ziglings
Does this look interesting but you're new to zig and feel left out? No problem, zig is young so most us of our new are as well. Here are some resources to help get you up to speed on zig
<ul>
<li><a>the official zig website</a></li>
<li><a>zig's one-page language documentation</a></li>
<li><a>ziglearn</a></li>
<li><a>ziglings exercises</a></li>
</ul>
- softprops 2023 | [] |
https://avatars.githubusercontent.com/u/6756180?v=4 | CxxInterop-tests | kassane/CxxInterop-tests | 2023-07-13T17:52:54Z | C++ FFI tests | devel | 1 | 6 | 0 | 6 | https://api.github.com/repos/kassane/CxxInterop-tests/tags | - | [
"cpp",
"d",
"dlang",
"ffi",
"interoperability",
"rust",
"swift",
"zig"
] | 32 | true | 2025-02-15T06:00:05Z | true | false | unknown | github | [] | C++ Interop testing
Requirements
<ul>
<li>C++ compiler + <a>CMake</a></li>
<li><a>Swift v5.9</a></li>
<li><a>LDC (LLVM D Compiler)</a></li>
<li><a>Rust toolchain</a></li>
<li><a>Zig toolchain</a> - replacing cmake to zig-build</li>
</ul>
Acknowledgments
<ul>
<li><a>Sy Brand</a> [C++ <=> Rust only]</li>
<li><a>Yosh</a> [C++ <=> Rust only]</li>
</ul>
Some References
| Video | Description |
| --- | --- |
| <a></a> | Yosh Wuyts provides a brief overview of the Rust programming language in this video. He explores three methods for facilitating communication between C++ and Rust. |
| <a></a> | Mathias delves into D's capabilities for interoperability with C++ in this video. The discussion covers design philosophy, limitations, and practical examples drawn from real-world scenarios. |
| <a></a> | Ed Yu provides a concise explanation of the <strong>zig build-system</strong> in C and/or C++ projects for streamlined cross-compilation. |
| <a></a> | Konrad Malawski demonstrates Swift integration in FoundationDB, a distributed database modernizing its C++ codebase. The video emphasizes Swift's seamless interoperability, facilitating a smooth transition of functions and types without generating bindings or compromising existing semantics. | | [] |
https://avatars.githubusercontent.com/u/206480?v=4 | singleflight.zig | karlseguin/singleflight.zig | 2023-06-03T10:20:06Z | Duplicate function call suppression for Zig | master | 0 | 6 | 1 | 6 | https://api.github.com/repos/karlseguin/singleflight.zig/tags | MIT | [
"zig",
"zig-library"
] | 33 | false | 2025-03-15T19:30:36Z | true | false | unknown | github | [] | Duplicate function call suppression for Zig
```zig
const singleflight = @import("singleflight");
// group is thread-safe
const group = singleflight.Group(*User).init(allocator);
defer group.deinit();
// multiple threads can call group.load on the same key
const result = try group.load(UserLoadState, "user:4", &loadUser, UserLoadState{.id = 4});
// result.value is the value returned by loadUser
// result.caller is true when this is the thread that called loadUser
// result.last is true when all waiting threads for this key have unblocked
...
const UserLoadState = struct {
id: u32,
}
fn loadUser(state: UserLoadState, _key: []const u8) !User {
// load the user, using either the app-specific state
// or the key
// ...
return user;
}
```
An application-specific "state" is provided to the <code>group.load</code> function and then passed back to the callback function. This allows the application to pass itself information necessary to load the object.
This library is not a cache. Assume thread 1, thread 2 and thread 3 all attempt to load "user:1". It is possible for one, two or all three threads to call <code>loadUser</code>. This is more likely when the callback, <code>loadUser</code> in this case, executes quickly. This happens because the Singleflight group tracks threads waiting for the result and cleans itself when the last blocked thread gets the result (on a per-key basis). Thread 1 can call <code>loadUser</code>, get the result before thread 2's intent in the key is registered. In this case, thread 1 will clean up the group and return the value.
In other words, this library is not a cache. See <a>cache.zig</a> if you want a cache (combining the two libraries makes sense). | [] |
https://avatars.githubusercontent.com/u/124872?v=4 | zig-cbc | jedisct1/zig-cbc | 2023-03-13T13:35:39Z | CBC mode for Zig. | master | 0 | 6 | 3 | 6 | https://api.github.com/repos/jedisct1/zig-cbc/tags | MIT | [
"aes",
"cbc",
"crypto",
"zig",
"zig-package"
] | 19 | false | 2025-04-17T23:55:06Z | true | true | unknown | github | [] | CBC mode for Zig
Don't use CBC.
Unless you really, really, really have to. | [] |
https://avatars.githubusercontent.com/u/12457438?v=4 | wasm-game-engine-test | judah-caruso/wasm-game-engine-test | 2023-09-19T15:19:07Z | A wasm-based game engine written in Go | main | 0 | 6 | 0 | 6 | https://api.github.com/repos/judah-caruso/wasm-game-engine-test/tags | - | [
"assemblyscript",
"ebitengine",
"odin",
"rust",
"wasm",
"wazero",
"zig"
] | 1,089 | false | 2024-08-19T08:06:31Z | false | false | unknown | github | [] | Wasm Game Engine Test
This repository was created to see how feasible it is to use <a>wazero</a> to drive a small game engine (using <a>Ebitengine</a>). It simply sets up Ebitengine and exports a small api for wasm to import.
If you're trying to do something similar, hopefully this provides a decent starting point.
Installation
<ul>
<li>Install the toolchain for the language you want to compile (zig, rust, odin, tinygo, assemblyscript)</li>
<li><code>cd</code> into their <code>[lang]-game</code> directory</li>
<li>run <code>./build.sh</code> (this will create a <code>game.wasm</code> file in the root directory)</li>
<li>run <code>go run .</code> in the root directory to start the game</li>
</ul>
Some minor benchmarks
Below are a few grain-of-salt metrics I've gathered for each bunnymark-styled demo. This <strong>isn't</strong> intended to be a direct comparison of performance, more to see how much overhead there is when calling between wazero/wasm and go.
Note: these were ran on a 2022 M2 MacBook Air (8GB)
<code>Language 60 Fps Max 60 Tps Max (Avg. Fps)
asc 22,000 71,000 (14)
odin 23,000 88,000 (15)
zig 24,000 83,000 (15)
go 25,000 94,000 (15)
rust 25,000 94,000 (15)</code>
Below compares this approach to other ways I've tested:
<code>Runtime 60 Fps Max 60 Tps Max (Avg. Fps)
go/goja 2,000 3,000 (18)
go/gopher-lua 13,000 22,000 (19)
go/browser[1] 13,000 49,000 (14)
go/wazero[2] 53,000 184,000 (15)
go/native[3] 55,000 192,000 (15)
go/native[4] 64,000 230,000 (14)</code>
<ul>
<li>60 Fps Max: number of entities before consistent fps is below 60</li>
<li>60 Tps Max: number of entities before consistent tps is below 60</li>
<li>
Avg. Fps: average fps when tps is passed tps max
</li>
<li>
<a>Ebitengine Sprites Example</a>
</li>
<li>BrutEngine (my custom wasm engine)</li>
<li><a>Ebitengine Bunnymark</a></li>
<li><a>Gophermark</a></li>
</ul>
From my tests, embedding wasm/wazero within a native go application
performs better than embedding lua/js or running wasm in the browser.
However, as expected, both still perform significantly worse than native compilation.
Keep in mind that "bunnymark" isn't a definitive benchmark and your mileage may vary.
License
Public Domain | [] |
https://avatars.githubusercontent.com/u/119983202?v=4 | streamvbyte-zig | spiraldb/streamvbyte-zig | 2023-09-27T15:34:58Z | Zig port of Stream VByte encoding | develop | 0 | 6 | 0 | 6 | https://api.github.com/repos/spiraldb/streamvbyte-zig/tags | MIT | [
"compression",
"zig"
] | 10 | false | 2025-01-01T04:07:39Z | true | false | unknown | github | [] | Zig StreamVByte
A Zig port of <a>Stream VByte</a>.
This project started as an experiment to explore the feasibility and
DevX of implementing compression codecs in Zig.
In particular,
* Leveraging comptime to avoid writing (or generating) repetitive code.
* Using the Zig @Vector API for portable SIMD.
Comptime Lookup Tables
Stream VByte leverages lookup tables (LUTs) for pre-computing shuffle
masks as well as the lengths of compressed quads.
Zig's comptime feature allows us to generate static LUTs at compile-time
by defining them in regular Zig. This makes it possible for the reader
to understand the origin of what are otherwise typically opaque "magic"
values.
Zig SIMD
Zig leans on LLVM for its <code>@Vector</code> SIMD API. While Zig offers a <code>@shuffle</code>
builtin to operate on vectors, LLVM (and therefore Zig) require the shuffle
mask to be comptime known.
Since the shuffle mask is a lookup based on runtime control bits, it isn't
possible to use the <code>@shuffle</code> builtin.
<blockquote>
It is worth noting at this point that we use Zig 0.11.0.
</blockquote>
We <em>were</em> able to generate functions for each of the shuffle masks, and then
store these function pointers in a LUT. But since these functions cannot be inlined, the overhead was far too much.
We also tried to <code>@cImport</code> the relevant instrinsics headers. But found that
Zig is currently unable to inline <code>callconv(.C)</code> extern functions.
This left us to implement a shuffle function ourselves using <code>pshufb</code>
(and <code>tbl.16b</code>) with Zig's inline ASM. Whilst this isn't ideal, it doesn't
seem unreasonable for these instructions to be supported by the builtin
<code>@shuffle</code> operator when the operand is only runtime known.
Benchmarks
We spent most of our time playing around with shuffle LUTs, so
the remainder of the code isn't particularly heavily optimized.
Nor have we run these benchmarks on a variety of architectures.
Take everything with a handful of salt. Especially given how
much variance there is in the "benchmarks".
```bash "M2 Macbook Air"
$ zig build test -Doptimize=ReleaseFast
Zig StreamVByte
Encode 10000000 ints between 0 and 10000 in mean 3467410ns
=> 2883 million ints per second
<code>Decode 10000000 ints between 0 and 10000 in mean 1681129ns
=> 5948 million ints per second
</code>
Original C StreamVByte
Encode 10000000 ints between 0 and 10000 in mean 2065012ns
=> 4842 million ints per second
<code>Decode 10000000 ints between 0 and 10000 in mean 1669633ns
=> 5989 million ints per second
</code>
```
The source code is released under the <a>MIT license</a>. | [] |
https://avatars.githubusercontent.com/u/102667323?v=4 | RISC8Emulator | VitorCarvalho67/RISC8Emulator | 2024-02-01T18:57:23Z | RISC8Emulator is a software recreation of the CHIP-8 system, a simple computer from the mid-1970s primarily used for playing video games | main | 0 | 6 | 0 | 6 | https://api.github.com/repos/VitorCarvalho67/RISC8Emulator/tags | MIT | [
"8-bit",
"chip8",
"ci",
"emulator",
"games",
"github-actions",
"mit-license",
"simple-project",
"video-game",
"zig"
] | 33 | true | 2024-08-13T00:08:44Z | true | false | unknown | github | [] |
RISC8Emulator
<a></a>
<strong>RISC8Emulator</strong> is a software recreation of the CHIP-8 system, a simple computer from the mid-1970s primarily used for playing video games. Written in Zig, a modern programming language, this emulator replicates the architecture and functionality of the original CHIP-8, offering a unique experience for retro gaming and computer history enthusiasts.
Features
<ul>
<li><strong>Memory</strong>: Emulates the CHIP-8's 4 KB RAM.</li>
<li><strong>Display</strong>: Simulates the 64x32 pixel monochrome display.</li>
<li><strong>Program Counter (PC)</strong>: Manages the flow of the program.</li>
<li><strong>Index Register (I)</strong>: A 16-bit register for pointing to memory locations.</li>
<li><strong>Stack</strong>: Utilized for storing 16-bit addresses for function calls and returns.</li>
<li><strong>Delay Timer</strong>: An 8-bit timer decrementing at a rate of 60 Hz.</li>
<li><strong>Sound Timer</strong>: Similar to the delay timer but emits a beep when not zero.</li>
<li><strong>Registers</strong>: Comprises 16 8-bit general-purpose registers (V0-VF).</li>
</ul>
File Structure
<ul>
<li><code>main.zig</code>: Entry point of the application, initializing the emulator.</li>
<li><code>display.zig</code>: Handles the CHIP-8's monochrome display.</li>
<li><code>device.zig</code>: Integrates components like memory and display.</li>
<li><code>cpu.zig</code>: Responsible for the CPU functionality and instruction execution.</li>
<li><strong><code>c.zig</code> File</strong>: This file is used to import the SDL2 library from C, facilitating graphical output and input handling.</li>
<li><code>bitmap.zig</code>: Manages bitmap operations for graphics.</li>
</ul>
Prerequisites
<ul>
<li>Zig programming language version 0.11 installed on your system.</li>
<li><strong>ROM Requirement</strong>: To run a game, a CHIP-8 ROM file must be added. This emulator does not come with any preloaded games, so you need to provide your own ROM.</li>
</ul>
Installation
<ol>
<li>
Clone the repository:
<code>bash
git clone https://github.com/alvarorichard/RISC8Emulator.git</code>
</li>
<li>
Navigate to the project directory:
<code>bash
cd RISC8Emulator</code>
</li>
</ol>
Running the Emulator
Execute the main.zig file with the Zig compiler to run the emulator:
<code>zig
zig run main.zig</code>
or just run :
<code>zig
zig build</code>
Contributing
Contributions to improve or enhance the emulator are always welcome. Please adhere to the standard pull request process for contributions. | [] |
https://avatars.githubusercontent.com/u/23733070?v=4 | plib | Luna1996/plib | 2023-08-24T11:59:49Z | collection of multiple modules, which includes a parser generator and parsers generated by it. | main | 0 | 6 | 0 | 6 | https://api.github.com/repos/Luna1996/plib/tags | - | [
"abnf",
"abnf-language",
"abstract-syntax-tree",
"ast",
"parser",
"parser-generator",
"toml",
"toml-config",
"toml-language",
"toml-parser",
"toml-parsing",
"toml-serializer",
"zig",
"zig-library",
"zig-package",
"ziglang"
] | 212 | false | 2025-04-25T12:13:15Z | true | true | unknown | github | [] | PLib
<code>plib</code> (short for parser library) is a collection of multiple modules, which includes a parser generator and parsers generated by it.
<code>plib</code> takes a pre-generated <a><code>ABNF</code></a> structure as input to produce a <code>parser</code>.\
<code>parser</code> will take raw text as input to generate the <a><code>AST</code></a> of it.
<blockquote>
<span class="bg-blue-100 text-blue-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-blue-900 dark:text-blue-300">NOTE</span>
Contribution is much welcomed, but beware that currently this is just a personal project for fun.
<span class="bg-yellow-100 text-yellow-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-yellow-900 dark:text-yellow-300">WARNING</span>
Lack of comments and documents. You need to dig into the bare code to use and knew the logic behind the library.
</blockquote>
Modules
<ul>
<li><a><code>plib</code></a>\
core module, parser generator</li>
<li><a><code>abnf</code></a>\
abnf file parser/serializer, <code>ABNF</code> structure generator, generate itself</li>
<li><a><code>toml</code></a>\
toml file parser/serializer, follow toml v1.0.0, passed all <a><code>toml-test</code></a> tests</li>
</ul>
How To
Generate ABNF
Use following command to generate the <code>ABNF</code> structure that defines ABNF syntax.
<code>zig build -Dstep=gen_abnf -Dname=file_name</code>
This command runs <a><code>gen_abnf.zig</code></a>, takes <code>src/raw/<file_name>.abnf</code> and outputs <code>src/gen/<file_name>.zig</code>.
Test Module
Use following command to test module.
<code>zig build -Dstep=test -Dname=mod_name</code>
toml-test
To test the <code>toml</code> module against <a><code>toml-test</code></a>, first make sure <code>toml-test</code> is on your PATH, then
<code>zig build -Dstep=toml_test</code>
Currently all tests is passed.
<code>toml-test v2024-05-31 [C:\repo\repo.zig\plib\zig-out\bin\toml_encoder.exe]: using embedded tests
encoder tests: 182 passed, 0 failed
toml-test v2024-05-31 [C:\repo\repo.zig\plib\zig-out\bin\toml_decoder.exe]: using embedded tests
valid tests: 182 passed, 0 failed
invalid tests: 371 passed, 0 failed</code>
Add New Parser
Suppose you want to add a json parser (maybe not since it's included in std lib). You should:
1. Add <code>src/raw/json.abnf</code>, which contains json's abnf definition.
2. Run <code>zig build -Dstep=gen_abnf -Dname=json</code> to generate <code>src/gen/json.zig</code>.
3. Modify <code>zig.build</code> (and <code>zig.build.zong</code> if so desired) to build a <code>json</code> module.
4. Add <code>src/mod/json/root.zig</code>, which is the root source file of <code>json</code> module. See <a><code>src/mod/toml/root.zig</code></a> for example.
5. If you are using vscode, you might also want to modify <code>.vscode/tasks.json</code>.
Use As Dependency
In your <code>build.zig.zon</code> add:
<code>zig
.dependencies = .{
.plib = .{
.url = "https://github.com/Luna1996/abnf/archive/main.tar.gz",
},
},</code>
In your <code>build.zig</code> add:
<code>zig
const plib_dep = b.dependency("plib", .{.toml = true});
const plib_mod = plib_dep.module("plib");
const toml_mod = plib_dep.module("toml");
main_mod.addImport("plib", plib);
main_mod.addImport("plib", toml);</code>
In your project add:
<code>zig
const plib = @import("plib");
const toml = @import("toml");</code> | [] |
https://avatars.githubusercontent.com/u/337093?v=4 | v4l2capture | tetsu-koba/v4l2capture | 2023-04-20T06:00:48Z | v4l2 video capturer written in Zig | main | 3 | 6 | 2 | 6 | https://api.github.com/repos/tetsu-koba/v4l2capture/tags | MIT | [
"v4l2",
"video-streaming",
"zig"
] | 69 | false | 2025-04-17T20:34:45Z | true | false | unknown | github | [] | V4L2 video capturer written in Zig
Capture video frames from V4l2 camera device.
How to Build and Show Usage
<code>shell-session
$ zig version
0.11.0-dev.2777+b95cdf0ae
$ zig build
$ ./zig-out/bin/v4l2capture
Usage: ./zig-out/bin/v4l2capture /dev/videoX URL [width height framerate pixelformat max_frames]
URL is 'file://filename', 'tcp://hostname:port' or just filename.
Default width, height and framerate is 640x480@30fps
pixelformat is FourCC such as MJPG and YUYV. Defaut is MJPG.
max_frames is the number of frames to capture. Default is unlimited(0). Stop by Control-C.</code>
Save to local file
<code>shell-session
$ ./zig-out/bin/v4l2capture /dev/video0 out.mjpg 320 240 30
warning: Requested format is 320x240 but set to 320x180.
^Cinfo: 1682150185282:Got SIGINT
info: 1682150185304:duration 24769ms, frame_count 743, 30.00fps</code>
Stop the process by entering ^C at an appropriate point.
Although 320x240 was requested, the camera did not support it, so the message states that it has been changed to 320x180.
Playing the generated mjpg file
```shell-session
$ ffprobe out.mjpg
...
Input #0, jpeg_pipe, from 'out.mjpg':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mjpeg (Baseline), yuvj422p(pc, bt470bg/unknown/unknown), 320x180, 25 fps, 25 tbr, 25 tbn, 25 tbc
```
Although it shows 25fps here, this is incorrect. The default value for ffprobe when the frame rate is unknown is 25fps.
When playing this with ffplay, you need to explicitly specify the frame rate.
<code>shell-session
$ ffplay -framerate 30 out.mjpg</code>
Sending MJPEG over TCP and remote playback
With the update of 2023/04/24, MJPEG can now be sent over TCP.
On the receiver:
<code>shell-session
$ ffplay -hide_banner -autoexit "tcp://:8999?listen"</code>
On the sender:
<code>shell-session
$ zig-out/bin/v4l2capture /dev/video0 tcp://host:8999 320 240 15</code> | [] |
https://avatars.githubusercontent.com/u/136999807?v=4 | spoke | spoke-data/spoke | 2023-06-18T18:45:11Z | The universal data connector | main | 0 | 6 | 0 | 6 | https://api.github.com/repos/spoke-data/spoke/tags | MIT | [
"ai",
"data-engineering",
"db2",
"duckdb",
"duckdb-engine",
"etl",
"etl-framework",
"etl-pipeline",
"kafka",
"mariadb",
"ml-ops",
"mssql",
"mysql",
"odbc",
"oracle",
"postgres",
"sql",
"streaming",
"zig"
] | 4,128 | false | 2024-12-22T02:40:36Z | true | true | unknown | github | [
{
"commit": "1003b5cbfb3a745ec997327354d06cd0cc40bc41.tar.gz",
"name": "simargs",
"tar_url": "https://github.com/jiacai2050/simargs/archive/1003b5cbfb3a745ec997327354d06cd0cc40bc41.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/jiacai2050/simargs"
},
{
"commit": "7b2fe71322... | Spoke
The universal data connector <a>spoke.sh</a>.
A local first development environment that brings a git like experience to data engineering
and reactive applications.
Development
Start a <code>nix</code> dev shell
<code>shell
nix develop -c $SHELL</code>
Install npm package:
<code>shell
nix run .#ui.install</code>
Run the development server:
<code>shell
nix run .#ui.dev</code>
Open <a>http://localhost:3000</a> with your browser to see the result.
<code>shell
nix run .#ui.open</code>
Build the <code>spoke</code> binary
<code>shell
nix build .#build-fast --no-sandbox</code>
Run the <code>spoke</code> binary
<code>shell
nix run .#build-fast --no-sandbox</code>
Authors
<ul>
<li>Alex Kwiatkowski - alex+git@fremantle.io</li>
</ul>
License
<code>spoke</code> is released under the <a>MIT license</a> | [] |
https://avatars.githubusercontent.com/u/6756180?v=4 | xwin-zig-test | kassane/xwin-zig-test | 2023-06-21T18:50:06Z | Testing Zig with xwin - Microsoft CRT headers and libraries + Windows SDK headers and libraries | main | 0 | 6 | 0 | 6 | https://api.github.com/repos/kassane/xwin-zig-test/tags | BSD-3-Clause | [
"cross-compile",
"llvm",
"msvc",
"msvcrt",
"rust",
"ucrt",
"windows-sdk",
"xwin",
"zig"
] | 27 | false | 2025-05-21T16:58:29Z | true | false | unknown | github | [] | Zig with XWin (Experimental)
What is <a>xwin</a>?
A utility for downloading and packaging the Microsoft CRT headers and libraries, and Windows SDK headers and libraries needed for compiling and linking programs targeting Windows.
Note
It's important to remind that the libraries and headers are owned by Microsoft.
This experiment is for testing purposes only. Possibly to make it easier to build hermetically.
Requirements
<ul>
<li><a>xwin</a></li>
<li><a>zig 0.14.x or higher</a></li>
</ul>
Testing
The main targets for this experiment are:
| Target | Native | Build | Host |
| --- | --- | --- | --- |
| msvc-x64 | Yes | 🆗 | Windows |
| msvc-x64 | No | 🆗 | Linux |
| msvc-x64 | No | 🆗 | MacOS |
| msvc-x86 | Yes | 🆗 | Windows |
| msvc-x86 | No | 🆗 | Linux |
| msvc-x86 | No | 🆗 | MacOS |
| msvc-arm64 | Yes | 🆗 | Windows |
| msvc-arm64 | No | 🆗 | Linux |
| msvc-arm64 | No | 🆗 | MacOS |
<strong>Note:</strong> On linux the LLD is case-sensitive. maybe solve don't use <code>xwin</code> <code>--disable-symlinks</code> flag. However, it breaks the macos build! | [] |
https://avatars.githubusercontent.com/u/680789?v=4 | zodbc | rupurt/zodbc | 2024-02-01T17:08:59Z | A blazing fast ODBC Zig client | main | 0 | 6 | 2 | 6 | https://api.github.com/repos/rupurt/zodbc/tags | MIT | [
"apache-arrow",
"odbc",
"performance",
"zig"
] | 128 | false | 2024-09-25T15:27:49Z | true | true | 0.12.0 | github | [
{
"commit": "beff935fe77a0ed794e8727d48e7780485abb880.tar.gz",
"name": "zig-cli",
"tar_url": "https://github.com/sam701/zig-cli/archive/beff935fe77a0ed794e8727d48e7780485abb880.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/sam701/zig-cli"
}
] | zodbc
A blazing fast ODBC Zig client
```console
<blockquote>
zodbc -h
zodbc
</blockquote>
USAGE:
zodbc [OPTIONS]
COMMANDS:
sql
dump
load
tables
table-privileges
columns
column-privileges
special-columns
primary-keys
foreign-keys
statistics
data-sources
functions
procedures
procedure-columns
info
attrs
benchmark
OPTIONS:
-h, --help Prints help information
```
Goals
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Fastest ODBC C ABI client library for bulk load/unload
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Kernel thread worker pool concurrency per ODBC connection
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> High level Zig bindings
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> ODBC row & column bindings
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> ODBC Zig bindings
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> ODBC to Arrow record batch reader/writer
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> ODBC zero copy C ABI
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> High level C ABI
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Expose all ODBC API's
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Database benchmarks
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Python bindings
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Elixir bindings
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Java bindings
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> .NET bindings
Getting Started
<ul>
<li><a>Usage</a></li>
<li><a>Commands</a><ul>
<li><a>sql</a></li>
<li><a>dump</a></li>
<li><a>load</a></li>
<li><a>tables</a></li>
<li><a>table-privileges</a></li>
<li><a>columns</a></li>
<li><a>column-privileges</a></li>
<li><a>special-columns</a></li>
<li><a>primary-keys</a></li>
<li><a>foreign-keys</a></li>
<li><a>statistics</a></li>
<li><a>data-sources</a></li>
<li><a>functions</a></li>
<li><a>procedures</a></li>
<li><a>procedure-columns</a></li>
<li><a>info</a></li>
<li><a>attrs</a><ul>
<li><a>env</a></li>
<li><a>con</a></li>
</ul>
</li>
<li><a>benchmark</a></li>
</ul>
</li>
<li><a>Library</a></li>
<li><a>Nix</a></li>
<li><a>Development</a></li>
</ul>
Usage
<ol>
<li>Add <code>zodbc</code> as a dependency in your <code>build.zig.zon</code>
<code>zig
.{
.name = "<name_of_your_package>",
.version = "<version_of_your_package>",
.dependencies = .{
.zodbc = .{
.url = "https://github.com/rupurt/zodbc/archive/<git_tag_or_commit_hash>.tar.gz",
.hash = "<package_hash>",
},
},
}</code></li>
</ol>
Set <code><package_hash></code> to <code>12200000000000000000000000000000000000000000000000000000000000000000</code>, and Zig will provide the correct found value in an error message.
<ol>
<li>Add <code>zodbc</code> as a dependency module in your <code>build.zig</code>
<code>zig
// ...
const zodbc_dep = b.dependency("zodbc", .{ .target = target, .optimize = optimize });
exe.root_module.addImport("zodbc", zodbc_dep.module("zodbc"));</code></li>
</ol>
Development
```console
<blockquote>
nix develop -c $SHELL
```
</blockquote>
```console
<blockquote>
make
```
</blockquote>
```console
<blockquote>
make test
```
</blockquote>
```console
<blockquote>
make run
```
</blockquote>
```console
<blockquote>
make clean
```
</blockquote>
```console
<blockquote>
make build
```
</blockquote>
```console
<blockquote>
make run -- -h
make run -- sql -h
...
```
</blockquote>
```console
<blockquote>
make exec -- -h
make exec -- sql -h
```
</blockquote>
```console
<blockquote>
make compose.up
make compose.down
```
</blockquote>
License
<code>zodbc</code> is released under the <a>MIT license</a> | [] |
https://avatars.githubusercontent.com/u/135145066?v=4 | cron | dying-will-bullet/cron | 2023-06-05T05:25:50Z | Cron library for Zig | master | 1 | 6 | 3 | 6 | https://api.github.com/repos/dying-will-bullet/cron/tags | MIT | [
"cron",
"cron-expression-parser",
"cron-parser",
"cronjob",
"crontab",
"zig",
"ziglang"
] | 48 | false | 2025-04-23T09:38:20Z | true | true | unknown | github | [
{
"commit": "master",
"name": "datetime",
"tar_url": "https://github.com/frmdstryr/zig-datetime/archive/master.tar.gz",
"type": "remote",
"url": "https://github.com/frmdstryr/zig-datetime"
}
] | cron ⏳
<a></a>
<strong>NOTE: The minimum supported Zig version for the current master branch is 0.14.</strong>
This library aims to provide a way to parse crontab schedule entries and determine the next execution time.
Supported format
| Field Name | Mandatory | Allowed Values | Default Value | Allowed Special Characters |
| ------------ | --------- | --------------- | ------------- | -------------------------- |
| Seconds | No | 0-59 | 0 | * / , - |
| Minutes | Yes | 0-59 | N/A | * / , - |
| Hours | Yes | 0-23 | N/A | * / , - |
| Day of month | Yes | 1-31 | N/A | * / , - ? L |
| Month | Yes | 1-12 or JAN-DEC | N/A | * / , - |
| Day of week | Yes | 0-6 or SUN-SAT | N/A | * / , - ? L |
| Year | No | 1970-2099 | * | * / , - |
<em>W and # symbols are <strong>not</strong> supported.</em>
If your cron entry has 5 values, minutes-day of week are used, default seconds is and default year is appended.
If your cron entry has 6 values, minutes-year are used, and default seconds are prepended.
As such, only 5-7 value crontab entries are accepted (and mangled to 7 values, as necessary).
This library also supports the convenient aliases:
<ul>
<li>@yearly</li>
<li>@annually</li>
<li>@monthly</li>
<li>@weekly</li>
<li>@daily</li>
<li>@hourly</li>
</ul>
To learn more about cron, visit <a>crontab.guru</a>.
Examples
The following example demonstrates how to use cron to build a simple scheduler.
```zig
const std = @import("std");
const Cron = @import("cron").Cron;
const datetime = @import("datetime").datetime;
fn job1(i: usize) !void {
const now = datetime.Datetime.now();
<code>var buf: [64]u8 = undefined;
const dt_str = try now.formatISO8601Buf(&buf, false);
std.log.info("{s} {d}th execution", .{ dt_str, i });
</code>
}
pub fn main() !void {
var c = Cron.init();
// At every minute.
try c.parse("<em>/1 * * * </em>");
<code>for (0..5) |i| {
const now = datetime.Datetime.now();
// Get the next run time
const next_dt = try c.next(now);
const duration = next_dt.sub(now);
// convert to nanoseconds
const nanos = duration.totalSeconds() * std.time.ns_per_s + duration.nanoseconds;
// wait next
std.time.sleep(@intCast(nanos));
try job1(i + 1);
}
</code>
}
```
Installation For Zig 0.14
Please refer to the latest Zig package documentation.
<code>zig fetch --save=cron git+https://github.com/dying-will-bullet/cron#master</code>
<code>zig fetch --save=datetime git+https://github.com/frmdstryr/zig-datetime?ref=master#b8dcd4948ac1dc29694a4d79794921121426981b</code>
Installation For Zig 0.11
Because <code>cron</code> needs to be used together with <code>datetime</code>, you need to add both of the following dependencies in <code>build.zig.zon</code>:
<code>.{
.name = my_project,
.version = "0.1.0",
.fingerprint = xxxxxxxxxxxxxxx,
.dependencies = .{
.cron = .{
.url = "https://github.com/dying-will-bullet/cron/archive/refs/tags/v0.2.0.tar.gz",
.hash = "1220f3f1e6659f434657452f4727889a2424c1b78ac88775bd1f036858a1e974ad41",
},
.datetime = .{
.url = "https://github.com/frmdstryr/zig-datetime/archive/ddecb4e508e99ad6ab1314378225413959d54756.tar.gz",
.hash = "12202cbb909feb6b09164ac997307c6b1ab35cb05a846198cf41f7ec608d842c1761",
},
},
}</code>
Add them in <code>build.zig</code>:
```diff
diff --git a/build.zig b/build.zig
index 60fb4c2..0255ef3 100644
--- a/build.zig
+++ b/build.zig
@@ -15,6 +15,9 @@ pub fn build(b: *std.Build) void {
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});
<ul>
<li>const opts = .{ .target = target, .optimize = optimize };</li>
<li>const cron_module = b.dependency("cron", opts).module("cron");</li>
<li>const datetime_module = b.dependency("datetime", opts).module("zig-datetime");
+
const exe = b.addExecutable(.{
.name = "m",
// In this case the main source file is merely a path, however, in more
@@ -23,6 +26,7 @@ pub fn build(b: *std.Build) void {
.target = target,
.optimize = optimize,
});</li>
<li>exe.addModule("cron", cron_module);</li>
<li>
exe.addModule("datetime", datetime_module);
// This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default
```
</li>
</ul>
API
<code>parse(input: []const u8) !void</code>
<ul>
<li>Params:</li>
<li><code>input</code>: The cron string to parse.</li>
<li>Returns: void.</li>
</ul>
<code>next(now: datetime.Datetime) !datetime.Datetime</code>
<ul>
<li>Params:</li>
<li><code>now</code>: It will use this datetime as the starting for calculations.</li>
<li>Returns: next execution datetime.</li>
</ul>
<code>previous(now: datetime.Datetime) !datetime.Datetime</code>
<ul>
<li>Params:</li>
<li><code>now</code>: It will use this datetime as the starting for calculations.</li>
<li>Returns: previous execution datetime.</li>
</ul>
LICENSE
MIT License Copyright (c) 2023, Hanaasagi | [] |
https://avatars.githubusercontent.com/u/15014128?v=4 | cetech1 | cyberegoorg/cetech1 | 2023-09-30T09:31:29Z | Yet another experimental game engine but now in Zig. Reincarnation of https://github.com/cyberegoorg/cetech | main | 0 | 6 | 0 | 6 | https://api.github.com/repos/cyberegoorg/cetech1/tags | WTFPL | [
"cetech1",
"experimental",
"game-engine",
"zig"
] | 43,182 | false | 2025-04-07T18:20:17Z | true | true | 0.14.0 | github | [
{
"commit": null,
"name": "cetech1",
"tar_url": null,
"type": "relative",
"url": "public/"
},
{
"commit": null,
"name": "editor",
"tar_url": null,
"type": "relative",
"url": "modules/editor/editor"
},
{
"commit": null,
"name": "editor_asset",
"tar_url": nu... | CETech 1
<a></a>
<a></a>
Yet another experimental game engine but now in <a>zig</a>.
<blockquote>
<span class="bg-green-100 text-green-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-green-900 dark:text-green-300">IMPORTANT</span>
Work in progressssssssssssss
</blockquote>
<a>Getting started</a>
<a>Documentation</a> | [
"https://github.com/cyberegoorg/cetech1"
] |
https://avatars.githubusercontent.com/u/41730?v=4 | temp.zig | abhinav/temp.zig | 2024-01-21T15:34:42Z | Create temporary files and directories | main | 1 | 6 | 3 | 6 | https://api.github.com/repos/abhinav/temp.zig/tags | BSD-3-Clause | [
"zig"
] | 28 | false | 2025-03-06T06:07:23Z | true | true | unknown | github | [] | 🗑️ temp.zig <a></a> <a></a>
Cross-platform temporary files and directories in Zig.
Features
<ul>
<li>Temporary files and directories in any location</li>
<li>Retain temporary artifacts on an opt-in basis</li>
<li>Customize naming schemes</li>
</ul>
Supported operating systems:
Unix-like systems and Windows.
API reference
Auto-generated API Reference for the library is available at
<a>https://abhinav.github.io/temp.zig/</a>.
Note that Zig's autodoc is currently in beta.
Some links may be broken in the generated website.
Installation
Use <code>zig fetch --save</code> to pull a version of the library
into your build.zig.zon.
(This requires at least Zig 0.11.)
<code>bash
zig fetch --save "https://github.com/abhinav/temp.zig/archive/0.3.0.tar.gz"</code>
Then, import the dependency in your build.zig:
```zig
pub fn build(b: *std.Build) void {
// ...
<code>const temp = b.dependency("temp", .{
.target = target,
.optimize = optimize,
});
</code>
```
And add it to the artifacts that need it:
<code>zig
const exe = b.addExecutable(.{
// ...
});
exe.root_module.addImport("temp", temp.module("temp"));</code>
License
This software is made available under the BSD3 license. | [] |
https://avatars.githubusercontent.com/u/12962448?v=4 | tgz | star-tek-mb/tgz | 2023-05-29T19:30:15Z | telegram bot library for zig | master | 0 | 6 | 0 | 6 | https://api.github.com/repos/star-tek-mb/tgz/tags | - | [
"telegram-bot",
"zig"
] | 74 | false | 2025-04-15T00:19:50Z | true | false | unknown | github | [] | Overview
tgz - zig library for telegram bots
Goals
<ul>
<li>
be fast at runtime
</li>
<li>
be fast at comptime
</li>
</ul>
Zig's current http/https client API is unstable. And also requires a lot of time to compile.
Initial idea was to parse JSON to structs, but it have been hurting compile time.
So decision was made to dot access to fields of json.
If we have following json:
<code>json
{
"ok": true,
"result": [
{
"name": "string",
}
]
}</code>
You can query like this:
<code>"ok" - true
"result" - length of array
"result.0" - length of object
"result.0.name" - "string"</code>
Usage
<code>zig
// do request without caring of response
try bot.do("sendPhoto", .{
.chat_id = chat_id,
.photo = File{photo},
.caption = text,
});
// do request and get json data
var res = try bot.method("getMe", .{});
defer res.deinit();
var is_bot = try res.dot(bool, "result.is_bot");</code>
Example
See <code>main.zig</code> | [] |
https://avatars.githubusercontent.com/u/5464072?v=4 | zig-iso-639-languages | nektro/zig-iso-639-languages | 2023-11-01T04:52:15Z | Zig package for ISO 639 Language codes | master | 0 | 5 | 0 | 5 | https://api.github.com/repos/nektro/zig-iso-639-languages/tags | 0BSD | [
"zig",
"zig-package"
] | 11 | false | 2025-05-21T20:33:16Z | true | false | unknown | github | [] | zig-iso-639-languages
<a></a>
<a></a>
<a></a>
<a></a>
ISO 639 Language codes
https://www.iso.org/iso-639-language-codes.html | [] |
https://avatars.githubusercontent.com/u/3117019?v=4 | imaginarium | Khitiara/imaginarium | 2024-01-18T00:03:26Z | OSDev Experiments In Zig | main | 0 | 5 | 0 | 5 | https://api.github.com/repos/Khitiara/imaginarium/tags | MPL-2.0 | [
"bootboot",
"osdev",
"zig"
] | 1,479 | false | 2025-05-19T01:19:16Z | true | true | unknown | github | [
{
"commit": null,
"name": "zuid",
"tar_url": null,
"type": "relative",
"url": "libs/zuid/"
},
{
"commit": "master",
"name": "limine",
"tar_url": "https://github.com/limine-bootloader/limine/archive/master.tar.gz",
"type": "remote",
"url": "https://github.com/limine-bootlo... | imaginarium
OSDev Experiments In Zig | [] |
https://avatars.githubusercontent.com/u/124872?v=4 | forro | jedisct1/forro | 2023-05-29T21:34:31Z | Forró : ARX-based cipher with faster diffusion than ChaCha. | master | 0 | 5 | 2 | 5 | https://api.github.com/repos/jedisct1/forro/tags | NOASSERTION | [
"arx",
"chacha20",
"cipher",
"forro",
"salsa20",
"zig",
"zig-package"
] | 7 | false | 2025-04-17T23:55:14Z | true | false | unknown | github | [] | Forró cipher
Forró is an ARX-based cipher, similar to Salsa and ChaCha, but with faster diffusion.
Ref: <a>Latin Dances Reloaded: Improved Cryptanalysis Against Salsa and ChaCha, and the Proposal of Forró</a>
This is an implementation for Zig. | [] |
https://avatars.githubusercontent.com/u/124872?v=4 | zig-ascon | jedisct1/zig-ascon | 2023-03-01T21:19:53Z | Ascon AEAD in Zig. | master | 0 | 5 | 0 | 5 | https://api.github.com/repos/jedisct1/zig-ascon/tags | - | [
"aead",
"ascon",
"ascon128a",
"crypto",
"nist",
"zig",
"zig-package"
] | 2 | false | 2025-04-17T23:55:41Z | true | false | unknown | github | [] | Ascon128a AEAD for Zig
Ascon is the winner of the NIST lightweight crypto competition, and is being standardized by NIST.
Does it make sense to use it on desktop/server-class CPUs? It does. When running WebAssembly.
On WebAssembly, it is significantly faster than ChaChaPoly, and doesn't have any of the side channels issues that AES-based ciphers commonly have.
Plus, it's small. And blessed by NIST. | [] |
https://avatars.githubusercontent.com/u/96352918?v=4 | wwise-zig | Cold-Bytes-Games/wwise-zig | 2023-05-23T19:24:46Z | Zig bindings to Audiokinetic Wwise | v2023.1 | 2 | 5 | 0 | 5 | https://api.github.com/repos/Cold-Bytes-Games/wwise-zig/tags | NOASSERTION | [
"audiokinetic-wwise",
"wwise",
"zig",
"zig-package"
] | 626 | false | 2024-07-02T20:01:06Z | true | true | unknown | github | [] | wwise-zig - Zig bindings to Audiokinetic Wwise (2023.1.9)
This package implement a native <a>Zig</a> binding for <a>Audiokinetic Wwise</a>. The included C binding is designed only to be used by the Zig binding. If you want to expand the C binding to be fully functional please submit any pull requests.
Each function name, structs and enums has been renamed to fit the Zig coding style. It should be easy to map to the <a>Wwise SDK documentation</a>.
Each major version of Wwise is contained within a branch. Select the correct branch and tag when importing the library with the Zig package manager.
The library assumes that you installed Wwise using the Wwise Launcher. We do not distribute any binary from Audiokinetic.
This is a 3rd party binding and it is not affiliated with Audiokinetic.
<a></a>
Zig version
This library uses zig nominated <a>2024.11.0-mach</a>. To install using <a><code>zigup</code></a>:
<code>sh
zigup 0.14.0-dev.2577+271452d22</code>
Versioning info
This binding mimic the versioning of Wwise but add the Zig binding version at the end.
Example:
2023.1.1-zig1
<ul>
<li>2023 = year</li>
<li>1 = major Wwise version</li>
<li>1 = minor Wwise version</li>
<li>-zig1 = Zig binding version</li>
</ul>
Supported platforms
| Platform | Architecture | Tested |
| -- | -- | -- |
| Windows | x86 (msvc ABI only) | ❌ |
| Windows | x86-64 (msvc ABI only) | ✅ |
| Linux | x86-64 | ✅ |
| Linux | aarch64 | ❌ |
| Android | arm64 | ❌ |
| Android | arm | ❌ |
| Android | x86 | ❌ |
| Android | x86-64 | ❌ |
| Mac | Universal (x86-64 and aarch64) | ❌ |
| iOS | | ❌ |
| tvOS | | ❌ |
<ul>
<li>On Windows, the default GNU ABI is not supported, always use the MSVC ABI</li>
<li>On Windows, we always use the latest supported Visual Studio (currently 2022)</li>
<li>No support for consoles yet</li>
</ul>
Import it in your project
<ol>
<li>Add this repo in your <code>build.zig.zon</code> file, you'll need to add the hash and update the commit hash to the latest commit in the branch
<code>zig
.@"wwise-zig" = .{
.url = "https://github.com/Cold-Bytes-Games/wwise-zig/archive/90cdc6877369b55af3ee2dfcf091dc547ed59f03.tar.gz",
.hash = "122053d2ec67ebe8a47b45ac32ddf41283b27c3519196b6730d9b826a463d1294299",
},</code></li>
<li>Import the dependency in your <code>build.zig</code>. See the Usage section for the list of available options.</li>
</ol>
```zig
const std = @import("std");
const wwise_zig = @import("wwise-zig");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
<code>const wwise_dependency = b.dependency("wwise-zig", .{
.target = target,
.optimize = optimize,
.use_communication = true,
.use_default_job_worker = true,
.use_spatial_audio = true,
.use_static_crt = true,
.include_file_package_io_blocking = true,
.configuration = .profile,
.static_plugins = @as([]const []const u8, &.{
"AkToneSource",
"AkParametricEQFX",
"AkDelayFX",
"AkPeakLimiterFX",
"AkRoomVerbFX",
"AkStereoDelayFX",
"AkSynthOneSource",
"AkAudioInputSource",
"AkVorbisDecoder",
}),
});
const exe = b.addExecutable(.{
.name = "wwise-zig-demo",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("wwise-zig", wwise_dependency.module("wwise-zig"));
</code>
}
```
Usage
Available options:
| Option | Values | Description |
| -- | -- | -- |
| <code>wwise_sdk</code> | <code>[]const u8</code> | Override the path to the Wwise SDK, by default it will use the path in environment variable WWISESDK |
| <code>configuration</code> | debug, profile, release | Which library configuration of Wwise to use (Default: profile) |
| <code>use_static_crt</code> | <code>bool</code> | On Windows, do you want to use the StaticCRT build of Wwise (Default: true) |
| <code>use_communication</code> | <code>bool</code> | Enable remote communication with Wwise Authoring. Disabled by default on Release configuration so you can leave it true at all time (Default: true) |
| <code>use_default_job_worker</code> | <code>bool</code> | Enable usage of the default job worker given by Audiokinetic. (Default: false) |
| <code>use_spatial_audio</code> | <code>bool</code> | Enable usagee of the Spatial Audio module (Default: false) |
| <code>string_stack_size</code> | <code>usize</code> | Stack size to use for functions that accepts AkOsChar and null-terminated strings (Default: 256) |
| <code>include_default_io_hook_deferred</code> | <code>bool</code> | Include the Default IO Hook Deferred (Default: false) |
| <code>include_file_package_io_deferred</code> | <code>bool</code> | Include the File Package IO Hook Deferred (Default: false) |
| <code>static_plugins</code> | []const []const u8 | List of static plugins to link to (Default: empty) |
We recommend using <code>AK</code> as your import name to match closely with the C++ API.
```zig
const AK = @import("wwise-zig");
pub fn main() !void {
var memory_settings: AK.AkMemSettings = undefined;
AK.MemoryMgr.getDefaultSettings(&memory_settings);
<code>try AK.MemoryMgr.init(&memory_settings);
defer AK.MemoryMgr.term();
</code>
}
```
You can also look at the Integration Demo ported to Zig here for how the API is used in a sample application: https://github.com/Cold-Bytes-Games/wwise-zig-demo
Handling AkOsChar and C null-terminated strings
<code>wwise-zig</code> is trying to save allocations when calling functions that accepts strings by using stack-allocated space to convert to <code>const AkOsChar*</code>/<code>const char*</code> or use a fallback allocator if the string is bigger than the stack size.
You can customize the size allocated by modifying the <code>string_stack_size</code> when importing the dependency.
Each function that handle strings looks similar to this:
```zig
pub fn dumpToFile(fallback_allocator: std.mem.Allocator, filename: []const u8) !void {
var stack_char_allocator = common.stackCharAllocator(fallback_allocator);
var allocator = stack_char_allocator.get();
<code>const filename_oschar = try common.toOSChar(allocator, filename);
defer allocator.free(filename_oschar);
c.WWISEC_AK_MemoryMgr_DumpToFile(filename_oschar);
</code>
}
```
Handling C++ inheritance
You can create derivated Zig struct from Wwise C++ clases that have virtual methods. Each binded class has a <code>FunctionTable</code> object like <code>IAkIOHookDeferredBatch</code> here:
<code>zig
pub const IAkIOHookDeferredBatch = opaque {
pub const FunctionTable = extern struct {
destructor: *const fn (self: *IAkIOHookBlocking) callconv(.C) void,
close: *const fn (self: *IAkIOHookBlocking, in_file_desc: *AkFileDesc) callconv(.C) common.AKRESULT,
get_block_size: *const fn (self: *IAkIOHookBlocking, in_file_desc: *AkFileDesc) callconv(.C) u32,
get_device_desc: *const fn (self: *IAkIOHookBlocking, out_device_desc: *stream_interfaces.NativeAkDeviceDesc) callconv(.C) void,
get_device_data: *const fn (self: *IAkIOHookBlocking) callconv(.C) u32,
batch_read: *const fn (
self: *IAkIOHookDeferredBatch,
in_num_transfers: u32,
in_transfer_items: [*]BatchIoTransferItem,
in_batch_io_callback: AkBatchIOCallback,
io_dispatch_results: [*]common.AKRESULT,
) callconv(.C) common.AKRESULT,
batch_write: *const fn (
self: *IAkIOHookDeferredBatch,
in_num_transfers: u32,
in_transfer_items: [*]BatchIoTransferItem,
in_batch_io_callback: AkBatchIOCallback,
io_dispatch_results: [*]common.AKRESULT,
) callconv(.C) common.AKRESULT,
batch_cancel: *const fn (
self: *IAkIOHookDeferredBatch,
in_num_transfers: u32,
in_transfer_items: [*]BatchIoTransferItem,
io_cancel_all_transfers_for_this_file: [*]*bool,
) callconv(.C) void,
};
}</code>
On the glue side, we inherit from the interface and call those functions with the instance of your Zig struct.
Each class has a method <code>createInstance()</code> and <code>destroyInstance</code> that are used to create an instance of your own derivated struct. It uses AK memory manager function to allocate the instance with the <code>AkMemID_Integration</code> memory tag.
<code>zig
var zig_io_blocking = ZigTestIAkOHookBlocking{};
var native_io_blocking = AK.StreamMgr.IAkIOHookBlocking.createInstance(
&zig_io_blocking,
&AK.StreamMgr.IAkIOHookBlocking.FunctionTable{
.destructor = @ptrCast(&ZigTestIAkOHookBlocking.destructor),
.close = @ptrCast(&ZigTestIAkOHookBlocking.close),
.get_block_size = @ptrCast(&ZigTestIAkOHookBlocking.getBlockSize),
.get_device_desc = @ptrCast(&ZigTestIAkOHookBlocking.getDeviceDesc),
.get_device_data = @ptrCast(&ZigTestIAkOHookBlocking.getDeviceData),
.read = @ptrCast(&read),
.write = @ptrCast(&write),
},
);
defer AK.StreamMgr.IAkIOHookBlocking.destroyInstance(native_io_blocking);</code>
However we recommend creating a helper function in your struct to create the correct instance with the function table properly filled.
Here's a quick sample of a derivated <code>IAkOHookBlocking</code> struct from our test suite:
```zig
const ZigTestIAkOHookBlocking = struct {
destructor_called: bool = false,
close_called: bool = false,
get_block_size_called: bool = false,
get_device_desc_called: bool = false,
get_device_data_called: bool = false,
read_called: bool = false,
write_called: bool = false,
close_size: i64 = 0,
<code>pub fn destructor(self: *ZigTestIAkOHookBlocking) callconv(.C) void {
self.destructor_called = true;
}
pub fn close(self: *ZigTestIAkOHookBlocking, in_file_desc: *AK.StreamMgr.AkFileDesc) callconv(.C) AK.AKRESULT {
self.close_size = in_file_desc.file_size;
self.close_called = true;
return .success;
}
pub fn getBlockSize(self: *ZigTestIAkOHookBlocking, in_file_desc: *AK.StreamMgr.AkFileDesc) callconv(.C) u32 {
_ = in_file_desc;
self.get_block_size_called = true;
return 512;
}
pub fn getDeviceDesc(self: *ZigTestIAkOHookBlocking, out_device_desc: *AK.NativeAkDeviceDesc) callconv(.C) void {
self.get_device_desc_called = true;
var zig_device_desc = AK.AkDeviceDesc{};
zig_device_desc.can_write = false;
zig_device_desc.can_read = true;
zig_device_desc.device_name = "wwise-zig IO";
out_device_desc.* = zig_device_desc.toC() catch unreachable;
}
pub fn getDeviceData(self: *ZigTestIAkOHookBlocking) callconv(.C) u32 {
self.get_device_data_called = true;
return 4269;
}
pub fn read(self: *ZigTestIAkOHookBlocking, in_file_desc: *AK.StreamMgr.AkFileDesc, in_heuristics: *AK.StreamMgr.AkIoHeuristics, out_buffer: ?*anyopaque, in_transfer_info: *AK.StreamMgr.AkIOTransferInfo) callconv(.C) AK.AKRESULT {
_ = in_file_desc;
_ = in_heuristics;
self.read_called = true;
if (out_buffer) |checked_buffer| {
var read_buffer = @as([*]u8, @ptrCast(checked_buffer));
@memset(read_buffer[in_transfer_info.file_position..in_transfer_info.requested_size], 0xC1);
}
return .success;
}
pub fn write(self: *ZigTestIAkOHookBlocking, in_file_desc: *AK.StreamMgr.AkFileDesc, in_heuristics: *AK.StreamMgr.AkIoHeuristics, in_data: ?*anyopaque, in_transfer_info: *AK.StreamMgr.AkIOTransferInfo) callconv(.C) AK.AKRESULT {
_ = in_heuristics;
_ = in_transfer_info;
_ = in_data;
_ = in_file_desc;
self.write_called = true;
return .success;
}
pub fn createIAkIOHookBlocking(self: *ZigTestIAkOHookBlocking) *AK.StreamMgr.IAkIOHookBlocking {
return AK.StreamMgr.IAkIOHookBlocking.createInstance(
self,
&AK.StreamMgr.IAkIOHookBlocking.FunctionTable{
.destructor = @ptrCast(&destructor),
.close = @ptrCast(&close),
.get_block_size = @ptrCast(&getBlockSize),
.get_device_desc = @ptrCast(&getDeviceDesc),
.get_device_data = @ptrCast(&getDeviceData),
.read = @ptrCast(&read),
.write = @ptrCast(&write),
},
);
}
</code>
};
```
Use the default I/O hook(s) from the SDK
First you need to include at least one I/O hook in the build options.
All the default I/O are included in the IOHooks namespace from the <code>wwise-zig</code> package.
Use the <code>create</code> and <code>destroy</code> function with a Zig allocator to create a instance of the I/O hook.
After that, you need to call <code>init</code> and <code>setBasePath</code> like in C++
```zig
const std = @import("std");
const AK = @import("wwise-zig");
pub fn main() !void {
var io_hook = try AK.IOHooks.CAkFilePackageLowLevelIODeferred.create(std.testing.allocator);
defer io_hook.destroy(std.testing.allocator);
<code>try io_hook.init(device_settings, false);
defer io_hook.term();
try io_hook.setBasePath(std.testing.allocator, ".");
const loaded_package_id = try io_hook.loadFilePackage(std.testing.allocator, "MyWwiseData.pck");
</code>
}
```
Generate the Sound Banks with the Zig build system
We are bundling a build step to generate the sound banks. To use it:
1. Include the wwise-zig dependency in youtr <code>build.zig.zon</code> file.
1. Import the wwise-zig module in your <code>build.zig</code>.
1. Call <code>addGenerateSooundBanksStep()</code> and pass the <code>std.Build</code> instance and some optioons.
1. After that, it is recommended that you add the generate sound banks steps as a dependency of your compile step.
Options available:
| Option | Values | Description |
| -- | -- | -- |
| <code>override_wwise_sdk_path</code> | <code>[]const u8</code> | Override the path of the Wwise SDK, if not it will use the WWISESDK environment variable |
| <code>platforms</code> | <code>[]const WwisePlatform</code> | Explicit list the platforms you want to generate the sound banks, if nothing specified, all the platforms will be generated |
| <code>languages</code> | <code>[]const []const u8</code> | Explicit list of the languages to generate, if not specified it will build all the languages |
| <code>target</code> | <code>std.zig.CrossTarget</code> | Instead of passing the platforms, you can use the target from Zig |
| <code>output_folder</code> | <code>[]const u8</code> | Output folder of the sound banks, will use the default in the project if omitted |
| <code>sound_banks</code> | <code>[]const []const u8</code> | List of sound banks to generate, if not specified it will build all the sound banks |
| <code>root_output_path</code> | <code>[]const u8</code> | Overrides the root output path specified in the soundbank settings|
Example:
```zig
const std = @import("std");
const wwise_zig = @import("wwise-zig");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
<code>const build_soundbanks_step = try wwise_zig.addGenerateSoundBanksStep(b, "WwiseProject/IntegrationDemo.wproj", .{
.target = target,
});
const exe = b.addExecutable(.{
.name = "wwise-zig-demo",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
exe.step.dependOn(&build_soundbanks_step.step);
// [...]
</code>
}
```
Generate a zig module with Wwise ID
If specified in the Wwise project settings, you can generate a C header file that contains all the unique ID of your events, soundbanks, states, switch, game parameters. We include a way to parse that header file and generate a Zig module on the fly.
You need to pass the main <code>wwise-zig</code> module to the function because we use <code>AkUniqueID</code> from the main module.
It is recommended that you add a dependency to the generated sound banks step if you use it in your <code>build.zig</code> file.
```zig
const std = @import("std");
const wwise_zig = @import("wwise-zig");
pub fn build(b: *std.Build) !void {
// [...]
const wwise_id_module = wwise_zig.generateWwiseIDModule(b, "WwiseProject/GeneratedSoundBanks/Wwise_IDs.h", wwise_package.module, .{
.previous_step = &build_soundbanks_step.step,
});
<code>exe.addModule("wwise-ids", wwise_id_module);
</code>
```
License
See LICENSE for more info. | [] |
https://avatars.githubusercontent.com/u/121278?v=4 | servers-benchmark | diegopacheco/servers-benchmark | 2023-09-19T07:47:18Z | 🚀 Servers Benchmark: Simple POC to benchmark servers and languages. | main | 0 | 5 | 19 | 5 | https://api.github.com/repos/diegopacheco/servers-benchmark/tags | Unlicense | [
"benchmark",
"bun",
"clojure",
"cpp",
"deno",
"elixr-lang",
"go",
"graalvm",
"haskell",
"java",
"java-21",
"julia",
"nim",
"nodejs",
"performance",
"python",
"ruby",
"rust",
"v",
"zig"
] | 26,159 | false | 2024-09-27T02:24:26Z | false | false | unknown | github | [] | 🚀 Servers Benchmark
<ul>
<li>1 - Java 20 - Tomcat 10.1</li>
<li>2 - Java 20 - Netty 4</li>
<li>3 - Java 20 - Netty 4 Reactive</li>
<li>4 - Java 21 - Netty 4 - GraalVM 21 - Boot 3x</li>
<li>5 - Java 20 - Undertow</li>
<li>6 - Java 20 - Micronaut</li>
<li>7 - Java 20 - Quarkus</li>
<li>8 - Java 21 - Smart Http</li>
<li>9 - Java 21 - nio-iouring</li>
<li>10 - Kotlin 1.9 - Ktor</li>
<li>11 - NodeJS 20 -Express</li>
<li>12 - Deno 1.37 - Fresh</li>
<li>13 - Bun 1.0 - Elysia</li>
<li>14 - Bun 1.0 - Hono </li>
<li>15 - Python 3.11 - Twisted</li>
<li>16 - Python 3.11 - Tornado</li>
<li>17 - V 0.4 - pico</li>
<li>18 - C++ - Drogon</li>
<li>19 - Go 1.21 - net/http</li>
<li>20 - Rust 1.71 - Actix</li>
<li>21 - Rust 1.71 - Axum</li>
<li>22 - Rust 1.71 - may_minihttp</li>
<li>23 - Zig 0.11 - Zap</li>
<li>24 - Julia 1.8.5 - Genie</li>
<li>25 - Nim 2 - httpbeast</li>
<li>26 - Ocaml 5.1 - http_async</li>
<li>27 - PHP 8.1 - embedded server</li>
<li>28 - PHP 8.1 - Nginx</li>
<li>29 - Scala 3.0 - JDK 21 - Zio Http</li>
<li>30 - Scala 3.0 - JDK 21 - Play 2.9</li>
<li>31 - Scala 3.0 - JDK 21 - Akka-Http</li>
</ul>
🚀 Servers Benchmark - Contributions
<ul>
<li>1 - Rust 1.71 - Hyper <a>(@andreixmartins)</a></li>
<li>2 - Lua 5.4 - Pegasus <a>(@andreixmartins)</a></li>
<li>3 - Ruby 3.2 - TCP <a>(@andreixmartins)</a></li>
<li>4 - Java 21 - default HTTP Server <a>(@alex-carvalho)</a></li>
<li>5 - Bun http - <a>(@mrarticuno)</a></li>
<li>6 - Bun http workers - <a>(@mrarticuno)</a></li>
<li>7 - Nodejs 20 http - <a>(@mrarticuno)</a></li>
<li>8 - Nodejs 20 http workers - <a>(@mrarticuno)</a></li>
<li>9 - Python 3.11 Flask - <a>(@rRickson)</a></li>
<li>10 - Python 3.11 fast-api-uvicorn - <a>(@rRickson)</a></li>
<li>11 - Python 3.11 fast-api-hypercorn - <a>(@rRickson)</a></li>
<li>12 - Java 21 - Quarkus Reactive - <a>(@dadpig)</a></li>
<li>13 - Dart 3.1 - Shelf - <a>(@brscherer)</a></li>
<li>14 - Java 17 - Quarkus Native - Mandrel Podman <a>(@andremayer)</a></li>
<li>15 - Clojure 1.11 - Ring/Jetty - <a>(@deividfsantos)</a></li>
<li>16 - Haskell Scotty - <a>(@deividfsantos)</a></li>
<li>17 - Elixir - Phoenix/Cowboy - <a>(@deividfsantos)</a></li>
<li>18 - C - <a>(@Thorugoh)</a></li>
<li>19 - Racket - Spin <a>(@kilpp)</a></li>
<li>20 - Crystal 1.9.2 - Spider - <a>(@LucasKonrath)</a></li>
<li>21 - Java 8 - Blade - <a>(@LucasKonrath)</a></li>
<li>22 - Gleam - Mist - <a>(@LucasKonrath)</a></li>
<li>23 - Rust 1.7.1 - Gotham - <a>(@andreixmartins)</a></li>
<li>24 - Rust 1.72.1 - Salvo <a>(@andremayer)</a></li>
<li>25 - Rust 1.74.0-nightly - xitca <a>(@andremayer)</a></li>
<li>26 - Haskell - Warp <a>(@brunohaetinger)</a></li>
<li>27 - Kotlin -Http4k <a>(@codegik)</a></li>
</ul>
Gatling reports 📈
<ul>
<li><a>Boot Netty 4</a></li>
<li><a>Boot Mono Netty 4</a></li>
<li><a>Boot Mono Netty 4 V2</a></li>
<li><a>Java 21 - Boot 3x Netty 4 - GraalVM 21</a></li>
<li><a>Boot Tomcat 10.1</a></li>
<li><a>Boot Undertow</a></li>
<li><a>Micronaut</a></li>
<li><a>Quarkus</a></li>
<li><a>Java 21 - Smart Http</a></li>
<li><a>Java 21 - nio-iouring</a></li>
<li><a>Kotlin 1.9 Ktor (Netty) </a></li>
<li><a>NodeJS 20 Express</a></li>
<li><a>Deno Fresh</a></li>
<li><a>Bun 1 Elysia</a></li>
<li><a>Bun 1 Hono</a> </li>
<li><a>V 0.4 pico</a></li>
<li><a>Python 3.11 Twisted</a></li>
<li><a>Python 3.11 Tornado</a></li>
<li><a>Go 1.21</a></li>
<li><a>C++ Drogon 3x</a></li>
<li><a>Rust 1.71 Actix</a></li>
<li><a>Rust 1.71 Axum</a></li>
<li><a>Rust 1.71 may_minihttp</a></li>
<li><a>Zig 0.11 Zap</a></li>
<li><a>Julia 1.8.5 Genie</a></li>
<li><a>Nim 2 - httpbeast</a></li>
<li><a>Ocaml 5 - http_async</a></li>
<li><a>PHP 8.1 - Embedded Server</a></li>
<li><a>PHP 8.1 - Nginx</a></li>
<li><a>Scala 3.0 - JDK 21 - Zio Http</a></li>
<li><a>Scala 3.0 - JDK 21 - Play 2.9</a></li>
<li><a>Scala 3.0 - JDK 21 - Akka Http</a></li>
</ul>
Gatling reports - Contributions 📈
<ul>
<li><a>Rust 1.71 Hyper</a></li>
<li><a>Lua 5.4 Pegasus</a></li>
<li><a>Ruby TCP</a></li>
<li><a>Java 21 - Default HTTP Server</a></li>
<li><a>Bun http</a></li>
<li><a>Bun http workers</a></li>
<li><a>Nodejs 20 http</a></li>
<li><a>Nodejs 20 http workers</a></li>
<li><a>Python 3.11 Flask</a></li>
<li><a>Python 3.11 fast-api-uvicorn</a></li>
<li><a>Python 3.11 fast-api-hypercorn</a></li>
<li><a>Java 21 - Quarkus Reactive</a></li>
<li><a>Dart 3 - Shelf</a></li>
<li><a>Java 17 - Quarkus Native - Mandrel Podman</a></li>
<li><a>Clojure 1.11 - Ring/Jetty</a></li>
<li><a>Haskell Scotty</a></li>
<li><a>Elixir - Phoenix/Cowboy</a> </li>
<li><a>C</a></li>
<li><a>Racket - Spin</a></li>
<li><a>Crystal 1.9.2 - Spider</a></li>
<li><a>Java 8 - Blade</a></li>
<li><a>Gleam - Mist</a></li>
<li><a>Rust 1.7.1 - Gotham</a></li>
<li><a>Rust 1.72.1 - Salvo</a></li>
<li><a>Rust 1.74.0-nightly (ca62d2c44 2023-09-30) - Xitca</a></li>
<li><a>Haskell - Warp</a></li>
<li><a>Kotlin - Http4k</a></li>
</ul>
Throwing a little bit of Salt 🧂
Things that this should be doing to be better.
* Wram up
* Run on AWS
* Have 2 different machines for server and gatling
* Make more rounds with more users, 10k, 100k, 1M
* Have other uses cases like, read json from DB, read static file, persist data, etc...
Results Summary (☕ Java)
1k users, during 1 minute non-stop
* Boot-Netty : 60000 total/OK, p99: 2 ms
* Boot-Tomcat : 60000 total/OK, p99: 6 ms
* Boot-Undertow : 60000 total/OK, p99: 15 ms
* Micronaut : 60000 total/OK, p99: 129 ms
* Quarkus : 60000 total/OK, p99: 4 ms
Build All 💻
Make sure you have installed and configured on the $PATH
1. Java sdk 20
2. Kotlin 1.9.10
3. Zig version 0.11
4. Rust 1.71.0
5. Go 1.21.0
6. g++ 11.4.0
7. bun 1.0.0
8. Deno 1.37
9. Nodejs 20
10. Python 3.11
11. V 0.4
12. Julia 1.8.5
13. Nim 2.0
14. Lua 5.4
15. Ruby 3.2.2
16. Dart 3.2.1
17. Podman 3.4.2
18. Clojure 1.11 / Leiningen 2.9
19. Haskell 9.2 / Cabal 3.6
20. gcc 11.4
21. Racket 8.2
22. Ocaml 5.1 / opam 2.1 / dune 3.7
23. PHP 8.1
24. Scala 3.3.1 / sbt 1.9.6
25. Crystal 1.9.2
26. Gleam 0.31.0 / mist 0.13.2
<code>bash
./build-all.sh</code>
build Java ☕
<ol>
<li>for Java - install sdkman - https://sdkman.io/
<code>bash
curl -s "https://get.sdkman.io" | bash</code>
<code>bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 20.0.2-amzn
sdk use java 20.0.2-amzn
java -version</code>
<code>bash
❯ java -version
openjdk version "20.0.1" 2023-04-18
OpenJDK Runtime Environment Homebrew (build 20.0.1)
OpenJDK 64-Bit Server VM Homebrew (build 20.0.1, mixed mode, sharing)</code></li>
</ol>
<code>bash
./mvnw clean install</code>
Important OS tuning
<ol>
<li>default file descriptors for linux is 1024, mac is 256 - need to be twecked.</li>
<li>also open files</li>
<li>switch to ip v4
here are steps on how to do it: https://gist.github.com/diegopacheco/ad1e63691380ad1a6b3be6b62910c3fb</li>
</ol>
for V and pico
gatling is having issues, but apache ab is working fine.
<code>bash
ab -n 60000 -c 1000 http://127.0.0.1:8080/</code>
```
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 6000 requests
Completed 12000 requests
Completed 18000 requests
Completed 24000 requests
Completed 30000 requests
Completed 36000 requests
Completed 42000 requests
Completed 48000 requests
Completed 54000 requests
Completed 60000 requests
Finished 60000 requests
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /
Document Length: 36 bytes
Concurrency Level: 1000
Time taken for tests: 487.475 seconds
Complete requests: 60000
Failed requests: 0
Total transferred: 6000000 bytes
HTML transferred: 2160000 bytes
Requests per second: 123.08 [#/sec] (mean)
Time per request: 8124.588 [ms] (mean)
Time per request: 8.125 [ms] (mean, across all concurrent requests)
Transfer rate: 12.02 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 13 9.0 13 56
Processing: 7043 8026 271.9 8059 15159
Waiting: 0 7 6.6 6 69
Total: 7056 8039 272.1 8069 15179
Percentage of the requests served within a certain time (ms)
50% 8069
66% 8072
75% 8075
80% 8077
90% 8090
95% 8105
98% 8126
99% 8129
100% 15179 (longest request)
<code>Fix gatling for V and pic by sharing connection.</code>Java
HttpProtocolBuilder httpProtocol = http
.baseUrl("http://localhost:8080")
.acceptHeader("text/html")
.doNotTrackHeader("1")
.userAgentHeader("Gat")
.shareConnections();
```
Open a PR to add new language / server?
<ol>
<li>Create a gatling simulation</li>
<li>Create a gatling script</li>
<li>Create a run.sh script - add the tuning for linux os pls</li>
<li>Add the new project with new language/framework (1 pr per lang/framework)</li>
<li>Dont publish gatling results</li>
<li>I will re-run on my machine, you can run all in our machine in our fork to compare different results with different hardware</li>
<li>Add a different script to install dependencies</li>
</ol>
Note on Java 21
Java 21 there is some performance degradetion comparing spring boot 3x and netty.
Correto JDK 21
```
================================================================================
---- Global Information --------------------------------------------------------
<blockquote>
request count 60000 (OK=60000 KO=0 )
min response time 0 (OK=0 KO=- )
max response time 276 (OK=276 KO=- )
mean response time 2 (OK=2 KO=- )
std deviation 14 (OK=14 KO=- )
response time 50th percentile 1 (OK=1 KO=- )
response time 75th percentile 1 (OK=1 KO=- )
response time 95th percentile 1 (OK=1 KO=- )
response time 99th percentile 8 (OK=8 KO=- )
mean requests/sec 923.077 (OK=923.077 KO=- )
---- Response Time Distribution ------------------------------------------------
t < 800 ms 60000 (100%)
800 ms <= t < 1200 ms 0 ( 0%)
t >= 1200 ms 0 ( 0%)
failed 0 ( 0%)
================================================================================
```
</blockquote>
Correto JDK 20
```
================================================================================
---- Global Information --------------------------------------------------------
<blockquote>
request count 60000 (OK=60000 KO=0 )
min response time 0 (OK=0 KO=- )
max response time 267 (OK=267 KO=- )
mean response time 2 (OK=2 KO=- )
std deviation 13 (OK=13 KO=- )
response time 50th percentile 1 (OK=1 KO=- )
response time 75th percentile 1 (OK=1 KO=- )
response time 95th percentile 1 (OK=1 KO=- )
response time 99th percentile 7 (OK=7 KO=- )
mean requests/sec 923.077 (OK=923.077 KO=- )
---- Response Time Distribution ------------------------------------------------
t < 800 ms 60000 (100%)
800 ms <= t < 1200 ms 0 ( 0%)
t >= 1200 ms 0 ( 0%)
failed 0 ( 0%)
================================================================================
```
</blockquote>
Application boot time on Java 21, GraalVM 21 and Netty
0.049 seconds
```
. <strong><em>_ _ __ _ _
/\ / </em></strong>'<em> __ _ </em>(<em>)</em> __ __ _ \ \ \ \
( ( )_<strong> | '<em> | '<em>| | '</em> \/ _` | \ \ \ \
\/ </em></strong>)| |<em>)| | | | | || (</em>| | ) ) ) )
' |<strong><em>_| .</em><em>|</em>| |<em>|</em>| |<em>_</em>, | / / / /
=========|_|==============|</strong><em>/=/</em>/<em>/</em>/
:: Spring Boot :: (v3.1.3)
2023-09-22T16:06:05.325-07:00 INFO 450420 --- [ main] c.g.d.sandboxspring.Application : Starting AOT-processed Application using Java 21 with PID 450420 (/mnt/e35d88d4-42b9-49ea-bf29-c4c3b018d429/diego/git/diegopacheco/servers-benchmark/server-boot-netty/target/server-boot-netty started by diego in /mnt/e35d88d4-42b9-49ea-bf29-c4c3b018d429/diego/git/diegopacheco/servers-benchmark/server-boot-netty)
2023-09-22T16:06:05.325-07:00 INFO 450420 --- [ main] c.g.d.sandboxspring.Application : No active profile set, falling back to 1 default profile: "default"
2023-09-22T16:06:05.361-07:00 INFO 450420 --- [ main] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port 8080
2023-09-22T16:06:05.362-07:00 INFO 450420 --- [ main] c.g.d.sandboxspring.Application : Started Application in 0.049 seconds (process running for 0.055)
Spring Boot 3.1.x working!
```
Server Spec
<code>Linux Kernel: 6.2.0-1009-lowlatency
OS : Ubuntu 22.04.3 LTS</code>
<code>bash
inxi -Fxz</code>
<code>System:
Kernel: 6.2.0-1009-lowlatency x86_64 bits: 64 compiler: N/A
Desktop: GNOME 42.9 Distro: Ubuntu 22.04.3 LTS (Jammy Jellyfish)
Machine:
Type: Laptop System: Avell High Performance product: Avell G1555 MUV / A62
v: Standard serial: <superuser required>
Mobo: Avell High Performance model: Avell G1555 MUV / A62 v: Standard
serial: <superuser required> UEFI: American Megatrends v: N.1.04
date: 08/13/2019
Battery:
ID-1: BAT0 charge: 44.9 Wh (96.1%) condition: 46.7/46.7 Wh (100.0%)
volts: 12.5 min: 11.4 model: standard status: Not charging
CPU:
Info: 6-core model: Intel Core i7-9750H bits: 64 type: MT MCP
arch: Coffee Lake rev: A cache: L1: 384 KiB L2: 1.5 MiB L3: 12 MiB
Speed (MHz): avg: 3498 high: 4202 min/max: 800/4500 cores: 1: 4154
2: 4200 3: 2600 4: 4196 5: 2600 6: 4092 7: 2600 8: 4127 9: 4202 10: 4014
11: 2600 12: 2600 bogomips: 62399
Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
Graphics:
Device-1: Intel CoffeeLake-H GT2 [UHD Graphics 630]
vendor: Tongfang Hongkong driver: i915 v: kernel bus-ID: 00:02.0
Device-2: NVIDIA TU116M [GeForce GTX 1660 Ti Mobile]
vendor: Tongfang Hongkong driver: nouveau v: kernel bus-ID: 01:00.0
Device-3: Logitech BRIO Ultra HD Webcam type: USB
driver: snd-usb-audio,uvcvideo bus-ID: 1-12.4:10
Device-4: Acer HD Webcam type: USB driver: uvcvideo bus-ID: 1-13:5
Display: wayland server: X.Org v: 1.22.1.1 with: Xwayland v: 22.1.1
compositor: gnome-shell driver: X: loaded: modesetting,nvidia
unloaded: fbdev,nouveau,vesa gpu: i915,nouveau resolution:
1: 3840x2160~60Hz 2: 1920x1080~60Hz
OpenGL: renderer: Mesa Intel UHD Graphics 630 (CFL GT2)
v: 4.6 Mesa 23.0.4-0ubuntu1~22.04.1 direct render: Yes
Network:
Device-1: Intel Cannon Lake PCH CNVi WiFi driver: iwlwifi v: kernel
bus-ID: 00:14.3
IF: wlo1 state: up mac: <filter>
Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
driver: r8169 v: kernel port: N/A bus-ID: 03:00.0
Drives:
Local Storage: total: 1.36 TiB used: 742.63 GiB (53.1%)
ID-1: /dev/nvme0n1 vendor: Samsung model: SSD 970 EVO Plus 500GB
size: 465.76 GiB temp: 50.9 C
ID-2: /dev/sda vendor: Crucial model: CT1000MX500SSD1 size: 931.51 GiB
Partition:
ID-1: / size: 456.89 GiB used: 372.27 GiB (81.5%) fs: ext4
dev: /dev/nvme0n1p2
ID-2: /boot/efi size: 511 MiB used: 6.1 MiB (1.2%) fs: vfat
dev: /dev/nvme0n1p1
Swap:
ID-1: swap-1 type: file size: 2 GiB used: 0 KiB (0.0%) file: /swapfile
Sensors:
System Temperatures: cpu: 84.0 C pch: 75.0 C mobo: 84.0 C gpu: nouveau
temp: 69.0 C
Fan Speeds (RPM): N/A
Info:
Processes: 449 Uptime: 1d 45m Memory: 62.65 GiB used: 10.58 GiB (16.9%)
Init: systemd runlevel: 5 Compilers: gcc: 11.4.0 clang: 16.0.4
Packages: 4360 Shell: Zsh v: 5.8.1 inxi: 3.3.13</code>
Gatling simulations summary
🏆 #1 - Winner
🥈 #2 - Second place
🥉 #3 - Thrid Place
🧮Criteria: Number of Requests, Max and p99 (usually max is what define it)
|#|Simulation|Reqs|Min|Max|Mean|p50|p75|p95|p99|
|-:|:-|-:|-:|-:|-:|-:|-:|-:|-:|
|🏆|Nim2beast|60000|0|36|0|0|0|1|1|
|🥈|JavaIOUring|60000|0|40|0|0|1|1|1|
|🥉|VPicov|60000|0|43|0|0|0|1|1|
|4|RustXitca|60000|0|44|0|0|1|1|1|
|5|Ruby|60000|0|45|0|0|1|1|1|
|6|PHPEmbededServer|60000|0|46|0|0|1|1|1|
|7|BunHono|60000|0|46|0|0|1|1|1|
|8|Go|60000|0|48|0|0|0|1|1|
|9|RustMayMinihttp|60000|0|48|0|0|1|1|4|
|10|ZigZap|60000|0|52|0|0|0|1|1|
|11|BunHttpServer|60000|0|56|0|0|1|1|1|
|12|NodeJSHttpServer|60000|0|57|0|0|0|1|1|
|13|RustSalvo|60000|0|57|0|0|1|1|2|
|14|CScratch|60000|0|59|0|0|1|1|1|
|15|RustHyper|60000|0|61|0|0|1|1|1|
|16|HaskellScotty|60000|0|61|0|0|1|1|5|
|17|RustAxum|60000|0|63|0|0|0|1|2|
|18|RustActix|60000|0|65|0|0|1|1|1|
|19|BunElysia|60000|0|67|0|0|1|1|2|
|20|HaskellWarp|60000|0|68|0|0|0|1|4|
|21|RustGotham|60000|0|77|0|0|0|1|1|
|22|GleamMist|60000|0|78|0|0|1|1|1|
|23|CppDrogon|60000|0|79|0|0|1|1|2|
|24|Netty|60000|0|84|0|0|1|1|2|
|25|NodeJSExpress|60000|0|84|1|0|1|1|2|
|26|NodeJSHttpServerWorker|60000|0|88|1|0|1|1|3|
|27|Netty|60000|0|91|1|0|1|1|9|
|28|BunHttpServerWorker|60000|0|96|0|0|1|1|2|
|29|PHPNginx|60000|0|99|0|0|1|1|1|
|30|DenoFresh|60000|0|106|1|0|1|1|2|
|31|PythonTwisted|60000|0|106|2|1|1|3|35|
|32|JavaSmartHttp|60000|0|114|0|0|1|1|1|
|33|QuarkusNative|60000|0|114|1|0|1|1|18|
|34|Http4k|60000|0|200|1|0|1|1|1|
|35|QuarkusReact|60000|0|220|1|1|1|1|5|
|36|NettyMono2|60000|0|236|1|1|1|1|5|
|37|Quarkus|60000|0|266|1|1|1|1|4|
|38|Undertow|60000|0|325|1|0|1|1|15|
|39|JavaBlade|60000|0|356|1|0|0|1|3|
|40|Tomcat|60000|0|360|1|0|1|1|6|
|41|Micronaut|60000|0|468|4|0|1|2|129|
|42|ClojureRingJetty|60000|0|481|16|1|2|120|323|
|43|NettyMono|60000|0|545|7|0|1|1|335|
|44|Ktor|60000|0|696|6|0|1|3|245|
|45|Scala3ZioHttp|60000|0|888|5|0|1|1|222|
|46|Lua|60000|0|1033|0|0|1|1|1|
|47|CrystalSpiderGazelle|60000|0|1041|5|1|1|32|83|
|48|DartShelf|60000|0|1068|3|1|1|6|55|
|49|RacketSpin|60000|0|1103|51|3|35|308|627|
|50|OcamlHttpAsync|60000|0|1106|1|0|1|2|6|
|51|PythonTornado|60000|0|1306|30|1|19|117|347|
|52|Scala3AkkaHttp|60000|0|1870|7|0|1|1|6|
|53|ElixirPhoenixCowboy|60000|248|1985|735|695|851|1139|1563|
|54|Scala3Play2|60000|0|2764|91|0|1|11|2314|
|55|PythonFlask|60000|0|3135|14|1|1|104|143|
|56|JavaHttpServer|60000|0|3194|18|0|1|3|568|
|57|PythonFastApi|60000|53|10340|4486|3948|7229|9709|10032|
|58|JuliaGenie|57929|9|10971|721|12|12|7199|8634|
|59|PythonFastApiHypercorn|56878|26|45622|25555|29579|37271|40736|41760|
| [] |
https://avatars.githubusercontent.com/u/39000560?v=4 | vk-kickstart | mikastiv/vk-kickstart | 2024-02-05T16:12:17Z | Vulkan initialization library | main | 0 | 5 | 1 | 5 | https://api.github.com/repos/mikastiv/vk-kickstart/tags | NOASSERTION | [
"helpers-library",
"initialization",
"vulkan",
"vulkan-library",
"zig",
"ziglang"
] | 527 | false | 2025-02-10T21:25:34Z | true | true | unknown | github | [
{
"commit": "e43d635893de4c8b89d5ca8aa142984872b7e68f",
"name": "vulkan",
"tar_url": "https://github.com/Snektron/vulkan-zig/archive/e43d635893de4c8b89d5ca8aa142984872b7e68f.tar.gz",
"type": "remote",
"url": "https://github.com/Snektron/vulkan-zig"
}
] | <code>vk-kickstart</code>
A Zig library to help with Vulkan initialization inspired by <a>vk-bootstrap</a>
The minimum required version is Vulkan 1.1
This library helps with:
- Instance creation
- Setting up debug environment (validation layers and debug messenger)
- Physical device selection based on a set of criteria
- Enabling physical device extensions
- Device creation
- Swapchain creation
- Getting queues
Setting up
Add <a><code>vulkan-zig</code></a> as a dependency to your build.zig.zon:
<code>zig fetch --save=vulkan_zig "https://github.com/Snektron/vulkan-zig/archive/<COMMIT_HASH>.tar.gz"</code>
Use the same version as vk-kickstart for the commit hash. See <a>build.zig.zon</a>
Then add vk-kickstart:
<code>zig fetch --save https://github.com/Mikastiv/vk-kickstart/archive/<COMMIT_HASH>.tar.gz</code>
Then update your build file with the following:
```zig
// Provide the path to the Vulkan registry (requires version >= 1.3.277)
const xml_path: []const u8 = b.pathFromRoot("vk.xml");
// Add the vulkan-zig module
const vkzig_dep = b.dependency("vulkan_zig", .{
.registry = xml_path,
});
exe.root_module.addImport("vulkan", vkzig_dep.module("vulkan-zig"));
// Add vk-kickstart
const kickstart_dep = b.dependency("vk_kickstart", .{
.registry = xml_path,
// Optional, default is false
.enable_validation = if (optimize == .Debug) true else false,
// Optional, default is false
.verbose = true,
});
exe.root_module.addImport("vk-kickstart", kickstart_dep.module("vk-kickstart"));
```
You can then import <code>vk-kickstart</code> as a module and vulkan-zig
<code>zig
const vkk = @import("vk-kickstart");
const vk = @import("vulkan");</code>
See <a>build.zig</a> for an example
How to use
For a code example, see <a>main.zig</a>
Instance creation
Using the <code>instance.CreateOptions</code> struct's fields, you can you can choose how you want the instance to be configured like the required api version.
Note: VK_KHR_surface and the platform specific surface extension are automatically enabled. Only works for Windows, MacOS and Linux (xcb, xlib or wayland) for now
```zig
const vk = @import("vulkan-zig");
pub const CreateOptions = struct {
/// Application name.
app_name: [<em>:0]const u8 = "",
/// Application version.
app_version: u32 = 0,
/// Engine name.
engine_name: [</em>:0]const u8 = "",
/// Engine version.
engine_version: u32 = 0,
/// Required Vulkan version (minimum 1.1).
required_api_version: u32 = vk.API_VERSION_1_1,
/// Array of required extensions to enable.
/// Note: VK_KHR_surface and the platform specific surface extension are automatically enabled.
required_extensions: []const [<em>:0]const u8 = &.{},
/// Array of required layers to enable.
required_layers: []const [</em>:0]const u8 = &.{},
/// pNext chain.
p_next_chain: ?*anyopaque = null,
/// Debug messenger options
debug: DebugMessengerOptions = .{},
};
```
Pass these options to <code>instance.create()</code> to create an instance
Physical device selection
You can set criterias to select an appropriate physical device for your application using <code>PhysicalDevice.SelectOptions</code>
Note: VK_KHR_subset (if available) and VK_KHR_swapchain are automatically enabled, no need to add them to the list
```zig
const vk = @import("vulkan-zig");
pub const SelectOptions = struct {
/// Vulkan render surface.
surface: vk.SurfaceKHR,
/// Name of the device to select.
name: ?[<em>:0]const u8 = null,
/// Required Vulkan version (minimum 1.1).
required_api_version: u32 = vk.API_VERSION_1_1,
/// Prefered physical device type.
preferred_type: vk.PhysicalDeviceType = .discrete_gpu,
/// Transfer queue preference.
transfer_queue: QueuePreference = .none,
/// Compute queue preference.
compute_queue: QueuePreference = .none,
/// Required local memory size.
required_mem_size: vk.DeviceSize = 0,
/// Required physical device features.
required_features: vk.PhysicalDeviceFeatures = .{},
/// Required physical device feature version 1.1.
required_features_11: vk.PhysicalDeviceVulkan11Features = .{},
/// Required physical device feature version 1.2.
required_features_12: ?vk.PhysicalDeviceVulkan12Features = null,
/// Required physical device feature version 1.3.
required_features_13: ?vk.PhysicalDeviceVulkan13Features = null,
/// Array of required physical device extensions to enable.
/// Note: VK_KHR_swapchain and VK_KHR_subset (if available) are automatically enabled.
required_extensions: []const [</em>:0]const u8 = &.{},
};
```
Pass these options to <code>PhysicalDevice.select()</code> to select a device
Device creation
For this, you only need to call <code>device.create()</code> with the previously selected physical device
Swapchain creation
Finally to create a swapchain, use <code>Swapchain.CreateOptions</code>
```zig
const vk = @import("vulkan-zig");
pub const CreateOptions = struct {
/// Graphics queue index
graphics_queue_index: u32,
/// Present queue index
present_queue_index: u32,
/// Desired size (in pixels) of the swapchain image(s).
/// These values will be clamped within the capabilities of the device
desired_extent: vk.Extent2D,
/// Swapchain create flags
create_flags: vk.SwapchainCreateFlagsKHR = .{},
/// Desired minimum number of presentable images that the application needs.
/// If left on default, will try to use the minimum of the device + 1.
/// This value will be clamped between the device's minimum and maximum (if there is a max).
desired_min_image_count: ?u32 = null,
/// Array of desired image formats, in order of priority.
/// Will fallback to the first found if none match
desired_formats: []const vk.SurfaceFormatKHR = &.{
.{ .format = .b8g8r8a8_srgb, .color_space = .srgb_nonlinear_khr },
},
/// Array of desired present modes, in order of priority.
/// Will fallback to fifo_khr is none match
desired_present_modes: []const vk.PresentModeKHR = &.{
.mailbox_khr,
},
/// Desired number of views in a multiview/stereo surface.
/// Will be clamped down if higher than device's max
desired_array_layer_count: u32 = 1,
/// Intended usage of the (acquired) swapchain images
image_usage_flags: vk.ImageUsageFlags = .{ .color_attachment_bit = true },
/// Value describing the transform, relative to the presentation engine’s natural orientation, applied to the image content prior to presentation
pre_transform: ?vk.SurfaceTransformFlagsKHR = null,
/// Value indicating the alpha compositing mode to use when this surface is composited together with other surfaces on certain window systems
composite_alpha: vk.CompositeAlphaFlagsKHR = .{ .opaque_bit_khr = true },
/// Discard rendering operation that are not visible
clipped: vk.Bool32 = vk.TRUE,
/// Existing non-retired swapchain currently associated with surface
old_swapchain: ?vk.SwapchainKHR = null,
/// pNext chain
p_next_chain: ?*anyopaque = null,
};
```
Pass these options and a the logical device to <code>Swapchain.create()</code> to create the swapchain
Todo list
<ul>
<li>Headless mode</li>
</ul> | [] |
https://avatars.githubusercontent.com/u/8588690?v=4 | itcc | themanyone/itcc | 2023-04-10T20:52:18Z | A RAD new way to program: simple, light-weight read-eval-print loop (REPL)s for C, C++, Rust, Hare, Zig, Go, and Crap... | master | 0 | 5 | 0 | 5 | https://api.github.com/repos/themanyone/itcc/tags | GPL-2.0 | [
"contest",
"go",
"golang",
"hare",
"interactive",
"programming",
"python",
"rad",
"repl",
"rust",
"zig"
] | 379 | false | 2025-03-30T00:43:33Z | false | false | unknown | github | [] | Interactive TCC
Make programming fun like Python.
An command-line shell for C, C++, Rust, Hare, Go, Zig, and the concise, regex-aware
CPP (CRAP). Also known as an evaluation context, or read-eval-print loop (REPL), this revolutionary shell tool allows programmers to type commands in a variety of compiled
langauges and see immediate results.
About this project. Interactive TCC (itcc) is a small python3 utility originally
forked from Interactive GCC (igcc). And we keep adding other languages to it. We do
our best to make the code work for us, but it comes with NO Warranties. You are free
to share and modify free software in according with the GNU General Public License
(GPL) Version 2. See the notice at the bottom of this page and COPYING.txt for
details. Get ITCC from GitHub https://github.com/themanyone/itcc
Dependencies. Build the optional TINYCC compiler (tcc) (or skip down to the C++ section
ad use GCC). The experimental MOB branch of tcc accepts random contributions from
anyone, so check it over carefully! Join the active mailing list, contribute fixes,
and update often. git clone https://repo.or.cz/tinycc.git/
Now with color listings. Install Colorama Highlight (required). Available through your
distro package manager, conda, or pip.
The main reason we like tcc is instant gratification. Owing to its small download
size, and the smallness of the resulting executables, tcc's one-pass build ensures
virtually no compiler delays between entering code and seeing the results! Tcc
supports Windows, Linux, Android and other targets with many common GCC extensions.
But it might lack some of the optimizations of GCC. Also, tcc is a C compiler, not a
C/C++ compiler suite like GCC.
Use our Interactive tcc shell, like this:
$ ./itcc
Released under GNU GPL version 2 or later, with NO WARRANTY.
Type ".h" for help.
tcc> int a = 5;
tcc> a -= 2;
tcc> if (a < 4) {
tcc> printf("a is %i\n", a);
tcc> }
a is 3
tcc> |
Pass arguments to Interactive TCC and operate on them.
$ ./itcc -- foo bar baz
tcc> puts(argv[2]);
bar
tcc> |
Interactive Crap
Interactive, concise, regex-aware preprocessor (icrap) <em>is standard C</em> (using tcc in
the background), without most of the semicolons, curly braces, and parenthesis. Like
Python, use tab or indent 4 spaces instead of adding curly braces. Use two spaces
instead of parenthesis. Since braces are added automatically, it saves typing. There
are also some exciting, new go-like language features that really simplify C coding.
Get crap from https://themanyone.github.io/crap/ Released under GNU GPL
version 2 or later, with NO WARRANTY. Type ".h" for help.
$./icrap -lm
crap> #include "math.h"
crap> for int x=0;x<5;x++
crap> printf "%i squared is %0.0f\n", x, pow(x, 2.0)
0 squared is 0
1 squared is 1
2 squared is 4
3 squared is 9
4 squared is 16
crap> |
Supply includes and libs on the command line. You can link against glib-2.0, plugins,
etc. Test code without the compile step. Add extra CFLAGS and args. It's all free.
icrap $(pkg-config --cflags --libs glib-2.0) -std=c11 -g -Wall -- foo myargs
crap> .l
#include
#include
crap> GDateTime *dt=g_date_time_new_now_local ();
crap> int yyyy,mm,dd
crap> g_date_time_get_ymd dt, &yyyy, &mm, &dd
crap> g_print "date: %.4d-%.2d-%.2d\n", yyyy, mm, dd
date: 2024-02-14
crap> puts argv[2]
myargs
crap> |
Interactive Tcc and Interactive Crap build upon the original Interactive GCC (igcc),
which is also included in this package. Those who have no problem converting C++ to C,
might even be able to struggle through some of following examples using itcc, or
icrap.
Interactive GCC
Use Interactive GCC for C++ programming, like this:
$ ./igcc
g++> int a = 5;
g++> a += 2;
g++> cout << a << endl;
7
g++> --a;
g++> cout << a << endl;
6
g++> |
It is possible to include header files you need like this:
$ ./igcc
g++> #include
g++> vector myvec;
g++> myvec.push_back( 17 );
g++> printf( "%d\n", myvec.size() );
1
g++> myvec.push_back( 21 );
g++> printf( "%d\n", myvec.size() );
2
g++> |
Start igcc with the -e option to see every compiler error notification, even a missing
closing brace from an unfinished block of code. These types of error notices are not
useful for interactive sessions, so we hide them. You can always use .e to check for
errors even without such warnings.
$ ./igcc -e
g++> #include
g++> map hits;
g++> hits["foo"] = 12;
g++> hits["bar"] = 15;
g++> for( map::iterator it = hits.begin(); it != hits.end(); ++it )
g++> {
[Compile error - type .e to see it.]
g++> cout << it->first << " " << it->second << endl;
[Compile error - type .e to see it.]
g++> }
bar 15
foo 12
g++> |
Extra include directories can be supplied:
$ ./igcc -Itest/cpp -Itest/cpp2
g++> #include "hello.h"
g++> hello();
Hello,
g++> #include "world.h"
g++> world();
world!
g++> |
Libs can be linked:
$ ./igcc -lm # bad example since libm.a is already linked in C++
g++> #include "math.h"
g++> cout << pow( 3, 3 ) << endl;
27
g++> |
Your own libs can be linked too:
$ ./igcc -Itest/cpp -Ltest/cpp -lmylib
g++> #include "mylib.h"
g++> defined_in_cpp();
defined_in_cpp saying hello.
g++> |
The cstdio, iostream and string headers are automatically included, and the std
namespace is already in scope.
Interactive Rust
We can now run rust interactively. Get rustup from http://rust-lang.org or your
distro's package manager. Use the nightly build for cutting-edge development.
rustup toolchain install nightly
rustup default nightly
Typing .h [std] or any such rust idiom brings up a local copy of the documentation
from https://rust-cli.github.io/book/tutorial/cli-args.html, which should be installed
when you install rust using the above method.
Now we can invoke irust. Arguments after the <code>--</code> are passed along to the interactive
session for us to play with.
$ ./irust -- foo bar baz
irust 0.3
Released under GNU GPL version 2 or later, with NO WARRANTY.
Type ".h" for help.
rust> use std::env;
rust> let args: Vec = env::args().collect();
rust> for arg in args.iter() {
rust> println!("{}", arg);
rust> }
foo
bar
baz
rust> |
Interactive Hare
Hare is a systems programming language with a static type system, manual memory
management, and a small runtime. It's well-suited for low-level, high-performance
tasks like operating systems, system tools, compilers, and networking software. Now
you can play with it interactively.
Hare Website: https://git.sr.ht/~sircmpwn/harelang.org
Hare compiler: git clone https://git.sr.ht/~sircmpwn/harec
Hare std libs: git clone https://git.sr.ht/~sircmpwn/hare
Depends on QBE: https://c9x.me/compile/code.html
Requires scdoc: https://git.sr.ht/~sircmpwn/scdoc
Compile everything from the latest sources. Once installed, it will work with our
interactive demo here. Also, be sure and get more help, libraries, and resources
below.
Interactive hare session:
$./ihare
ihare 0.3
Released under GNU GPL version 2 or later, with NO WARRANTY.
Get hare from https://sr.ht/~sircmpwn/hare/sources
Type ".h" for help.
hare> const greetings = [
hare> "Hello, world!",
hare> "¡Hola Mundo!",
hare> "Γειά σου Κόσμε!",
hare> "Привіт, світ!",
hare> "こんにちは世界!",
hare> ];
hare> for (let i = 0z; i < len(greetings); i += 1) {
hare> fmt::println(greetings[i])!;
hare> };
Hello, world!
¡Hola Mundo!
Γειά σου Κόσμε!
Привіт, світ!
こんにちは世界!
hare>
hare> // get help on rt::timespec
hare> .h rt::timespec
type timespec = struct {
tv_sec: time_t,
tv_nsec: i64,
};
hare> |
Interactive Zig
$ izig
izig 0.3
Released under GNU GPL version 2 or later, with NO WARRANTY.
Get zig from distro package or https://ziglang.org/
Type ".h" for help.
zig> const stdout = std.io.getStdOut().writer();
zig> try stdout.print("Hello, {s}!\n", .{"world"});
Hello, world!
zig> |
Interactive Go
$ igo
igo 0.3
Released under GNU GPL version 2 or later, with NO WARRANTY.
Get go from https://go.dev/
Type ".h" for help.
go> fmt.Println("Welcome to the playground!")
Welcome to the playground!
go> import "time"
go> fmt.Println("The time is", time.Now())
The time is 2024-03-02 10:28:25
go> .L
package main
import "fmt"
import "time"
func main() {
fmt.Println("Welcome to the playground!")
fmt.Println("The time is", time.Now())
}
go> |
FAQ. Issues.
How does it work? Does it re-run the entire code block each time?
Yes. Although it runs all the code each time, it only prints the new output.
Supposedly. There appears to be some bugs with detecting what was already printed,
causing some new lines to produce no output. In that case, just press CTRL-C or CTRL-D
and restart it. We're working on that...
Your Editor Is Now a REPL
Our replacement is here. Any language. Any editor.
We made a REPL maker! This command is all you need.
$ repl.sh [compiler] -run [sources]
It watches <code>test.c</code> for changes. If it detects any, it compiles and runs.
Compiler options supported. After <code>--</code> my args are available inside script.
$ repl.sh tcc $CFLAGS $LIBS -run test.c -- my args
Use <code>runner</code> if your compiler does not have a -run option.
$ repl.sh runner gcc $CFLAGS $LIBS test.c -- my args
The <code>hare</code> build system.
$ repl.sh runner hare build hello.ha -- my args
Some new Smurf language? Smurfy.
$ repl.sh smurf run papa.smurf -- my args
Get REPL Ace free from https://github.com/themanyone/REPLace
Updating This Package
itcc is published on GitHub. Get it from https://github.com/themanyone/itcc where
developers can submit bug reports, fork, and pull requests with code contributions.
Other REPLs
REPLAce: a REPL for all languages https://github.com/themanyone/REPLace
various languages in the browser http://repl.it
csharp: included with monodevelop http://www.csharphelp.com/
psysh: comes with php for php code http://php.net
evcxr: another Rust REPL https://github.com/evcxr/evcxr
ipython: interactive python https://github.com/ipython/ipython
rep.lua: a lua REPL https://github.com/hoelzro/lua-repl
re.pl: perl command line https://github.com/daurnimator/rep
d8-314: from V8, JavaScript https://developers.google.com/v8/
csi: from chicken, a scheme REPL http://call-cc.org/
RStudio: interactive R coding https://rstudio.com/
Ruby IRB: REPL tool for Ruby https://ruby-doc.org/stdlib-2.7.2/libdoc/irb/rdoc/IRB.html
numerous bash-like shells and interpreters
Legacy Code
For Python2, you may opt to download Andy Balaam's original IGCC tarball from the
Sourceforge download area:
https://sourceforge.net/projects/igcc/files/
Untar it like so:
tar -xjf igcc-0.1.tar.bz2
And then start the program like this:
cd igcc-0.1
./igcc
Links
IGCC home page:
http://www.artificialworlds.net/wiki/IGCC/IGCC
IGCC Sourceforge page:
http://sourceforge.net/projects/igcc/
Andy Balaam's home page:
http://www.artificialworlds.net
Andy Balaam's blog:
http://www.artificialworlds.net/blog
Contact
Andy Balaam may be contacted on axis3x3 at users dot sourceforge dot net
Copyright
IGCC is Copyright (C) 2009 Andy Balaam
IGCC is Free Software released under the terms of the GNU General Public License
version 2 or later.
IGCC comes with NO WARRANTY
See the file COPYING for more information.
This fork is maintained with updated code, which is Copyright (C) 2024 by Henry Kroll
III under the same license. Blame him if there are problems with these updates. Issues
for this fork are maintained on GitHub.
Browse Themanyone
- GitHub https://github.com/themanyone
- YouTube https://www.youtube.com/themanyone
- Mastodon https://mastodon.social/@themanyone
- Linkedin https://www.linkedin.com/in/henry-kroll-iii-93860426/
- <a>TheNerdShow.com</a> | [] |
https://avatars.githubusercontent.com/u/463136?v=4 | zig-osc | guidoschmidt/zig-osc | 2023-07-22T12:40:08Z | zig OSC package | main | 1 | 5 | 0 | 5 | https://api.github.com/repos/guidoschmidt/zig-osc/tags | MIT | [
"multimedia",
"multimedia-tools",
"open-sound-control",
"opensoundcontrol",
"osc",
"zig"
] | 59 | false | 2025-05-20T20:17:28Z | true | true | unknown | github | [
{
"commit": "8db1aa2f5efdf1e2ff6dd5f5f8efe1b4f44ff978.tar.gz",
"name": "network",
"tar_url": "https://github.com/MasterQ32/zig-network/archive/8db1aa2f5efdf1e2ff6dd5f5f8efe1b4f44ff978.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/MasterQ32/zig-network"
}
] | <a></a>
zig-osc
Open Sound Control package for <a>zig</a>
Features
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> OSC Messages
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> OSC Arguments
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> integer, i32
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> float, f32
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> OSC-string
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> OSC-blob
Examples
<code>zig build run-*example*</code> to run any of the <a>examples</a>
<ul>
<li><code>zig build run-server</code> example server implementation for receiving OSC messages</li>
<li><code>zig build run-client</code> example client implementation for sending OSC messages</li>
<li><code>zig build run-tracker</code> mini tracker application which sends OSC messages to
VCV Rack</li>
</ul>
Acknowledgements
<code>zig-osc</code> wouldn't be possible without the great work on
<a><code>zig-network</code></a>, thanks to <a>Felix
Queißner (@ikskuh)</a> and all contributors. Please
consider a star or sponsorship on the <a>zig-network repository</a>.
Links & References
<ul>
<li><a>OSC Specifications</a></li>
<li><a>Features and Future of Open Sound</a></li>
</ul> | [] |
https://avatars.githubusercontent.com/u/116503189?v=4 | rezolve | nylvon/rezolve | 2023-12-18T23:33:02Z | ReZolve is a symbolic computer algebra system that acts as a mathematical compiler written in Zig. | main | 0 | 5 | 0 | 5 | https://api.github.com/repos/nylvon/rezolve/tags | MIT | [
"algebra",
"algebra-system",
"computer-algebra-calculus",
"computer-algebra-system",
"math",
"mathematics",
"maths",
"solver",
"symbolic",
"symbolic-computation",
"zig",
"ziglang"
] | 140 | false | 2025-01-05T21:35:01Z | true | false | unknown | github | [] | rezolve
ReZolve is a symbolic computer algebra system that acts as a mathematical compiler written in Zig. | [] |
https://avatars.githubusercontent.com/u/184591186?v=4 | sh1107 | charlottia/sh1107 | 2023-03-12T05:12:36Z | SH1107 OLED (I²C) driver, plus virtual hardware testbench. | main | 0 | 5 | 0 | 5 | https://api.github.com/repos/charlottia/sh1107/tags | - | [
"amaranth",
"amaranth-hdl",
"cxxrtl",
"fpga",
"i2c",
"icebreaker",
"oled",
"sh1107",
"zig"
] | 3,672 | false | 2025-03-30T00:50:33Z | false | false | unknown | github | [] | sh1107
This repository is a testbed for exploring <a>Amaranth</a> while learning digital
design. It consists of a basic driver for SH1107-type OLEDs over I²C such as the
<a>Pimoroni 1.12" 128x128 monochrome OLED</a>, a read/write I²C
controller, plus a simple SPI flash reader. The driver supports commands akin to
old BASIC: <code>CLS</code>, <code>PRINT</code>, <code>LOCATE</code>. The classic IBM 8x8 font is used to this
end.
Execute the package to see what it can do:
```console
$ py -m sh1107 -h
usage: sh1107 [-h] {test,formal,build,rom,vsh} ...
positional arguments:
{test,formal,build,rom,vsh}
test run the unit tests and sim tests
formal formally verify the design
build build the design, and optionally program it
rom build the ROM image, and optionally program it
vsh run the Virtual SH1107
options:
-h, --help show this help message and exit
```
The current test deployment targets are:
<ul>
<li>iCEBreaker (<a>Crowd Supply</a>,
<a>1BitSquared</a>).</li>
<li>Connect PMOD1 A1 to SDA, A2 to SCL.</li>
<li>OrangeCrab (<a>1BitSquared</a>).</li>
<li>Connect the pins named SDA and SCL.</li>
<li>The code currently expects you have rev 0.2 with an 85F like I do. It's
trivial to add support for rev 0.1 and/or the 25F.</li>
</ul>
Requirements
If no version is specified, the most recent release or the version in your
package manager is probably fine, and if neither concept applies, just try the
latest commit.
For a detailed guide on installing specific versions of some of these tools,
please see <a>Installing an HDL toolchain from source</a>. On Nix,
<a>hdx</a> packages everything — <code>nix develop '.?submodules=1'</code>/<code>nix-shell</code> will
use it.
To run at all:
<ul>
<li><a>Python 3</a> (3.8+ works; I work on 3.12 beta)</li>
<li><a>Amaranth</a> ([<code>d218273</code>] or later)</li>
<li><a>Board definitions for Amaranth</a></li>
</ul>
To run vsh:
<ul>
<li><a>Zig</a> (~[<code>50339f5</code>] or later)</li>
<li><a>SDL2</a></li>
</ul>
To build and deploy:
<ul>
<li><a>nextpnr</a> configured with appropriate flows:</li>
<li><a>Project IceStorm</a> for iCEBreaker</li>
<li><a>Project Trellis</a> for OrangeCrab<ul>
<li>[<code>dfu-util</code>] to upload the bitstream and ROM</li>
</ul>
</li>
</ul>
To run formal tests:
<ul>
<li><a>Yosys</a> ([<code>d3ee4eb</code>] or later)</li>
<li><a>SymbiYosys</a></li>
<li><a>Z3</a> (4.12+ is known to work; 4.8 is known not to)</li>
</ul>
TODOs
<ul>
<li>try QSPI.</li>
<li>OrangeCrab: try on-board DDR3 instead of EBR.</li>
</ul>
vsh
Maybe the most interesting thing right now is the Virtual SH1107 for testing the
gateware. It emulates the internal state of the SH1107 device — what you see
rendered is what you should see on the display.
<a></a> <a></a>
Initially this was implemented in Python and ran cooperatively with Amaranth's
own simulator, like the unit tests, but it was pretty slow. It's now written in
<a>Zig</a>, and interacts with the simulated hardware running on its own thread by
compiling it to C++ through Yosys's <a>CXXRTL backend</a>.
```console
$ py -m sh1107 vsh -h
usage: sh1107 vsh [-h] [-i] [-f] [-c] [-s {100000,400000,2000000}] [-t TOP]
[-v] [-O {none,rtl,zig,both}]
options:
-h, --help show this help message and exit
-i, --whitebox-i2c simulate the full I2C protocol; by default it is
replaced with a blackbox for speed
-f, --whitebox-spifr simulate the full SPI protocol for the flash reader;
by default it is replaced with a blackbox for speed
-c, --compile compile only; don't run
-s {100000,400000,2000000}, --speed {100000,400000,2000000}
I2C bus speed to build at
-t TOP, --top TOP which top-level module to simulate (default:
oled.Top)
-v, --vcd output a VCD file
-O {none,rtl,zig,both}, --optimize {none,rtl,zig,both}
build RTL or Zig with optimizations (default: both)
```
I²C
By default, the I²C circuit is stubbed out with a
<a>blackbox</a> that acts close enough to the real controller
for the rest of the design, and the Virtual SH1107
<a>spies</a> on the inputs to the blackbox directly. This
is fast.
At the most fine-grained level (<code>vsh -i</code>), it responds to the gateware by doing
edge detection at I²C level, <a>spying</a> on the I²C
lines. This method is faster than the pure Python version I started with, but
still slow enough to take several seconds to clear the screen when not compiled
with optimizations.
SPI flash
Sequences of SH1107 commands used by the driver are packed into a ROM image
which is separately programmed onto the on-board flash. The driver reads the
contents into RAM on startup over SPI.
By default, the SPI flash reader component is stubbed out with a
<a>blackbox</a>, which emulates the component's
<a>interface</a>, returning data bytes directly to the OLED
driver from the ROM embedded in the build.
This blackbox can be replaced with a <a>whitebox</a> (<code>vsh
-f</code>), which emulates at one level lower, emulating the <a>SPI
interface</a> itself, returning data bitwise to the <a>flash
reader</a>. | [] |
https://avatars.githubusercontent.com/u/88196711?v=4 | codotaku_image_viewer | CodesOtakuYT/codotaku_image_viewer | 2023-04-02T17:09:54Z | Tiny fast cross platform image viewer | master | 0 | 5 | 2 | 5 | https://api.github.com/repos/CodesOtakuYT/codotaku_image_viewer/tags | MIT | [
"fast",
"image-viewer",
"raylib",
"raylib-zig",
"tiny",
"zig",
"ziglang"
] | 69 | false | 2024-06-08T16:40:13Z | true | false | unknown | github | [] | Codotaku Image Viewer 0.1.0
A tiny fast simple cross platform open source image viewer made using Ziglang and Raylib.
No GUI, so you can focus on viewing the images!
Around 1 mb executable with support for most popular image formats even PSD!
- import multiple images or directories recursively by dropping them into the window or in the command line arguments.
- If numbers are included in the command line arguments, it will switch the max recursions for the next arguments and drops.
- toggle image texturing filter (NEAREST, BILINEAR, TRILINEAR) by pressing <code>P</code>
- unload and clear all the imported textures by pressing <code>Backspace</code>.
- toggle fullscreen by pressing <code>F</code>
- move around by holding down <code>left mouse button</code> anywhere in the window and drag.
- zoom towards the mouse and outwards from it by using the <code>Mouse Wheel</code>
- go back to 1:1 zoom by pressing <code>middle mouse button</code> (mouse wheel)
- hold <code>Left Shift Key</code> to rotate instead of zoom around the mouse.
- easily cross compile to any platform, thanks to Zig build system.
- 0.1.0 fully created in a youtube video tutorial! https://www.youtube.com/watch?v=DMURJbpo94g
1 - Make sure to clone the repo recursively with the submodule(s), cd into the directory.
2 - Setup project dependencies like translating C header files.
You need zig installed in your system and available in the environment variables!
3 - Run this in the root directory of the repo to build a fast release binary.
4 - Enjoy!
This open source project is open to contributions!
<code>sh
git clone --recursive https://github.com/CodesOtakuYT/codotaku_image_viewer
cd codotaku_image_viewer
zig run setup.zig
zig build run -Doptimize=ReleaseFast</code> | [] |
https://avatars.githubusercontent.com/u/125603463?v=4 | zig-json | brochweb/zig-json | 2023-02-16T19:27:00Z | zig-json is a zig program with an optimized JSON parsing implementation. | main | 0 | 5 | 1 | 5 | https://api.github.com/repos/brochweb/zig-json/tags | BSD-3-Clause | [
"json",
"zig"
] | 47,855 | false | 2024-11-21T18:12:08Z | true | false | unknown | github | [] | zig-json
<code>zig-json</code> is a zig program with an optimized JSON parsing implementation. It only parses to a <code>JsonValue</code> enum, not to a Zig struct, but it ends up being around twice as fast as <code>std.json.Parser</code> on some benchmarks.
This is a research project, it is not tested for production, but only provided as an example zig program to optimize. Suggestions for improving reliability, speed or memory usage are welcome.
For more information, read <a>my blog post</a>.
Benchmarks
Each command was run several times, with the best time taken. The zsh <code>time</code> utility with a <code>$TIMEFMT</code> that shows memory was used for benchmarking.
| file | json implementation | max memory (KB) | time (secs) |
| :----------------------: | :-----------------: | :-------------: | :---------: |
| tests/ascii_strings.json | zig-json | 100096 | 0.033 |
| tests/ascii_strings.json | std.json | 87232 | 0.152 |
| tests/numbers.json | zig-json | 94064 | 0.058 |
| tests/numbers.json | std.json | 220432 | 0.091 |
| tests/random.json | zig-json | 206512 | 0.154 |
| tests/random.json | std.json | 380240 | 0.300 |
| tests/food.json | zig-json | 1424 | 0.003 |
| tests/food.json | std.json | 1536 | 0.003 |
| tests/geojson.json | zig-json | 51104 | 0.031 |
| tests/geojson.json | std.json | 78944 | 0.038 |
A <a>Broch Web Solutions</a> project | [] |
https://avatars.githubusercontent.com/u/45130910?v=4 | ubik | Ratakor/ubik | 2023-09-06T13:23:52Z | A kernel | master | 0 | 5 | 0 | 5 | https://api.github.com/repos/Ratakor/ubik/tags | ISC | [
"kernel",
"zig"
] | 598 | false | 2024-11-05T16:55:18Z | true | true | unknown | github | [
{
"commit": "master.tar.gz",
"name": "limine",
"tar_url": "https://github.com/48cf/limine-zig/archive/master.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/48cf/limine-zig"
}
] | Ubik
A kernel
TODO
<ul>
<li>Rework VMM -> rework sched -> work on VFS -> work on ELF</li>
<li>Add a checklist/roadmap</li>
<li>Move tty and drivers out of kernel space</li>
<li>Replace json with zon</li>
<li>Replace unreachable with @panic</li>
<li>Provide compatibility with Linux ABI</li>
<li>Support RISC-V64, aarch64 and x86_64</li>
<li>Replace @import("root") with @import("main.zig") to allow for testing</li>
<li>Replace limine with a custom bootloader?</li>
<li>write core in zig and the rest in nov</li>
</ul>
Clone, build and run
Make sure to have <code>zig master</code>, <code>xorriso</code> and <code>qemu-system-x86</code> then run
<code>console
% git clone git@github.com:ratakor/ubik --recursive
% zig build run</code>
File structure
This shouldn't be in readme.
TODO: move init function at the end of file (or top?)
<ol>
<li>imports</li>
<li>type definitions</li>
<li>constants</li>
<li>variables</li>
<li>init function</li>
<li>pub functions</li>
<li>other functions</li>
</ol> | [] |
https://avatars.githubusercontent.com/u/20910059?v=4 | zig_TermCurs | AS400JPLPC/zig_TermCurs | 2023-06-09T18:49:27Z | Terminal access function Zig-Lang and Generator | master | 1 | 5 | 0 | 5 | https://api.github.com/repos/AS400JPLPC/zig_TermCurs/tags | MIT | [
"curses-library",
"generator",
"linux",
"terminal",
"zig",
"zig-lang"
] | 31,713 | false | 2025-04-15T18:59:29Z | false | false | unknown | github | [] | zig_TermCurs
terminal access function
<strong>zig 0.14.0</strong>
<strong>Major library restructuring:</strong>
remove library
Libtui (curse, log, calling, crypt, mmap,regex)
Libznd (decimal,field,date)
libsql currently only includes sqlite, postgresql to follow
All builds have been changed accordingly
The aim is to make projects independent
<strong>TESTING</strong>
<em>look at the bottom of the testing page</em>
<strong>os linux</strong>
Normally should work POSIX
<strong>the termcurs library, does what ncurse does (hopefully).
it manages the interface between the terminal and the user.
as does the 5250 of the OS400 with PC sauce.
Panel, window, field, grid, menu etc.
this can be used with a terminal with some editing eg: F10 etc. for convenience.
the easiest way is to make your own terminal with libvte of which I provide an example in the src-c folder.
this produces very lightweight programs for doing utilities or intensive typing for business management.
Currently everything is not operational and the goal is to make a screen generator to simplify development, considering that this is only secondary and that the heart of the problem is the program itself and not the interface.</strong>
** I use the gencurs program to thoroughly test the termcurs lib.**
Thank you
a little more : XYAMAN
Resumption of the project https://github.com/xyaman/mibu
Thank you
https://zig.news/
https://zig.news/lhp/want-to-create-a-tui-application-the-basics-of-uncooked-terminal-io-17gm
thank you for your valuable explanations David Vanderson
https://zig.news/david_vanderson
Structure the complex build
https://zig.news/xq/zig-build-explained-part-3-1ima
thank you for your valuable explanations Sam Atman
https://github.com/mnemnion/mvzr/
extra..., to follow and have a history
https://github.com/kissy24/zig-logger/
<strong>In the example, some errors are introduced such as the mail, all of this is voluntary and allows you to see the default interaction of the input control.</strong>
| Field | Regex | Text | Type |
| -------------------- | ------------ | -------- | -------------------------------------- |
| TEXT_FREE | Y | Y | Free |
| TEXT_FULL | Y | Y | Letter Digit Char-special |
| ALPHA | Y | Y | Letter |
| ALPHA_UPPER | Y | Y | Letter |
| ALPHA_NUMERIC | Y | Y | Letter Digit espace - |
| ALPHA_NUMERICT_UPPER | Y | Y | Letter Digit espace - |
| PASSWORD | N | Y | Letter Digit and normaliz char-special |
| YES_NO | N | Y | 'y' or 'Y' / 'o' or 'O' |
| UDIGIT | N | Y | Digit unsigned |
| DIGIT | N | Y | Digit signed |
| UDECIMAL | N | Y | Decimal unsigned |
| DECIMAL | N | Y | Decimal signed |
| DATE_ISO | DEFAULT | Y | YYYY/MM/DD |
| DATE_FR | DEFAULT | Y | DD/MM/YYYY |
| DATE_US | DEFAULT | Y | MM/DD/YYYY |
| TELEPHONE | Y OR DEFAULT | Y | +(033) 6 00 01 00 02 |
| MAIL_ISO | DEFAULT | Y | normalize mail regex |
| SWITCH | N | N / BOOL | CTRUE CFALSE |
| FUNC | N | y | <strong>dynamic function call</strong> |
| TASK | N | y | <strong>dynamic function call ex: control</strong> |
| CALL | N | y | **dynamic call exter |
| | | | |
MOUSE
| Type | up | down | left | Middle | right | X/Y |
| -------- | ---- | ------ | ------ | -------- | ------- | ----- |
| Menu | Y | Y | Y | Y | Y | N |
| GRID | Y | Y | Y | Y | Y | N |
| FIELD | Y | Y | Y | Y | Y | N |
| getKEY | Y | Y | Y | Y | Y | Y |
| | | | | | | |
FIELD
| KEY | text |
| ----------- | ---------------------------------------------|
| MOUSE | mouse array reference |
| escape | Restores the original area |
| ctrl-H | Show help |
| ctrl-P | exec program extern |
| home | Position at start of area |
| end | Position at end of area |
| right | Position + 1 of area |
| tab | Position + 1 of area |
| left | Position - 1 of area |
| shift tab | Position - 1 of area |
| bacspace | Position of area and delete char |
| insert | Position of area change cursor |
| enter | Control valide update origine next field |
| up | Control valide update origine prior field |
| down | Control valide update origine next field |
| char | Treatment of the character of the area |
| func | Interactive function linked to the input area. |
| task | Task executed after input in the zone. |
| call | Interactive function exec program extern |
GRID
| KEY | text |
| ---------- | -------------- |
| MOUSE | active |
| escape | return key |
| F12 | return key |
| enter | return ligne |
| up | prior ligne |
| down | next ligne |
| pageUp | prior page |
| pageDown | next page |
| return | Arg |
COMBO
| KEY | text |
| ---------- | ------------------------ |
| CellPos | Position start display |
| MOUSE | active |
| escape | return key |
| enter | return field |
| up | prior ligne |
| down | next ligne |
| pageUp | prior page |
| pageDown | next page |
| | |
---Organization-project------------------------------------------
→ folder deps: Filing of files zig including reference sources
→ folder libtui: zig source files
→ folder libznd: zig source files
→ folder libsql: zig source files
→ folder src_c: C/C++ source files
→ folder src_zig: ZIG-lang source files
→ build: build+source-name ex: buildexemple
→ makefile
<strong>LIBRARY</strong>
--peculiarity-------------------------------------------------
test alt-ctrl ctrshift... etc for
But it is no longer transportable.
another way is to use IOCTL but again, there is a good chance of being forced to use root.
Anyway, to make management applications or Terminal type tools are more than enough.
ctrl or alt combinations plus Fn(1..36) TAB Backspace home end insert delete pageup pagedown enter escape alt ctrl left rigth up down altgr mouse
and the utf8 keyboard is a lot.
--styling-------------------------------------------------
make it compatible as close as possible to IBM 400 ex:
ex: pub const AtrLabel : stl.ZONATRB = .{
.styled=[_]i32{@enumToInt(stl.Style.styleBright),
@enumToInt(stl.Style.styleItalic),
@enumToInt(stl.Style.notstyle),
@enumToInt(stl.Style.notstyle)},
.backgr = stl.BackgroundColor.bgBlack,
.backBright = false,
.foregr = stl.ForegroundColor.fgGreen,
.foreBright = true
};
-------Current treatments------------------------------------
→ forms.zig
→ fram / panel / label /button / Menu / Grid / Combo / dynamic function Exec ** OK
→ Preparation of "Field" processing as well as keyboard input.
Please wait, if there are bugs everything is not fixed.
-------TESTING------------------------------------
→ <em>Use the gtk Term.c terminal, it's much simpler terminals ex: exf4-terminal</em>
-------To write and think--------------------------------
→ inspiration <code><br /></code>
<ul>
<li><a>nim-termcurs</a></li>
</ul>
---------------------------------------------------------
| for information|
→ 2023-02-28
Hello, it is now possible to use a terminal without leaving a trace, I added in "curse" the "reset" function,
on the other hand, i included in the cls function the underlying cleanup of the terminal, i put here the terminal start function for, you help ( xfce4-terminal --hide-menubar --hide-scrollbar --hide -toolbar --geometry="158x42" --font="DejaVu Sans Mono 12" just add -e ./...program
→ 2023-02-28
<strong>Applications no longer need lib-GTK VTE</strong>
in general to debug well, to use the console, it is advisable to deactivate preferences F10 and ALT... ,
then compile with SMALL and to ensure violation of ALT-F4 use the cpp program gtk-vte an example is there.
But in terminal mode the application is viable (to do with the commit data-base)
→ 2023-02-05 Doc version 0.11.1 "view use TermCurs"
<a>READ-DOCS</a>
les news:
→ 2024-01-04
LINUX
Should it work with MAC?
TRADUCTOR chatgpt
Hello, there are very significant changes, why?
Firstly, for better memory management.
Greater coherence.
All modules have their own allocators.
Avoiding back-and-forth between modules.
"CURSED" (named in memory of "NCURSEW"):
Encompasses everything needed for writing to a terminal, including reading keyboard codes, mouse management, cursor handling, UTF8 work. I may introduce the "termios" concept for META codes. I took advantage of the restructuring to bring clarification.
"FORMS":
Includes management for:
LABEL - BUTTON - LINEV - LINEH - FIELD - FRAME - PANEL
Works with a matrix corresponding to the terminal surface so that the window can be restored. The FORMS allocator is designed for Fields and panel initialization. FORMS no longer includes GRID management, which is autonomous, nor MENU, which is autonomous
"GRID":
Functions similarly to forms, allowing the display and retrieval of arguments either from a database or working as a combo. It is autonomous, but you must consider that it should be included in your Panel, as it positions itself within the terminal window.
"MENU":
Operates like GRID but is much simplified; the returned argument is usize.which doesn't work with the matrix but directly with the terminal.
"UTILS": (various tools and functions)
Contains various functions to manage the control needs of FIELD or STRING management ([] u8 const).
The Example program demonstrates how to manage and use these functions. A tip: the first Panel can serve as the definition of the terminal window.
"MATCH": (regex MVZR pur zig)
"LOGGER":
Allows for a written record of variables or waypoints.
"CALLPGM": Executes in Zig mode, manages the call and the wait.
→ PANEL
Adding the 'mdlPanel' function.
- F2 : view panel
- F6 : Choix panel for update
- F9 : Create Panel
- F11 : Update Panel
- F12 : return
→ FORMS
Adding the 'mdlForms' function.
- F1 : help
- F11 : update and return
- F12 : return
- Alt-T: Create Title
- Alt-L: Create Label
- Alt-F: Create Field
- Alt-G: View Grid
- Alt-U: Update Field
- Alt-H: Creat Line Horizontal
- Alt-V: Creat Line Vertical
- Alt-W: Tools menu (View , Order , Remove )
→ GRID
Adding the 'mdlGrid' function.
- F1 : help
- F11 : update and return
- F12 : return
- Alt-G: Create GRID definition
- Alt-C: Create text columns
- Alt-R: Remove GRID
- Alt-W: Tools menu (View GRID, View Cell, Order Cell, Remove Cell, Update Grid)
→ MENU
Added MENU definition function
you have to understand the menu option as a fixed combo with constant values
- F1 : help
- F11 : update and return
- F12 : return
- Alt-M: Create MENU definition
- Alt-C: Create / UPDATE text columns
- Alt-V: View MENU
- Alt-D: Remove MENU
- Alt-H: display higth MENU
- Alt-L: display low MENU
- Alt-X: Fixed display work menu
- Alt-R: Fefresh terminal
→ Gensrc
Added Gensrc definition Programme
- Folder : choix du model
- Control : list control
- List : List of the DSPF nomencalature
- Link-Combo : combo assignment CtrlV validation
- SrcMenu : output srs-lst
- SrcForms : output srs-lst
- Clear *all : Cleaning arraylist buffers
- Exit : Exit
→ 2024-11-20 15:40
- update library CURSED -> Modification of keyboard key retrieval for a terminal in a more functional way.
- update module MDLFILE -> Improved sorting algorithm integrated, with the ability to add a file attribute.
- I am currently testing source code generation, and sometimes I question my code, particularly the way I approach the matrix.
→ 2024-11-23 15:40
- update MOUSE -> click Left Middle = none click Right Enter for MENU and GRID
- new module -> Gensrc SrcMenu SrcForms générate source main
- I am currently testing source code generation, and sometimes I question my code, particularly the way I approach the matrix.
- update ENV-WORK
- update MenuDEV.sh new MenuTEST.sh
- First test Gensrc - srcforms - srcMenu
- folder OUT-ZIG to test
- use for test only folder(repertoire)
→ 2024-11-26 20:28
Please refer to the files in the directory: dspf/repertoire/.
You will notice that function keys are assigned, such as F9 for adding a record and F11 for updating a record; these are standard industrial practices recommended in management.
You can compare the output source with the SRC program.
→ 2024-12:18 00:00
"I have refactored all the sources to make them compatible with Zig's LSP and code editors: all indentation tabs are spaces '....' and not '→'.
At the moment, I just finished testing the decimal function, and I now need to test the zstring function to ensure everything complies with industrial SQL database standards, such as varchar(10) or decimal(5,2).
For decimal, see my Git repository Zdecimal; the number of digits goes far beyond the limitations of C or Zig."
→ 2024-12-19 04:20
add ztring
→ 2024-12-21 04:20
harmonization of functions between ZSTRING AND DECIMAL, in order to have a simplification in programming
→ 2025-01-05 02:52
Fixed bug for range detected zig 0.14.0-dev.2598 from "mdlforms" / "mdlgrids".
err: for (vgrd.items[gridNum].pageRows)...
ex: for (0..vgrd.items[gridNum].pageRows)...>
→ 2025-01-05 18:31 update Terminal.7z clear cache
→ 2025-01-16 10:32
→ 2025-03-12 02:52 update 0.14.0
→ 2025-03-12 06:40 unicode.Decode deprecated change Utf8View
→ 2025-04-15 11:00 add function update Grid
→ 2025-04-15 11:00 standardization of color functions
→ 2025-04-15 11:00 Correction of a position cursor bug with the mouse
→ 2025-04-15 11:00 new “isfile” test with “access”.
<strong>big bug input change module utils of libtui</strong>
Anyway, it's all fixed now.
I've been chasing memory leaks too much
Hello, sorry for the bug in the zone entry, I tried to run after the leaks euuhh a big slap.
I worked on the dates and that led me to restructure all the libraries for a smoother future.
I retested and only compiled.
LIBTUI: includes everything related to the terminal and its execution.
LIBZND: processing -> Decimal, Zfield, Date-time.
LIBSQL: in preparation now that I've finished DATE-TIME
I'm going to work on open date space so that FIELDs are easy to access.
the source generator isn't finished, I'd like to process the GRIDs, that's why I'm on sql....
I recommend using the GENSRC program (C/C++) that emulates a clean terminal and allows for debugging.
You can see the source generation of formsrc and formtest, which has been reworked.
Keep in mind that the generation is a skeleton; I am trying to reduce the repetitive overhead of programming so we can focus on the requested functionality.
I haven't finished yet; I still need to make changes, for example, the GRID SFLD, which is a grid with data, etc.
------------------------------------------------------------------
Now that the entire designer allows for saving and restoring the code, this has allowed me to test my functions, and especially to take a little tour of the Zig language. I opted for working and writing with maximum use of the Zig language, so I don't use addressing or hex code; everything is in Zig.
PAUSE
In the current state, one could very well use JSON files and encapsulate them in the program, and why not make the forms in the project dynamic... I did this on the AS400. | [] |
https://avatars.githubusercontent.com/u/80269251?v=4 | Sudoku | nilostolte/Sudoku | 2023-03-08T16:51:28Z | Simple 9x9 Sudoku brute force solver with intrinsic parallel candidate set processing using bits to represent digits in the [1, 9] range, and bitwise operations to test a candidate against the candidate set, all at once. | main | 0 | 5 | 0 | 5 | https://api.github.com/repos/nilostolte/Sudoku/tags | - | [
"bitwise-operators",
"brute-force-algorithm",
"c",
"java",
"optmization",
"sudoku",
"zig"
] | 275 | false | 2025-04-17T12:14:00Z | false | false | unknown | github | [] |
Sudoku
Simple 9x9 Sudoku brute force solver with intrinsic parallel candidate set processing using bits to represent digits in the [1, 9] range, and bitwise operations to test a candidate against the candidate set, all at once.
It can be upgraded for 16x16 or 25x25 grids.
The algorithm was implemented in <a>Java</a>, in <a>C</a>, as well as in <a>Zig</a>. The description
below concerns the Java implementation, even though the <a>C implementation</a> is quite similar, but
without classes. <a>Zig implementation</a> is similar to C's but faster and with an OOP style stack. In
the Zig version <a>many optimizations</a> allowed to achieve a minimum running time of 0.7916
miliseconds for the same
<a>test grid</a> run on my
Intel Core i7-2670QM @ 2.20GHz laptop:
The supplied Windows 64 executables for the <a>C</a> and <a>Zig</a> implementations can be
used to solve arbitrary grids as described in the <a>documentation</a>.
Grid
This is the <a>class</a> containing the grid to be solved.
Input
The grid can be initialized using a 9x9 matrix of type <code>char[][]</code> or through a linear string containing all the elements, representating
empty elements as 0 (or ' . ' in the C or Zig version), both given line by line. The <code>char[][]</code> is the unique input, however, and it must exist before being able to use
any other input format. Even though the 9x9 matrix contains characters (it's a <code>char[][]</code>), the digits are not represented as ASCII or Unicode
characters but rather as integers. In other words, the character '0' is actually represented by 0, and so forth.
In the string input format the string is just copied over the existing input <code>char[][]</code> matrix using the static function <code>set</code>. This string uses
ASCII representation for the digits which are converted to integers by the function <code>set</code>.
An additional representation is possible, as illustrated in <a>Main.java</a>, by
representing the charcater '0' with the character '.' in the string. In this case one adds <code>.replace('.','0')</code> at the end of the string as shown.
Both string input formats are common representations of Sudoku grids on the web.
Data Structures
The main data structure in <code>Grid</code> is <code>matrix</code> which is a 9x9 matrix in identical format as the input matrix for the grid. This is the matrix
where the input matrix is copied to.
Auxiliary Data Structures
The main auxiliary data structures are the most interesting part of this class, besides the solver algorithm itself:
<ul>
<li><code>lines</code> - an array with 9 positions, each one, corresponding to a line in the grid, and functioning as a set where each bit represents a digit
already present in that line.</li>
<li><code>cols</code> - an array with 9 positions, each one, corresponding to a column in the grid, and functioning as a set where each bit represents a digit
already present in that column.</li>
<li><code>cells</code> - a 3x3 matrix, corresponding to a 3x3 cell that the grid is subdivided, with 9 positions, each one functioning as a set where each bit
represents a digit already present in that cell.</li>
</ul>
Additional Auxiliary Data Structures
<ul>
<li><code>stk</code> - the stack to implement the backtracking algorithm. It uses an array of 81 positions. It uses the <code>push</code> and <code>pop</code> operators as shown in
the <a>algorithm</a> below. The <code>push</code> operator not only stores the digit, its
<a>binary representation</a>,
the line and column (<code>i</code> and <code>j</code>) of the element inserted in a stack node (<code>StkNode</code>), <em>"pushing"</em> the node in the stack, but also inserts the
digit in the internal matrix (<code>matrix[i][j]</code>) as well as its binary representation into the auxiliary data structures, thus, updating the candidate
set of the new element inserted. The <code>pop</code> operation only removes the node from the stack, but the node is not garbage collected. It remains in the
stack as an unused element. Nodes are lazily allocated, as <code>null</code> elements are found while pushing.</li>
<li><code>cel</code> - an array with 9 positions, each one is the inverse mapping of the indices in the lines and columns transformed into indices in the 3x3
matrix <code>cells</code>.</li>
</ul>
Representing a set of present digits with bits
All main auxiliary data structures use a common notation to represent a set of digits present in the line, column, or cell, accordingly.
A bit is set to one at the position corresponding to a digit present in the set, or set to zero if it's position corresponds to a digit that
is absent. By reversing the bits one gets the "candidate set" of digits that are still missing in the corresponding line, column or cell. For
a better understanding of this candidate set scheme, please refer to the
<a>subsection</a> explaining how digits are represented in binary.
Let's suppose a particular line, column or cell having the digits, 1, 3, 4 and 9. This set is then represented by the following binary number:
<strong>100001101</strong> = <strong>0x10D</strong>
<ul>
<li>the first rightmost bit corresponds to the digit 1, and in this case it's present in the set already.</li>
<li>the second bit on its left corresponds to the digit 2, and its clearly not present yet since its value is zero.</li>
<li>bits three and four, corresponding to the digits 3 and 4, respectively, are clearly present, because they are both set to one.</li>
<li>bits five, six, seven, and eight are all zeros, and thus, digits 5, 6, 7 and 8 are clearly absent in the set.</li>
<li>bit 9 is 1. Therefore, the digit 9 is also present in the set.</li>
</ul>
Final Candidate Set
In order to obtain a candidate set for a given <code>matrix[i][j]</code> element of the grid one calculates:
<strong><code>lines[i] | cols[j] | cells[ cel[i] ][ cel[j] ]</code></strong> (1)
The expression in (1) gives a set where all bits containing zeros correspond to the available digits that are possible to be in <code>matrix[i][j]</code>.
The candidate set is detected by the absent elements in the set, that is, all bits which are zero.
The interest in this notation is that the concatenation of all three sets is obtained by just using two bitwise or operations.
One can observe how <code>cel</code> inverse mapping works to access the corresponding cell in <code>cells</code>. First, <code>i</code> and <code>j</code> are used as indices in <code>cel</code>. <code>cel[i]</code> and <code>cel[j]</code> give the corresponding line and column in <code>cells</code>. Therefore, <code>cells[cel[i]][cel[j]]</code> corresponds to the cell where <code>matrix[i][j]</code> is contained.
Algorithm
<code>java
public void solve() {
StkNode node;
int digit = 1, code = 1, inserted;
int i, j;
char[] line = matrix[0];
char c;
i = j = 0;
do {
c = line[j];
if (c == 0) {
inserted = lines[i]|cols[j]|cells[cel[i]][cel[j]];
for ( ; digit != 10 ; digit++, code <<= 1 ) {
if (( code & inserted ) == 0 ) {
push(i, j, code, digit);
digit = code = 1;
break;
}
}
if ( digit == 10 ) { // no insertion -> backtrack to previous element
node = pop(); // pop previous inserted i, j, and digit
i = node.i;
j = node.j;
digit = node.digit;
code = node.code;
remove(node); // remove digit from data structures
digit++; code <<= 1; // let's try next digit;
line = matrix[i]; // maybe line has changed
continue; // short-circuit line by line logic
}
}
if ( j == 8 ) { // line by line logic
j = -1; i++; // last line element, advance to next line
if (i < 9) line = matrix[i]; // update line from grid matrix
}
j++; // advance to next element in the line
} while (i < 9);
}</code>
Binary Representation for Digits
In the binary representation, a digit is always a power of two, since it's a number with only one bit set to 1 at the position corresponding
to the digit. The table below shows the correspondence between digits and their binary representation:
| Digit | Binary Representation | Hexadecimal | Decimal |
| :---: | :-------------------: | :---------: | :-----: |
| 0 | <strong>000000000</strong> | 0x000 | 0 |
| 1 | <strong>000000001</strong> | 0x001 | 1 |
| 2 | <strong>000000010</strong> | 0x002 | 2 |
| 3 | <strong>000000100</strong> | 0x004 | 4 |
| 4 | <strong>000001000</strong> | 0x008 | 8 |
| 5 | <strong>000010000</strong> | 0x010 | 16 |
| 6 | <strong>000100000</strong> | 0x020 | 32 |
| 7 | <strong>001000000</strong> | 0x040 | 64 |
| 8 | <strong>010000000</strong> | 0x080 | 128 |
| 9 | <strong>100000000</strong> | 0x100 | 256 |
The binary representation as exposed in the table above is often called here as the <em>"code"</em> of the digit.
Implementation of Digit Retrieval in Candidate Set
As we can see the variable <code>inserted</code> contains the "candidate set" for a given <code>matrix[i][j]</code>. This algorithm is quite simple but it
contains a major drawback. Since the digit is represented with a 1 bit in its corresponding position in variable <code>code</code>, and it accesses
the candidate set in a sequential way, it loops until an empty bit is found (<code>( code & inserted ) == 0 )</code>) or if it finds no available
candidate (<code>digit == 10</code>).
This means that even if there are no available candidates, the algorithm has to loop over all the remaining bits sequentially. Even if the binary
representation allows to deal with the candidate set with all elements in parallel, that is, all elements at once, we still have to access
it one by one sequentially even when there are no useful results. This problem is adressed with some partial solutions as shown <a>here</a> and
<a>here</a>, but this later employs far too many operations, despite
the fact it's a branchless solution. It's only interesting when associated with other optimizations as it has been done in the
<a>C version</a>.
Stack and Backtracking implementation
Digits are tried in ascending order from 1 to 9 for each element in the grid that is not yet occupied. That's why <code>digit</code> and <code>code</code>
variables are both initialized with 1. Every time a new digit is tried against the candidate set, and a successful candidate is found
(that is, when <code>( code & inserted ) == 0 )</code>), the digit is pushed on the stack.
The <code>push</code> function also updates <code>matrix[i][j]</code>, <code>lines[i]</code>, <code>cols[j]</code> and <code>cells[cel[i]][cel[j]]</code> with the new digit. Please check the
<a>code</a> and the description of
<a><code>stk</code></a> for details.
When no suitable candidate is found (that is, when <code>( code & inserted ) == 0 )</code> fails for every candidate tried), then the <code>for</code> loop
ends, and <code>digit == 10</code>. In this case, we need to backtrack, that is, remove the current candidate, and advance the previous inserted
digit to be the next candidate. This is taken care by the instructions found under the <code>if ( digit == 10 )</code> statement, where the previous
candidate is popped from the stack, removed from <code>matrix</code> and the auxiliary data structures (function <code>remove</code>), and advanced to
be the next candidate (<code>digit</code> is incremented and <code>code</code> is shifted left). Notice that this command sequence terminates with a <code>continue</code>
statement in order to skip the line by line logic. Since the line and column (<code>i</code> and <code>j</code>) of the element to be dealt next are already
known (they were popped from the stack), modifying <code>i</code> or <code>j</code> is not required. Also of note, if all the possible candidates were
tried, <code>digit</code> will become 10, the <code>for</code> loop is summarily skipped, and the flow goes back into this code sequence to backtrack once
again, dealing with the cases of "cascaded" backtracking sequences.
This completes the backtracking mechanism, allowing, as can be easily infered, to obtain the solution of the input grid in the internal
matrix. As shown in <a>Main.java</a>, the solution is printed using the function
<code>print</code>.
Parallel check for no candidates
The logic to check if there are no candidates with no loops is much more involved than what's done in the algorithm above, but its not rocket
science. It only requires more effort to use our bit representation in a smarter way.
Mask to Filter Candidate Sets
Every power of two subtracted by one is always equal to a sequence of ones on the right of the position it was previously one (except in the
case of 02, since there are no more binary digits on the right of 1). For example, the digit 8 in binary is 128 in our
representation. When subtracted by one, that's 127, that is, 8 bits set to 1 on the right of bit 8:
<strong>128 - 1 = 010000000 - 1 = 001111111</strong>
By reversing every bit of this result one obtains a mask that's unique when all these bits are 1, that is, when there are no candidates from
the bit in the current position until the last bit:
<strong>~001111111 = 110000000</strong>
That is, by executing a bitwise <em>and</em> operation (<code>&</code>) between this mask and a candidate set, and if the result is identical to this mask,
we can say there is no available candidates left in the candidate set, starting with the digit we are trying, 8 in this case.
Let's check the same logic with digit = 5:
<strong>~(000010000 - 1) = ~000001111 = 111110000</strong>
Then by testing if
<strong>111110000 & inserted == 111110000</strong>
What this is actually saying is that there are no candidates neither for 5, neither any digit above it. In other words, this is exactly the
condition we were looking for.
One could call this as <code>reachable</code>, that is, more formally speaking what we've got is:
<strong><code>reacheable = (~(code-1)) & 0x1ff;</code></strong>
Notice that we have to filter out all bits above bit 9. Then the condition searched would be written like
<strong><code>if ( (inserted & reacheable ) == reacheable )</code></strong> (2)
Changes in the Algorithm
In this case <code>if</code> statement (2) can substitute the following <code>if</code> statement in the algorithm:
<strong><code>if ( digit == 10 )</code></strong>
And we should place <code>if</code> statement (2) above the <code>for</code> loop statement instead of the order presented in the algorithm. In this
case the <code>for</code> can be written with no final condition, since it would never be reached:
<strong><code>for ( ; ; digit++, code <<= 1 )</code></strong> (3)
The reason for that is that if there are no candidates, as calculated here, then the condition of the <code>if</code> statement (2) must be true
and, therefore, the <code>continue</code> statement relative to the do-while statement is executed before the <code>for</code> statement (3) is ever reached.
This obviously short-circuits the <code>for</code> statement (3), since it is now below the <code>if</code> statement (2). If the <code>for</code> statement (3) is reached,
the condition in the <code>if</code> statement (2) must have been false. In this situation there will always be a valid candidate and the
<code>break</code> command relative to the <code>for</code> statement (3) will be executed, always ending this loop with no need to test the end condition.
Simplification of this Optimization - Eliminating the Mask
Another way to see this optimization is by observing that instead of calculating the mask as explained above, which implies using an intermediate
variable <code>reacheable</code>, one can infere an equivalent conclusion by simply discarding this variable and using the following test instead of if statement (2):
<strong><code>if ( (inserted + code ) > 511 )</code></strong> (2a)
Which we call here an alternative to (2), or (2a) for short.
If there are only ones in <code>inserted</code> starting at the position of the 1 in <code>code</code>, adding <code>code</code> to <code>inserted</code> will result in
some value that is obviously beyond 511 (or 0x1ff). Therefore, we can detect the same situation with only the test (2a), not only
eliminating the need of calculating the mask, but also the need of the variable <code>reacheable</code>.
Benchmarks
The benchmarks to measure algorithm performance were performed on an i7 2.2 Ghz machine in Java and in C.
The <a>executable file compiled in C</a> has
been done with optimization option <code>-O3</code> using the <strong>gcc</strong> compiler on Windows provided in
<a><strong>w64devkit</strong></a>, which is a Mingw-w64 <strong>gcc</strong> compiler that is portable (can be installed by just
copying the directory structure in disk, SD card, or thumb drive).
Main Test Grid
The benchmarks were executed with several different grids, but particularly with this
one, which is known to be time consuming in automatic methods, and used to compare speed of different methods
on the web:
| <em>1</em> | <em>2</em> | <em>3</em> | <em>4</em> | <em>5</em> | <em>6</em> | <em>7</em> | <em>8</em> | <em>9</em>
:------:|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:|:-----:
<strong><em>1</em></strong> | | | | | | | | | |
<strong><em>2</em></strong> | | | | | | | | | |
<strong><em>3</em></strong> | | | | | | | | | |
<strong><em>4</em></strong> | | | | | | | | | |
<strong><em>6</em></strong> | | | | | | | | | |
<strong><em>6</em></strong> | | | | | | | | | |
<strong><em>7</em></strong> | | | | | | | | | |
<strong><em>8</em></strong> | | | | | | | | | |
<strong><em>9</em></strong> | | | | | | | | | |
Benchmarks in Java
The minimal time measured for the optimized algorithm to solve the above grid after several attempts was 10 miliseconds,
and the double for the unoptimized algorithm. Nevertheless, the times verified were quite variable as usual in Java
while measuring fast algorithms like this. This is the reason it would worth trying to implement it with an entirely
compiled language (Java is only compiled when the JIT compiler is triggered) to verify if execution times are less
variable. It looks like that for this kind of problem, an enterily compiled language would be more appropriate, since
one expects similar times for the same grid running at different times. Unfortunately this is not the case for this
Java implementation.
Benchmarks in C
Astonishingly, execution times running the executable compiled in C were only slightly more constant than in Java. The
times varied from 1.5 miliseconds to 5.26 miliseconds. However, these variations were considerably much less significant
than in Java. Also, C offered roughly about an order of magnitude to about twice less time than the Java implementation
of the same optimized algorithm. Several optimizations were devised besides the ones mentioned below. After all these
optimizations were applied, one obtained a significant
<a>improvement in performance</a> and the
<a>Windows 64 executable supplied</a> was generated with
the resulting source code.
Brachless Next Candidate Determination
The parallel test for no candidates allows to discard unnecessary <code>for</code> loop iterations, while also discarding the unecessary end
condition of the <code>for</code> loop (since the order of the <code>if</code> statement (2) and the <code>for</code> statement was reversed). Nevertheless, for
detecting the first candidate one still has to loop and test the digits one by one sequentially against the <code>inserted</code> set.
But there is a way to calculate the next candidate without any loop. The technique can be illustrated through and example.
Supposing the set <code>included = 101011110</code> (that is {9,7,5,4,3,2}, the set of digits already inserted) and
<code>digit = 000000010</code> (2), one starts by adding both:
<code>101011110 // included digits set: {9,7,5,4,3,2}
+ 000000010 // digit = 2</code>
Which is equal to <strong><code>101100000</code></strong>. One now does an exclusive or with <code>included</code>:
<code>101100000
^ 101011110</code>
Which is equal to <strong><code>000111110</code></strong>. One now adds digit again:
<code>000111110
+ 000000010</code>
Which is equal to <strong><code>001000000</code></strong>. The bit representation of the next candidate, is obtained by shifting one position to
right:
<code>001000000 >> 1</code>
Which is equal to <strong><code>000100000</code></strong>. This corresponds to the digit 6, which is exactly the first zero bit found by
applying the for loop (3).
Therefore, assuming <code>code</code> as the bit representation of the digit, one calculates the next candidate doing:
<code>java
code = (((code + inserted) ^ inserted) + code) >> 1; // branchless code calculation</code>
The problem is that one only obtains the bit representation of the digit, not the digit itself. As, one can see, <code>digit</code> is
necessary to be able to use this technique.
Branchless Transformation from Bit Representation
To obtain the digit from its code, one "assembles" the bit configuration of the digit from its bit representation (<code>code</code>) as follows:
<code>java
digit = ( code >> 8 ) |
(( code & 0x40 ) >> 6 ) |
(( code & 0x140) >> 5 ) |
(( code & 0xf0 ) >> 4 ) |
(( code & 0x20 ) >> 3 ) |
(( code & 0x14 ) >> 2 ) |
(( code & 0x0c ) >> 1 ) |
( code & 3);</code>
This conversion is not only complex to understand, but also requires a high number of operations. Trying out this code and the
brachless calculation of the next candidate as shown
<a>previously</a>, the minimal time
in C passed from 1.5 to 1.4 miliseconds, which apparently wouldn't seem to justify the effort.
However, after multiple further opimizations, including using <code>register</code> variables, the minimal running time was reduced to
1.2 miliseconds. This corresponds to a speedup of roughly 20%, which starts to become quite consequential. It's clear that
this is also consequence of the highly "imperative" way of implementing this <a>algorithm</a>
which manifestly highly benefits the C implementation, that in itself is more easily optimizable by employing extremely low level
gimmicks that are absent in Java.
Table to Convert from Bit Representation
Another way to do the calculation <a>above</a>
is using tables. For example, in C:
<code>C
unsigned short c1[] = { 0, 1, 2, 0, 3 };
unsigned short c2[] = { 0, 4, 5, 0, 6 };
unsigned short c3[] = { 0, 7, 8, 0, 9 };</code>
One can compose the digit from its bit representation <code>code</code> in the following way:
<code>C
digit = c1[code & 7] | c2[(code >> 3) & 7] | c3[code >> 6];</code>
This code is more understandable than the <a>previous</a>
one. If the digit is 1, 2 or 3, one simply filters the first 3 bits of <code>code</code>and index the table <code>c1</code> with this result. Position 3 is invalid
since <code>code</code> has only 1 bit set, and, thus, it can't be 3. Notwithstanding, the resulting operation can be zero, in the case the binary
representation doesn't have any bit set in that range. In this case, to satisfy the branchless logic, the table value is 0.
If the digit is 4, 5 or 6, one shifts <code>code</code> to the right 3 positions and filters the first 3 bits and index the table <code>c2</code>
with this result. The same logic applies to digits 7, 8 and 9, using table <code>c3</code>. Since one doesn't know which one is correct, one simply
apply a binary or operation with the 3 results, after all only one of them contains the good digit. The other two will be zero.
Trying this solution instead of the <a>previous</a>,
had a significant impact in the minimal execution time of the compiled C code, that was reduced to practically 1 millisecond, that is,
an optimization of more than 30%, since the initial minimal time in our comparisons was 1.5 milliseconds.
Conclusion
The several optimizations proposed are complex to understand and most of them do not result in a significant speed up. The
<a>initial algorithm</a> and
in the <a>Java</a> and <a>C</a>
codes, are more clear and relatively easy to understand after the binary representation is understood.
The idea of parallelizing the code by dealing with the whole candidate set at once just using binary representation is promising.
However, it falls short if one was thinking in using its intrisic parallelism in the entire algorithm. As seen
<a>above</a>, the
approach allows branchless solutions for the sequential search of a candidate from an arbitrary digit value, which only partially
exploits this intrisic paralellism. Notwithstanding, it's heavily relying on the integer addition carry propagation mechanism,
which is actually a sequential mechanism, but implemented highly efficiently in hardware. This is just additional ingenuity, but
not the same approach. The actual problem in this partial solution is that it's highly complex and requires a high number
of operations. Thus, it highly diverges from the extreme simplicity of the original algorithm. Fortunately, associated with numerous
other low level optimizations in C language, it contributed to a significant
speedup (as can be seen <a>here</a>), and
a better speedup as well as less complexity (as seen <a>here</a>).
A comparative test between the Java implementation and an identical C inplementation has given a considerable advantage to the C
implementation, not only in terms of raw performance, but also in terms of less variability in times measured for solving
the same grid, even though, variable execution times were also present in the C implementation. This was expected since Java
activates the JIT compiler not quite regularly in codes that are executed in short ammounts of time like this one.
Given the extremely short execution times, the low level nature of the <a>original algorithm</a>,
and the considerable amount of low level optmizations that are possible in C language, one may confortably conclude that C is the
most appropriate language to use the algorithm, since it will provide faster answers. This means, that the C implementation can be seen
as the ideal engine for an interactive program where the grid can be entered through a GUI and that the solution must be supplied
in real time when it is requested by the user. | [] |
https://avatars.githubusercontent.com/u/5464072?v=4 | zig-js | nektro/zig-js | 2023-11-20T20:54:33Z | [WIP] An ECMAScript module for Zig. | master | 0 | 5 | 0 | 5 | https://api.github.com/repos/nektro/zig-js/tags | MPL-2.0 | [
"zig",
"zig-package"
] | 388 | false | 2025-05-21T20:33:35Z | true | false | unknown | github | [] | zig-js
<a></a>
<a></a>
<a></a>
<a></a>
An ECMAScript module for Zig. Currently includes a parser.
Progress
<code>Build Summary: 3/7 steps succeeded; 3 failed; 3643/4696 tests passed; 16 skipped; 1037 failed
test transitive failure
├─ run test 1817/1984 passed, 159 failed, 8 skipped
│ └─ zig test Debug native success 1m MaxRSS:2G
├─ run test 1624/1983 passed, 351 failed, 8 skipped
│ └─ zig test Debug native success 50s MaxRSS:2G
└─ run test 202/729 passed, 527 failed
└─ zig test Debug native success 50s MaxRSS:2G</code> | [] |
https://avatars.githubusercontent.com/u/5885545?v=4 | monkey-lang | JacobCrabill/monkey-lang | 2023-05-24T14:21:35Z | An implementation of the Monkey programming language in Zig | main | 0 | 5 | 0 | 5 | https://api.github.com/repos/JacobCrabill/monkey-lang/tags | MIT | [
"interpreter",
"monkey-programming-language",
"zig"
] | 134 | false | 2025-03-17T02:34:05Z | true | false | unknown | github | [] | Monkey Interpreter in Zig
An implementation of the Monkey programming language in Zig
Following Thorsten Ball's <a>"Writing An Interpreter in Go"</a>
Status
The lexer and parser are working to some extent; to run tests, do:
- Lexer: <code>zig build test-lexer -fsummary</code>
- Parser: <code>zig build test-parser -fsummary</code>
Note: <code>-fsummary</code> forces the test summary to be displayed; otherwise silence means success. | [] |
https://avatars.githubusercontent.com/u/109168613?v=4 | larZig | Bunland/larZig | 2023-12-07T04:57:21Z | Lar javascript runtime | main | 0 | 5 | 1 | 5 | https://api.github.com/repos/Bunland/larZig/tags | - | [
"javascript",
"javascriptcore",
"runtime",
"zig"
] | 5,707 | false | 2024-11-27T08:42:13Z | true | false | unknown | github | [] | Lar Runtime
A javascript runtime written in zig that uses javascriptcore as the javascript engine.
Api List
Console Api Status
<code>typescript
console.assert(value[, ...message]) // ready
console.clear() // ready
console.count([label]) // ready
console.countReset([label]) // ready
console.debug(data[, ...args]) // ready
console.dir(obj[, options]) // soon
console.dirxml(...data) // soon
console.error([data][, ...args]) // soon
console.group([...label]) // soon
console.groupCollapsed() // soon
console.groupEnd() // soon
console.info([data][, ...args]) // soon
console.log([data][, ...args]) // ready
console.table(tabularData[, properties]) // soon
console.time([label]) // soon
console.timeEnd([label]) // soon
console.timeLog([label][, ...data]) // soon
console.trace([message][, ...args]) // soon
console.warn([data][, ...args]) // soon
console.prompt([labe]) // ready</code>
FS Api Status
<code>typescript
lar.writeFile([path], [data]) // ready
lar.readFile([path]) // ready
lar.existsFile([path]) // ready
lar.removeFile([path]) // ready</code>
Shell Api Status
<code>typescript
lar.shell("ls -l") // ready</code>
Learning Project
This is a personal learning project focused on understanding how JavaScript runtimes written in C, Go, or Zig are created. As such, it's not recommended to use the Lar Runtime for production purposes.
Code Usage
If you decide to use any code from this runtime, I kindly request that you mention Lar Runtime in your project documentation, as well as in your code comments. | [] |
https://avatars.githubusercontent.com/u/43040593?v=4 | 9p-zig | dantecatalfamo/9p-zig | 2023-03-13T05:37:27Z | 9P2000 protocol implemented in zig | master | 0 | 5 | 0 | 5 | https://api.github.com/repos/dantecatalfamo/9p-zig/tags | MIT | [
"9p",
"9p2000",
"filesystem",
"plan9",
"protocol",
"zig",
"zig-library",
"zig-package"
] | 41 | false | 2025-02-19T06:18:06Z | true | false | unknown | github | [] | 9p-zig
9P2000 protocol client/server implemented in zig
Files
<ul>
<li><code>src/main.zig</code> - Test case</li>
<li><code>src/9p.zig</code> - Library</li>
<li><code>u9fs-server.sh</code> - Test server script</li>
</ul>
Example
Client
```zig
const std = @import("std");
const debug = std.debug;
const z9p = @import("9p.zig");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
var allocator = gpa.allocator();
<code>// Open connection
const stream = try std.net.tcpConnectToHost(allocator, "127.0.0.1", 5640);
defer stream.close();
std.debug.print("Connected\n", .{});
// Initialize client
var client = z9p.simpleClient(allocator, stream.reader(), stream.writer());
defer client.deinit();
// Setup protocol
try client.connect(std.math.maxInt(u32));
// Login to the server with name at endpoint, returning a handle
const root = try client.attach(null, "dante", "");
defer root.clunk() catch unreachable;
std.debug.print("root: {any}\n", .{ root });
// Return a directory handle associated with the root
const top_dir = try root.walk(&.{ "" });
std.debug.print("top_dir: {any}\n", .{ top_dir });
// Open the directory for reading
try top_dir.open(.{});
std.debug.print("opened: {any}\n", .{ top_dir });
// Get directory information
const stat = try top_dir.stat();
defer stat.deinit();
std.debug.print("stat: {any}\n", .{ stat });
std.debug.print("size: {d}\n", .{ stat.length });
// Example of reading a directory (or file)
const buf = try top_dir.reader().readAllAlloc(allocator, 99999);
defer allocator.free(buf);
std.debug.print("reader: {any}\n", .{ buf });
// List files and directories in a directory
const files = try top_dir.files();
defer files.deinit();
for (files.stats) |s| {
std.debug.print("{s} {s:6} {s:6} {d:8} {s}\n", .{ s.mode, s.uid, s.gid, s.length, s.name });
}
// Close a handle, deallocate it
try top_dir.clunk();
// Open another directory
const tmp = try root.walk(&.{ "tmp" });
// Create a file, handle is now associated with the file
try tmp.create("testing", .{ .user_read = true, .user_write = true, .group_read = true, .world_read = true }, .{});
// Delete the file associated with the handle, deallocate it
try tmp.remove();
const passwd = try root.walk(&.{ "etc", "passwd" });
defer passwd.clunk() catch unreachable;
try passwd.open(.{});
const pass_data = try passwd.reader().readAllAlloc(allocator, 99999);
defer allocator.free(pass_data);
std.debug.print("/etc/passwd:\n{s}\n", .{ pass_data });
const new_file = try root.walk(&.{ "tmp" });
defer new_file.remove() catch unreachable;
// Create a file and write to it
try new_file.create("new_thing.txt", .{ .user_write = true, .user_read = true }, .{ .perm = .write });
const tons_of_data = [_]u8{'a'} ** 10000;
try new_file.writer().print(&tons_of_data, .{});
</code>
}
```
Server
WIP | [] |
https://avatars.githubusercontent.com/u/6128108?v=4 | rit | micahswitzer/rit | 2023-05-07T22:51:58Z | RISC-V InTerpreter, soon to be RISC-V jIT-er | master | 0 | 4 | 0 | 4 | https://api.github.com/repos/micahswitzer/rit/tags | - | [
"risc-v",
"zig"
] | 19 | false | 2024-05-30T20:34:16Z | true | false | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/6136245?v=4 | zig-base32 | jsign/zig-base32 | 2023-12-31T13:41:08Z | base32 encoding & decoding | main | 0 | 4 | 1 | 4 | https://api.github.com/repos/jsign/zig-base32/tags | MIT | [
"base32",
"encoding",
"zig"
] | 17 | false | 2025-02-06T06:19:13Z | true | true | unknown | github | [] | zig-base32
base32 encoding & decoding heavily inspired by <code>std.base64</code>.
License
MIT. | [] |
https://avatars.githubusercontent.com/u/14016168?v=4 | zig-xed | silversquirl/zig-xed | 2024-01-23T03:59:31Z | Intel X86 Encoder Decoder library, as a Zig package | main | 0 | 4 | 0 | 4 | https://api.github.com/repos/silversquirl/zig-xed/tags | Apache-2.0 | [
"assembly",
"x86",
"x86-64",
"x86-assembly",
"zig",
"zig-package"
] | 2,880 | false | 2025-04-09T06:14:34Z | true | true | unknown | github | [] | Zig package for Intel XED
This package compiles Intel's X86 Encoder Decoder library using the Zig build system.
There is no dependency on Python; all generated code is committed into this repository directly. | [] |
https://avatars.githubusercontent.com/u/41730?v=4 | txtar.zig | abhinav/txtar.zig | 2023-12-26T12:36:24Z | Simple, readable format for storing multiple files together. | main | 1 | 4 | 0 | 4 | https://api.github.com/repos/abhinav/txtar.zig/tags | BSD-3-Clause | [
"zig",
"zig-library"
] | 43 | false | 2025-05-12T03:41:45Z | true | true | unknown | github | [] | 🗃️ txtar.zig <a></a> <a></a>
txtar.zig is a Zig library for interfacing with the <a>txtar format</a>.
API reference
Auto-generated API Reference for the library is available at
<a>https://abhinav.github.io/txtar.zig/</a>.
Note that Zig's autodoc is currently in beta.
Some links may be broken in the generated website.
Installation
Use <code>zig fetch --save</code> to pull a version of the library
into your build.zig.zon.
<code>bash
zig fetch --save "https://github.com/abhinav/txtar.zig/archive/0.5.0.tar.gz"</code>
Then, import the dependency in your build.zig:
```zig
pub fn build(b: *std.Build) void {
// ...
<code>const txtar = b.dependency("txtar", .{
.target = target,
.optimize = optimize,
});
</code>
```
And add it to the executables that need it:
<code>zig
const exe = b.addExecutable(.{
// ...
});
exe.addModule("txtar", txtar.module("txtar"));</code>
Finally, in your code:
<code>zig
const txtar = @import("txtar");</code>
These instructions may grow out of date as the Zig package management tooling
and APIs evolve.
The txtar format
txtar is a simple text-based format to store multiple files together.
It looks like this:
<code>-- foo.txt --
Everything here is part of foo.txt
until the next file header.
-- bar/baz.txt --
Similarly, everything here
is part of bar/baz.txt
until the next header or end of file.</code>
It's meant to be human-readable and easily diff-able,
making it a good candidate for test case data.
See <a>golang.org/x/tools/txtar</a>,
which defines the format and provides its Go implementation.
License
This software is made available under the BSD3 license. | [] |
https://avatars.githubusercontent.com/u/28966224?v=4 | zvm | weskoerber/zvm | 2024-02-07T20:24:24Z | Zig Version Manager - POSIX-compliant shell script to manage multiple active Zig versions. | main | 5 | 4 | 0 | 4 | https://api.github.com/repos/weskoerber/zvm/tags | MIT | [
"version-manager",
"zig",
"ziglang"
] | 123 | false | 2025-01-02T21:03:33Z | false | false | unknown | github | [] | zvm - Zig Version Manager
A script to manage your <a>Zig</a> versions.
Features
<ul>
<li>Single POSIX-compliant shell script</li>
<li>Shell completions (bash, zsh)</li>
<li>Few dependencies (you probably have them installed already)</li>
</ul>
Getting Started
First, make sure <code>ZVM_BIN</code> is on your <code>PATH</code>. By default, it's <code>~/.local/bin</code>:[^1]
- On Linux, <code>/home/<username>/.local/bin</code>
- On Windows, <code>C:\Users\<username>\.local\bin</code>
- On MacOS, <code>/Users/<username>/.local/bin</code>
Next, determine if you need to explicitly set your target. On Linux you
probably won't have to. If you're on Windows or MacOS, see the
<a>Cross-platform support</a> section below.
Prerequisites
<ul>
<li>A POSIX-compliant shell</li>
<li><a>curl</a></li>
<li><a>jq</a></li>
<li>tar</li>
<li>unzip</li>
</ul>
Usage
Without any commands, <code>zvm</code> will print the active Zig version and exit.
Specific actions may be performed my providing a command.
Commands
<code>list</code>
Alias: <code>ls</code>
List Zig versions from the remote index:
<code>shell
zvm list</code>
List installed Zig versions:
<code>shell
zvm list -i
zvm list --installed</code>
<code>install</code>
Alias: <code>i</code>
Install a Zig version:
<code>shell
zvm install 0.12.0</code>
Install a Zig version and make it active immediately:
<code>shell
zvm install -u 0.12.0
zvm install --use 0.12.0</code>
<code>use</code>
Use an installed Zig version:
<code>shell
zvm use 0.12.0</code>
<code>uninstall</code>
Alias: <code>rm</code>
Uninstall a Zig version:
<code>shell
zvm uninstall 0.11.0</code>
By default, the <code>uninstall</code> command will prevent the current version from being
uninstalled. To bypass, there are 2 options:
1. Fall back to the newest installed version with <code>-l,--use-latest</code>
2. Force removal
- Note that after forcing removal, the <code>zig</code> command will no longer exist
and you'll have to use the <code>use</code> command to select a new version
<code>help</code>
Alias: <code>h</code>
Show <code>zvm</code> help:
<code>shell
zvm help</code>
Customizing
Environment
<ul>
<li><code>ZVM_HOME</code> - <code>zvm</code> home directory (where <code>zvm</code> downloads and extracts Zig tarballs)</li>
<li><code>ZVM_BIN</code> - <code>zvm</code> bin directory (where <code>zvm</code> symlinks Zig binaries)</li>
<li><code>ZVM_MIRROR</code> - Specify a mirror to use</li>
<li><code>ZVM_MIRRORLIST</code> - Specify the source for the list of mirrors <code>zvm</code> considers<ul>
<li>By default, this is <code>mirrors.json</code> from
<a>mlugg/setup-zig</a></li>
</ul>
</li>
</ul>
TODO
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Support building from source? (in-progress, see #14)
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Allow custom download location (default: <code>$HOME/.local/share/zvm</code>)
- 9b1afd4
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Allow custom install prefix (default: <code>$HOME/.local/bin/zig</code>)
- 9b1afd4
Cross-platform support
Linux
Native support. <code>zvm</code>'s detected native target will likely work, but you can
override it if you need to.
Windows
Supported via various Linux subsystems (git-bash, WSL, etc.).
<code>zvm</code> uses <code>uname</code> to detect the target and it currently only uses what <code>uname</code>
provides, which will differ depending on the Linux subsystem used (git-bash,
WSL, mingw, etc). However, <a>Zig's
targets</a> use
<code>windows</code> as the OS name. Due to this, for now you'll have to explicitly set
your target:
<code>shell
zvm --target <arch>-windows</code>
Replace <code><arch></code> with one of the following:
- On a 32-bit system, <code>x86</code> (e.g. <code>x86-windows</code>)
- On a 64-bit x86 system, <code>x86-64</code> (e.g. <code>x86_64-windows</code>)
- On a 64-bit aarch64 system, aarch64 (e.g. <code>aarch64-windows</code>)
MacOS
Supported natively but shares the same gotchas as the Windows support.
<code>zvm</code> uses <code>uname</code> to detect the target and it currently only uses what <code>uname</code>
provides. However, <a>Zig's
targets</a> use
<code>macos</code> as the OS name instead of <code>darwin</code>, which is what <code>uname</code> will return.
Due to this, for now you'll have to explicitly set your target:
<code>shell
zvm --target <arch>-macos</code>
Replace <code><arch></code> with one of the following:
- On a 64-bit x86 system, <code>x86-64</code> (e.g. <code>x86_64-macos</code>)
- On a 64-bit aarch64 system (a.k.a 'Apple silicon'), <code>aarch64</code> (e.g.
<code>aarch64-macos</code>)
[^1]: You can override this path with the <code>ZVM_BIN</code> environment variable. See
the <a>Environment</a> section for details. | [] |
https://avatars.githubusercontent.com/u/6756180?v=4 | docker-zig | kassane/docker-zig | 2023-08-24T14:30:33Z | Minimal Container to use Zig toolchain | main | 2 | 4 | 0 | 4 | https://api.github.com/repos/kassane/docker-zig/tags | MIT | [
"docker",
"docker-image",
"docker-images",
"docker-multiarch",
"dockerfile",
"zig"
] | 53 | false | 2025-04-28T20:25:23Z | false | false | unknown | github | [] | Docker-Zig
<strong>DockerHub:</strong> https://hub.docker.com/u/kassany
Minimal Container to use Zig toolchain. Downloaded by <a>zigup</a> (Thx <a>@marler8997</a>)
Tags = version
<ul>
<li><code>latest</code>: <code>master</code></li>
<li><code>0.11.0</code>: <code>0.11.0</code></li>
<li><code>0.12.0</code>: <code>0.12.0</code></li>
<li><code>0.13.0</code>: <code>0.13.0</code></li>
<li><code>0.14.0</code>: <code>0.14.0</code></li>
</ul>
```bash
busybox (x86_64)
docker run --rm -v $(pwd):/app -w /app kassany/ziglang:{tagname}
debian (x86_64|ARM64|ARM32v7|PPC64LE)
docker run --rm -it -v $(pwd):/app -w /app kassany/bookworm-ziglang:{tagname} bash
alpine 3.18 (x86_64|ARM64|ARM32v7|PPC64LE|RISCV64)
docker run --rm -it -v $(pwd):/app -w /app kassany/alpine-ziglang:{tagname} ash
``` | [] |
https://avatars.githubusercontent.com/u/5464072?v=4 | zig-UrlValues | nektro/zig-UrlValues | 2023-02-28T04:20:36Z | null | main | 0 | 4 | 0 | 4 | https://api.github.com/repos/nektro/zig-UrlValues/tags | MIT | [
"zig",
"zig-package"
] | 21 | false | 2025-05-21T20:33:32Z | true | false | unknown | github | [] | zig-UrlValues
<a></a>
<a></a>
<a></a>
<a></a>
A Zig type for parsing <code>application/x-www-form-urlencoded</code> HTTP <form> data which can then be accessed with an API inspired by <a>URLSearchParams</a> | [] |
https://avatars.githubusercontent.com/u/40350332?v=4 | minimd-zig | Chanyon/minimd-zig | 2023-04-05T14:34:03Z | simple markdown parser | main | 0 | 4 | 1 | 4 | https://api.github.com/repos/Chanyon/minimd-zig/tags | MPL-2.0 | [
"markdown",
"markdown-parser",
"markdown-zig",
"zig",
"zig-package",
"ziglang"
] | 117 | false | 2025-04-27T01:38:51Z | true | true | unknown | github | [
{
"commit": "c2ab7370004843db38094c708e82d191b2912399.tar.gz",
"name": "uuid",
"tar_url": "https://github.com/Chanyon/zig-uuid/archive/c2ab7370004843db38094c708e82d191b2912399.tar.gz.tar.gz",
"type": "remote",
"url": "https://github.com/Chanyon/zig-uuid"
},
{
"commit": "9ce0b13e6b0008796... | simple-markdown-parse
Markdown Grammar
<ul>
<li>headline
<code># heading1 => <h1></h1>
## heading2 => <h2></h2>
### heading3 => <h3></h3>
#### heading4 => <h4></h4>
##### heading5 => <h5></h5>
###### heading6 => <h6></h6></code></li>
<li>paragraph
<code>hello world
<p>hello world</p></code></li>
<li>strong
<code>**test** => <strong>test</strong>
*test* => <em>test</em>
***test*** => <strong><em>test</em></strong>
__hello__ => <strong>test</strong></code></li>
<li>
blockquote
```
> hello => <blockquote>hello</blockquote>
<blockquote>
hello
<blockquote>
world
=> <blockquote>hello<blockquote>world</blockquote></blockquote>
<code>- separation line</code>
--- =>
<code>- link</code>
<a>link</a> => <a>link</a>
<a>https://github.com</a> => <a>https://github.com</a>
<code>- image</code>
=>
</blockquote>
</blockquote>
<a></a>
=> <a></a>"
<code>- delete line</code>
~~test~~ =>
test
hello~~test~~world =>
hellotestworld
<code>- code</code>
<code>test</code> => <code>test</code>
<code>`test`</code> => <code> <code>test</code> </code>
=<code>{
"width": "100px",
"height": "100px",
"fontSize": "16px",
"color": "#ccc",
}
=</code>
=>
<code>{ "width": "100px", "height": "100px", "fontSize": "16px", "color": "#ccc",}</code>
```
</li>
<li>
footnote
```
test<a>^1</a>
=>
test<a>[1]</a>
<a>[^1]</a>: ooo
</li>
</ul>
<code>- task list</code>
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> task one
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> task two
<code>- table</code>
| Syntax | Description | Test |
| :---------- | ----------: | :-----: |
| Header | Title | will |
| Paragraph | Text | why |
```
<ul>
<li>unordered list
```</li>
<li>test<ul>
<li>test2<ul>
<li>test3</li>
</ul>
</li>
<li>test4</li>
</ul>
</li>
<li>test5</li>
<li>test6
```</li>
<li>ordered list
```</li>
<li>test<ol>
<li>test2<ol>
<li>test3</li>
</ol>
</li>
<li>test4</li>
</ol>
</li>
<li>test5</li>
<li>test6
```</li>
<li>escape characters
<code>\[\]
\<test\>
\*test\* \! \# \~ \-
\_ test \_ \(\)</code></li>
</ul>
DONE
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> 无序列表
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> 有序列表
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> 表格语法
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> 内嵌HTML
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> 脚注(footnote)
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> task list
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> 转义字符
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> html tag inline style
- [X] 代码块高亮 ```c ```
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> 标题目录 | [] |
https://avatars.githubusercontent.com/u/5870990?v=4 | nonograms | ianprime0509/nonograms | 2023-03-28T03:21:13Z | A Nonograms game for GNOME | main | 8 | 4 | 0 | 4 | https://api.github.com/repos/ianprime0509/nonograms/tags | 0BSD | [
"game",
"gnome",
"nonograms",
"zig"
] | 378 | false | 2025-03-26T03:24:43Z | true | true | 0.14.0 | github | [
{
"commit": "master",
"name": "gobject",
"tar_url": "https://github.com/ianprime0509/zig-gobject/releases/download/v0.3.0/bindings-gnome47.tar.zst/archive/master.tar.gz",
"type": "remote",
"url": "https://github.com/ianprime0509/zig-gobject/releases/download/v0.3.0/bindings-gnome47.tar.zst"
},... | Nonograms
A WIP <a>Nonograms</a> game written using Zig
and GTK.
This project is often used as a testing ground for new
<a>zig-gobject</a> changes, so it is
not guaranteed that it will always be buildable from scratch (the zig-gobject
dependency may refer to a relative path to a custom local build). This will
change as this project approaches some form of stability.
Flatpak build and install command:
<code>sh
flatpak-builder \
--user \
--install \
--force-clean \
--state-dir=zig-out/flatpak-builder \
--install-deps-from=flathub \
--repo=zig-out/repo \
zig-out/builddir \
build-aux/dev.ianjohnson.Nonograms.yaml</code> | [] |
https://avatars.githubusercontent.com/u/30719925?v=4 | yatlc | jsfpdn/yatlc | 2023-03-11T19:14:12Z | yet-another-toy-language compiler | main | 0 | 4 | 1 | 4 | https://api.github.com/repos/jsfpdn/yatlc/tags | - | [
"compiler",
"llvm",
"zig"
] | 638 | false | 2024-09-27T10:57:06Z | true | false | unknown | github | [] | yatlc: yet-another-toy-language compiler
<blockquote>
This is a repository for the yatl compiler, a project for a compiler course.
yatlc is written in <a>Zig 0.11.0</a> and uses LLVM.
</blockquote>
<strong>yatl is an imperative, statically typed, lexically scoped and memory-unsafe language.</strong>
Sample code can be found in the <a><code>/examples</code></a> directory.
See <a>DOCS</a> for more information.
<strong>yatlc is a single-pass compiler</strong>. The recursive descent parser does not explicitely
build the abstract syntax tree but directly emits the LLVM IR.
Building yatlc
To build the compiler, run <code>zig build</code>, emitting <code>./zig-out/bin/yatlc</code> binary.
Running yatlc
To see help, run <code>./zig-out/bin/yatlc --help</code>.
To compile a yatl program, run <code>./zig-out/bin/yatlc path/to/file.ytl -o binary_name</code>.
Testing <code>yatlc</code>
To run tests, run <code>zig test src/tests.zig</code>.
When testing an unexpected compiler error, it is helpful to build yatlc with <code>zig build -Doptimize=debug</code>
to emit more information during runtime when something happens. | [] |
https://avatars.githubusercontent.com/u/122347252?v=4 | nats-client | epicyclic-dev/nats-client | 2023-08-14T06:40:44Z | NATS client for zig (currently a wrapper around NATS.c). Mirror of https://crux.epicyclic.dev/factotum/nats.zig | master | 0 | 4 | 2 | 4 | https://api.github.com/repos/epicyclic-dev/nats-client/tags | Apache-2.0 | [
"nats-client",
"zig"
] | 1,944 | false | 2025-03-19T02:35:04Z | true | true | 0.14.0 | github | [
{
"commit": "master",
"name": "nats_c",
"tar_url": "https://github.com/allyourcodebase/nats.c/archive/master.tar.gz",
"type": "remote",
"url": "https://github.com/allyourcodebase/nats.c"
}
] | NATS - Zig Client
This is a Zig client library for the <a>NATS messaging system</a>. It's currently a thin wrapper over <a>NATS.c</a>, which is included and automatically built as part of the package.
There are three main goals:
<ol>
<li>Provide a Zig package that can be used with the Zig package manager.</li>
<li>Provide a native-feeling Zig client API.</li>
<li>Support cross-compilation to the platforms that Zig supports.</li>
</ol>
<code>nats.c</code> is compiled against a copy of LibreSSL that has been wrapped with the zig build system. This appears to work, but it notably is not specifically OpenSSL, so there may be corner cases around encrypted connections.
Status
All basic <code>nats.c</code> APIs are wrapped. The JetStream APIs are not currently wrapped, and the streaming API is not wrapped. It is unlikely I will wrap these as I do not require them for my primary use case. Contributions on this front are welcome. People who are brave or desperate can use these APIs unwrapped through the exposed <code>nats.nats_c</code> object.
In theory, all wrapped APIs are referenced in unit tests so that they are at least checked to compile correctly. The unit tests do not do much in the way of behavioral testing, under the assumption that the underlying C library is well tested. However, there may be some gaps in the test coverage around less-common APIs.
The standard workflows around publishing and subscribing to messages seem to work well and feel (in my opinion) sufficiently Zig-like. Some of the APIs use getter/setter functions more heavily than I think a native Zig implementation would, due to the fact that the underlying C library is designed with a very clean opaque handle API style.
Zig Version Support
Since the language is still under active development, any written Zig code is a moving target. The master branch targets zig <code>0.14</code>.
Using
These bindings are ready-to-use with the Zig package manager. This means you will need to create a <code>build.zig.zon</code> and modify your <code>build.zig</code> to use the dependency.
```sh
bootstrap your zig project if you haven't already
zig init
add the nats-client dependency
zig fetch --save git+https://github.com/epicyclic-dev/nats-client.git
```
You can then use <code>nats_client</code> in your <code>build.zig</code> with:
<code>zig
const nats_dep = b.dependency("nats_client", .{
.target = target,
.optimize = optimize,
.@"enable-libsodium" = true, // Use libsodium for optimized implementations of some signing routines
.@"enable-tls" = true, // enable SSL/TLS support
.@"force-host-verify" = true, // force hostname verification for TLS connections
.@"enable-streaming" = true, // build with support for NATS streaming extensions
});
your_exe.root_module.addImport("nats", nats_dep.artifact("nats"));</code>
Building
Some basic example executables can be built using <code>zig build examples</code>. These examples expect you to be running a copy of <code>nats-server</code> listening for unencrypted connections on <code>localhost:4222</code> (the default NATS port).
Testing
Unit tests can be run using <code>zig build test</code>. The unit tests expect an executable named <code>nats-server</code> to be in your PATH in order to run properly.
License
Unless noted otherwise (check file headers), all source code is licensed under the Apache License, Version 2.0 (which is also the <code>nats.c</code> license).
```
Licensed under the Apache License, Version 2.0 (the "License");
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
``` | [] |
https://avatars.githubusercontent.com/u/70587974?v=4 | zig-soroban-sdk | heytdep/zig-soroban-sdk | 2023-08-04T13:12:16Z | Zig SDK for writing Soroban smart contracts | main | 0 | 4 | 0 | 4 | https://api.github.com/repos/heytdep/zig-soroban-sdk/tags | - | [
"blockchain",
"soroban",
"zig"
] | 43 | false | 2024-08-15T12:19:20Z | true | false | unknown | github | [] | zig-soroban-sdk
Zig SDK for writing <a>Soroban</a> contracts.
Why a Zig SDK for Soroban?
Introducing a Zig SDK offers distinct advantages: zig provides an exceptional level of control over their code (for example carefully choosing performance or safety for every operation depending on the needs). Moreover, Zig's first-class WebAssembly compilation compatibility aligns perfectly with the Soroban virtual machine. Lastly, this SDK expands the language options for Soroban developers contributing to a more adaptable ecosystem.
Progress
Ultimately I aim to make the sdk complete (all conversions, support for host functions) and make it ergonomic. This is the current progress:
<ul>
<li>
conversions
<ul>
<li>bool</li>
<li>void</li>
<li>u32, i32</li>
<li>u64Small, i64small</li>
<li>TimepointSmall</li>
<li>DurationSmall</li>
<li>u128small, i128small</li>
<li>u256, i256 (TODO: switch to env functions for operations).</li>
<li>small symbols</li>
</ul>
</li>
<li>
host functions
<ul>
<li>none</li>
</ul>
</li>
</ul>
Also, there is no spec generation for the contracts currently (although it's a P1 feature), so you'll either have to first write the contract's interface in rust and then manually inject WASM bytecode from the rust contract's wasm custom section to Zig's wasm, or you can use the RPC (or js soroban client) instead of the CLI and only inject the contract env meta (so you don't have to write the rust contract).
About The Types
Given rust's ability to generate conversions thorugh macros, contracts built with the rust sdk can directly interact with the host using the already <code>Val</code>-decoded types: decoding and encoding from and to <code>Val</code> is already taken care of.
Zig promotes a clarity and predictability approach to metaprogramming: <code>comptime</code>. This means that it might be possible to have a similar style to the rust sdk, but I haven't explored a solution yet also since it seems that <code>comptime</code> parameters are not allowed on exported wasm fns due to C-ABI compatibility.
This means that I'm currently writing the SDK around wrapper types that implement <code>Val</code> conversions. For example, a multiplier contract currently looks like:
```zig
const soroban_sdk = @import("soroban_sdk");
const Val = soroban_sdk.val.Val;
const U32 = soroban_sdk.val.U32;
export fn multiply(a_: Val, b_: Val, c_: Val, d_: Val) Val {
const a = U32.from_val(a_) catch unreachable;
const b = U32.from_val(b_) catch unreachable;
const c = U32.from_val(c_) catch unreachable;
const d = U32.from_val(d_) catch unreachable;
<code>return a.mul(b).mul(c).mul(d).to_val();
</code>
}
``` | [] |
https://avatars.githubusercontent.com/u/6136245?v=4 | zig-eth-secp256k1 | jsign/zig-eth-secp256k1 | 2023-10-28T12:37:46Z | A Zig libsecp256k1 wrapper with bells and whistles for Ethereum | main | 1 | 4 | 3 | 4 | https://api.github.com/repos/jsign/zig-eth-secp256k1/tags | MIT | [
"cryptography",
"ethereum",
"secp256k1",
"zig"
] | 214 | false | 2025-05-13T15:20:40Z | true | true | unknown | github | [] | zig-eth-secp256k1
A Zig libsecp256k1 wrapper with bells and whistles for Ethereum | [] |
https://avatars.githubusercontent.com/u/45130910?v=4 | 2048.zig | Ratakor/2048.zig | 2023-08-22T02:14:33Z | 2048 in zig | master | 0 | 4 | 0 | 4 | https://api.github.com/repos/Ratakor/2048.zig/tags | ISC | [
"2048",
"2048-game",
"zig"
] | 463 | false | 2024-11-04T20:10:17Z | true | false | unknown | github | [] | 2048.zig
2048 in zig with undo, automatic save and other cool stuff
Installation
Pick one of the release or build it yourself ;)
To build have a look at <code>zig build --help</code> or just run
<code>zig build -Doptimize=ReleaseSafe</code> the executable will be at zig-out/bin/2048.
Available on the <a>AUR</a>!
Usage
```
$ 2048 --help
Usage: 2048 [options]
Options:
-s, --size [n] | Set the board size to n
-h, --help │ Print this help message
-v, --version | Print version information
Commands:
↑ w k | Classic movements
←↓→ asd hjl |
q | Quit the game
r | Restart the game
u | Undo one action
``` | [] |
https://avatars.githubusercontent.com/u/155341942?v=4 | learning-zig-karlseguin | jkitajima/learning-zig-karlseguin | 2024-01-01T19:57:39Z | Brazilian Portuguese translation of "Learning Zig" blog series by Karl Seguin | main | 0 | 4 | 1 | 4 | https://api.github.com/repos/jkitajima/learning-zig-karlseguin/tags | CC-BY-SA-4.0 | [
"blog",
"ebook",
"pt-br",
"translation",
"zig"
] | 69 | false | 2025-03-21T20:16:45Z | false | false | unknown | github | [] | Aprendendo Zig
Este repositório contém os arquivos de tradução do livro "Learning Zig", escrito por <a>Karl Seguin</a>
<blockquote>
This repository contains the translation files of the book "Learning Zig," written by Karl Seguin
</blockquote>
Versão original
A série de publicações "Learning Zig" foi originalmente concebida por Karl Seguin e apresentada em seu <a>blog pessoal</a>.
Essas publicações destacam-se por sua abordagem didática excepcional, proporcionando um recurso valioso tanto para iniciantes que estão dando os primeiros passos em Zig quanto para aqueles que desejam consolidar os conceitos fundamentais utilizados no dia-a-dia. A qualidade do conteúdo oferecido pelo autor não só torna possível uma leitura sequencial para compreensão abrangente, mas também permite seu uso como uma referência prática, à medida que se aprofunda em conhecimentos mais avançados.
Algumas outras publicações conhecidas do autor são listadas abaixo:
- <a>The Little Go Book</a>
- <a>The Little Redis Book</a>
- <a>The Little MongoDB Book</a>
Contribuições
A tradução realizada neste trabalho é inteiramente livre. Dessa forma, caso identifique algum erro ortográfico, explicações pouco esclarecidas ou conceitos de programação mal traduzidos, convido você a contribuir, através de uma PR e colaborar na aprimoração desta tradução do material sobre Zig em português.
O principal objetivo desta tradução é fornecer um conteúdo de qualidade em língua portuguesa para a comunidade Zig e, acima de tudo, auxiliar aqueles que estão iniciando no vasto universo da programação (principalmente em nível de sistemas).
Licença
<a>CC-BY-SA-4.0</a> | [] |
https://avatars.githubusercontent.com/u/72305366?v=4 | zchat | zigster64/zchat | 2023-06-21T01:20:10Z | Experiment using the eventSource API to do realtime comms with web clients, without the need for websockets | main | 0 | 4 | 0 | 4 | https://api.github.com/repos/zigster64/zchat/tags | MIT | [
"chat",
"cuniform",
"zig"
] | 662 | false | 2025-02-22T05:37:02Z | true | true | unknown | github | [
{
"commit": "refs",
"name": "http",
"tar_url": "https://github.com/zigster64/http.zig/archive/refs.tar.gz",
"type": "remote",
"url": "https://github.com/zigster64/http.zig"
}
] | zchat
Experiment using the eventSource API to do realtime comms with web clients, without the need for websockets
Click on any Cuniform (or Emoji) to transmit the data for that code.
Click on any PAIR of Hexidecimal values to combine them and transmit the character for that combined code.
Click 00 to reset the chat, and start a fresh new chat.
for example - if you Click 4 8 6 9
This will transmit 2 letters - 48 (H) and 69 (i)
Which will print "Hi"
What could be easier ?
What Really ?
Yes !
The actual point of this repo is to do some relatively cool <code>net-web-dev</code> things in Zig, with very little code.
<ul>
<li>Doing realtime updates from a standard HTTP/1 GET request, using Zig (without websockets)</li>
<li>Do long running http handlers </li>
<li>How to use a global state object in a Zig HTTP server, that gets referenced from http handlers</li>
<li>How to sleep/block long running threads, and signal them using std.Thread.Conditon.broadcast() to make realtime updates as the state changes</li>
<li>How to use the new package manager with <code>build.zig.zon</code>, in this case referencing a dev branch of a repo as a dependency</li>
</ul>
Code
This code is split into 2 components :
1 - The Zig server, which is mananged by the build.zig file, with the code in the src/ directory
2 - The UI, which is a simple React app using https://github.com/robtaussig/react-use-websocket
How it works
The React App is served from the Zig server, and presents a simple chat window + some state buttons
to toggle world state.
When the web user submits changes, these are sent to the Zig server via a standard HTTP POST request.
The react client also creates a persisent connection to the server using the eventSource API
https://developer.mozilla.org/en-US/docs/Web/API/EventSource
This just waits for incoming messages from the server, and then acts on them as they come in. Simple !
At the server end, it runs a standard web server based on https://github.com/karlseguin/http.zig
(NOTE - actually, this needs some hacks to get it working with event-stream, so its using this branch here
https://github.com/zigster64/http.zig - branch "event-source")
Basic HTTP GET requests are used to serve up the react app
Basic HTTP POST requests are used to "send messages" or other updates
A simple HTTP GET request using the eventSource API is used to communicate state changes from the server back to the client in realtime.
Just straight HTTP, and a bit of multitasking at the server end using <code>std.Thread</code>
No websockets needed
Gitting and Building
Install Zig - https://ziglang.org/download/
This repo uses Zig master (currently 0.11.0-dev...)
To download the code
<code>git clone https://github.com/zigster64/zchat.git
cd zchat</code>
To build the server (this repo uses the built-in Zig package manager, so it auto pulls in dependenices)
<code>zig build</code>
To build the React app (using npm)
<code>cd ui
npm install
npm run build</code>
Alternative - use bun to build the react app !
<code>cd ui
bun install
bun run build</code>
Then, once both the server and the react app are built, do the following to run the server :
<code>./zig-out/bin/zchat</code>
or <code>zig build run</code> works as well.
This will spawn the server on http://localhost:3000
Now point a couple of browser tabs at that address, and behold - realtime messaging !
What is the web client doing here ?
The web client makes a persistent connect to GET http://localhost:3000/events
which is an endpoint of mime type <code>text/event-stream</code>
This is a text protocol that packages messages in the format
```
: comment
data: Some UTF-8 encoded data.
data: Can be anything - can be TEXT, can be JSON
data: can be protobuf encoded if you want !
data: Finish up with a blank line to denote end of message.
```
The connection is held open at the end of the message, and the client is expected to wait around till the next
message arrives.
If the connection is dropped, then you need to handle that yourself. Is easy enough. The EventSource protocol does
not define transport layer behaviour such as reconnection policies. Its just a simple streaming text format.
Thats a 2 second intro ... and its really that simple. The full spec for the protocol is here :
https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events
Then using the hooks provided in the https://github.com/robtaussig/react-use-websocket package,
the react app simply listens for events and then acts on them as new events come in.
Its basically using webWorkers to run a "event listener thread" in the browser. Sounds complicated,
but as you can see, the code is really simple.
What is the Server doing ?
Server is pretty simple to.
Uses standard threads to implement the following :
<ul>
<li>Implement a single instance of a "World State" </li>
<li>In the main thread, implement a web server to listen for GET requests, and serve up static data</li>
<li>Add a POST handler to accept updates from web clients, and update the world state</li>
<li>Add a GET handler for /events - if seen, spawn a new thread that sends the current world state, and then waits for the next event</li>
<li>When the world state changes, use <code>std.Thread.Condition.broadcast()</code> to signal all event threads to send the next update to connected clients</li>
</ul>
Great, now what ? How to can use this and profit ?
The last thing the world needs is another chat application, in this hyper-connected world of ours.
Get off the computer, and go play with the dog, do some home cooking, or ride some bike trails in the forest instead. Thank me later.
In the meantime ... this repo may be useful if you like doing some Zig coding, and want to see how the eventSource API
might be good fit for web realtime updates instead of assuming that you need to do websockets every time.
Main difference is that websockets are a 2-way persistent connection between client and server.
EventSources are just a 1-way stream of updates from the server to the client.
EventSounces are much easier to code up a state updater compared to websockets.
EventSources do not automatically handle re-connection logic, or other sorcercy without additional code ... its just an event stream.
WebSockets are great, but it may be overkill for a lot of use cases ? | [] |
https://avatars.githubusercontent.com/u/61315998?v=4 | tomlz | eddineimad0/tomlz | 2023-11-03T17:22:54Z | A Toml Parser written in zig | main | 2 | 4 | 2 | 4 | https://api.github.com/repos/eddineimad0/tomlz/tags | MIT | [
"parser",
"toml",
"toml-parser",
"zig",
"zig-package"
] | 1,498 | false | 2025-05-06T09:52:40Z | true | true | 0.14.0 | github | [] | A TOML parser written in zig that targets v1.0 specs of TOML.
Supported zig versions
✅ <a>0.14.0</a>
Test suite coverage
<a>toml-test</a> is a language-agnostic test suite to verify the correctness of TOML parsers and writers.
The parser fails 2 tests in the invalid set that involves dotted keys, the 2 tests expect the parser to reject a niche confusing use case of toml dotted keys however they are accepted by the parser. this might get fixed in the future but for now it's not a priority.
Usage
```zig
const std = @import("std");
const toml = @import("tomlz");
const io = std.io;
var gpa: std.heap.DebugAllocator(.{}) = .init;
pub fn main() !void {
defer std.debug.assert(gpa.deinit() == .ok);
const allocator = gpa.allocator();
<code>// the toml parser takes an allocator and uses it internally
for all allocations.
var p = toml.Parser.init(allocator);
// when done deinit the parser to free all allocated resources.
defer p.deinit();
const toml_input =
\\message = "Hello, World!"
;
// the TOML parser accepts a io.StreamSource as an input source.
// the StreamSource should live as long as the parser.
var toml_stream = io.StreamSource{
.const_buffer = io.FixedBufferStream([]const u8){
.buffer = src,
.pos = 0,
},
};
// use parse to start parsing the input source.
var parsed = p.parse(&toml_stream) catch {
std.log.err("The stream isn't a valid TOML document, {}\n",.{err});
// handle error.
};
// parsed is of type toml.TomlTable which is an alias to
// std.StringHashMap(TomlValue).
// toml.TomlValue type is a union with the following fields:
// pub const TomlValue = union(TomlType) {
// Boolean: bool,
// Integer: i64,
// Float: f64,
// String: []const u8,
// Array: []TomlValue,
// Table: TomlTable,
// TablesArray: []TomlTable,
// DateTime: DateTime,
// };
// aside from DateTime all other types are standard zig types.
// all data returned by the parser is owned by the parser and
// will be freed once deinit is called or if parse() is called again,
// consider cloning anything you need to outlive the parser.
var iter = parsed.iterator();
while (iter.next()) |pair| {
// the key is of type []const u8.
std.debug.print("\n{s} => ", .{pair.key_ptr.*});
switch (pair.value_ptr.*) {
// ... do whatever
}
}
</code>
}
```
Build options
The build.zig file contains various options that can be used to customize
the behaviour of the parser when building, check it out for more details. | [
"https://github.com/javiorfo/ztatusbar",
"https://github.com/paoda/zba"
] |
https://avatars.githubusercontent.com/u/25565268?v=4 | kzigg | spiral-ladder/kzigg | 2024-01-07T05:14:28Z | KZG polynomial commitments in Zig | main | 0 | 4 | 2 | 4 | https://api.github.com/repos/spiral-ladder/kzigg/tags | Apache-2.0 | [
"crypto",
"eip-4844",
"ethereum",
"kzg",
"zig",
"zk"
] | 243 | false | 2024-10-14T16:47:07Z | true | false | unknown | github | [] | KZG Polynomial Commitments
An implementation of <a><strong>KZ</strong>ig<strong>G</strong> polynomial commitments</a> in Zig, using <a><code>blst</code></a> as the backend via Zig's C interop.
Heavily based on <a>c-kzg-4844</a>.
<em>Disclaimer: this repository is me learning how KZG and 4844 works underneath and is not meant for real world use.</em>
Prerequisites
You need Zig installed and <code>blst</code> built to use as a static library.
This repo is built and tested on <code>v0.13.0</code>.
Test
<code>sh
zig build test -Doptimize=ReleaseSafe</code>
Benchmark
<code>sh
zig build benchmark</code> | [] |
https://avatars.githubusercontent.com/u/55436060?v=4 | zig-regex-oniguruma | arats-io/zig-regex-oniguruma | 2023-11-12T12:35:48Z | Zig Regex Wrapper for Oniguruma | main | 0 | 4 | 0 | 4 | https://api.github.com/repos/arats-io/zig-regex-oniguruma/tags | MIT | [
"regex",
"zig",
"zig-package"
] | 7 | false | 2025-01-30T23:31:09Z | true | true | 0.13.0 | github | [] | Zig RegEx wrapper for Oniguruma
Using https://github.com/kkos/oniguruma.
Oniguruma is a modern and flexible regular expressions library. It encompasses features from different regular expression implementations that traditionally exist in different languages.
Usage
Include the libregex-oniguruma into the <code>build.zig.zon</code> file.
<code>.dependencies = .{
.libregex-oniguruma = .{
.url = "https://github.com/arats-io/zig-regex-oniguruma/archive/refs/tags/v0.1.0.tar.gz",
.hash = "12201fd38f467e6c64ee7bca53da95863b6c05da77fc51daf0ab22079ede57cbd4e2",
},
},</code> | [] |
https://avatars.githubusercontent.com/u/135145066?v=4 | base64-simd | dying-will-bullet/base64-simd | 2023-07-02T03:41:49Z | SIMD Base64 encoder/decoder, support streaming | master | 1 | 4 | 2 | 4 | https://api.github.com/repos/dying-will-bullet/base64-simd/tags | BSD-2-Clause | [
"base64",
"simd",
"zig",
"zig-library",
"ziglang"
] | 32 | false | 2025-01-03T17:01:53Z | true | true | unknown | github | [] | base64-simd 🚀
<a></a>
Make base64 encoding/decoding faster and simpler.
This is a Zig binding for <a>aklomp/base64</a>,
accelerated with SIMD. It could encode at 1.45 times the speed of the standard library.
<ul>
<li><a>Getting Started</a></li>
<li><a>API Reference</a></li>
<li><a>b64encode</a><ul>
<li><a>Example</a></li>
</ul>
</li>
<li><a>b64decode</a><ul>
<li><a>Example</a></li>
</ul>
</li>
<li><a>b64StreamEncoder</a></li>
<li><a>b64StreamDecoder</a></li>
<li><a>Benchmark</a></li>
<li><a>Run the benchmark</a></li>
<li><a>Benchmark results</a><ul>
<li><a>Environment</a></li>
<li><a>Encoding</a></li>
<li><a>Decoding</a></li>
</ul>
</li>
<li><a>LICENSE</a></li>
</ul>
Getting Started
There can be different installation ways, and here is an example of using submodules for installation.
Create a new project with <code>zig init-exe</code>. Then add this repo as a git submodule,
assuming that all your dependencies are stored in the <code>deps</code> directory.
<code>$ mkdir deps && cd deps
$ git clone --recurse-submodules https://github.com/dying-will-bullet/base64-simd.git</code>
Then add the following to your <code>build.zig</code>
```diff
diff --git a/build.zig b/build.zig
index 9faac30..4ecd5cb 100644
--- a/build.zig
+++ b/build.zig
@@ -1,4 +1,5 @@
const std = @import("std");
+const base64 = @import("deps/base64-simd/build.zig");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
@@ -24,6 +25,14 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
<ul>
<li>const base64_mod = b.addModule("base64", .{</li>
<li>.source_file = .{ .path = "deps/base64-simd/src/lib.zig" },</li>
<li>});</li>
<li>// Add the base64 module</li>
<li>exe.addModule("base64", base64_mod);</li>
<li>// Link</li>
<li>base64.buildAndLink(b, exe) catch @panic("Failed to link base64");
+
// This declares intent for the executable to be installed into the
// standard location when the user invokes the "install" step (the default
// step when running <code>zig build</code>).
```</li>
</ul>
Edit <code>src/main.zig</code>
```zig
const std = @import("std");
const base64 = @import("base64");
pub fn main() !void {
const s = "Hello World";
<code>var out: [32]u8 = undefined;
const res = base64.b64encode(s, &out, .default);
std.debug.print("{s}\n", .{res});
</code>
}
```
Execute <code>zig build run</code> and you will see the base64 encoded string of <code>Hello World</code>.
API Reference
b64encode
<code>zig
fn b64encode(
s: []const u8,
out: []u8,
flag: Flag,
) []const u8</code>
The <code>b64encode</code> function encodes a given input byte string <code>s</code> using Base64 encoding,
and stores the result in the <code>out</code>.
Set flags to <code>.default</code> for the default behavior, which is runtime feature detection on x86,
a compile-time fixed codec on ARM, and the plain codec on other platforms.
See more flags in <code>Flag</code> enum.
Example
```zig
const s = "Hello World";
<code>var out: [32]u8 = undefined;
const res = b64encode(s, &out, .default);
try testing.expectEqualStrings("SGVsbG8gV29ybGQ=", res);
</code>
```
b64decode
<code>zig
fn b64decode(
s: []const u8,
out: []u8,
flag: Flag,
) ![]const u8</code>
The <code>b64decode</code> function decodes a given Base64 encoded byte string <code>s</code>
and stores the result in the <code>out</code>. Returns abyte string representing the decoded data stored in the <code>out</code> buffer.
Example
```zig
const s = "SGVsbG8gV29ybGQ=";
<code>var out: [32]u8 = undefined;
const res = try b64decode(s, &out, .default);
try testing.expectEqualStrings("Hello World", res);
</code>
```
b64StreamEncoder
Similar to <code>b64encode</code>, but in stream.
```zig
const s = [_][]const u8{ "H", "e", "l", "l", "o", " ", "W", "o", "r", "l", "d" };
<code>var out: [4]u8 = undefined;
var encoder = b64StreamEncoder.init(.default);
for (s) |c| {
const part = encoder.encode(c, &out);
std.debug.print("{s}", .{part});
}
std.debug.print("{s}\n", .{encoder.final(&out)});
</code>
```
b64StreamDecoder
Similar to <code>b64decode</code>, but in stream.
```zig
const s = [_][]const u8{
"S", "G", "V", "s", "b", "G", "8", "g", "V", "2", "9", "y", "b", "G", "Q", "=",
};
<code>var out: [4]u8 = undefined;
var decoder = b64StreamDecoder.init(.default);
for (s) |c| {
const part = try decoder.decode(c, &out);
std.debug.print("{s}", .{part});
}
</code>
```
Benchmark
Run the benchmark
<code>$ bash benchmark/bench.sh</code>
The report will be generated in <code>benchmark/result.json</code>.
Benchmark results
Environment
<ul>
<li>ArchLinux 6.3.9-arch1-1</li>
<li>CPU: AMD Ryzen 7 5800H with Radeon Graphics @ 16x 3.2GHz</li>
<li>Zig: 0.11.0-dev.3739+939e4d81e, <code>-Doptimize=ReleaseFast</code></li>
<li>Benchmark Tools: hyperfine 1.17.0</li>
</ul>
Encoding
1000 rounds of testing, encoding 10000 records each time.
```
Command './zig-out/bin/bench --encode --std'
runs: 1000
mean: 0.039 s
stddev: 0.001 s
median: 0.039 s
min: 0.037 s
max: 0.051 s
percentiles:
P_05 .. P_95: 0.038 s .. 0.041 s
P_25 .. P_75: 0.038 s .. 0.039 s (IQR = 0.001 s)
Command './zig-out/bin/bench --encode --simd'
runs: 1000
mean: 0.027 s
stddev: 0.002 s
median: 0.026 s
min: 0.025 s
max: 0.067 s
percentiles:
P_05 .. P_95: 0.026 s .. 0.030 s
P_25 .. P_75: 0.026 s .. 0.027 s (IQR = 0.001 s)
```
Decoding
1000 rounds of testing, encoding 10000 records each time.
```
Command './zig-out/bin/bench --decode --std'
runs: 1000
mean: 0.042 s
stddev: 0.003 s
median: 0.041 s
min: 0.039 s
max: 0.104 s
percentiles:
P_05 .. P_95: 0.040 s .. 0.045 s
P_25 .. P_75: 0.040 s .. 0.042 s (IQR = 0.002 s)
Command './zig-out/bin/bench --decode --simd'
runs: 1000
mean: 0.036 s
stddev: 0.003 s
median: 0.035 s
min: 0.033 s
max: 0.101 s
percentiles:
P_05 .. P_95: 0.034 s .. 0.041 s
P_25 .. P_75: 0.034 s .. 0.036 s (IQR = 0.002 s)
```
LICENSE
This repository is licensed under the BSD 2-clause License. See the LICENSE file.
<ol>
<li><a>aklomp/base64 LICENSE</a></li>
<li><a>dying-will-bullet/base64-simd LICENSE</a></li>
</ol> | [] |
https://avatars.githubusercontent.com/u/47845580?v=4 | zigo | nopdan/zigo | 2023-09-12T15:36:02Z | Download and manage Zig compilers. | master | 0 | 4 | 0 | 4 | https://api.github.com/repos/nopdan/zigo/tags | MIT | [
"zig"
] | 41 | false | 2023-09-25T20:51:20Z | false | false | unknown | github | [] | zigo
<a></a>
<a></a>
Download and manage Zig compilers.
<code>zigo</code> is a dependency free binary program.
<blockquote>
Inspired by <a>zigup</a>, <a>zvm</a>, <a>scoop</a>
</blockquote>
Install
<ul>
<li>Download from <a>releases</a>.</li>
</ul>
<code>sh
unzip ./zigo-linux-amd64.zip
chmod +x ./zigo
./zigo</code>
<ul>
<li>From source: <code>go install github.com/nopdan/zigo@latest</code></li>
</ul>
Add <code>~/.zig/current</code> to the environment variable.
Usage
<code>zigo <version></code>
Download the specified version of zig compiler and set it as default.
examples: <code>zigo 0.11.0</code>, <code>zigo master</code>
<code>sh
❯ ./zigo master
downloading https://ziglang.org/builds/zig-linux-x86_64-0.12.0-dev.374+742030a8f.tar.xz...
progress: 42.96 MiB / 42.96 MiB ( 100.0 % ) 13.96 MiB/s
done. save cache to /home/cx/.cache/zigo/zig-linux-x86_64-0.12.0-dev.374+742030a8f.tar.xz
installing master => 0.12.0-dev.374+742030a8f...
successfully installed!
❯ zig version
0.12.0-dev.374+742030a8f</code>
<code>zigo use <version></code>
Set the specific installed version as the default.
<code>zigo ls</code>
List installed compiler versions.
<code>sh
❯ ./zigo ls
* master => 0.12.0-dev.312+cb6201715
0.11.0
0.12.0-dev.307+7827265ea
0.12.0-dev.312+cb6201715</code>
<code>zigo rm <version></code>
Remove the specified compiler.
Append <code>-f</code> or <code>--force</code> to force deletion.
Use <code>zigo rm --all</code> or <code>zigo rm -a</code> to remove all installed compilers.
```sh
❯ ./zigo rm 0.10.1
removed 0.10.1
❯ ./zigo rm 0.11.0
cannot remove the version you are using.
❯ ./zigo rm 0.11.0 -f
removing 0.11.0... done.
```
<code>zigo clean</code>
Clean up unused dev version compilers.
<code>sh
❯ ./zigo ls
* master => 0.12.0-dev.353+4a44b7993
0.11.0
0.12.0-dev.312+cb6201715
0.12.0-dev.352+4d29b3967
0.12.0-dev.353+4a44b7993
❯ ./zigo clean
removed 0.12.0-dev.312+cb6201715
removed 0.12.0-dev.352+4d29b3967
❯ ./zigo ls
* master => 0.12.0-dev.353+4a44b7993
0.11.0
0.12.0-dev.353+4a44b7993</code>
<code>zigo mv <install-dir></code>
Move the zig installation directory.
<strong>Default installation directory is</strong> <code>~/.zig</code>.
<code>zigo -h</code>
Print help message.
Build
Install <code>Go 1.21.0+</code>
<code>sh
git clone https://github.com/nopdan/zigo.git
cd zigo
go mod tidy
go build</code> | [] |
https://avatars.githubusercontent.com/u/63115601?v=4 | libuv-zig | lithdew/libuv-zig | 2023-07-30T10:09:02Z | A fork of libuv packaged for Zig. | main | 0 | 4 | 0 | 4 | https://api.github.com/repos/lithdew/libuv-zig/tags | - | [
"zig"
] | 1,504 | false | 2025-01-19T09:42:06Z | true | false | unknown | github | [] | libuv-zig
This is a fork of <a>libuv</a> packaged for Zig. The build system has been replaced with <code>build.zig</code>. | [] |
https://avatars.githubusercontent.com/u/71920313?v=4 | xcb.zig | MidstallSoftware/xcb.zig | 2024-01-22T22:25:53Z | Xcb for Zig | master | 4 | 4 | 1 | 4 | https://api.github.com/repos/MidstallSoftware/xcb.zig/tags | GPL-3.0 | [
"xcb",
"xcb-bindings",
"zig"
] | 123 | false | 2025-03-08T00:05:49Z | true | true | unknown | github | [
{
"commit": null,
"name": "libxcb",
"tar_url": null,
"type": "remote",
"url": "https://gitlab.freedesktop.org/xorg/lib/libxcb/-/archive/libxcb-1.16/libxcb-libxcb-1.16.tar.gz"
},
{
"commit": null,
"name": "xcbproto",
"tar_url": null,
"type": "remote",
"url": "https://gitla... | xcb.zig
Xcb for Zig | [] |
https://avatars.githubusercontent.com/u/16236219?v=4 | dylanlangston.com | dylanlangston/dylanlangston.com | 2024-01-20T21:53:17Z | Source code for my personal site 😎 | main | 26 | 4 | 0 | 4 | https://api.github.com/repos/dylanlangston/dylanlangston.com/tags | MIT | [
"aws",
"github-actions",
"personal-website",
"rust",
"svelte",
"tailwindcss",
"typescript",
"zig"
] | 7,222 | false | 2025-05-19T02:59:01Z | true | true | 0.13.0 | github | [
{
"commit": null,
"name": "raylib",
"tar_url": null,
"type": "relative",
"url": "raylib"
},
{
"commit": null,
"name": "raygui",
"tar_url": null,
"type": "relative",
"url": "raygui"
},
{
"commit": null,
"name": "emscripten",
"tar_url": null,
"type": "re... | <a>dylanlangston.com</a>
<strong>The source code for my personal website. 🚧 Currently under construction. 🚧</strong>
<a></a>
<a></a>
<a></a>
<a></a>
<a></a>
<a></a>
Overview 👀
My personal website is built with a modern tech stack to ensure performance and flexibility. It utilizes the following technologies:
- <a>🇿 Zig</a> and <a>🎮 raylib</a> for client-side rendering.
- <a>🌐 Emscripten</a> for compiling to <a>🕸️ WebAssembly</a>.
- <a>🛠️ Binaryen</a> for optimizing WebAssembly.
- <a>🦀 Rust</a> for backend logic utilizing <a>🔢 AWS Lambda</a>.
- <a>🐍 Python</a> for additional backend logic utilizing AWS Lambda.
- <a>🧠 Gemini API</a> for accessing to Google's Gemini generative AI models.
- <a>🖥️ Svelte</a> for building interactive user interfaces.
- <a>📝 TypeScript</a> for improving JavaScript code reliability and developer efficiency.
- <a>🎨 TailwindCSS</a> for styling components with utility-first CSS.
- <a>🚀 Vite</a> for fast development and optimized production builds.
- Hosted on <a>🌍 AWS S3</a> and distributed globally via <a>☁️ AWS CloudFront</a> for high availability and scalability.
- <a>📦 SAM CLI</a> for deploying serverless applications.
```mermaid
flowchart TB
subgraph "Frontend - Static Site"
direction LR
S1("Svelte")
S2("Typescript")
S3("Tailwindcss")
S4("Vite")
S5("AWS S3")
S6("AWS CloudFront")
<code> subgraph "HTML 5 Canvas"
direction LR
A1("Zig")
A2("Raylib")
A3(Emscripten)
A4("Binaryen")
A1 -.C Interop.- A2 -.- A3
A1 -.WebAssembly.- A3
A3 ==Optimize==> A4
end
S3 -.- S1 -.- S2 -.- S3 -.- subGraph0 -.- S2
S1 -.- subGraph0
S1 & S2 & S3 & subGraph0 --Bundle--> S4 ==Hosting==> S5 ==CDN==> S6
end
subgraph "Rust Backend - API"
direction LR
I1("Rust")
I2("Cargo Lambda")
I3("AWS Lambda")
I4("AWS API Gateway")
I5("AWS SES")
I1 -.- I2 -.- I3 --> I4
I3 -.- I5 -.- I2
end
subgraph "Python Backend - API"
direction LR
P1("Python")
P2("Gemini API")
P3("AWS Lambda")
P4("AWS API Gateway")
P1 -.- P2 -.- P3 --> P4
end
subGraph1 <-..-> subGraph2
subGraph1 <-..-> subGraph3
</code>
```
Build Process 🏗️
The build process for my personal website involves the following steps:
1. <strong>Development Environment Setup:</strong> Use Docker for consistent environment setup across different machines. GitHub Actions can be integrated for automation.
2. <strong>Code Compilation:</strong> Utilize Rust for server-side code and Zig/Emscripten along with Svelte/TypeScript for client-side code.
3. <strong>Optimization:</strong> Optimize compiled assets for production using Binaryen and Vite to ensure minimal file sizes and optimal performance.
4. <strong>Deployment:</strong> Deploy optimized assets to AWS S3 and configure CloudFront for global content distribution using SAM CLI.
```mermaid
flowchart LR
B1("Makefile")
<code>B7("Docker")
B8("Github Actions")
B9("AWS SAM CLI")
subgraph "HTML 5 Canvas"
B2("Zig")
B3("Emscripten")
end
subgraph "Static Site"
B12("Svelte")
B13("TypeScript")
B5("NodeJS/Bun")
B6("Vite")
B4("Binaryen")
end
subgraph "Rust API"
B10("rust")
B11("cargo")
end
subgraph "Python API"
B14("python")
B15("zip")
end
B2 -.- B3
B5 -.- B6 -.- B4
B10 -.- B11
B13 -.- B12
B14 -.- B15
B5 -.- B12
B13 -.- B5
B1 --Build--> subGraph0 --Build--> subGraph1 --Build--> subGraph2 --Build--> subGraph3 --Release--> B9
B8 --Dev Container--> B7 --Setup--> B1
B8 ~~~ B9
B8 ~~~ B1
B8 ~~~ subGraph0
</code>
```
Dev Environment 💻
This repository includes a <em><a>devcontainer.json</a></em> to get up and running quickly with a full-featured development environment in the cloud![^local-development]
<a></a>
<a></a>
Credits 🙌
The website design and development is the singular effort of <a>@dylanlangston</a>. Closed for contributions but feel free to fork or open an issue if you have a question!
License 📜
This repo is licensed under the <a>MIT License</a>. See the <a><code>LICENSE</code></a> file for details.
[^local-development]: For local development check out <a>Dev Containers</a> and <a>DevPod</a>. | [] |
https://avatars.githubusercontent.com/u/6756180?v=4 | asio-zig | kassane/asio-zig | 2023-06-05T13:12:39Z | asio (standalone) event-loop to C API - Experimental (uses zig 0.12.0) | main | 4 | 4 | 2 | 4 | https://api.github.com/repos/kassane/asio-zig/tags | MIT | [
"asio",
"asio-library",
"asynchronous",
"c",
"concurrency",
"cplusplus",
"cpp",
"ffi-bindings",
"threading",
"zig"
] | 30 | false | 2025-01-25T14:42:16Z | true | true | unknown | github | [
{
"commit": "10a3e0c11415f074dd9968b9c0e3a1a05b753f3d",
"name": "asio",
"tar_url": "https://github.com/kassane/asio/archive/10a3e0c11415f074dd9968b9c0e3a1a05b753f3d.tar.gz",
"type": "remote",
"url": "https://github.com/kassane/asio"
}
] | Asio-zig (C Wrapper) - Event-loop
The wrapper provides functions for initializing the ASIO library, running it, stopping it, and posting tasks to be executed asynchronously within the event-loop. It handles the necessary conversions and memory management required to interface with ASIO from C or Zig code. Additionally, it utilizes ASIO's thread pool (<code>asio::static_thread_pool</code>) for multithreading support, allowing tasks to be executed concurrently on multiple threads.
How to build and run
<ul>
<li>Need <a>zig 0.13.0</a> or master.</li>
</ul>
```bash
Zig binding test (only)
$> zig build test
Build all C examples
$> zig build -Doptimize={option} # to debug no need <code>-Doptimize</code> flag
<code>``
**Note:**</code>{option} == Debug (default) | ReleaseSafe | ReleaseFast | ReleaseSmall` | [] |
https://avatars.githubusercontent.com/u/12962448?v=4 | zigcurl | star-tek-mb/zigcurl | 2023-05-28T11:00:29Z | libcurl packaged with zig | master | 0 | 4 | 1 | 4 | https://api.github.com/repos/star-tek-mb/zigcurl/tags | - | [
"curl",
"fetch",
"http",
"https",
"zig"
] | 10,585 | false | 2024-06-15T15:42:34Z | true | false | unknown | github | [] | Overview
libcurl packaged with zig
Versions
curl 8.1.1
mbedtls 3.4.0
zlib 1.2.13
Simple usage
```zig
const c = @cImport({
@cInclude("curl/curl.h");
});
_ = c.curl_global_init(c.CURL_GLOBAL_DEFAULT);
defer c.curl_global_cleanup();
var curl = c.curl_easy_init();
defer c.curl_easy_cleanup(curl);
_ = c.curl_easy_setopt(curl, c.CURLOPT_URL, "https://www.google.com/");
_ = c.curl_easy_setopt(curl, c.CURLOPT_SSL_VERIFYPEER, @as(c_int, 0));
_ = c.curl_easy_setopt(curl, c.CURLOPT_SSL_VERIFYHOST, @as(c_int, 0));
var res = c.curl_easy_perform(curl);
```
Building and linking example
See <code>build.zig</code> and <code>main_tests</code> linking example.
Credits
For original work
https://github.com/mattnite/zig-libcurl | [] |
https://avatars.githubusercontent.com/u/499599?v=4 | asdf-zig | liyu1981/asdf-zig | 2024-01-11T23:34:43Z | Zig plugin for the asdf version manager | asdf-zig-custom-version | 0 | 4 | 0 | 4 | https://api.github.com/repos/liyu1981/asdf-zig/tags | Apache-2.0 | [
"zig"
] | 685 | true | 2024-09-11T05:50:38Z | false | false | unknown | github | [] | asdf-zig
<a>Zig</a> plugin for asdf version manager
Build History
<a></a>
Installation
<code>bash
asdf plugin-add zig https://github.com/asdf-community/asdf-zig.git</code>
Usage
Check <a>asdf</a> readme for instructions on how to
install & manage versions.
License
Licensed under the
<a>Apache License, Version 2.0</a>. | [] |
https://avatars.githubusercontent.com/u/78925721?v=4 | ZTerm | RGBCube/ZTerm | 2023-05-16T19:28:27Z | Terminal abstraction library for Zig. | master | 0 | 4 | 0 | 4 | https://api.github.com/repos/RGBCube/ZTerm/tags | MIT | [
"blazingly-fast",
"console",
"loading-bar",
"spinner",
"terminal",
"zig",
"zig-lib"
] | 14 | false | 2023-11-25T05:10:20Z | true | false | unknown | github | [] | ZTerm
Terminal abstraction library for Zig.
Contents
This is a simple guide to using the library.
The contents will be briefly covered here.
Spinner
```zig
const std = @import("std");
const time = std.time;
const zterm = @import("zterm");
pub fn main() !void {
var sp = zterm.Spinner{
.charset = zterm.Spinner.charsets[3],
.message = "Selling all your data to the CCP...",
};
try sp.start();
<code>time.sleep(3 * time.ns_per_s);
sp.setMessage("Calculating very important stuff while selling your data...");
time.sleep(2 * time.ns_per_s);
try sp.stop(.{
.charset = "✓",
.message = "Successfully sold all your data to the CCP! You data is not in safe hands!",
});
</code>
}
```
License
```
MIT License
Copyright (c) 2023-present RGBCube
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
``` | [] |
https://avatars.githubusercontent.com/u/10933561?v=4 | piping-server-zig | nwtgck/piping-server-zig | 2023-04-15T08:08:29Z | Piping Server in Zig (experimental) | develop | 0 | 3 | 0 | 3 | https://api.github.com/repos/nwtgck/piping-server-zig/tags | MIT | [
"piping-server",
"zig"
] | 34 | false | 2023-04-20T18:21:53Z | false | false | unknown | github | [] | 404 | [] |
https://avatars.githubusercontent.com/u/116503189?v=4 | metaplasia | nylvon/metaplasia | 2023-07-09T23:00:39Z | Type reflection, coercion, and generation written in Zig, for Zig. | main | 2 | 3 | 0 | 3 | https://api.github.com/repos/nylvon/metaplasia/tags | BSD-3-Clause | [
"compiletime",
"dynamic",
"interface",
"metaprogramming",
"metatype",
"static",
"types",
"zig",
"ziglang"
] | 70 | false | 2024-11-28T16:55:49Z | true | true | unknown | github | [] | ➤ Metaplasia ⚡🦠
What is this?
<strong>Metaplasia</strong> is a library that offers users the ability to do a few <em>fun things</em> with their types and objects in Zig, such as:
<ol>
<li>Easy reflection</li>
<li>Interfaces</li>
<li>Compile-time and run-time (and hybrid)!</li>
<li>Type merging</li>
<li>Type generation</li>
</ol>
Why would I want any of this?
<ul>
<li>Interfaces are important and make sure that your code obeys a standard implementation such that it can be swapped out with another bit without needing to re-write everything, thus increasing modularity!
But they also serve an important role as sanity checks for your code!
```zig
// A simple reader interface
const IReader =
Blank()
.And(IsInType(FindFieldAs("buffer", []u8))
.And(IsInType(FindFunctionAs("read_fn", fn([]u8, []u8) []u8));</li>
</ul>
// "grant" returns the type defined below at compile-time if and only if it implements IReader
const custom_reader_type = IReader.Grant(
struct {
buffer: []u8,
<code> pub fn read_fn(path: []u8, options: []u8) []u8 {
// ...
}
});
</code>
<code>- Ever wanted to have a reader and a writer in one package, having those written already, but did not want to write this mixed type by hand? Type merging is the solution! Simply pass two types as</code>zig
// Naive type-merging
const writer_type = struct { ... };
const reader_type = struct { ... };
// Obtain a writer and reader combined type
const writer_reader_type = InferAndMerge([_]type {writer_type, reader_type});
// Safe type-merging
const safe_writer_type = IWriter.Grant(struct { ... });
const safe_reader_type = IReader.Grant(struct { ... });
// This type matches both interfaces, because the original types matched them, if not, we'd get a compile error explaining the situation!
// This type can be used as both a writer and a reader, swap freely!
const safe_writer_reader_type = InferAndMerge([_]type {safe_writer_type, safe_reader_type});
```
<ul>
<li>Now think of a game, where you would have a lot of types, and you would want to re-use them to build more advanced, complex types based off of the original ones. Or, what about procedural types?
```zig
// Some base type that's going to be used in a lot of places
const entity_type = InferAndMerge([_]type {health_type, damage_type, identity_type, ...});</li>
</ul>
// A new player type that 'extends' the entity type. Inheritance, but without all the fuss!
const player_type = InferAndMerge([_]type {entity_type, physics_type, chat_type, ... });
// ...
// insert example for procedural types
};
```
Current status
Below is the status of current features.
Blank means not implemented.
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Reflection (#2)
<br/><input type='checkbox' class='w-4 h-4 text-green-500 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' checked disabled></input> Interfaces (#5)
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Type merging
<br/><input type='checkbox' class='w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600' disabled></input> Type generation | [] |
https://avatars.githubusercontent.com/u/5464072?v=4 | zig-color | nektro/zig-color | 2023-09-15T01:34:27Z | null | master | 1 | 3 | 0 | 3 | https://api.github.com/repos/nektro/zig-color/tags | MIT | [
"zig",
"zig-package"
] | 37 | false | 2025-05-21T20:33:43Z | true | false | unknown | github | [] | zig-color
<a></a>
<a></a>
<a></a>
<a></a>
A pure-Zig library for parsing and manipulating colors in and between multiple spaces.
Supports
<ul>
<li>sRGB</li>
<li>LinearRGB</li>
<li>CMYK</li>
<li>HSL</li>
<li>HSV</li>
<li>YUV</li>
<li>YCbCr</li>
</ul> | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.