avatar_url
stringlengths
46
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
45 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
0
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
60 values
repo_from
stringclasses
3 values
dependencies
listlengths
0
121
readme_content
stringlengths
0
437k
dependents
listlengths
0
21
https://avatars.githubusercontent.com/u/12723818?v=4
waylock
ifreund/waylock
2019-12-12T00:58:16Z
[mirror] A small, secure Wayland screenlocker
master
1
426
19
426
https://api.github.com/repos/ifreund/waylock/tags
ISC
[ "screenlocker", "wayland", "wayland-client", "zig" ]
339
false
2025-05-17T12:45:05Z
true
true
unknown
github
[ { "commit": "v0.3.0.tar.gz", "name": "wayland", "tar_url": "https://codeberg.org/ifreund/zig-wayland/archive/v0.3.0.tar.gz.tar.gz", "type": "remote", "url": "https://codeberg.org/ifreund/zig-wayland" }, { "commit": "v0.3.0.tar.gz", "name": "xkbcommon", "tar_url": "https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.3.0.tar.gz.tar.gz", "type": "remote", "url": "https://codeberg.org/ifreund/zig-xkbcommon" } ]
waylock Waylock is a small screenlocker for Wayland compositors implementing <code>ext-session-lock-v1</code>. The <code>ext-session-lock-v1</code> protocol is significantly more robust than previous client-side Wayland screen locking approaches. Importantly, the screenlocker crashing does not cause the session to be unlocked. Install from your <a>package manager</a> The main repository is on <a>codeberg</a>, which is where the issue tracker may be found and where contributions are accepted. Read-only mirrors exist on <a>sourcehut</a> and <a>github</a>. Building Note: If you are packaging waylock for distribution, see <a>PACKAGING.md</a>. To compile waylock first ensure that you have the following dependencies installed: <ul> <li><a>zig</a> 0.14</li> <li>wayland</li> <li>wayland-protocols</li> <li>xkbcommon</li> <li>pam</li> <li>pkg-config</li> <li>scdoc (optional, but required for man page generation)</li> </ul> Then run, for example: <code>zig build -Doptimize=ReleaseSafe --prefix /usr install</code> Note that PAM will only use configuration files in the system directory, likely <code>/etc/pam.d</code> by default. Therefore care must be taken if installing to a prefix other than <code>/usr</code> to ensure the configuration file <a>pam.d/waylock</a> is found by PAM. Usage See the <code>waylock(1)</code> man page or the output of <code>waylock -h</code> for an overview of the command line options. Run the waylock executable to lock the session. All monitors will be blanked with the <code>-init-color</code>. Typing causes the color to change to the <code>-input-color</code>. <code>Esc</code> or <code>Ctrl-U</code> clears all current input, while <code>backspace</code> deletes the last UTF-8 codepoint. To unlock the session, type your password and press <code>Enter</code>. If the password is correct, waylock will unlock the session and exit. Otherwise, the color will change to the <code>-fail-color</code> and you may try again. In order to automatically run waylock after a certain amount of time with no input or before sleep, the <a>swayidle</a> utility or a similar program may be used. See the <code>swayidle(1)</code> man page for details. Licensing Waylock is released under the ISC License.
[]
https://avatars.githubusercontent.com/u/3932972?v=4
SDL.zig
ikskuh/SDL.zig
2019-12-02T07:43:30Z
A shallow wrapper around SDL that provides object API and error handling
master
17
402
88
402
https://api.github.com/repos/ikskuh/SDL.zig/tags
MIT
[ "gamedev", "sdl", "sdl2", "zig", "zig-package", "ziglang" ]
995
false
2025-05-15T23:44:01Z
true
true
0.14.0
github
[]
SDL.zig A Zig package that provides you with the means to link SDL2 to your project, as well as a Zig-infused header implementation (allows you to not have the SDL2 headers on your system and still compile for SDL2) and a shallow wrapper around the SDL apis that allow a more Zig-style coding with Zig error handling and tagged unions. Getting started Linking SDL2 to your project This is an example <code>build.zig</code> that will link the SDL2 library to your project. ```zig const std = @import("std"); const sdl = @import("sdl"); // Replace with the actual name in your build.zig.zon pub fn build(b: *std.Build) !void { // Determine compilation target const target = b.standardTargetOptions(.{}); <code>// Create a new instance of the SDL2 Sdk // Specifiy dependency name explicitly if necessary (use sdl by default) const sdk = sdl.init(b, .{}); // Create executable for our example const demo_basic = b.addExecutable(.{ .name = "demo-basic", .root_source_file = b.path("my-game.zig"), .target = target, }); sdk.link(demo_basic, .dynamic, sdl.Library.SDL2); // link SDL2 as a shared library // Add "sdl2" package that exposes the SDL2 api (like SDL_Init or SDL_CreateWindow) demo_basic.root_module.addImport("sdl2", sdk.getNativeModule()); // Install the executable into the prefix when invoking "zig build" b.installArtifact(demo_basic); </code> } ``` Using the native API This package exposes the SDL2 API as defined in the SDL headers. Use this to create a normal SDL2 program: ```zig const std = @import("std"); const SDL = @import("sdl2"); // Add this package by using sdk.getNativeModule pub fn main() !void { if (SDL.SDL_Init(SDL.SDL_INIT_VIDEO | SDL.SDL_INIT_EVENTS | SDL.SDL_INIT_AUDIO) &lt; 0) sdlPanic(); defer SDL.SDL_Quit(); <code>var window = SDL.SDL_CreateWindow( "SDL2 Native Demo", SDL.SDL_WINDOWPOS_CENTERED, SDL.SDL_WINDOWPOS_CENTERED, 640, 480, SDL.SDL_WINDOW_SHOWN, ) orelse sdlPanic(); defer _ = SDL.SDL_DestroyWindow(window); var renderer = SDL.SDL_CreateRenderer(window, -1, SDL.SDL_RENDERER_ACCELERATED) orelse sdlPanic(); defer _ = SDL.SDL_DestroyRenderer(renderer); mainLoop: while (true) { var ev: SDL.SDL_Event = undefined; while (SDL.SDL_PollEvent(&amp;ev) != 0) { if(ev.type == SDL.SDL_QUIT) break :mainLoop; } _ = SDL.SDL_SetRenderDrawColor(renderer, 0xF7, 0xA4, 0x1D, 0xFF); _ = SDL.SDL_RenderClear(renderer); SDL.SDL_RenderPresent(renderer); } </code> } fn sdlPanic() noreturn { const str = @as(?[*:0]const u8, SDL.SDL_GetError()) orelse "unknown error"; @panic(std.mem.sliceTo(str, 0)); } ``` Using the wrapper API This package also exposes the SDL2 API with a more Zig-style API. Use this if you want a more convenient Zig experience. <strong>Note:</strong> This API is experimental and might change in the future ```zig const std = @import("std"); const SDL = @import("sdl2"); // Created in build.zig by using exe.root_module.addImport("sdl2", sdk.getWrapperModule()); pub fn main() !void { try SDL.init(.{ .video = true, .events = true, .audio = true, }); defer SDL.quit(); <code>var window = try SDL.createWindow( "SDL2 Wrapper Demo", .{ .centered = {} }, .{ .centered = {} }, 640, 480, .{ .vis = .shown }, ); defer window.destroy(); var renderer = try SDL.createRenderer(window, null, .{ .accelerated = true }); defer renderer.destroy(); mainLoop: while (true) { while (SDL.pollEvent()) |ev| { switch (ev) { .quit =&gt; break :mainLoop, else =&gt; {}, } } try renderer.setColorRGB(0xF7, 0xA4, 0x1D); try renderer.clear(); renderer.present(); } </code> } ``` <code>build.zig</code> API <code>``zig /// Just call</code>Sdk.init(b, .{})<code>to obtain a handle to the Sdk! /// Use</code>sdl` as dependency name by default. const Sdk = @This(); /// Creates a instance of the Sdk and initializes internal steps. /// Initialize once, use everywhere (in your <code>build</code> function). /// /// const SdkOption = struct { /// dep_name: ?[]const u8 = "sdl", /// maybe_config_path: ?[]const u8 = null, /// maybe_sdl_ttf_config_path: ?[]const u8 = null, /// }; pub fn init(b: <em>Build, opt: SdkOption) </em>Sdk /// Returns a module with the raw SDL api with proper argument types, but no functional/logical changes /// for a more <em>ziggy</em> feeling. /// This is similar to the <em>C import</em> result. pub fn getNativeModule(sdk: <em>Sdk) </em>Build.Module; /// Returns a module with the raw SDL api with proper argument types, but no functional/logical changes /// for a more <em>ziggy</em> feeling, with Vulkan support! The Vulkan module provided by <code>vulkan-zig</code> must be /// provided as an argument. /// This is similar to the <em>C import</em> result. pub fn getNativeModuleVulkan(sdk: <em>Sdk, vulkan: </em>Build.Module) *Build.Module; /// Returns the smart wrapper for the SDL api. Contains convenient zig types, tagged unions and so on. pub fn getWrapperModule(sdk: <em>Sdk) </em>Build.Module; /// Returns the smart wrapper with Vulkan support. The Vulkan module provided by <code>vulkan-zig</code> must be /// provided as an argument. pub fn getWrapperModuleVulkan(sdk: <em>Sdk, vulkan: </em>Build.Module) *Build.Module; /// Links SDL2 or SDL2_ttf to the given exe and adds required installs if necessary. /// <strong>Important:</strong> The target of the <code>exe</code> must already be set, otherwise the Sdk will do the wrong thing! pub fn link(sdk: <em>Sdk, exe: </em>Build.Step.Compile, linkage: std.builtin.LinkMode, comptime library: Library) void; ``` Dependencies All of those are dependencies for the <em>target</em> platform, not for your host. Zig will run/build the same on all source platforms. Windows For Windows, you need to fetch the correct dev libraries from the <a>SDL download page</a>. It is recommended to use the MinGW versions if you don't require MSVC compatibility. MacOS Right now, cross-compiling for MacOS isn't possible. On a Mac, install SDL2 via <code>brew</code>. Linux If you are cross-compiling, no dependencies exist. The build Sdk compiles a <code>libSDL2.so</code> stub which is used for linking. If you compile to your target platform, you require SDL2 to be installed via your OS package manager. Support Matrix This project tries to provide you the best possible development experience for SDL2. Thus, this project supports the maximum amount of cross-compilation targets for SDL2. The following table documents this. The rows document the <em>target</em> whereas the columns are the <em>build host</em>: | | Windows (x86_64) | Windows (i386) | Linux (x86_64) | MacOS (x86_64) | MacOS (aarch64) | |-----------------------|------------------|----------------|----------------|----------------|-----------------| | <code>i386-windows-gnu</code> | ✅ | ✅ | ✅ | ✅ | ⚠️ | | <code>i386-windows-msvc</code> | ✅ | ✅ | ✅ | ✅ | ⚠️ | | <code>x86_64-windows-gnu</code> | ✅ | ✅ | ✅ | ✅ | ⚠️ | | <code>x86_64-windows-msvc</code> | ✅ | ✅ | ✅ | ✅ | ⚠️ | | <code>x86_64-macos</code> | ❌ | ❌ | ❌ | ✅ | ❌ | | <code>aarch64-macos</code> | ❌ | ❌ | ❌ | ❌ | ⚠️ | | <code>x86_64-linux-gnu</code> | 🧪 | 🧪 | ✅ | 🧪 | ⚠️ | | <code>aarch64-linux-gnu</code> | 🧪 | 🧪 | 🧪 | 🧪 | ⚠️ | Legend: - ✅ Cross-compilation is known to work and tested via CI - 🧪 Experimental cross-compilation support, covered via CI - ⚠️ Cross-compilation <em>might</em> work, but is not tested via CI - ❌ Cross-compilation is not possible right now Contributing You can contribute to this project in several ways: - Use it! This helps me to track bugs (which i know that there are some), and usability defects (which we can resolve then). I want this library to have the best development experience possible. - Implement/improve the linking experience: Right now, it's not possible to cross-compile for MacOS, which is very sad. We might find a way to do so, though! Also VCPKG is not well supported on windows platforms. - Improve the wrapper. Just add the functions you need and make a PR. Or improve existing ones. I won't do it for you, so you have to get your own hands dirty!
[]
https://avatars.githubusercontent.com/u/46852732?v=4
ZigGBA
wendigojaeger/ZigGBA
2019-12-08T23:29:41Z
Work in progress SDK for creating Game Boy Advance games using Zig programming language.
master
6
375
15
375
https://api.github.com/repos/wendigojaeger/ZigGBA/tags
MIT
[ "gba", "sdk", "zig" ]
679
false
2025-04-23T01:27:59Z
true
false
unknown
github
[]
Zig GBA This is a work in progress SDK for creating Game Boy Advance games using the <a>Zig</a> programming language. Once Zig has a proper package manager, I hope that it would as easy as import the ZigGBA package. Inspired by <a>TONC GBA tutorial</a> <strong>This project is up for adoption for a new maintainer!</strong> Setup This project uses submodules, so post clone, you will need to run: <code>bash git submodule update --init</code> Build This library uses zig nominated <a>2024.10.0-mach</a>. To install using <a><code>zigup</code></a>: <code>sh zigup 0.14.0-dev.1911+3bf89f55c</code> To build, simply use Zig's integrated build system <code>bash zig build</code> First example running in a emulator First example running on real hardware
[]
https://avatars.githubusercontent.com/u/380158?v=4
zhp
frmdstryr/zhp
2019-12-03T21:11:48Z
A Http server written in Zig
master
11
356
23
356
https://api.github.com/repos/frmdstryr/zhp/tags
MIT
[ "http", "zig" ]
828
false
2025-05-07T09:12:21Z
true
false
unknown
github
[]
ZHP <a></a> A (work in progress) Http server written in <a>Zig</a>. If you have suggestions on improving the design please feel free to comment! Features <ul> <li>A zero-copy parser and aims to compete with these <a>parser_benchmarks</a> while still rejecting nonsense requests. It currently runs around ~1000MB/s.</li> <li>Regex url routing thanks to <a>ctregex</a></li> <li>Struct based handlers where the method maps to the function name</li> <li>A builtin static file handler, error page handler, and not found page handler</li> <li>Middleware support</li> <li>Parses forms encoded with <code>multipart/form-data</code></li> <li>Streaming responses</li> <li>Websockets</li> </ul> See how it compares in the <a>http benchmarks</a> done by kprotty (now very old). It's a work in progress... feel free to contribute! Demo Try out the demo at <a>https://zhp.codelv.com</a>. <blockquote> Note: If you try to benchmark the server it'll ban you, please run it locally or on your own server to do benchmarks. </blockquote> To make and deploy your own app see: - <a>demo project</a> - <a>zig buildpack</a> Example See the <code>example</code> folder for a more detailed example. ```zig const std = @import("std"); const web = @import("zhp"); pub const io_mode = .evented; pub const log_level = .info; const MainHandler = struct { pub fn get(self: <em>MainHandler, request: </em>web.Request, response: *web.Response) !void { _ = self; _ = request; try response.headers.put("Content-Type", "text/plain"); _ = try response.stream.write("Hello, World!"); } }; pub const routes = [_]web.Route{ web.Route.create("home", "/", MainHandler), }; pub const middleware = [_]web.Middleware{ web.Middleware.create(web.middleware.LoggingMiddleware), }; pub fn main() anyerror!void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer std.debug.assert(!gpa.deinit()); const allocator = gpa.allocator(); <code>var app = web.Application.init(allocator, .{.debug=true}); defer app.deinit(); try app.listen("127.0.0.1", 9000); try app.start(); </code> } ```
[]
https://avatars.githubusercontent.com/u/15308111?v=4
routez
Vexu/routez
2019-06-08T11:33:41Z
Http server for Zig
master
3
250
8
250
https://api.github.com/repos/Vexu/routez/tags
MIT
[ "http", "server", "zig" ]
175
false
2025-05-17T15:53:40Z
true
false
unknown
github
[]
Routez HTTP server for Zig. Example <a>basic</a> Run with <code>zig build basic</code> ```Zig const std = @import("std"); const Address = std.net.Address; usingnamespace @import("routez"); const allocator = std.heap.page_allocator; pub const io_mode = .evented; pub fn main() !void { var server = Server.init( allocator, .{}, .{ all("/", indexHandler), get("/about", aboutHandler), get("/about/more", aboutHandler2), get("/post/{post_num}/?", postHandler), static("./", "/static"), all("/counter", counterHandler), }, ); var addr = try Address.parseIp("127.0.0.1", 8080); try server.listen(addr); } fn indexHandler(req: Request, res: Response) !void { try res.sendFile("examples/index.html"); } fn aboutHandler(req: Request, res: Response) !void { try res.write("Hello from about\n"); } fn aboutHandler2(req: Request, res: Response) !void { try res.write("Hello from about2\n"); } fn postHandler(req: Request, res: Response, args: *const struct { post_num: []const u8, }) !void { try res.print("Hello from post, post_num is {}\n", args.post_num); } var counter = std.atomic.Int(usize).init(0); fn counterHandler(req: Request, res: Response) !void { try res.print("Page loaded {} times\n", counter.fetchAdd(1)); } ```
[]
https://avatars.githubusercontent.com/u/1950733?v=4
zig-okredis
kristoff-it/zig-okredis
2019-08-21T17:53:43Z
Zero-allocation Client for all the various Redis forks
master
2
240
19
240
https://api.github.com/repos/kristoff-it/zig-okredis/tags
MIT
[ "okredis", "redis", "redis-client", "zero-allocation", "zig" ]
1,537
false
2025-05-11T15:52:01Z
true
true
0.14.0
github
[]
OkRedis <a></a> <a></a> OkRedis is a zero-allocation client for Redis 6+ Handy and Efficient OkRedis aims to offer an interface with great ergonomics without compromising on performance or flexibility. Project status OkRedis is currently in alpha. The main features are mostly complete, but a lot of polishing is still required. Zig version <code>0.14.0</code> is supported. Everything mentioned in the docs is already implemented and you can just <code>zig run example.zig</code> to quickly see what it can do. Remember OkRedis only supports Redis 6 and above. Zero dynamic allocations, unless explicitly wanted The client has two main interfaces to send commands: <code>send</code> and <code>sendAlloc</code>. Following Zig's mantra of making dynamic allocations explicit, only <code>sendAlloc</code> can allocate dynamic memory, and only does so by using a user-provided allocator. The way this is achieved is by making good use of RESP3's typed responses and Zig's metaprogramming facilities. The library uses compile-time reflection to specialize down to the parser level, allowing OkRedis to decode whenever possible a reply directly into a function frame, <strong>without any intermediate dynamic allocation</strong>. If you want more information about Zig's comptime: - <a>Official documentation</a> - <a>What is Zig's Comptime?</a> (blog post written by me) By using <code>sendAlloc</code> you can decode replies with arbrirary shape at the cost of occasionally performing dynamic allocations. The interface takes an allocator as input, so the user can setup custom allocation schemes such as <a>arenas</a>. Quickstart ```zig const std = @import("std"); const okredis = @import("./src/okredis.zig"); const SET = okredis.commands.strings.SET; const OrErr = okredis.types.OrErr; const Client = okredis.Client; pub fn main() !void { const addr = try std.net.Address.parseIp4("127.0.0.1", 6379); var connection = try std.net.tcpConnectToAddress(addr); <code>var client: Client = undefined; try client.init(connection); defer client.close(); // Basic interface try client.send(void, .{ "SET", "key", "42" }); const reply = try client.send(i64, .{ "GET", "key" }); if (reply != 42) @panic("out of towels"); // Command builder interface const cmd = SET.init("key", "43", .NoExpire, .IfAlreadyExisting); const otherReply = try client.send(OrErr(void), cmd); switch (otherReply) { .Nil =&gt; @panic("command should not have returned nil"), .Err =&gt; @panic("command should not have returned an error"), .Ok =&gt; std.debug.print("success!", .{}), } </code> } ``` Available Documentation The reference documentation <a>is available here</a>. <ul> <li> <a>Using the OkRedis client</a> <ul> <li><a>Connecting</a></li> <li><a>Buffering</a></li> <li><a>Evented vs blocking I/O</a></li> <li><a>Pipelining</a></li> <li><a>Transactions</a></li> <li><a>Pub/Sub</a></li> </ul> </li> <li> <a>Sending commands</a> <ul> <li><a>Base interface</a></li> <li><a>Command builder interface</a></li> <li><a>Validating command syntax</a></li> <li><a>Optimized command builders</a></li> <li><a>Creating new command builders</a></li> <li><a>An afterword on command builders vs methods</a></li> </ul> </li> <li> <a>Decoding Redis Replies</a> <ul> <li><a>Introduction</a></li> <li><a>The first and second rule of decoding replies</a></li> <li><a>Decoding Zig types</a><ul> <li><a>Void</a></li> <li><a>Numbers</a></li> <li><a>Optionals</a></li> <li><a>Strings</a></li> <li><a>Structs</a></li> </ul> </li> <li><a>Decoding Redis errors and nil replies as values</a><ul> <li><a>Redis OK replies</a></li> </ul> </li> <li><a>Allocating memory dynamically</a><ul> <li><a>Allocating strings</a></li> <li><a>Freeing complex replies</a></li> <li><a>Allocating Redis Error messages</a></li> <li><a>Allocating structured types</a></li> </ul> </li> <li><a>Parsing dynamic replies</a></li> <li><a>Bundled types</a></li> <li><a>Decoding types in the standard library</a></li> <li><a>Implementing decodable types</a><ul> <li><a>Adding types for custom commands (Lua scripts or Redis modules)</a></li> <li><a>Adding types used by a higher-level language</a></li> </ul> </li> </ul> </li> </ul> Extending OkRedis If you are a Lua script or Redis module author, you might be interested in reading the final sections of <code>COMMANDS.md</code> and <code>REPLIES.md</code>. Embedding OkRedis in a higher level language Take a look at the final section of <code>REPLIES.md</code>. TODOS <ul> <li>Implement remaining command builders</li> <li>Better connection management (ipv6, unixsockets, ...)</li> <li>Streamline design of Zig errors</li> <li>Refine support for async/await and think about connection pooling</li> <li>Refine the Redis traits</li> <li>Pub/Sub</li> </ul>
[]
https://avatars.githubusercontent.com/u/3932972?v=4
LoLa
ikskuh/LoLa
2019-07-17T17:56:20Z
LoLa is a small programming language meant to be embedded into games.
master
15
207
11
207
https://api.github.com/repos/ikskuh/LoLa/tags
MIT
[ "compiler", "interpreter", "language", "lola-language", "programming-language", "script-language", "zig", "zig-package" ]
13,512
false
2025-05-18T05:27:14Z
true
true
unknown
github
[ { "commit": "9425b94c103a031777fdd272c555ce93a7dea581", "name": "args", "tar_url": "https://github.com/ikskuh/zig-args/archive/9425b94c103a031777fdd272c555ce93a7dea581.tar.gz", "type": "remote", "url": "https://github.com/ikskuh/zig-args" }, { "commit": "d068b14cd30577783de018e280428953d098b3d2", "name": "any_pointer", "tar_url": "https://github.com/ikskuh/any-pointer/archive/d068b14cd30577783de018e280428953d098b3d2.tar.gz", "type": "remote", "url": "https://github.com/ikskuh/any-pointer" } ]
LoLa Programming Language LoLa is a small programming language meant to be embedded into games to be programmed by the players. The compiler and runtime are implemented in Zig and C++. Short Example <code>js var list = [ "Hello", "World" ]; for(text in list) { Print(text); }</code> You can find more examples in the <a>examples</a> folder. Why LoLa when there is <em>X</em>? LoLa isn't meant to be your next best day-to-day scripting language. Its design is focused on embedding the language in environments where the users want/need/should write some small scripts like games or scriptable applications. In most script languages, you as a script host don't have control over the execution time of the scripts you're executing. LoLa protects you against programming errors like endless loops and such: Controlled Execution Environment Every script invocation gets a limit of instructions it might execute. When either this limit is reached or the script yields for other reasons (asynchronous functions), the execution is returned to the host. This means, you can execute the following script "in parallel" to your application main loop without blocking your application <em>and</em> without requiring complex multithreading setups: <code>js var timer = 0; while(true) { Print("Script running for ", timer, " seconds."); timer += 1; Sleep(1.0); }</code> Native Asynchronous Design LoLa features both synchronous and asynchronous host functions. Synchronous host function calls are short-lived and will be executed in-place. Asynchronous functions, in contrast, will be executed multiple times until they yield a value. When they don't yield a value, control will be returned to the script host. This script will not exhaust the instruction limit, but will only increment the counter, then return control back to the host: <code>js var counter = 0; while(true) { counter += 1; Yield(); }</code> This behaviour can be utilized to wait for certain events in the host environment, for example to react to key presses, a script could look like this: <code>js while(true) { var input = WaitForKey(); if(input == " ") { Print("Space was pressed!"); } }</code> <em>Note that the current implementation is not thread-safe, but requires to use the limited execution for running scripts in parallel.</em> Native "RPC" Design LoLa also allows executing multiple scripts on the same <em>environment</em>, meaning that you can easily create cross-script communications: ```js // script a: var buffer; function Set(val) { buffer = val; } function Get() { return val; } // script b: // GetBuffer() returns a object referencing a environment for "script a" var buffer = GetBuffer(); buffer.Set("Hello, World!"); // script c: // GetBuffer() returns a object referencing a environment for "script a" var buffer = GetBuffer(); Print("Buffer contains: ", buffer.Get()); ``` With a fitting network stack and library, this can even be utilized cross-computer. This example implements a small chat client and server that could work with LoLa RPC capabilities: ```js // Chat client implementation: var server = Connect("lola-rpc://random-projects.net/chat"); if(server == void) { Print("Could not connect to chat server!"); Exit(1); } while(true) { var list = server.GetMessages(GetUser()); for(msg in list) { Print("&lt; ", msg); } <code>Print("&gt; "); var msg = ReadLine(); if(msg == void) break; if(msg == "") continue; server.Send(GetUser(), msg); </code> } ``` ```js // Chat server implementation var messages = CreateDictionary(); function Send(user, msg) { for(other in messages.GetKeys()) { if(other != user) { var log = messages.Get(other); if(log != void) { log = log ++ [ user + ": " + msg ]; } else { log = []; } messages.Set(other, log); } } } function GetMessages(user) { var log = messages.Get(user); if(log != void) { messages.Set(user, []); return log; } else { return []; } } ``` Serializable State As LoLa has no reference semantics except for objects, it is easy to understand and learn. It is also simple in its implementation and does not require a complex garbage collector or advanced programming knowledge. Each LoLa value can be serialized/deserialized into a sequence of bytes (only exception are object handles, those require some special attention), so saving the current state of a environment/vm to disk and loading it at a later point is a first-class supported use case. This is especially useful for games where it is favourable to save your script state into a save game as well without having any drawbacks. Simple Error Handling LoLa provides little to no in-language error handling, as it's not designed to be robust against user programming errors. Each error is passed to the host as a panic, so it can show the user that there was an error (like <code>OutOfMemory</code> or <code>TypeMismatch</code>). In-language error handling is based on the dynamic typing: Functions that allow in-language error handling just return <code>void</code> instead of a actual return value or <code>true</code>/<code>false</code> for <em>success</em> or <em>failure</em>. This allows simple error checking like this: <code>js var string = ReadFile("demo.data"); if(string != void) { Print("File contained ", string); }</code> This design decision was made with the idea in mind that most LoLa programmers won't write the next best security critical software, but just do a quick hack in game to reach their next item unlock. Smart compiler As LoLa isn't the most complex language, the compiler can support the programmer. Even though the language has fully dynamic typing, the compiler can do some type checking at compile time already: <code>js // warning: Possible type mismatch detected: Expected number|string|array, found boolean if(a &lt; true) { }</code> Right now, this is only used for validating expressions, but it is planned to extend this behaviour to annotate variables as well, so even more type errors can be found during compile time. Note that this is a fairly new feature, it does not catch all your type mismatches, but can prevent the obvious ones. Starting Points To get familiar with LoLa, you can check out these starting points: <ul> <li><a>Documentation</a></li> <li><a>LoLa Examples</a></li> <li><a>Script Host Examples</a></li> </ul> When you want to contribute to the compiler, check out the following documents: <ul> <li><a>Source Code</a></li> <li><a>Bison Grammar</a></li> <li><a>Flex Tokenizer</a></li> <li><a>Issue List</a></li> </ul> Visual Studio Code Extension If you want syntax highlighting in VSCode, you can install the <a><code>lola-vscode</code></a> extension. Right now, it's not published in the gallery, so to install the extension, you have to sideload it. <a>See the VSCode documentation for this</a>. Building Continous Integration <a></a> <a></a> Requirements <ul> <li>The <a>Zig Compiler</a> (Version 0.12.0-dev.3438+5c628312b or newer)</li> </ul> Building <code>sh zig build ./zig-cache/bin/lola</code> Examples To compile the host examples, you can use <code>zig build examples</code> to build all provided examples. These will be available in <code>./zig-cache/bin</code> then. Running the test suite When you change things in the compiler or VM implementation, run the test suite: <code>sh zig build test</code> This will execute all zig tests, and also runs a set of predefined tests within the <a><code>src/test/</code></a> folder. These tests will verify that the compiler and language runtime behave correctly. Building the website The website generator is gated behind <code>-Denable-website</code> which removes a lot of dependencies for people not wanting to render a new version of the website. If you still want to update/change the website or documentation, use the following command: <code>sh zig build -Denable-website "-Dversion=$(git describe --tags || git rev-parse --short HEAD)" website</code> It will depend on <a>koino</a>, which is included as a git submodule. Adding new pages to the documentation is done by modifying the <code>menu_items</code> array in <code>src/tools/render-md-page.zig</code>.
[]
https://avatars.githubusercontent.com/u/2389051?v=4
zua
squeek502/zua
2019-12-17T07:44:03Z
An implementation of Lua 5.1 in Zig, for learning purposes
master
0
191
8
191
https://api.github.com/repos/squeek502/zua/tags
0BSD
[ "lua", "lua-vm", "zig" ]
876
false
2025-05-15T05:32:14Z
true
false
unknown
github
[]
Zua An attempt at a <a>Lua</a> 5.1 implementation in <a>Zig</a>. Goals, in order of priority: 1. Learn more about Lua internals 2. Learn more about Zig 3. Anything else Status <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> Lexer (llex.c/.h) -&gt; <a>lex.zig</a> + [x] Keywords + [x] Identifiers + [x] <code>..</code>, <code>...</code> + [x] <code>==</code>, <code>&gt;=</code>, <code>&lt;=</code>, <code>~=</code> + [x] String literals (single/double quoted and multi-line (<code>[[</code>)) + [x] Comments (<code>--</code> and <code>--[[</code>) + [x] Numbers + [x] Improve tests, perhaps use fuzz testing - See <a>Fuzzing As a Test Case Generator</a> and <a>squeek502/fuzzing-lua</a> + [ ] Cleanup implementation <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> String parsing (in Lua this was done at lex-time) -&gt; <a>parse_literal.zig</a> (see <a><code>4324bd0</code></a> for more details) <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> Number parsing (in Lua this was done at lex-time) -&gt; <a>parse_literal.zig</a> + [x] Basic number parsing + [ ] Proper <code>strtod</code>-compatible number parsing implementation <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> Parser (lparser.c/.h) (in Lua this was done as one step with no AST intermediate) + [x] Parsing tokens into an AST -&gt; <a>parse.zig</a> (mostly done, needs some more testing/cleanup) + [ ] Compiling the AST into bytecode -&gt; <a>compiler.zig</a> <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> ... Why Lua 5.1? It's what I'm most familiar with, and I'm also assuming that 5.1 is simpler internally than more recent Lua versions. Building / running <ul> <li><code>zig build</code> to build zua.exe</li> <li><code>zig build test</code> to build &amp; run the main test suite</li> <li><code>zig build run</code> to build &amp; run zua.exe (does nothing right now)</li> <li><code>zig build lua51_tests</code> to run tests on the PUC Lua 5.1 test files (currently it just tests parsing them)</li> <li><code>zig build fuzzed_lex</code> to run lexer tests on a large set of inputs/outputs generated by <a>fuzzing-lua</a></li> <li><code>zig build bench_lex</code> to run a benchmark of the lexer (this benchmark needs improvement)</li> <li><code>zig build fuzzed_strings</code> to run string parsing tests on a set of inputs/outputs generated by <a>fuzzing-lua</a></li> </ul>
[]
https://avatars.githubusercontent.com/u/219422?v=4
fundude
fengb/fundude
2019-03-20T23:23:56Z
Gameboy emulator: Zig -> wasm
master
37
190
8
190
https://api.github.com/repos/fengb/fundude/tags
MIT
[ "gameboy-emulator", "wasm", "zig" ]
4,880
false
2025-04-23T19:10:01Z
true
false
unknown
github
[]
🚧 Under Construction 🚧 Game compatibility Perfect emulation: - <em>none</em> Playable: - <strong>Tetris</strong> - <strong>Super Mario Land</strong> - <strong>Bionic Commando</strong> - <strong>Pokemon Red/Blue</strong> - <strong>Kirby's Dreamland</strong> - <strong>Dr. Mario</strong> - <strong>Zelda: Link's Awakening</strong> Implementation details | | | |-|-| | CPU | some bugs, incorrect instruction durations | | Video | mostly working -- render hacks | | Joypad | should work | | Timer | untested, poor timing | | Interrupts | untested | | Serial | ❌ | | Audio | ❌ | Development Dependencies: - zig 0.6.0+ - node.js 10.0.0+ ```bash Pull down this project $ git clone https://github.com/fengb/fundude.git $ cd fundude Build the wasm -- release-safe increases performance by &gt;10x compared to the default debug mode $ zig build -Drelease-safe Start the server $ yarn install $ yarn dev ```
[]
https://avatars.githubusercontent.com/u/33362396?v=4
colorstorm
benbusby/colorstorm
2019-05-15T16:49:50Z
A color theme generator for editors and terminal emulators
main
8
187
11
187
https://api.github.com/repos/benbusby/colorstorm/tags
MIT
[ "atom", "atom-theme", "color-themes", "dark-syntax-theme", "dark-theme", "editor-theme", "intellij-theme", "nintendo", "screenshot", "snes", "sublime", "sublime-theme", "syntax-highlighting", "theme", "vim", "vim-colorscheme", "vscode", "vscode-theme", "zig", "ziglang" ]
19,432
false
2025-05-09T10:27:30Z
true
false
unknown
github
[]
:art: <em>A command line tool to generate color themes for editors (Vim, VSCode, Sublime, Atom) and terminal emulators (iTerm2, Hyper).</em> <a></a> <a></a> <a></a> Contents 1. <a>Install</a> 1. <a>Usage</a> 1. <a>Creating Themes</a> 1. <a>Screenshots</a> Install Arch Linux (AUR) <code>yay -S colorstorm</code> Other distros In progress, check back soon! From Source <ul> <li>Install <a>Zig</a></li> <li>Run: <code>make release</code></li> <li>Move <code>zig-out/bin/colorstorm</code> into your <code>PATH</code></li> </ul> Usage ```bash $ colorstorm [-o outdir] [-g generator] input -o|--outdir: The directory to output themes to (default: "./colorstorm-out") -g|--gen: Generator type (default: all) Available types: all, atom, vscode, vim, sublime, iterm, hyper -i|--input: The JSON input file to use for generating the themes See: https://github.com/benbusby/colorstorm#creating-themes ``` Supported Editors <ul> <li>Vim</li> <li>VSCode</li> <li>Sublime</li> <li>Atom</li> </ul> Supported Terminal Emulators <ul> <li>iTerm2</li> <li>Hyper</li> </ul> Creating Themes You can create themes for all available editors and terminal emulators using a single JSON file to define the colors. The file should be an array (even for one theme), with the following structure: <code>json [ { "theme_name_full": "Moonside", "theme_name_safe": "moonside", "color_bg_main": "#000000", "color_bg_alt1": "#080808", "color_bg_alt2": "#131313", "color_fg": "#ffffff", "color_linenr": "#9e5dc8", "color_select": "#5a1359", "color_type": "#f6f929", "color_accent": "#fd35fa", "color_string": "#ff6693", "color_boolean": "#fd9935", "color_variable": "#c67ff4", "color_number": "#aaef64", "color_comment": "#7ca454", "color_function": "#5e9aff" }, { ... } ]</code> Value names are mostly self-explanatory, but here is a breakdown of what each field means: Field Explanation <code>theme_name_full</code> The full name of the theme that will appear in theme file documentation <code>theme_name_safe</code> The value to use as the filename for the theme <code>color_bg_main</code> Primary background color <code>color_bg_alt1</code> A separate background color to use for UI elements like file trees and tab bars <code>color_bg_alt2</code> A separate background color to use for UI elements like line numbers and gutters <code>color_fg</code> The foreground color (all generic text) <code>color_linenr</code> The color used for line numbers <code>color_select</code> The color used for selecting a word or lines of text <code>color_type</code> The color used for variable types (int, float, etc) <code>color_accent</code> An "accent" color -- typically used for special cases (like current line number highlight or badge backgrounds) <code>color_string</code> The color used for strings <code>color_boolean</code> The color used for boolean values <code>color_variable</code> The color used for variable instances and constants <code>color_number</code> The color used for numeric values <code>color_comment</code> The color used for code comments <code>color_function</code> The color used for function names Screenshots <ul> <li><a>Earthbound Themes</a></li> </ul> <a></a> <a></a> <a></a> <a></a> Earthbound Moonside Zombie Threed Fire Spring Devil's Machine Dusty Dunes Magicant (Light Theme) Cave of the Past (Monochrome)
[]
https://avatars.githubusercontent.com/u/1006268?v=4
setup-zig
goto-bus-stop/setup-zig
2019-10-05T10:53:59Z
use a @ziglang compiler in your github actions workflows
default
10
154
20
154
https://api.github.com/repos/goto-bus-stop/setup-zig/tags
NOASSERTION
[ "actions", "github-action", "github-actions", "zig", "ziglang" ]
1,468
false
2025-03-27T17:05:41Z
false
false
unknown
github
[]
setup-zig Use the zig compiler in your Github Actions workflows <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> This GitHub Action is unmaintained. Please use <a>mlugg/setup-zig</a> instead. </blockquote> <a>Usage</a> - <a>License: Apache-2.0</a> Usage In a Github Actions workflow file, do something like: <code>yaml jobs: test: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{matrix.os}} steps: - uses: actions/checkout@v2 - uses: goto-bus-stop/setup-zig@v2 - run: zig build test lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: goto-bus-stop/setup-zig@v2 - run: zig fmt --check .</code> Optionally set a Zig version: <code>yaml - uses: goto-bus-stop/setup-zig@v2 with: version: 0.7.0</code> The default is to use the nightly <code>master</code> builds. Or <a>pin to a specific commit</a> using <code>version+commithash</code> syntax: <code>yaml - uses: goto-bus-stop/setup-zig@v2 with: version: 0.6.0+4b48fccad</code> If you are running Zig on Windows machines, you need to make sure that your .zig files use \n line endings and not \r\n. The <code>actions/checkout</code> action auto-converts line endings to <code>\r\n</code> on Windows runners, so add a <code>.gitattributes</code> file: <code>*.zig text eol=lf</code> This action caches the downloaded compilers in your repository's Actions cache by default, to reduce the load on the Zig Foundation's servers. Cached compilers are only about 60MB each per version/OS/architecture. If this is really bad for you for some reason you can disable the caching. <code>yaml - uses: goto-bus-stop/setup-zig@v2 with: cache: false</code> License <a>Apache-2.0</a>
[]
https://avatars.githubusercontent.com/u/801803?v=4
zig-wasm-dom
shritesh/zig-wasm-dom
2019-04-19T02:28:22Z
Zig + WebAssembly + JS + DOM
gh-pages
3
152
13
152
https://api.github.com/repos/shritesh/zig-wasm-dom/tags
-
[ "dom", "wasm", "webassembly", "zig" ]
28
false
2025-05-11T21:10:43Z
false
false
unknown
github
[]
zig-wasm-dom An example demonstrating Zig interacting with the DOM via JS. Compile with <code>zig build-lib zigdom.zig -target wasm32-freestanding -dynamic -OReleaseSmall</code>
[]
https://avatars.githubusercontent.com/u/219422?v=4
wazm
fengb/wazm
2020-01-23T00:52:17Z
Web Assembly Zig Machine
master
9
118
9
118
https://api.github.com/repos/fengb/wazm/tags
MIT
[ "interpreter", "wasm", "zig" ]
381
false
2024-12-28T02:42:37Z
true
false
unknown
github
[]
wazm — Web Assembly Zig Machine | Feature | Implemented | Tested | |:------|:------:|:------:| | Bytecode parser | ✅ | ⚠️ | | Bytecode output | ❌ | ❌ | | WAT parser | 🚧 | ⚠️ | | WAT output | ❌ | ❌ | | Execution | ✅ | 🐛 | | WASI | 🚧 | ⚠️ | ```bash $ git clone https://github.com/fengb/wazm.git $ cd wazm $ zig build test ```
[]
https://avatars.githubusercontent.com/u/22677068?v=4
zig-bare-metal-raspberry-pi
markfirmware/zig-bare-metal-raspberry-pi
2019-09-20T02:55:23Z
Bare metal raspberry pi program written in zig
master
6
97
7
97
https://api.github.com/repos/markfirmware/zig-bare-metal-raspberry-pi/tags
-
[ "bare-metal", "raspberry-pi", "zig" ]
1,892
false
2025-04-24T05:35:30Z
true
false
unknown
github
[]
Privacy Bluetooth signals are collected and displayed on the screen Function zig logo is displayed The frame buffer cursor moves around the screen in response to the tv remote controller buttons. This requires the Consumer Electronics Control (CEC) feature on the tv. Presently only working on rpi3b+ due to some code generation issues Not yet working on armv6 raspberry pi models Not yet tested on rpi4b Testing <code>zig build qemu -Dqemu </code> (yes, the -Dqemu is needed at this time) or <code>zig build qemu -Dqemu -Dnodisplay </code> to omit the frame buffer display
[]
https://avatars.githubusercontent.com/u/380158?v=4
zig-datetime
frmdstryr/zig-datetime
2019-12-19T17:15:38Z
A date and time module for Zig
master
2
97
14
97
https://api.github.com/repos/frmdstryr/zig-datetime/tags
MIT
[ "zig" ]
210
false
2025-05-03T15:55:17Z
true
true
unknown
github
[]
Zig Datetime <a></a> <a></a> A datetime module for Zig with an api similar to python's Arrow. <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> DST is now implemeted to the library. Some timezones that relying on islamic calendar for DST might not work yet. It is also possible that we might have skipped some timezones by mistake because there are a lot of timezones. <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> With DST implementation, the <code>shiftTimezone</code> method changed and now taking timezone argument passed by value contrary to before that it was passed by pointer. </blockquote> ```zig const allocator = std.heap.page_allocator; const date = try Date.create(2019, 12, 25); const next_year = date.shiftDays(7); assert(next_year.year == 2020); assert(next_year.month == 1); assert(next_year.day == 1); // In UTC const now = Datetime.now(); const now_str = try now.formatHttp(allocator); defer allocator.free(now_str); std.debug.warn("The time is now: {}\n", .{now_str}); // The time is now: Fri, 20 Dec 2019 22:03:02 UTC ```
[ "https://github.com/g41797/syslog", "https://github.com/paoda/zba", "https://github.com/soheil-01/zpe" ]
https://avatars.githubusercontent.com/u/3276684?v=4
weekend-raytracer-zig
Nelarius/weekend-raytracer-zig
2019-05-21T06:12:37Z
A Zig implementation of the "Ray Tracing in One Weekend" book
master
1
96
9
96
https://api.github.com/repos/Nelarius/weekend-raytracer-zig/tags
-
[ "computer-graphics", "ray-tracing-in-one-weekend", "raytracing", "zig" ]
46
false
2025-05-08T20:57:23Z
true
false
unknown
github
[]
Ray Tracing in One Weekend (Zig) This is a fairly straightforward implementation of Peter Shirley's "Ray Tracing in One Weekend" book in the Zig programming language To run: <code>$ zig build run -Drelease-fast</code> Dependencies <ul> <li>[email protected]: https://ziglang.org/</li> <li>SDL2: https://wiki.libsdl.org/Installation</li> </ul>
[]
https://avatars.githubusercontent.com/u/57543193?v=4
pbui-main
pbui-project/pbui-main
2020-01-15T17:15:19Z
The main repository for the PBUI project
master
18
96
9
96
https://api.github.com/repos/pbui-project/pbui-main/tags
MIT
[ "toolsets", "userland", "zig" ]
327
false
2025-02-10T19:04:17Z
true
false
unknown
github
[]
pbui-main Like idlebin, but in zig What is the PBUI project? The PBUI (POSIX-compliant BSD/Linux Userland Implementation) project is a a free and open source project intended to implement some standard library toolsets in the Zig programming language. We will also implement some basic applets and a shell to demonstrate usage of the toolsets as well as provide functionality. Another goal of the PBUI project is to help improve documentation for Zig through our blog posts, some of which will take the form of tutorials that explain how to use both our toolsets and other Zig functions when creating applets. By doing this, we hope to make Zig more user friendly and encourage others to create Zig-based applications. Dependencies Supported operating systems: - Linux kernel &gt;= <code>5.4.23</code> (Validated for Ubuntu) - Zig <code>0.6.0</code> How do I get Zig? Visit the <a>Zig download page</a>, where you can find source code and compiled binaries for your operating system. Zig is also available <a> via various package managers</a>. Installation After cloning the repository, run <code>zig build</code>. The <code>pbui</code> executable will be located in <code>zig-cache/bin/pbui</code>. Usage For a list of applets, run <code>./pbui</code> or <code>./pbui -h</code>. Currently supported applets include: - <code>basename</code> - <code>dirname</code> - <code>false</code> - <code>head</code> - <code>ls</code> - <code>main</code> - <code>mkdir</code> - <code>rm</code> - <code>sleep</code> - <code>tail</code> - <code>true</code> - <code>wc</code> - <code>zigsay</code> - <code>cat</code> - <code>du</code> - <code>uniq</code> - <code>shuf</code> - <code>sha1</code> - <code>sort</code> To run a given applet, use: <code>./pbui [APPLET] [arguments]</code>. Running applets individually To run applets individually, you can use <code>ln -s path/to/repository/zig-cache/bin/pbui APPLET_NAME</code>. Then, you can execute the symlink, removing the need to prefix with "./pbui". You can even replace your default shell's applets with ours if you want less functionality but more zig! Here is an example:
[]
https://avatars.githubusercontent.com/u/219422?v=4
zee_alloc
fengb/zee_alloc
2019-05-21T14:23:17Z
tiny Zig allocator primarily targeting WebAssembly
master
6
87
7
87
https://api.github.com/repos/fengb/zee_alloc/tags
MIT
[ "memory-allocation", "tiny", "wasm", "zig" ]
604
false
2025-03-10T19:05:16Z
true
false
unknown
github
[]
zee_alloc — <em>zig wee allocator</em> A tiny general purpose allocator targeting WebAssembly. This allocator has not been well tested. Use at your own peril. Getting Started In zig: ```zig const zee_alloc = @import("zee_alloc"); pub fn foo() void { var mem = zee_alloc.ZeeAllocDefaults.wasm_allocator.alloc(u8, 1000); defer zee_alloc.ZeeAllocDefaults.wasm_allocator.free(mem); } ``` Exporting into wasm: ```zig const zee_alloc = @import("zee_alloc"); comptime { (zee_alloc.ExportC{ .allocator = zee_alloc.ZeeAllocDefaults.wasm_allocator, .malloc = true, .free = true, .realloc = false, .calloc = false, }).run(); } ``` Goals <em>(inspired by Rust's <a>wee_alloc</a>)</em> <ol> <li>Tiny compiled output</li> <li>Tiny compiled output x2</li> <li>Malloc/free compatibility</li> <li>Avoid long-term fragmentation</li> <li>Reasonably fast alloc and free</li> <li>Code simplicity — probably goes in hand with tiny output</li> </ol> <strong>Non-goals</strong> <ul> <li>Debugging — this library probably will never do a good job identifying errors. Zig has a great <a>debug allocator</a> in the works, and zig programs should be able to easily swap allocators.</li> <li>Compact memory — fixed allocation frames are used for speed and simplicity. Memory usage will never be optimum unless the underlying algorithm completely changes</li> <li>Thread performance — wasm is single-threaded</li> </ul> Benchmarks ``` Benchmark Mean(ns) DirectAllocator.0 50842 DirectAllocator.1 98343 DirectAllocator.2 203980 DirectAllocator.3 49908 DirectAllocator.4 103635 DirectAllocator.5 195941 DirectAllocator.6 47367 DirectAllocator.7 101733 DirectAllocator.8 202697 Arena_DirectAllocator.0 11837 Arena_DirectAllocator.1 19591 Arena_DirectAllocator.2 30689 Arena_DirectAllocator.3 30916 Arena_DirectAllocator.4 52425 Arena_DirectAllocator.5 75673 Arena_DirectAllocator.6 44874 Arena_DirectAllocator.7 67557 Arena_DirectAllocator.8 96276 ZeeAlloc_DirectAllocator.0 15892 ZeeAlloc_DirectAllocator.1 24435 ZeeAlloc_DirectAllocator.2 49564 ZeeAlloc_DirectAllocator.3 26656 ZeeAlloc_DirectAllocator.4 52462 ZeeAlloc_DirectAllocator.5 93854 ZeeAlloc_DirectAllocator.6 51493 ZeeAlloc_DirectAllocator.7 95223 ZeeAlloc_DirectAllocator.8 250187 FixedBufferAllocator.0 177 FixedBufferAllocator.1 412 FixedBufferAllocator.2 1006 FixedBufferAllocator.3 296 FixedBufferAllocator.4 785 FixedBufferAllocator.5 1721 FixedBufferAllocator.6 848 FixedBufferAllocator.7 1546 FixedBufferAllocator.8 3331 Arena_FixedBufferAllocator.0 299 Arena_FixedBufferAllocator.1 573 Arena_FixedBufferAllocator.2 1624 Arena_FixedBufferAllocator.3 1115 Arena_FixedBufferAllocator.4 1868 Arena_FixedBufferAllocator.5 4422 Arena_FixedBufferAllocator.6 1706 Arena_FixedBufferAllocator.7 3389 Arena_FixedBufferAllocator.8 8430 ZeeAlloc_FixedBufferAllocator.0 232 ZeeAlloc_FixedBufferAllocator.1 577 ZeeAlloc_FixedBufferAllocator.2 1165 ZeeAlloc_FixedBufferAllocator.3 443 ZeeAlloc_FixedBufferAllocator.4 907 ZeeAlloc_FixedBufferAllocator.5 1848 ZeeAlloc_FixedBufferAllocator.6 907 ZeeAlloc_FixedBufferAllocator.7 1721 ZeeAlloc_FixedBufferAllocator.8 3836 ``` Architecture — <a>Buddy memory allocation</a> <em>Caveat: I knew <strong>nothing</strong> about memory allocation when starting this project. Any semblence of competence is merely a coincidence.</em> <code>idx frame_size 0 &gt;65536 jumbo 1 65536 wasm page size 2 32768 3 16384 4 8192 5 4096 6 2048 7 1024 8 512 9 256 10 128 11 64 12 32 13 16 smallest frame</code> Size order is reversed because 0 and 1 are special. I believe counting down had slightly better semantics than counting up but I haven't actually tested it. Wasm only allows for allocating entire pages (64K) at a time. Current architecture is heavily influenced by this behavior. In a real OS, the page size is much smaller at 4K. Everything should work as expected even if it does not run as efficient as possible. Each allocation frame consists of 2 usizes of metadata: the frame size and a pointer to the next free node. This enables some rudimentary debugging as well as a simple lookup when we only have the allocated data-block (especially important for C compatibility). For allocations &lt;=64K in size, we find the smallest usable free frame. If it's bigger than necessary, we grab the smallest power of 2 we need and resize the rest to toss back as free nodes. This is O(log k) which is O(1). For allocations &gt;64K, we iterate through list 0 to find a matching size, O(n). Free jumbo frames are never divided into smaller allocations. ZeeAlloc only supports pointer alignment at 2x usize — 8 bytes in wasm. There are a few ideas to expand this to up-to half page_size but nothing concrete yet.
[]
https://avatars.githubusercontent.com/u/1950733?v=4
zig-cuckoofilter
kristoff-it/zig-cuckoofilter
2019-05-12T18:17:24Z
Production-ready Cuckoo Filters for any C ABI compatible target.
master
0
83
3
83
https://api.github.com/repos/kristoff-it/zig-cuckoofilter/tags
MIT
[ "bloom-filter", "c-abi", "cffi", "cuckoo-filter", "filter", "p11c", "probabilistic-data-structures", "zig" ]
131
false
2025-04-07T16:37:00Z
false
false
unknown
github
[]
zig-cuckoofilter <a></a> <a></a> <a></a> Production-ready Cuckoo Filters for any C ABI compatible target. Used by <a></a> What's a Cuckoo Filter? Cuckoo filters are a probabilistic data structure that allows you to test for membership of an element in a set without having to hold the whole set in memory. This is done at the cost of having a probability of getting a false positive response, which, in other words, means that they can only answer "Definitely no" or "Probably yes". The false positive probability is roughly inversely related to how much memory you are willing to allocate to the filter. The most iconic data structure used for this kind of task are Bloom filters but Cuckoo filters boast both better practical performance and efficiency, and, more importantly, the ability of <strong>deleting elements from the filter</strong>. Bloom filters only support insertion of new items. Some extensions of Bloom filters have the ability of deleting items but they achieve so at the expense of precision or memory usage, resulting in a far worse tradeoff compared to what Cuckoo filters offer. What Makes This Library Interesting It's production-ready Most Cuckoo Filter implementations available on GitHub get the computer science aspect right but fail at the engineering level, rendering each basically unsuitable for most serious use cases. These problems go from not offering a way to persit and restore the filter, up to silent corruption of the filter when its fill-rate increases too much (because the implementation has no vacant/homeless slot). This implementation covers all these aspects in full, giving to you complete control over the filter while making sure that misusage gets <strong>always</strong> properly reported. It's for advanced users Instead of making a Bloom-like interface, I leave to the caller to choose a hashing function to use, and which byte(s) of the original item to use as fingerprint. This would not produce good ergonomics with Bloom filters as they rely on multiple hashings (dozens for low error rates!). This requires the user to know the basics of hashing and how these data structures work but on the upside: <ul> <li>If you are already handling hashed values, no superfluous work is done.</li> <li>To perform well, Cuckoo filters rely on a good choice of fingerprint for each item, and it should not be left to the library.</li> <li><strong>The hash function can be decided by you, meaning that this library is hashing-function agnostic</strong>.</li> </ul> It's written in Zig (https://ziglang.org) Which means that the code is clear, free of C gotchas, and that you can dynamically link to it from any C ABI compatible language. Zig is simpler and safer than C but operates at the same abstraction level (i.e. no gc, explicit memory management, pointers, etc). Zig can compile C code and Zig shared object files can be used in a normal C compilation process. It doesn't manage memory All memory allocation/freeing is done by the caller. This makes this library suitable for embedding in any kind of ecosystem. For example, take a look at <a>kristoff-it/redis-cuckoofilter</a>. Using zig-cuckoofilter from C or other languages (Python, Go, JavaScript, ...) Read the provided examples In <a><code>c-abi-examples/</code></a> you will find a few different simple examples on how to use the library from C code or in your language of choice by using the C Foreign Function Interface. Read the rest of this README To learn how to use all the functionalities of this library, read the rest of the README. It's Zig code so you can't copy it verbatim, but for each function there's a C equivalent in <a><code>cuckoofilter_c.zig</code></a>. Download binaries or compile it yourself You can download pre-compiled binaries from the Release section on GitHub. To compile the code yourself you need to <a>install the Zig compiler</a>. Each file in <a><code>c-abi-examples/</code></a> will have comments that will tell you more precisely what you need. Please read the <a>official Zig documentation</a> to learn more about available targets, build modes, static/dynamic linking, etc. Usage Quickstart ```zig const std = @import("std"); const hasher = std.hash.Fnv1a_64; const cuckoo = @import("./src/cuckoofilter.zig"); fn fingerprint(x: []const u8) u8 { return x[0]; } pub fn main() !void { const universe_size = 1000000; const memsize = comptime cuckoo.Filter8.size_for(universe_size); <code>var memory: [memsize]u8 align(cuckoo.Filter8.Align) = undefined; var cf = try cuckoo.Filter8.init(memory[0..]); const banana_h = hasher.hash("banana"); const banana_fp = fingerprint("banana"); const apple_h = hasher.hash("apple"); const apple_fp = fingerprint("apple"); _ = try cf.maybe_contains(banana_h, banana_fp); // =&gt; false _ = try cf.count(); // =&gt; 0 try cf.add(banana_h, banana_fp); _ = try cf.maybe_contains(banana_h, banana_fp); // =&gt; true _ = try cf.maybe_contains(apple_h, apple_fp); // =&gt; false _ = try cf.count(); // =&gt; 1 try cf.remove(banana_h, banana_fp); _ = try cf.maybe_contains(banana_h, banana_fp); // =&gt; false _ = try cf.count(); // =&gt; 0 </code> } ``` Extended example This is also available in <a>example.zig</a>. ```zig const std = @import("std"); const hasher = std.hash.Fnv1a_64; const cuckoo = @import("./src/cuckoofilter.zig"); fn fingerprint8(x: []const u8) u8 { return x[0]; } fn fingerprint32(x: []const u8) u32 { // Just a sample strategy, not suitable for all types // of input. Imagine if you were adding images to the // filter: all fingerprints would be the same because // most formats have a standard header. In that case // you want to make sure to use the actual graphical // data to pluck your fingerprint from. return @bytesToSlice(u32, x[0..@sizeOf(u32)])[0]; } pub fn main() !void { <code>// Assume we want to keep track of max 1 Million items. const universe_size = 1000000; // Let's use Filter8, a filter with 1 byte long // fingerprints and a 3% max *false positive* error rate. // Note: Cuckoo filters cannot produce false negatives. // Error % information: _ = cuckoo.Filter8.MaxError; // ╚═&gt; 3.125e-02 (~0.03, i.e. 3%) _ = cuckoo.Filter16.MaxError; // ╚═&gt; 1.22070312e-04 (~0.0001, i.e. 0.01%) _ = cuckoo.Filter32.MaxError; // ╚═&gt; 9.31322574e-10 (~0.000000001, i.e. 0.0000001%) // First let's calculate how big the filter has to be: const memsize = comptime cuckoo.Filter8.size_for(universe_size); // The value of memsize has to be a power of two and it // is *strongly* recommended to keep the fill rate of a // filter under 80%. size_for() will pad the number for // you automatically and then round up to the closest // power of 2. size_for_exactly() will not apply any // padding before rounding up. // Use capacity() to know how many items a slice of memory // can store for the given filter type. _ = cuckoo.Filter8.capacity(memsize); // =&gt; 2097152 // Note: this function will return the theoretical maximum // capacity, without subtracting any padding. It's smart // to adjust your expectations to match how much memory // you have to allocate anyway, but don't get too greedy. // I say `theoretical` because an overfilled filter will // start refusing inserts with a TooFull error. // This is how you allocate static memory for the filter: var memory: [memsize]u8 align(cuckoo.Filter8.Align) = undefined; // Note: the filter benefits from a specific alignment // (which differs from type to type) so you must specify it // when allocating memory. Failing to do so will result in // a comptime error. // Instantiating a filter var cf8 = try cuckoo.Filter8.init(memory[0..]); // // FILTER USAGE // const banana_h = hasher.hash("banana"); const banana_fp = fingerprint8("banana"); const apple_h = hasher.hash("apple"); const apple_fp = fingerprint8("apple"); _ = try cf8.maybe_contains(banana_h, banana_fp); // =&gt; false _ = try cf8.count(); // =&gt; 0 try cf8.add(banana_h, banana_fp); _ = try cf8.maybe_contains(banana_h, banana_fp); // =&gt; true _ = try cf8.maybe_contains(apple_h, apple_fp); // =&gt; false _ = try cf8.count(); // =&gt; 1 try cf8.remove(banana_h, banana_fp); _ = try cf8.maybe_contains(banana_h, banana_fp); // =&gt; false _ = try cf8.count(); // =&gt; 0 // The filter can also be used with dynamic memory. // It's up to you to manage that via an allocator. const example_allocator = std.heap.c_allocator; // Don't forget to free the memory afterwards. const memsize32 = comptime cuckoo.Filter32.size_for_exactly(64); var dyn_memory = try example_allocator.alignedAlloc(u8, cuckoo.Filter32.Align, memsize32); defer example_allocator.free(dyn_memory); var dyn_cf32 = try example_allocator.create(cuckoo.Filter32); defer example_allocator.destroy(dyn_cf32); dyn_cf32.* = try cuckoo.Filter32.init(dyn_memory); // When restoring a persisted filter, you should only persist the individual fields // as, for example, .buckets is a slice that points to `dyn_memory` which would be // invalid upon restore (wrong pointer) and just a waste of space when stored. // Upon loading, to reconnect the filter and its `dyn_memory`, use bytesToBuckets. // Here's an example (which is not necessary to make this script work, as we just created // the entire filter): // // dyn_cf32.buckets = cuckoo.Filter32.bytesToBuckets(dyn_memory); // // USAGE FAILURE SCENARIOS // // 1. Adding too many colliding items (because of bad entropy or // because you are adding multiple copies of the same item) const pear_h = hasher.hash("pear"); const pear_fp = fingerprint32("pear"); try dyn_cf32.add(pear_h, pear_fp); try dyn_cf32.add(pear_h, pear_fp); try dyn_cf32.add(pear_h, pear_fp); try dyn_cf32.add(pear_h, pear_fp); try dyn_cf32.add(pear_h, pear_fp); // No more space for items with equal hash and fp, // next insert will fail. dyn_cf32.add(pear_h, pear_fp) catch |err| switch (err) { error.TooFull =&gt; std.debug.warn("yep, too full\n"), else =&gt; unreachable, }; // Other inserts that don't collide can still succeed const orange_h = hasher.hash("orange"); const orange_fp = fingerprint32("orange"); try dyn_cf32.add(orange_h, orange_fp); // 2. You can only delete elements that were inserted before. // Trying to delete a non-existing item has a chance of // breaking the filter (makes false negatives possible). // Deleting a non-existing item can either cause the // deletion of another colliding item or fail to find // a matching fingerprint in the filter. In the second // case the filter locks down and returns an error for // all operations, as it is now impossible to know what // the correct state would be. dyn_cf32.remove(0, 0) catch |err| switch (err) { error.Broken =&gt; std.debug.warn(".remove, broken\n"), }; _ = dyn_cf32.is_broken(); // =&gt; true dyn_cf32.add(orange_fp, orange_fp) catch |err| switch (err) { error.Broken =&gt; std.debug.warn(".add, broken\n"), error.TooFull =&gt; {}, }; if (dyn_cf32.count()) |_| { std.debug.warn(".count, works\n"); // won't be printed } else |err| switch (err) { error.Broken =&gt; std.debug.warn(".count, broken\n") } // Since searching does not mutate the filter, if the item // is found, no error is returned: _ = try dyn_cf32.maybe_contains(orange_h, orange_fp); // =&gt; true // But if an item is not found, we don't know if it was wrongly // deleted or not, so the filter has to return an error in order // to ensure that it does not return a false negative response. if (dyn_cf32.maybe_contains(0, 0)) |_| { std.debug.warn(".maybe_contains, works\n"); // won't be printed } else |err| switch (err) { error.Broken =&gt; std.debug.warn(".maybe_contains, broken\n") } // You should *NEVER* get into that situation. If you do, it's // a programming error. If your program runs in an environment // where a request that involves the filter might be repeated // (e.g. web servers), mark each request by a unique ID and // keep some kind of commit log to ensure you don't run the // same request twice, as it's semantically wrong to expect // idempotence from Cuckoo filter commands. // 3. Other small errors could be trying to pass to init memory // with the wrong alignment or a wrong buffer size. Try to // use the provided functions (i.e. size_for, size_for_exactly) // to always have your buffers be the right size. You can // also use those functions to reason about your data and even // opt not to use a filter if the tradeoff is not worth it. if (cuckoo.Filter8.init(memory[1..13])) |_| { std.debug.warn(".init, works\n"); // won't be printed } else |err| switch (err) { error.BadLength =&gt; std.debug.warn(".init failed, use .size_for()!\n") } // // FIXING TOO FULL // // Filter8 and Filter16 have 4 element-wide buckets, // while Filter32 has 2 element-wide buckets. // Each fingerprint has two buckets that can be used to // house it. This means that you can have, respectively, // up to 8 (F8, F16) and 4 (F32) collisions/copies before both // buckets fill completely and you get TooFull. In practice, // you get an extra chance because of how filters work internally. // There's a special slot that houses a single fingerprint that // could not find space in one of its 2 candidate slots. // The problem is that once that "safety" slot is filled, the // filter becomes much more succeptible to collisions and is forced // to return TooFull when in fact it could try to make space. // If you are also deleting elements from the filter, and // not just adding them, this is what you can do to try and // recover from that situation. // Returns true if the safety slot is occupied. var bad_situation = dyn_cf32.is_toofull(); // Note that you might not have ever received a TooFull error for // this function to return true. In our previous example with // dyn_cf32, it took us 5 insertions to obtain a TooFull error. // This function would return true after 4. // Try to fix the situation: if (bad_situation) { dyn_cf32.fix_toofull() catch |err| switch (err) { error.Broken =&gt; {}, error.TooFull =&gt; {}, }; } // With this function you can only fix TooFull, not Broken. // If fix_toofull returns TooFull, it means that it failed. // In practice you will need to free more elements before // being able to fix the situation, but in theory calling // the function multiple times might eventually fix the // situation (i.e. it can make progress each call). // That said, going back to practical usage, you are probably // in a problematic situation when it gets to that point. // To ensure you never have to deal with these problems, // make sure you: // (1) Never overfill/undersize a filter. // (2) Get entropy right for the fingerprinting function. // // A trick to get (2) right is to pluck it not out of the // original element, but out of hash2(element). Just make sure // you use a different hasing function, independent from the // fitst one, otherwise you're going to still end up with too // little entropy, and be aware of the increased computational // cost. Secondary hashing might be worth it for semi-strucutred // data where you might find it hard to know if you're plucking // "variable" data or part of the structure (e.g. JSON data), // since the latter is bound to have lower entropy. // // PRNG Stuff // // Cuckoo Filters need a random number generator to decide which // fingerprint to evict when a given bucket pair is full. This // library provides a default implementation that uses the Zig // standard library's Xoroshiro implementation, seeded by default to 42. // If your application has short-lived sessions, a static seed won't be // good enough, as it will basically result in giving out the same // number over and over again, similarly to what is shown in that one // dilbert strip. To fix that use seed_default_prng: var buf: [8]u8 = undefined; try std.crypto.randomBytes(buf[0..]); const seed = std.mem.readIntSliceLittle(u64, buf[0..8]); cuckoo.seed_default_prng(seed); // Additionally, you might also want to provide your own PRNG // implementation, either because you have specific needs (CSPRNG) or // because you might want to make the filter fully deterministic and thus // need to be able to persist and restore the PRNG's state. // You can customize the PRNG of each filter by providing an appropriate // function pointer: dyn_cf32.rand_fn = DilbertRandom; // From now on `dyn_cf32` will stop using the default implementation // (shared by default by all filters) and will instead only use the // provided function. If you use this functionality, *make sure to // set the function pointer again when loading the filter from disk*. // If you're fine with the default implementation and want more control // than just seeding, use .get_default_prng_state() and // .set_default_prng_state(), but beware that you are modifying a // "singleton" struct used by all filters. If you are in a multi-threaded // context this might cause problems if you are executing // .add / .delete / .fix_toofull and altering the prng singleton at the // same time. In that case you will have to customize .rand_fn </code> } fn DilbertRandom() u1 { return 1; } ``` This will output: <code>yep, too full .remove, broken .add, broken .count, broken .maybe_contains, broken .init failed, use .size_for()!</code> Planned Features <ul> <li>(maybe) Full-fledged wrappers for the most common languages? It's not that hard to get there given where I got to with <code>c-abi-examples</code>.</li> </ul> License MIT License Copyright (c) 2019 Loris Cro 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/132159?v=4
embedded_zig
tralamazza/embedded_zig
2019-06-18T23:15:47Z
minimal Zig embedded ARM example (STM32F103 blue pill)
master
2
81
12
81
https://api.github.com/repos/tralamazza/embedded_zig/tags
-
[ "arm", "stm32f103", "zig" ]
13
false
2025-04-26T05:46:30Z
true
false
unknown
github
[]
embedded_zig A "minimal" ARM cortex-M firmware in Zig running on a STM32F103. It blinks. building Get <a>GNU Arm Embedded Toolchain</a> and <a>Zig</a> in <code>PATH</code> and type: <code>make </code> running on a <a>bluepill</a> Run OpenOCD on a terminal: <code>openocd -f /usr/share/openocd/scripts/interface/stlink-v2.cfg -f /usr/share/openocd/scripts/target/stm32f1x.cfg </code> Open your favorite GDB: <code>arm-none-eabi-gdb firmware.elf -ex 'target extended-remote :3333' load r </code> Bonus: you can type <code>make</code> inside gdb and <code>load</code> it again. issues If you have any linking issues uncomment the line below (in the <code>Makefile</code>) to use GNU ld: <code># zig build-exe ${BUILD_FLAGS} $(OBJS:%=--object %) --name [email protected] --linker-script ${LINKER_SCRIPT} arm-none-eabi-ld ${OBJS} -o [email protected] -T ${LINKER_SCRIPT} -Map [email protected] --gc-sections </code> raq (rarely asked questions) a) Shouldn't the Makefile... A: lalalala b) How do I flash this? A: see <a>running on a bluepill</a> c) Why didn't you use <code>@cImport()</code>? A: yes
[]
https://avatars.githubusercontent.com/u/1578924?v=4
zig-sparse-set
Srekel/zig-sparse-set
2019-11-15T21:18:21Z
Sparse sets for zig, supporting both SOA and AOS style
master
0
70
2
70
https://api.github.com/repos/Srekel/zig-sparse-set/tags
NOASSERTION
[ "public-domain", "sparse-sets", "zig" ]
776
false
2025-04-28T21:45:39Z
true
false
unknown
github
[]
:ferris_wheel: zig-sparse-set :ferris_wheel: An implementation of Sparse Sets for Zig. :confused: What is a Sparse Set? :confused: A Sparse Set - well, this implementation technique specifically at least - is a fairly simple data structure with some properties that make it especially useful for some aspects in game development, but you know... it's probably interesting for other areas too. Here's a good introduction: https://research.swtch.com/sparse Basically, sparse sets solve this problem: You have a bunch of <strong><em>sparse</em></strong> handles, but you want to loop over the values they represent linearly over memory. :point_down: Example :point_down: Maybe your game has a few hundred <strong>entities</strong> with a certain <strong>component</strong> (specific piece of game data) at any given time. An entity is a 16 bit ID (handle) and the entities containing this component eventually gets spread out randomly over 0..65535 during runtime. :anguished: In your frame update function, it would be nice to <strong>not</strong> do this... :anguished: <code>zig for (active_entities) |entity| { var some_big_component = &amp;self.big_components[entity]; some_big_component.x += 3; }</code> ... because it would waste memory. Or, in the case that the component isn't huge, but it's expensive to instantiate (i.e. you can't just zero-init it, for example), you need to do that 65k times at startup. Additionally, you'll be skipping over swaths of memory, so every access will likely be a cache miss. :worried: Similarly, you might want to avoid this... :worried: <code>zig for (self.components) |some_component| { if (some_component.enabled) { some_component.x += 3; } }</code> ...because you'll be doing a lot of looping over data that isn't of interest. Also, you need to store a flag for every component. So potentially cache misses for the <code>+=</code> operation here too. (Note that the flag could be implemented as a bitset lookup, for example, which would probably be better, but still have the same underlying problem). :heart_eyes: With a sparse set, you can always simply loop over the data linearly: :heart_eyes: <code>zig for (self.component_set.toValueSlice()) |*some_component| { some_component.x += 3; }</code> :sunglasses: But wait, there's more! :sunglasses: 1) <strong>O(1)</strong> Lookup from sparse to dense, and vice versa. 2) <strong>O(1)</strong> <strong>Has,</strong> <strong>Add</strong>, and <strong>Remove</strong>. 3) <strong>O(1)</strong> <strong>Clear</strong> (remove all elements). 4) <strong>O(d)</strong> iteration (dense list). 5) Elements of sparse and dense lists do not need to be (and are not) initialized upon startup - they are undefined. 6) Supports SOA-style component layout. (See <strong>References</strong> below if you're unfamiliar with what that is) 7) Supports AOS-style too by optionally storing and managing a value array internally. 8) Can be inspected "easily" in a debugger. 9) Optional error-handling. 10) Even if you don't need to loop over the values, a sparse set is a potential alternative to a hash map. 11) Optionally growable. :star: [1] This is nice and important because you can then do: <code>zig for (self.component_set.toValueSlice()) |*some_component, dense_index| { some_component.x += 3; var entity = self.component_set.getByDense(dense_index); self.some_other_system.doStuffWithEntity(entity, some_component.x, 1234567); }</code> :star: [2] The O(1) remove is important. It is solved by swapping in the last element into the removed spot. So there's two things to consider there: 1) Is it cheap to copy the data? Like, if your component is large or needs some kind of allocation logic on copy. 2) Is it OK that the list of components are <strong>unsorted</strong>? If not, sparse sets are not a good fit. :star: [5] Special care has been taken (depending on a couple of coming Zig changes) to ensure that neither Valgrind nor Zig will complain about possibly accessing uninitialized memory. :star: [6] With the standard SparseSet implementation, it doesn't actually store any data - you have to do that manually. If you want to, you can store it in an SOA - "Structure of Arrays" manner, like so: (<strong>Note:</strong> For both the following SOA example and the AOS example below, you can look at src/test.zig for the whole example.) <code>zig const Entity = u32; const Vec3 = struct { x: f32 = 0, y: f32 = 0, z: f32 = 0, }; const MyPositionSystemSOA = struct { component_set: sparse_set.SparseSet(Entity, u8) = undefined, xs: [256]f32 = [_]f32{0} ** 256, ys: [256]f32 = [_]f32{0} ** 256, zs: [256]f32 = [_]f32{0} ** 256,</code> The trick then is to <strong>make sure</strong> you handle the dense indices: ```zig const MyPositionSystem = struct { // ... <code>pub fn addComp(self: *Self, ent: Entity, pos: Vec3) void { var dense = self.component_set.add(ent); self.xs[dense] = pos.x; self.ys[dense] = pos.y; self.zs[dense] = pos.z; } pub fn removeComp(self: *Self, ent: Entity) void { var dense_old: u8 = undefined; var dense_new: u8 = undefined; self.component_set.removeWithInfo(ent, &amp;dense_old, &amp;dense_new); self.xs[dense_new] = self.xs[dense_old]; self.ys[dense_new] = self.ys[dense_old]; self.zs[dense_new] = self.zs[dense_old]; } pub fn updateComps(self: *Self) void { for (self.component_set.toSparseSlice()) |ent, dense| { self.xs[dense] += 3; } } </code> }; ``` :star: [7] With SparseSetAOS, things are simplified for you, and this will probably be the most common use case. It has the same API but has a few additional functions, and also stores an internal list of all the data. ```zig const MyPositionSystemAOS = struct { component_set: sparse_set_aos.SparseSetAOS(Entity, u8, Vec3) = undefined, <code>// ... pub fn addComp(self: *Self, ent: Entity, pos: Vec3) void { _ = self.component_set.add(ent, pos); } pub fn removeComp(self: *Self, ent: Entity) void { self.component_set.remove(ent); } pub fn getComp(self: *Self, ent: Entity) Vec3 { return self.component_set.getValueBySparse(ent).*; } pub fn updateComps(self: Self) void { for (self.component_set.toValueSlice()) |*value, dense| { value.x += 3; } } </code> ``` :star: [8] Compared to a sparse-handle-as-index lookup, you don't have a long list of "duds" between each valid element. And compared to a hash map, it should be more straightforward to introspect the sparse set's linear list. :star: [9] All functions that can assert from bad usage (e.g. adding more handles than the capacity, or indexing out of bounds) also has a corresponding "OrError" function that does Zig-style error handling. :smiling_imp: Hold up... What's the catch? :smiling_imp: 1) Well, there's the unsorted thing. 2) If you remove things frequently, and/or your objects are expensive to copy, it may outweigh the benefit of having the data continuous in memory. 3) The lookup requires <code>@sizeOf(DenseT) * MaxSparseValue</code> bytes. So for the example above, if you know that you will never have more than 256 of a specific component, then you can store the dense index as a <code>u8</code>. This would result in you needing <code>65536 * 1 byte = 64 kilobytes</code>. If you need more than 256 components, and say only 16k entities, you'd need 32 kilobytes. * <strong>Note:</strong> The dense -&gt; sparse lookup is likely significantly smaller: <code>@sizeof(SparseT) * MaxDenseValue</code>, so for example <code>256 * 2 bytes = 512 bytes</code>. 4) If you don't need to loop over the elements, and are starved for memory, a hash map might be a better option. 5) Compared to looking the value up directly using the sparse handle as an array index, there's an extra indirection. 6) Using uninitialized memory may cause some validators to complain. As mentioned above, Valgrind and Zig should be fine. So, all in all, there are of course benefits and drawbacks to sparse sets. You'll have to consider this on a case-by-case basis. :page_with_curl: License :page_with_curl: Pick your license: Public Domain (Unlicense) or MIT. :statue_of_liberty: Examples :statue_of_liberty: See <code>src/test.zig</code>. Especially the MyPositionSystem ones. Here is the "unit test" that is used for generating documentation, it uses all of the functionality: ```zig test "docs" { const Entity = u32; const DenseT = u8; const DocValueT = i32; const DocsSparseSet = SparseSet(.{ .SparseT = Entity, .DenseT = DenseT, .ValueT = DocValueT, .allow_resize = .NoResize, .value_layout = .InternalArrayOfStructs, }); <code>var ss = DocsSparseSet.init(std.debug.global_allocator, 128, 8) catch unreachable; defer ss.deinit(); var ent1: Entity = 1; var ent2: Entity = 2; _ = try ss.addOrError(ent1); _ = try ss.addValueOrError(ent2, 2); std.testing.expectEqual(@as(DenseT, 2), ss.len()); try ss.removeOrError(ent1); var old: DenseT = undefined; var new: DenseT = undefined; try ss.removeWithInfoOrError(ent2, &amp;old, &amp;new); _ = ss.toSparseSlice(); _ = ss.toValueSlice(); std.testing.expectEqual(@as(DenseT, 0), ss.len()); ss.clear(); std.testing.expectEqual(@as(DenseT, 8), ss.remainingCapacity()); _ = try ss.addValueOrError(ent1, 10); std.testing.expectEqual(@as(DenseT, 0), try ss.getBySparseOrError(ent1)); std.testing.expectEqual(@as(DocValueT, 10), (try ss.getValueBySparseOrError(ent1)).*); std.testing.expectEqual(@as(Entity, ent1), try ss.getByDenseOrError(0)); std.testing.expectEqual(@as(DocValueT, 10), (try ss.getValueByDenseOrError(0)).*); </code> } ``` :paperclip: References :paperclip: <ul> <li><a>incrediblejr's</a> C implementation <a>ijss</a>.</li> <li>The above <a>article</a> describing this technique.</li> <li>The <a>Zig</a> language.</li> <li>Jonathan Blow SOA/AOS <a>video</a> overview.</li> <li>My <a>twitter</a>.</li> </ul>
[]
https://avatars.githubusercontent.com/u/11783095?v=4
uefi-examples
nrdmn/uefi-examples
2019-09-28T20:05:53Z
UEFI examples in Zig
master
2
70
7
70
https://api.github.com/repos/nrdmn/uefi-examples/tags
-
[ "uefi", "zig" ]
28
false
2025-03-24T06:57:45Z
false
false
unknown
github
[]
UEFI examples in Zig This repo contains examples about how to use Zig to build UEFI apps. Recommended reading order: 1. hello 1. protocols 1. events 1. memory 1. exit_boot_services 1. efivars 1. hii (TODO) How to build and run. Run <code>zig build</code> in any of the subdirectories to build. Then you can copy the output file to a FAT32 formatted device to <code>efi/boot/bootx64.efi</code>. Alternatively you can use QEMU with <code>qemu-system-x86_64 -bios /usr/share/edk2-ovmf/OVMF_CODE.fd -hdd fat:rw:. -serial stdio</code>. FAQ How much stack space do I get? At least 128 KiB before calling <code>exitBootServices()</code>. After calling <code>exitBootServices()</code> you have to provide at least 4 KiB. Why does my computer reboot after 5 minutes? By default, your firmware's watchdog reboots your system after 5 minutes if your application does not call <code>exitBootServices()</code>. You can disable the watchdog timer using <code>boot_services.setWatchdogTimer(0, 0, 0, null)</code>. Where do I get more information? Read the spec. It's really well written. Further reading <ul> <li>https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf</li> <li>https://www.intel.com/content/dam/doc/guide/efi-driver-writers-v1-10-guide.pdf</li> <li>Beyond BIOS: Developing with the Unified Extensible Firmware Interface</li> </ul>
[]
https://avatars.githubusercontent.com/u/28556218?v=4
linenoize
joachimschmidt557/linenoize
2020-01-30T13:46:37Z
A port of linenoise to zig
master
4
68
12
68
https://api.github.com/repos/joachimschmidt557/linenoize/tags
MIT
[ "readline", "zig", "zig-package" ]
122
false
2025-05-11T21:10:25Z
true
true
unknown
github
[ { "commit": "master", "name": "wcwidth", "tar_url": "https://github.com/joachimschmidt557/zig-wcwidth/archive/master.tar.gz", "type": "remote", "url": "https://github.com/joachimschmidt557/zig-wcwidth" } ]
linenoize A port of <a>linenoise</a> to zig aiming to be a simple readline for command-line applications written in zig. It is written in pure zig and doesn't require libc. <code>linenoize</code> works with the latest stable zig version (0.14.0). In addition to being a full-fledged zig library, <code>linenoize</code> also serves as a drop-in replacement for linenoise. As a proof of concept, the example application from linenoise can be built with <code>zig build c-example</code>. Features <ul> <li>Line editing</li> <li>Completions</li> <li>Hints</li> <li>History</li> <li>Multi line mode</li> <li>Mask input mode</li> </ul> Supported platforms <ul> <li>Linux</li> <li>macOS</li> <li>Windows</li> </ul> Add linenoize to a project Add linenoize as a dependency to your project: <code>bash zig fetch --save git+https://github.com/joachimschmidt557/linenoize.git#v0.1.0</code> Then add the following code to your <code>build.zig</code> file: <code>zig const linenoize = b.dependency("linenoize", .{ .target = target, .optimize = optimize, }).module("linenoise"); exe.root_module.addImport("linenoize", linenoize);</code> Examples Minimal example ```zig const std = @import("std"); const Linenoise = @import("linenoise").Linenoise; pub fn main() !void { const allocator = std.heap.page_allocator; <code>var ln = Linenoise.init(allocator); defer ln.deinit(); while (try ln.linenoise("hello&gt; ")) |input| { defer allocator.free(input); std.debug.print("input: {s}\n", .{input}); try ln.history.add(input); } </code> } ``` Example of more features ``` zig const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const log = std.log.scoped(.main); const Linenoise = @import("linenoise").Linenoise; fn completion(allocator: Allocator, buf: []const u8) ![]const []const u8 { if (std.mem.eql(u8, "z", buf)) { var result = ArrayList([]const u8).init(allocator); try result.append(try allocator.dupe(u8, "zig")); try result.append(try allocator.dupe(u8, "ziglang")); return result.toOwnedSlice(); } else { return &amp;[_][]const u8{}; } } fn hints(allocator: Allocator, buf: []const u8) !?[]const u8 { if (std.mem.eql(u8, "hello", buf)) { return try allocator.dupe(u8, " World"); } else { return null; } } var debug_allocator: std.heap.DebugAllocator(.{}) = .init; pub fn main() !void { defer _ = debug_allocator.deinit(); const allocator = debug_allocator.allocator(); <code>var ln = Linenoise.init(allocator); defer ln.deinit(); // Load history and save history later ln.history.load("history.txt") catch log.err("Failed to load history", .{}); defer ln.history.save("history.txt") catch log.err("Failed to save history", .{}); // Set up hints callback ln.hints_callback = hints; // Set up completions callback ln.completions_callback = completion; // Enable mask mode // ln.mask_mode = true; // Enable multiline mode // ln.multiline_mode = true; while (try ln.linenoise("hellö&gt; ")) |input| { defer allocator.free(input); log.info("input: {s}", .{input}); try ln.history.add(input); } </code> } ```
[]
https://avatars.githubusercontent.com/u/45124880?v=4
metronome
TM35-Metronome/metronome
2019-03-06T19:26:32Z
A set of tools for modifying and randomizing Pokémon games
master
23
52
4
52
https://api.github.com/repos/TM35-Metronome/metronome/tags
MIT
[ "command-line-tool", "pokemon", "randomiser", "zig" ]
6,648
false
2025-05-21T09:44:26Z
true
false
unknown
github
[]
Metronome <a></a> <a></a> ==== A set of tools for randomizing and modifying Pokémon games. Build External dependencies: * <a>Zig <code>master</code></a> * Linux only: * <a>zenity</a> (optional file dialog) After getting the dependencies just clone the repo and its submodules and run: <code>zig build</code> All build artifacts will end up in <code>zig-out/bin</code>. See <code>zig build --help</code> for build options. Resources Links to external resources documenting the layout of Pokemom games. Roms <ul> <li><a>Gameboy Advance / Nintendo DS / DSi - Technical Info</a></li> <li><a>Gb info</a></li> <li><a>Nds formats</a></li> </ul> Gen 1 Gen 2 Gen 3 <ul> <li><a>Pokémon Emerald Offsets</a></li> </ul> Gen 4 <ul> <li><a>HGSS File System</a></li> <li><a>HG/SS Mapping File Specifications</a></li> <li><a>HG/SS Pokemon File Specifications</a></li> <li><a>HG/SS Encounter File Specification</a></li> <li><a>D/P/PL/HG/SS scripting and map structure</a></li> </ul> Gen 5 <ul> <li><a>BW2 File System</a></li> <li><a>BW Trainer data</a></li> <li><a>BW Move data</a></li> </ul> All Gens <ul> <li><a>Bulbapedia on Pokemon Data Structures</a></li> <li><a>Pokemon Game Disassemblies</a></li> </ul>
[]
https://avatars.githubusercontent.com/u/106511?v=4
zig-general-purpose-allocator
andrewrk/zig-general-purpose-allocator
2019-02-22T01:12:39Z
work-in-progress general purpose allocator intended to be eventually merged into Zig standard library. live streamed development
master
0
51
5
51
https://api.github.com/repos/andrewrk/zig-general-purpose-allocator/tags
MIT
[ "zig" ]
95
false
2024-12-04T15:55:33Z
false
false
unknown
github
[]
This Project Has Been Merged Upstream This code was integrated into the Zig Standard Library in <a>Pull Request #5998</a>. <strong>This repository is no longer maintained.</strong> GeneralPurposeDebugAllocator This is the code for <a>my Zig Live Coding Stream</a>. This is a work-in-progress general purpose allocator intended to be eventually merged into the <a>Zig</a> standard library, with the focus on these goals: <ul> <li>Detect double free, and print stack trace of:</li> <li>Where it was first allocated</li> <li>Where it was freed the first time</li> <li> Where it was freed the second time </li> <li> Detect leaks and print stack trace of: </li> <li> Where it was allocated </li> <li> When a page of memory is no longer needed, give it back to resident memory, but keep it mapped with no permissions (read/write/exec) so that it causes page faults when used. </li> <li> Make pointer math errors unlikely to harm memory from unrelated allocations </li> <li> It's OK for these mechanisms to cost some extra bytes and for memory to become a little fragmented. </li> <li> OK for performance cost for these mechanisms. </li> <li> Rogue memory writes should not harm the allocator's state. </li> <li> Cross platform. Allowed to take advatage of a specific operating system's features, but should work everywhere, even freestanding, by wrapping an existing allocator. </li> <li> Compile-time configuration, including: </li> <li>Whether the allocatior is to be thread-safe. If thread-safety is disabled, then the debug allocator will detect invalid thread usage with it.</li> <li>How many stack frames to collect.</li> </ul> Goals for Other General Purpose Allocators But Not This One ReleaseFast and ReleaseSmall Modes: <ul> <li>Low fragmentation is primary concern</li> <li>Performance of worst-case latency is secondary concern</li> <li>Performance of average-case latency is next</li> <li>Finally, having freed memory unmapped, and pointer math errors unlikely to harm memory from unrelated allocations are nice-to-haves.</li> </ul> ReleaseSafe Mode: <ul> <li>Low fragmentation is primary concern</li> <li>All the safety mechanisms from Debug Mode are the next concern.</li> <li>It's OK for these mechanisms to take up some percent overhead of memory, but not at the cost of fragmentation, which can cause the equivalent of memory leaks.</li> </ul> Current Status <ul> <li>POSIX-only so far.</li> <li>Most basic functionality works. See Roadmap below for what's left to do.</li> <li>Not well tested yet.</li> </ul> Memory leak detection: Double free detection: Current Design Small allocations are divided into buckets: <code>index obj_size 0 1 1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024 11 2048</code> The main allocator state has an array of all the "current" buckets for each size class. Each slot in the array can be null, meaning the bucket for that size class is not allocated. When the first object is allocated for a given size class, it allocates 1 page of memory from the OS. This page is divided into "slots" - one per allocated object. Along with the page of memory for object slots, as many pages as necessary are allocated to store the BucketHeader, followed by "used bits", and two stack traces for each slot (allocation trace and free trace). The "used bits" are 1 bit per slot representing whether the slot is used. Allocations use the data to iterate to find a free slot. Frees assert that the corresponding bit is 1 and set it to 0. The memory for the allocator goes on its own page, with no write permissions. On call to reallocFn and shrinkFn, the allocator uses mprotect to make its own state writable, and then removes write permissions before returning. However bucket metadata is not protected in this way yet. Buckets have prev and next pointers. When there is only one bucket for a given size class, both prev and next point to itself. When all slots of a bucket are used, a new bucket is allocated, and enters the doubly linked list. The main allocator state tracks the "current" bucket for each size class. Leak detection currently only checks the current bucket. Reallocation detects if the size class is unchanged, in which case the same pointer is returned unmodified. If a different size class is required, the allocator attempts to allocate a new slot, copy the bytes, and then free the old slot. Large objects are allocated directly using <code>mmap</code> and their metadata is stored in a <code>std.HashMap</code> backed by a simple direct allocator. The hash map's data is memory protected with the same strategy as the allocator's state. Roadmap <ul> <li>Port to Windows</li> <li>Make sure that use after free tests work.</li> <li>Test mmap hints on other platforms:</li> <li>macOS</li> <li>FreeBSD</li> <li>Ability to print stats</li> <li>Requested Bytes Allocated (total of n for every alloc minus n for every free)</li> <li>Resident Bytes (pagesize * number of pages mmapped for slots)</li> <li>Overhead Bytes (how much memory the allocator state is using)</li> <li>Validation fuzz testing</li> <li>vary the size and alignment of allocations</li> <li>vary the number of and kind of operations in between allocations and corresponding frees</li> <li>vary whether or not the backing allocator succeeds</li> <li>how much memory capacity it goes up to</li> <li>When allocating new pages for small objects, if virtual address space is exhausted, fall back to using the oldest freed memory, whether that be unused pages, or freed slots.</li> <li>When falling back to old unused pages, if we get an error from the OS from reactivating the page, then fall back to a freed slot.</li> <li>Implement handling of multiple threads.</li> <li>On invalid free, print nearest allocation/deallocation stack trace</li> <li>Do the memory protection for bucket metadata too</li> <li>Catch the error when wrong size or wrong alignment is given to free or realloc/shrink.</li> <li>Performance benchmarking</li> <li>Do we need meta-buckets?</li> <li>Iterate over usize instead of u8 for used bits</li> <li>When configured to be non-thread-safe, then detect usage with multiple threads, and print stack traces showing where it was used in each thread.</li> <li>Write unit tests / regression tests</li> <li>Make <code>std.HashMap</code> return bytes back to the allocator when the hash map gets smaller.</li> <li>Make deallocated but still mapped bytes be <code>0xdd</code>.</li> <li>Detect when client uses the wrong <code>old_align</code> or <code>old_mem.len</code>.</li> <li>Keep track of first allocation stack trace as well as reallocation stack trace for large objects.</li> <li>Test whether it is an improvement to try to use an mmap hint when growing a large object and it has to mmap more.</li> <li>Once a bucket becomes full, remove it from the linked list of buckets that are used to find allocation slots.</li> </ul>
[]
https://avatars.githubusercontent.com/u/15308111?v=4
zuri
Vexu/zuri
2019-06-03T18:03:11Z
URI parser for Zig
master
2
48
6
48
https://api.github.com/repos/Vexu/zuri/tags
MIT
[ "uri", "zig" ]
45
false
2025-05-15T09:15:47Z
true
false
unknown
github
[]
zuri <a>URI</a> parser written in <a>Zig</a>. Example <code>Zig const uri = try Uri.parse("https://ziglang.org/documentation/master/#toc-Introduction"); assert(mem.eql(u8, uri.scheme, "https")); assert(mem.eql(u8, uri.host, "ziglang.org")); assert(mem.eql(u8, uri.path, "/documentation/master/")); assert(mem.eql(u8, uri.fragment, "toc-Introduction"));</code> Zig version By default the master branch version requires the latest Zig master version. For Zig 0.6.0 use commit 89ff8258ccd09d0a4cfda649828cc1c45f2b1f8f.
[]
https://avatars.githubusercontent.com/u/11783095?v=4
uefi-paint
nrdmn/uefi-paint
2019-08-02T22:06:30Z
UEFI-bootable touch paint app
master
0
47
2
47
https://api.github.com/repos/nrdmn/uefi-paint/tags
-
[ "uefi", "zig" ]
66
false
2025-04-11T00:55:03Z
true
false
unknown
github
[]
Build with <code>zig build</code>, run on a device with a touchscreen.
[]
https://avatars.githubusercontent.com/u/13176?v=4
zootdeck
donpdonp/zootdeck
2019-05-29T22:46:41Z
Fediverse GTK Desktop Reader
main
1
44
1
44
https://api.github.com/repos/donpdonp/zootdeck/tags
NOASSERTION
[ "fediverse", "mastodon", "zig" ]
5,195
false
2025-03-17T10:56:23Z
true
true
0.13.0
github
[]
Zootdeck fediverse desktop reader https://donpdonp.github.io/zootdeck/ Features <ul> <li>Any number of columns</li> <li>Column Sources: Mastodon account, Mastodon public feed</li> <li>per-column filtering on specific tags, or image-only mode</li> <li>native linux/GTK+3 app written in zig</li> </ul> Column specifiers <ul> <li><code>@mastodon.server</code></li> <li><code>@[email protected]</code></li> <li>Public feed</li> <li>Option to do oauth sign-in to read your own feed</li> <li><code>[email protected]</code></li> </ul> Roadmap <ul> <li>initial QT support</li> <li>initial lemmy support</li> <li>create a post</li> <li>css themes: overall, per-tag, per-host</li> <li>osx/windows</li> </ul> Build instructions ``` $ sudo apt install ragel libgtk-3-dev libcurl4-openssl-dev libgumbo-dev $ git clone https://github.com/donpdonp/zootdeck Cloning into 'zootdeck'... $ cd zootdeck $ make zig build $ ./zig-out/bin/zootdeck zootdeck linux x86_64 tid 7f565d1caf00 <code>``</code>zig-out/bin/zootdeck<code>is a stand-alone binary that can be copied to</code>/usr/local/bin/` or where ever you like.
[]
https://avatars.githubusercontent.com/u/801803?v=4
zigfmt-web
shritesh/zigfmt-web
2019-04-27T18:56:18Z
zig fmt on the web
gh-pages
2
44
5
44
https://api.github.com/repos/shritesh/zigfmt-web/tags
-
[ "fmt", "wasm", "webassembly", "zig" ]
555
false
2025-01-25T16:17:01Z
false
false
unknown
github
[]
zigfmt-web Compile with <code>zig build-lib -target wasm32-freestanding --release-small fmt.zig</code>
[]
https://avatars.githubusercontent.com/u/7283681?v=4
zigdig
lun-4/zigdig
2019-05-12T05:39:02Z
naive dns client library in zig
master
1
40
7
40
https://api.github.com/repos/lun-4/zigdig/tags
MIT
[ "dns", "zig", "zig-package" ]
647
false
2025-05-02T17:20:51Z
true
true
0.14.0
github
[]
zigdig naive dns client library in zig help me decide if this api is good: https://github.com/lun-4/zigdig/issues/10 what does it do <ul> <li>serialization and deserialization of dns packets as per rfc1035</li> <li>supports a subset of rdata (i do not have any plans to support 100% of DNS, but SRV/MX/TXT/A/AAAA are there, which most likely will be enough for your use cases)</li> <li>has helpers for reading <code>/etc/resolv.conf</code> (not that much, really)</li> </ul> what does it not do <ul> <li>no edns0</li> <li>support all resolv.conf options</li> <li>can deserialize pointer labels, but does not serialize into pointers</li> <li>follow CNAME records, this provides only the basic serialization/deserializtion</li> </ul> how do <ul> <li>zig 0.14.0: https://ziglang.org</li> <li>have a <code>/etc/resolv.conf</code></li> <li>tested on linux, should work on bsd i think</li> </ul> ``` git clone ... cd zigdig zig build test zig build install --prefix ~/.local/ ``` and then <code>bash zigdig google.com a</code> or, for the host(1) equivalent <code>bash zigdig-tiny google.com</code> using the library getAddressList-style api ```zig const dns = @import("dns"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer { _ = gpa.deinit(); } var allocator = gpa.alloator(); <code>var addresses = try dns.helpers.getAddressList("ziglang.org", allocator); defer addresses.deinit(); for (addresses.addrs) |address| { std.debug.print("we live in a society {}\n", .{address}); } </code> } ``` full api ```zig const dns = @import("dns"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer { _ = gpa.deinit(); } var allocator = gpa.alloator(); <code>var name_buffer: [128][]const u8 = undefined; const name = try dns.Name.fromString("ziglang.org", &amp;name_buffer); var questions = [_]dns.Question{ .{ .name = name, .typ = .A, .class = .IN, }, }; var packet = dns.Packet{ .header = .{ .id = dns.helpers.randomHeaderId(), .is_response = false, .wanted_recursion = true, .question_length = 1, }, .questions = &amp;questions, .answers = &amp;[_]dns.Resource{}, .nameservers = &amp;[_]dns.Resource{}, .additionals = &amp;[_]dns.Resource{}, }; // use helper function to connect to a resolver in the systems' // resolv.conf const conn = try dns.helpers.connectToSystemResolver(); defer conn.close(); try conn.sendPacket(packet); // you can also do this to support any Writer // const written_bytes = try packet.writeTo(some_fun_writer_goes_here); const reply = try conn.receivePacket(allocator, 4096); defer reply.deinit(); // you can also do this to support any Reader // const packet = try dns.Packet.readFrom(some_fun_reader, allocator); // defer packet.deinit(); const reply_packet = reply.packet; logger.info("reply: {}", .{reply_packet}); try std.testing.expectEqual(packet.header.id, reply_packet.header.id); try std.testing.expect(reply_packet.header.is_response); // ASSERTS that there's one A resource in the answer!!! you should verify // reply_packet.header.opcode to see if there's any errors const resource = reply_packet.answers[0]; var resource_data = try dns.ResourceData.fromOpaque( reply_packet, resource.typ, resource.opaque_rdata, allocator ); defer resource_data.deinit(allocator); // you now have an std.net.Address to use to your hearts content const ziglang_address = resource_data.A; </code> } ``` it is recommended to look at zigdig's source on <code>src/main.zig</code> to understand how things tick using the library, but it boils down to three things: - packet generation and serialization - sending/receiving (via a small shim on top of std.os.socket) - packet deserialization
[]
https://avatars.githubusercontent.com/u/22677068?v=4
zig-bare-metal-microbit
markfirmware/zig-bare-metal-microbit
2019-11-09T16:48:00Z
Bare metal microbit program written in zig
master
4
36
2
36
https://api.github.com/repos/markfirmware/zig-bare-metal-microbit/tags
MIT
[ "bare-metal", "microbit", "zig" ]
205
false
2025-03-01T05:23:24Z
true
false
unknown
github
[]
zig-bare-metal-microbit See also <a>zig-bare-metal-raspberry-pi</a> and <a>Awesome Zig Bootables</a> <ul> <li>Displays "Z" on the leds</li> <li>Events from buttons A and B are broadcast on ble and when received are printed on the uart line</li> </ul> The goal is to replace the <a>ble buttons broadcaster</a> with zig on bare metal. This broadcaster is processed by <a>ultibo-ble-observer</a>. Although it has no encryption, no privacy and no authentication, it is still useful for controlling a model railroad in a home or club setting, or at a demo. <ul> <li><a>microbit</a><ul> <li><a>runtime - not used in this bare-metal project</a><ul> <li><a>led matrix display driver</a></li> </ul> </li> <li><a>nrf51822</a></li> <li><a>reference</a></li> <li><a>arm cortex-m0</a><ul> <li><a>cortex m0 user's guide</a></li> </ul> </li> <li><a>armv6m</a></li> <li><a>edge connector and pins</a></li> <li><a>pin assignments (sheet 5 of schematic)</a></li> </ul> </li> </ul>
[]
https://avatars.githubusercontent.com/u/106511?v=4
lua-in-the-browser
andrewrk/lua-in-the-browser
2019-05-16T23:54:19Z
using zig to build lua for webassembly
master
2
34
3
34
https://api.github.com/repos/andrewrk/lua-in-the-browser/tags
-
[ "lua", "webassembly", "zig" ]
210
false
2025-02-01T09:18:42Z
true
false
unknown
github
[]
lua-in-the-browser This is the result of a <a>2.5 hour live coding stream</a> in which I tried to build <a>Lua</a> using <a>ZIG</a>, targeting <a>WebAssembly</a>. Status Able to produce <code>lib/lua.wasm</code>, however in the browser it says <code>LinkError: import object field 'getc' is not a Function</code>. To make further progress it is required to make modifications to Lua source code in order to remove the dependency on a file system. This depends on <a>pending modifications to Zig</a>. How to build it and run it <code>zig build install --prefix . python3 -m http.server</code> Then visit the link printed with a modern browser such as Firefox.
[]
https://avatars.githubusercontent.com/u/1327032?v=4
zig-win32
GoNZooo/zig-win32
2019-09-06T08:02:55Z
Bindings for win32, with and without WIN32_LEAN_AND_MEAN
master
1
31
2
31
https://api.github.com/repos/GoNZooo/zig-win32/tags
MIT
[ "win32", "win32api", "zig", "zig-package" ]
1,335
false
2025-04-05T01:53:48Z
true
false
unknown
github
[]
zig-win32 Archived I would suggest using <a>this library</a> instead. If there is some reason you cannot, feel free to reach out and I'll unarchive this so people can continue to work on it if they want. Linking You will need to add something like the following to your <code>build.zig</code> depending on what you end up using: If you're using the <code>win32.c</code> module, most functions are annotated with their library information, so you don't need to link anything, but at the time of writing the <code>lean_and_mean</code> module is not annotated. With that in mind, you may have to add build instructions like the following, depending on which functions you use: <code>zig const exe = b.addExecutable("executable-name", "src/main.zig"); exe.addPackagePath("win32", "./dependencies/zig-win32/src/main.zig"); exe.linkSystemLibrary("c"); exe.linkSystemLibrary("gdi32"); exe.linkSystemLibrary("user32"); exe.linkSystemLibrary("kernel32");</code> Usage in files A simple import will do it, access the sub-namespaces with <code>c</code> and <code>lean_and_mean</code>: <code>zig const win32 = @import("win32"); _ = win32.c.MessageBoxA(...);</code> Or import one of the sub-namespaces directly: <code>zig const win32 = @import("win32").lean_and_mean; _ = win32.MessageBoxA(...);</code> Macros not available in the FFI files <code>MAKEINTRESOURCE{A,W}</code> is not available in the generated files, but is available in the top namespace: <code>zig const win32 = @import("win32"); const resource: windows.LPSTR = win32.MAKEINTRESOURCEA(32512);</code>
[]
https://avatars.githubusercontent.com/u/14085211?v=4
Sustenet
Quaint-Studios/Sustenet
2020-01-21T02:44:43Z
Sustenet is a networking solution built with Rust and Zig, formerly C#, for game engines like Unity3D, Godot, and Unreal Engine. The primary focus is on scaling by allowing multiple servers to work together.
master
12
27
1
27
https://api.github.com/repos/Quaint-Studios/Sustenet/tags
MIT
[ "client", "game", "godot", "multiplayer", "netcode", "networking", "player", "players", "regions", "rust", "rust-lang", "server", "sockets", "unity", "unity-networking", "unity3d", "unreal", "zig", "ziglang" ]
7,474
false
2025-05-08T12:54:05Z
false
false
unknown
github
[]
Sustenet A Rust &amp; Zig, formerly C#, networking solution for the Godot Engine, Unreal Engine, and Unity3D. The primary focus is to enable scaling by allowing multiple servers to work together. <a></a> <a></a> <a></a> <blockquote> <strong>Sustenet powers <a>Reia</a> — a large-scale multiplayer game and the primary showcase for this networking solution.</strong> </blockquote> Sustenet is a networking solution for game engines designed for MMOs and large-scale multiplayer games. It is built in Rust and Zig, with a focus on modularity, security, and extensibility. The primary Game Engine supported by Sustenet is current Godot. But it's flexible and can be integrated with Unity3D, Unreal Engine, and other game engines. Support for other engines will continue to grow over time. Collaboration While I am still in the process of designing the structure of this project, I will not be actively accepting any collaborative efforts via pull requests. If there's an open issue, feel free to contribute. I'll work with you through it. I am also open to being pointed in certain directions. Articles and documentation on specific issues are greatly appreciated. Even discussing it directly is welcome. If you're interested in that, feel free to join <a>Reia's Discord</a>. You can discuss more about it there. We're very close to getting Sustenet to a point where it can actively accept contributions daily! Features <ul> <li><strong>Master/Cluster Architecture:</strong> Central master server coordinates distributed cluster servers for seamless scaling.</li> <li><strong>Secure Communication:</strong> AES-256-GCM encryption, key management, and base64 utilities.</li> <li><strong>Plugin Support:</strong> Easily extend server logic with custom Rust plugins.</li> <li><strong>Unified Logging:</strong> Consistent macros and log levels for debugging and monitoring.</li> <li><strong>Configurable:</strong> TOML-based configuration for all server types.</li> <li><strong>Extensible Protocols:</strong> Common event types, protocol enums, and packet definitions.</li> </ul> Usage Add <code>sustenet</code> as a dependency in your <code>Cargo.toml</code> (from crates.io): <code>toml [dependencies] sustenet = { version = "0.1.4", features = ["shared", "cluster", "master", "client", "full"] } # Choose your features</code> Or via git: <code>toml [dependencies] sustenet = { git = "https://github.com/Quaint-Studios/Sustenet", version = "0.1.4", features = ["shared", "cluster", "master", "client", "full"] }</code> Example: Writing a Cluster Plugin Below is a minimal example of a custom plugin for a cluster server, based on <a><code>rust_example/src/main.rs</code></a>: ```rust use sustenet::cluster::{ LOGGER, cleanup, start }; use sustenet::shared::ServerPlugin; use tokio::io::AsyncReadExt; use tokio::sync::mpsc::Sender; struct Reia { sender: std::sync::OnceLock&lt;Sender&lt;Box&lt;[u8]&gt;&gt;&gt;, } impl Reia { fn new() -&gt; Self { Reia { sender: std::sync::OnceLock::new(), } } <code>// Actual implementation of the receive function async fn handle_data( tx: Sender&lt;Box&lt;[u8]&gt;&gt;, command: u8, reader: &amp;mut tokio::io::BufReader&lt;tokio::net::tcp::ReadHalf&lt;'_&gt;&gt; ) { LOGGER.info(&amp;format!("Received new command: {}", command)); // Send a test message back to the sender if let Err(e) = tx.send(Box::new([20])).await { LOGGER.error(&amp;format!("Failed to send message. {e}")); } // Read the message from the reader let len = reader.read_u8().await.unwrap() as usize; let mut passphrase = vec![0u8; len]; match reader.read_exact(&amp;mut passphrase).await { Ok(_) =&gt; {} Err(e) =&gt; { LOGGER.error(&amp;format!("Failed to read passphrase to String: {:?}", e)); return; } }; } </code> } // Plugin initialization impl ServerPlugin for Reia { fn set_sender(&amp;self, tx: Sender&lt;Box&lt;[u8]&gt;&gt;) { // Set the sender if self.sender.set(tx).is_err() { LOGGER.error("Failed to set sender."); } } <code>fn receive&lt;'plug&gt;( &amp;self, tx: Sender&lt;Box&lt;[u8]&gt;&gt;, command: u8, reader: &amp;'plug mut tokio::io::BufReader&lt;tokio::net::tcp::ReadHalf&lt;'_&gt;&gt; ) -&gt; std::pin::Pin&lt;Box&lt;dyn std::future::Future&lt;Output = ()&gt; + Send + 'plug&gt;&gt; { Box::pin(Self::handle_data(tx, command, reader)) } fn info(&amp;self, message: &amp;str) { println!("{message}"); } </code> } [tokio::main] async fn main() { start(Reia::new()).await; cleanup().await; } ``` Configuration Each cluster server uses a <code>Config.toml</code> file for settings. Example below: ```toml [all] server_name = "Default Cluster Server" max_connections = 0 port = 0 [cluster] key_name = "cluster_key" master_ip = "127.0.0.1" master_port = 0 domain_pub_key = "https://site-cdn.playreia.com/game/pubkey.pub" # Remove this if you want to use the server's bandwidth to send a key to a user directly. | Currently does nothing. ``` Modules auth <ul> <li><a><code>main.rs</code></a>: Entry point for the authentication server (WIP).</li> <li><a><code>lib.rs</code></a>: Authentication logic, planned for integration with Supabase and Turso.</li> </ul> client <ul> <li><a><code>main.rs</code></a>: Entry point for the client, handles startup and shutdown.</li> <li><a><code>lib.rs</code></a>: Core logic for client operation, including server discovery, connection management, and data transfer.</li> </ul> cluster <ul> <li><a><code>main.rs</code></a>: Entry point for the cluster server, handles startup and plugin integration.</li> <li><a><code>lib.rs</code></a>: Core logic for cluster operation, including master connection, client handling, and plugin support.</li> </ul> master <ul> <li><a><code>main.rs</code></a>: Entry point for the master server, handles startup and main event loop.</li> <li><a><code>lib.rs</code></a>: Core logic for master server operation, including cluster and client management.</li> <li><a><code>security.rs</code></a>: Security primitives and helpers for loading keys and generating passphrases.</li> </ul> shared <ul> <li><a><code>config.rs</code></a>: Handles and reads the <em>Config.toml</em> file.</li> <li><a><code>lib.rs</code></a>: Contains the plugin definition and other core functions.</li> <li><a><code>logging.rs</code></a>: Logging macros and log level/type enums.</li> <li><a><code>macros.rs</code></a>: Useful macros for error handling and parsing.</li> <li><a><code>network.rs</code></a>: Protocols, events, and cluster info types.</li> <li><a><code>packets.rs</code></a>: Packet enums for master and cluster communication.</li> <li><a><code>security.rs</code></a>: AES encryption, key management, and base64 helpers.</li> <li><a><code>utils.rs</code></a>: Constants and utility functions.</li> </ul> Real-World Usage Sustenet is actively used in <a>Reia</a>, a large-scale multiplayer game. For more real-world examples, see <a>Quaint-Studios/Reia</a>. License This project is licensed under the MIT license. Old README <blockquote> Note: This section of the README was out of date since we were still migrating from C# to Rust/Zig. Things like solutions and project files no longer exist. Regardless, the layout should remain the same for everything. It's left here to get a good understanding of what we're trying to accomplish. </blockquote> Vision <em>This is a rough vision of where this project is headed, a more detailed layout will eventually be added.</em> The goal for Sustenet is to develop a connetion of servers. There are four major components in Sustenet. <ul> <li>The <code>Master</code> server is where all clusters go to be registered. There should really only be one Master Server. But I can't stop you if you want to do something more with it.</li> <li>The <code>Cluster</code> would be considered your traditional server. You load Sustenet as a Cluster and it contains some configurations:<ul> <li><code>Key</code> - The Cluster has a key in it, much like the SSH key you place on a server. Each Cluster should have a unique key. But, like I said, I can't stop you. You can reuse keys if you'd like. Just be aware that if one key is compromised, they all are. I will need some more research on how much security is required in an instance like this. Or what other approaches are an option.</li> <li><code>Master Server IP</code> - This is just telling the Cluster what IP to register to.</li> <li><code>[Master Server Port = 6256]</code> - Again, just some information to properly connect to the Master Server.</li> <li><code>[Connection Limit = 0]</code> - This is an optional property. Since it's set to 0, no connection limit is being enforced.</li> <li><em>more soon...</em></li> </ul> </li> <li>The <code>Fragment</code> is used to give different settings to certain areas in a Cluster. This includes the size of the Fragment in-game, the amount of players in it before the settings might change, keeping track of which players are in this Fragment, and update-rates.</li> <li> The <code>Client</code> is simply a Client. They'll connect to the Master server and have two options: <ul> <li>Login immediately, joining whatever Cluster they've been automatically allocated to, based on how much traffic the other Clusters are experiencing or based on their ping.</li> <li>Manaully select a cluster, browsing their names and other information. If there's a connection limit, then lock access to join that server.</li> </ul> That's it. After that, they'll just send and receive messages from their Cluster and the Cluster will handle swapping the player between Fragments based on their position. </li> </ul> Sustenet is aiming to improve this methodology over time. It's a learning experience. The structure may change over time. This will be the route taken for now though. Building &amp; Testing Here's a little context on the structure. There are two solutions. <code>Sustenet</code> and <code>SustenetUnity</code>. The former generates an executable while the latter generates a library. <code>SustenetUnity</code> also excludes all files related to the master server. Inside of the SustenetUnity.csproj file under PostBuild is a line that says <code>ImplementationPath</code>. That is the path you want the library to be automatically exported to. It's advised to change it to something valid. Other than that, everything should work as is. Testing with no GUI You can run the Sustenet.exe by itself with the parameter --master (this is the default options, so you don't actually have to provide it) and --client in two separate programs. This will show you an example connection.
[]
https://avatars.githubusercontent.com/u/17973728?v=4
tree-sitter-zig
GrayJack/tree-sitter-zig
2019-11-22T09:47:45Z
Tree-sitter package for the Zig programming language
master
4
26
4
26
https://api.github.com/repos/GrayJack/tree-sitter-zig/tags
BSD-3-Clause
[ "tree-sitter", "tree-sitter-zig", "zig", "ziglang" ]
23,359
false
2024-12-12T17:03:15Z
true
false
unknown
github
[]
tree-sitter-zig Zig grammar for <a>tree-sitter</a> Testing the parser Install dependency <code>sh npm install</code> Test a zig file <code>sh ./node_modules/tree-sitter-cli/tree-sitter parse &lt;ZIG_FIlE&gt;</code> References <a>Zig master branch docs</a>
[]
https://avatars.githubusercontent.com/u/7283681?v=4
ziget
lun-4/ziget
2019-05-09T20:08:58Z
simple wget in zig without libc
master
0
21
3
21
https://api.github.com/repos/lun-4/ziget/tags
Unlicense
[ "networking", "zig" ]
12
false
2025-04-21T15:49:09Z
true
false
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/3932972?v=4
SoftRenderLib
ikskuh/SoftRenderLib
2020-01-12T01:28:53Z
A collection of software rendering routines
master
0
21
0
21
https://api.github.com/repos/ikskuh/SoftRenderLib/tags
MIT
[ "rasterizer", "rasterizer-3d", "software-rasterizer", "software-renderer", "software-rendering", "zig", "ziglang" ]
3,858
false
2024-10-15T18:52:17Z
true
false
unknown
github
[]
Zig Software Rasterizer A high-performance software rasterizer written in Zig. Click the screenshot to see a video of the thing in action: <a></a>
[]
https://avatars.githubusercontent.com/u/17990536?v=4
open3DMM
jayrod246/open3DMM
2019-05-09T19:31:51Z
rewriting 3D Movie Maker from source
main
3
21
1
21
https://api.github.com/repos/jayrod246/open3DMM/tags
MIT
[ "3dmm", "open3dmm", "zig" ]
265,038
false
2025-01-20T12:26:08Z
true
true
unknown
github
[ { "commit": "1d1b90bd3f592f3641d53486ad5085e750668f94.tar.gz", "name": "open3dmm-core", "tar_url": "https://github.com/jayrod246/open3DMM-core/archive/1d1b90bd3f592f3641d53486ad5085e750668f94.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/jayrod246/open3DMM-core" } ]
404
[]
https://avatars.githubusercontent.com/u/7284585?v=4
zig-string
hwu1001/zig-string
2019-07-14T06:20:52Z
Strings for Zig
master
6
19
3
19
https://api.github.com/repos/hwu1001/zig-string/tags
-
[ "zig", "ziglang" ]
33
false
2025-03-02T23:38:57Z
false
false
unknown
github
[]
A String struct made for Zig. Inspired by this repo: https://github.com/clownpriest/strings/ To test: <code>$ cd zig-string/ $ zig test string.zig</code> Basic Usage: ```zig const std = @import("std"); const String = @import("/some/path/string.zig").String; pub fn main() !void { var buf: [1024]u8 = undefined; var fba = std.heap.ThreadSafeFixedBufferAllocator.init(buf[0..]); var s = try String.init(&amp;fba.allocator, "hello, world"); defer s.deinit(); var matches = try s.findSubstringIndices(&amp;fba.allocator, "hello"); defer fba.allocator.free(matches); // Should print: // 0 // hello, world for (matches) |val| { std.debug.warn("{}\n", val); } std.debug.warn("{}\n", s.toSliceConst()); } ```
[]
https://avatars.githubusercontent.com/u/6039952?v=4
hoodie
gernest/hoodie
2019-04-22T23:44:36Z
pure zig language server with swagger and bling bling
master
0
19
1
19
https://api.github.com/repos/gernest/hoodie/tags
MIT
[ "language-server-protocol", "linter", "lsp", "lsp-ser", "zig", "zig-auto-complete", "zig-fmt", "zig-fmt-imports", "zig-goto-symbol", "zig-outline" ]
983
false
2024-12-27T23:58:08Z
true
false
unknown
github
[]
hoodie zig language server with swagger and bling bling
[]
https://avatars.githubusercontent.com/u/748913?v=4
ip.zig
euantorano/ip.zig
2019-04-26T17:44:51Z
A Zig library for working with IP Addresses
master
0
19
2
19
https://api.github.com/repos/euantorano/ip.zig/tags
BSD-3-Clause
[ "ip-address", "zig", "zig-library" ]
53
false
2025-03-24T23:45:39Z
true
false
unknown
github
[]
ip.zig <a></a> A Zig library for working with IP Addresses Current Status <ul> <li>[X] Constructing IPv4/IPv6 addresses from octets or bytes</li> <li>[X] IpAddress union</li> <li>[X] Various utility methods for working with IP addresses, such as: comparing for equality; checking for loopback/multicast/globally routable</li> <li>[X] Formatting IPv4/IPv6 addresses using <code>std.format</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> Parsing IPv4/IPv6 addresses from strings<ul> <li>[X] Parsing IPv4 addresses <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> Parsing IPv6 addresses<ul> <li>[X] Parsing simple IPv6 addresses <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> Parsing IPv4 compatible/mapped IPv6 addresses <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> Parsing IPv6 address scopes (<code>scope id</code>)</li> </ul> </li> </ul> </li> </ul>
[]
https://avatars.githubusercontent.com/u/3932972?v=4
zig-gamedev-lib
ikskuh/zig-gamedev-lib
2019-10-05T14:33:33Z
xq's Zig Game Development Library
master
2
16
1
16
https://api.github.com/repos/ikskuh/zig-gamedev-lib/tags
Zlib
[ "game-development", "zig" ]
566
false
2023-01-27T20:17:30Z
false
false
unknown
github
[]
xq's Zig Game Development Library <blockquote> <strong>NOTE:</strong> THIS PROJECT IS NOW ARCHIVED AS THE CODE IN IT SPLIT INTO SEVERAL OTHER PROJECTS. </blockquote> Modules <ul> <li><strong>math3d</strong>: contains basic vector math for game development</li> <li><strong>wavefrontObj</strong>: Load <a>Wavefront Object</a> 3d models</li> <li><strong>netbpm</strong>: Load <a>Netbpm</a> images</li> <li><strong>gles2</strong>: OpenGL ES 2.0 loader/binding</li> </ul> Usage <strong>Make the module available as <code>xq3d</code>:</strong> ```zig pub fn build(b: *Builder) void { const exe = b.addExecutable(…); <code>… exe.addPackagePath("xq3d", "…/zig-gamedev-lib/src/lib.zig"); … </code> } ``` <strong>Include the module:</strong> ```zig const xq3d = @import("xq3d"); ``` Documentation Read the source. There is none at the moment.
[]
https://avatars.githubusercontent.com/u/65570835?v=4
lscolors
ziglibs/lscolors
2019-11-03T15:47:57Z
A zig library for colorizing paths according to LS_COLORS
master
0
16
1
16
https://api.github.com/repos/ziglibs/lscolors/tags
MIT
[ "ls-colors", "zig", "zig-package", "ziglang" ]
98
false
2025-05-07T07:19:42Z
true
true
0.14.0
github
[ { "commit": "master", "name": "ansi_term", "tar_url": "https://github.com/ziglibs/ansi_term/archive/master.tar.gz", "type": "remote", "url": "https://github.com/ziglibs/ansi_term" } ]
lscolors A zig library for colorizing paths according to the <code>LS_COLORS</code> environment variable. Designed to work with Zig 0.14.0. Quick Example ```zig const std = @import("std"); const LsColors = @import("lscolors").LsColors; pub fn main() !void { var gpa: std.heap.DebugAllocator(.{}) = .init; defer _ = gpa.deinit(); const allocator = gpa.allocator(); <code>var lsc = try LsColors.fromEnv(allocator); defer lsc.deinit(); var dir = try std.fs.cwd().openDir(".", .{ .iterate = true }); defer dir.close(); var iterator = dir.iterate(); while (try iterator.next()) |itm| { std.log.info("{}", .{try lsc.styled(itm.name)}); } </code> } ```
[ "https://github.com/joachimschmidt557/zigfd" ]
https://avatars.githubusercontent.com/u/11783095?v=4
uefi-freetype
nrdmn/uefi-freetype
2019-09-22T23:01:30Z
Zig UEFI FreeType Demo
master
2
15
2
15
https://api.github.com/repos/nrdmn/uefi-freetype/tags
-
[ "freetype", "uefi", "zig" ]
38
false
2025-01-04T22:12:50Z
true
false
unknown
github
[]
To build: - <code>git submodule update --init</code> - Go to the definition of <code>FT_Encoding</code> in freetype2/include/freetype/freetype.h and comment out the 'for backward compatibility' lines (see https://github.com/ziglang/zig/issues/2115) - <code>make</code>
[]
https://avatars.githubusercontent.com/u/54989751?v=4
wapc-guest-zig
wapc/wapc-guest-zig
2019-09-11T18:33:25Z
SDK for creating waPC WebAssembly Guest Modules in Zig
master
1
14
2
14
https://api.github.com/repos/wapc/wapc-guest-zig/tags
Apache-2.0
[ "sdk", "wasm", "webassembly", "zig", "ziglang" ]
8
false
2023-10-04T13:16:24Z
false
false
unknown
github
[]
waPC Guest Library for Zig This is the Zig implementation of the <strong>waPC</strong> standard for WebAssembly guest modules. It allows any waPC-compliant WebAssembly host to invoke to procedures inside a Zig compiled guest and similarly for the guest to invoke procedures exposed by the host. Example The following is a simple example of synchronous, bi-directional procedure calls between a WebAssembly host runtime and the guest module. <code>hello.zig</code> (copy <code>wapc.zig</code> into the same directory) ```zig const wapc = @import("wapc.zig"); const std = @import("std"); const mem = std.mem; export fn __guest_call(operation_size: usize, payload_size: usize) bool { return wapc.handleCall(operation_size, payload_size, &amp;functions); } var functions = [_]wapc.Function{ wapc.Function{.name = &amp;"hello", .invoke = sayHello}, }; fn sayHello(allocator: *mem.Allocator, payload: []u8) ![]u8 { const hostHello = try wapc.hostCall(allocator, &amp;"myBinding", &amp;"sample", &amp;"hello", &amp;"Simon"); const prefix = "Hello, "; const message = try allocator.alloc(u8, prefix.len + payload.len + hostHello.len + 1); mem.copy(u8, message, &amp;prefix); mem.copy(u8, message[prefix.len..], payload); mem.copy(u8, message[prefix.len+payload.len..], hostHello); message[message.len-1] = '!'; return message; } ``` <code>sh zig build-lib hello.zig -target wasm32-freestanding</code>
[]
https://avatars.githubusercontent.com/u/1806407?v=4
zig-containers
Sahnvour/zig-containers
2019-04-16T20:57:56Z
A container library for Zig.
master
0
14
0
14
https://api.github.com/repos/Sahnvour/zig-containers/tags
-
[ "containers", "zig" ]
61
false
2025-01-04T10:56:34Z
true
false
unknown
github
[]
A set of containers for Zig May turn useful, or not. This is mostly a testbed for a few containers, especially <code>hashmap.zig</code> which ended up in the standard library. Benchmarks A couple benchmarks are available (and can be tinkered with): <code>shell zig build bench -Drelease-fast</code> and more interestingly, a simplified implementation in Zig of <a>this one</a> which ended up in <a>gotta go fast</a>. <code>shell zig build martinus -Drelease-fast</code> The <code>martinus</code> benchmark directly uses the standard library's hashmap, and supports <code>-Doverride-lib-dir=path/to/lib</code> for in-place testing.
[]
https://avatars.githubusercontent.com/u/1806407?v=4
zig-benchmark
Sahnvour/zig-benchmark
2019-02-16T17:53:42Z
Small and easy micro-benchmarking library.
master
0
14
4
14
https://api.github.com/repos/Sahnvour/zig-benchmark/tags
Apache-2.0
[ "benchmarking", "zig" ]
18
false
2025-01-04T10:56:32Z
false
false
unknown
github
[]
Goal zig-benchmark provides a minimal API to do micro-benchmarking. Everything it contains is very barebones compared to mature benchmarking frameworks, but usable nonetheless. Features <ul> <li>easy to use</li> <li>runs every micro-benchmark in fixed time</li> <li>pre-warming, to get the caches ready</li> <li>ugly text report</li> </ul> Example Simple ```zig const bench = @import("bench.zig"); fn longCompute(ctx: *bench.Context) void { while (ctx.run()) { // something you want to time } } pub fn main() void { bench.benchmark("longCompute", longCompute); } ``` With arguments ```zig const bench = @import("bench.zig"); fn longCompute(ctx: *bench.Context, x: u32) void { while (ctx.run()) { // something you want to time } } pub fn main() void { bench.benchmarkArgs("longCompute", longCompute, []const u32{ 1, 2, 3, 4 }); } ``` Works with <code>type</code>s as arguments, too. With explicit timing ```zig const bench = @import("bench.zig"); fn longCompute(ctx: *bench.Context) void { while (ctx.runExplicitTiming()) { // do some set-up <code> ctx.startTimer(); // something you want to time ctx.stopTimer(); } </code> } pub fn main() void { bench.benchmark("longCompute", longCompute); } ```
[]
https://avatars.githubusercontent.com/u/6039952?v=4
base32
gernest/base32
2019-10-12T07:26:58Z
base32 encoding/decoding for ziglang
master
0
13
3
13
https://api.github.com/repos/gernest/base32/tags
MIT
[ "base32", "base32hex", "zig", "ziglang" ]
25
false
2025-03-24T07:04:43Z
true
true
unknown
github
[]
base32 This implements <code>base32</code> <code>encoding</code> and <code>decoding</code> for the zig programming language (ziglang) Installation First fetch dependency by running: <code>zig fetch --save git+https://github.com/gernest/base32</code> Then update your <code>build.zig</code> file to load the module: <code>const base32 = b.dependency("base32", .{}); exe.root_module.addImport("base32", base32.module("base32"));</code> Usage <code>example.zig</code> ```zig const std = @import("std"); const base32 = @import("src/base32.zig"); const stdout = std.io.getStdOut().writer(); pub fn main() !void { try encodeString(); try stdout.print("\n\n", .{}); try decodeString(); } fn encodeString() !void { const src = "any + old &amp; data"; const size = comptime base32.std_encoding.encodeLen(src.len); var buf: [size]u8 = undefined; const out = base32.std_encoding.encode(&amp;buf, src); try stdout.print("ExampleEncodingToString:\nsource: \"{s}\"\noutput: {s}\n", .{src, out}); } fn decodeString() !void { const src = "ONXW2ZJAMRQXIYJAO5UXI2BAAAQGC3TEEDX3XPY="; const size = comptime base32.std_encoding.decodeLen(src.len); var buf: [size]u8 = undefined; const out = try base32.std_encoding.decode(&amp;buf, src); try stdout.print("ExampleDecodingString:\nsource: {s}\noutput: \"{s}\"\n", .{src, out}); } ``` ``` $ zig run example.zig ExampleEncodingToString: source: "any + old &amp; data" output: MFXHSIBLEBXWYZBAEYQGIYLUME====== ExampleDecodingString: source: ONXW2ZJAMRQXIYJAO5UXI2BAAAQGC3TEEDX3XPY= output: "some data with and " ```
[]
https://avatars.githubusercontent.com/u/30035?v=4
markzig
demizer/markzig
2019-11-06T20:48:21Z
Markdown parser for Zig
master
0
13
0
13
https://api.github.com/repos/demizer/markzig/tags
BSD-2-Clause
[ "html", "markdown", "parse", "scanner", "tokenizer", "webview", "zig" ]
141
false
2025-03-24T06:52:53Z
true
false
unknown
github
[]
Markzig CommonMark compliant Markdown parsing for Zig! Markzig is a library and command line tool for converting markdown to html or showing rendered markdown in a webview. Usage Not yet applicable. Status 4/649 tests of the CommonMark 0.29 test suite pass! Milestone #1 Parse and display a basic document <a>test.md</a>. <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> Tokenize <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> Parse <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> Render to HTML - [X] Display markdown document in <a>webview</a>. Milestone #2 <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> 50% tests pass
[]
https://avatars.githubusercontent.com/u/173219?v=4
zigmkv
vi/zigmkv
2019-10-03T06:43:19Z
[wip] Matroska/webm (mkv) parser in Zig
master
0
13
0
13
https://api.github.com/repos/vi/zigmkv/tags
-
[ "matroska", "mkv", "parser", "webm", "zig", "ziglang" ]
50
false
2024-12-28T00:21:46Z
true
false
unknown
github
[]
zigmkv A work in progress Matroska/webm (mkv) parser in Zig. For now it contains elements database, can decode mkv files to element tree, but it does not yet handle parse frame content and calculate proper timecodes. Main idea was to evaluate Zig as a general purpose programming language. Tested with zig version 0.8.0. <code>$ zig build $ zig-out/bin/zigmkv l2dump &lt; some_file.mkv open 0x1a45dfa3 (EBML) type=Type.master size=35 open 0x4286 (EBMLVersion) type=Type.uinteger size=1 number 1 close 0x4286 (EBMLVersion) type=Type.uinteger open 0x42f7 (EBMLReadVersion) type=Type.uinteger size=1 number 1 close 0x42f7 (EBMLReadVersion) type=Type.uinteger open 0x42f2 (EBMLMaxIDLength) type=Type.uinteger size=1 number 4 close 0x42f2 (EBMLMaxIDLength) type=Type.uinteger ...</code>
[]
https://avatars.githubusercontent.com/u/15584994?v=4
zig-json-decode
haze/zig-json-decode
2019-12-10T04:26:20Z
Create a zig type to easily decode json from a struct
master
0
12
1
12
https://api.github.com/repos/haze/zig-json-decode/tags
MIT
[ "json", "zig" ]
22
false
2024-03-06T17:44:58Z
true
false
unknown
github
[]
zig-json-decode To use, simply clone and link in your zig project Example ```zig // ./build.zig ===== exe.addPackagePath("zig-json-decode", "zig-json-decode/src/main.zig"); // ./src/main.zig ===== const Decodable = @import("zig-json-decode").Decodable; const Skeleton = struct { key: []const u8, // json key mapping const json_key: []const u8 = "oddly_named_key"; }; const FleshedType = Decodable(Skeleton); //... const json = \{"oddly_named_key": "test"} ; const foo = try FleshedType.fromJson(.{}, allocator, (try parser.parse(json)).root.Object); ``` 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> Map json keys to struct fields <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> Dump objects as JSON <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> Create custom decode functions specifically tailored to skeleton structs TODO <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> Alternative key names
[]
https://avatars.githubusercontent.com/u/5253988?v=4
zig-armv8m-test
yvt/zig-armv8m-test
2019-06-27T15:32:08Z
Minimal Zig-based app for Armv8-M + TrustZone
master
0
12
2
12
https://api.github.com/repos/yvt/zig-armv8m-test/tags
Apache-2.0
[ "arm", "cortex-m33", "iot", "microcontroller", "trustzone", "zig" ]
51
false
2025-01-18T14:40:54Z
true
false
unknown
github
[]
Zig on Cortex-M33 This repository includes a small example application that runs on <a>AN505</a>, a Cortex-M33-based prototyping system on FPGA. Written mostly in <a>Zig</a> and partly in assembler. Usage You need the following things before running this example: <ul> <li>Either of the following:<ul> <li><a>QEMU</a> 4.0.0 or later. Older versions are not tested but might work.</li> <li>Arm <a>MPS2+</a> FPGA prototyping board configured with AN505. The encrypted FPGA image of AN505 is available from <a>Arm's website</a>.</li> </ul> </li> <li>Zig <a><code>2cb1f93</code></a> (Aug 16, 2019) or later</li> </ul> Do the following: <code>shell $ zig build -Drelease-small qemu (Hit ^A X to quit QEMU) The Secure code is running! Booting the Non-Secure code... NS: Hello from the Non-Secure world! \</code> <a></a> License This project is dual-licensed under the Apache License Version 2.0 and the MIT License.
[]
https://avatars.githubusercontent.com/u/5727856?v=4
ZNA
Aransentin/ZNA
2019-09-03T23:06:46Z
Network analyzer experiment
master
0
12
1
12
https://api.github.com/repos/Aransentin/ZNA/tags
-
[ "zig" ]
17
false
2024-12-28T02:47:13Z
true
false
unknown
github
[]
ZNA Network analyzer experiment
[]
https://avatars.githubusercontent.com/u/657581?v=4
zig-raylib-experiments
BitPuffin/zig-raylib-experiments
2019-06-04T19:44:35Z
Some classic game implementations in Zig using raylib
master
0
12
1
12
https://api.github.com/repos/BitPuffin/zig-raylib-experiments/tags
-
[ "game-development", "raylib", "raylib-examples", "zig", "zig-examples" ]
2,088
false
2023-07-17T18:35:46Z
true
false
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/3932972?v=4
ZigPaint
ikskuh/ZigPaint
2019-08-13T21:43:29Z
A simple paint application written in Zig. Used to create an OpenGL loader/wrapper and a minimal UI system.
master
0
11
0
11
https://api.github.com/repos/ikskuh/ZigPaint/tags
-
[ "opengl", "zig" ]
32
false
2024-10-09T04:24:59Z
true
false
unknown
github
[]
ZigPaint A simple paint application written in Zig. Used to create an OpenGL loader/wrapper and a minimal UI system.
[]
https://avatars.githubusercontent.com/u/11783095?v=4
uefi-gameoflife
nrdmn/uefi-gameoflife
2019-07-14T06:21:30Z
Game of Life for UEFI, written in Zig
master
0
11
0
11
https://api.github.com/repos/nrdmn/uefi-gameoflife/tags
-
[ "gameoflife", "uefi", "zig" ]
8
false
2024-09-30T02:29:37Z
true
false
unknown
github
[]
UEFI bootable Game of Life in Zig Build with <code>zig build</code>, run with <code>qemu-system-x86_64 -bios /usr/share/edk2-ovmf/OVMF.fd -hdd fat:rw:.</code>
[]
https://avatars.githubusercontent.com/u/8798829?v=4
zig-error-abi
suirad/zig-error-abi
2019-11-26T22:23:12Z
Library that allows zig errors to be returned from external functions
master
0
8
0
8
https://api.github.com/repos/suirad/zig-error-abi/tags
MIT
[ "abi", "dynamic-library", "errors", "static-library", "zig" ]
4
false
2023-05-01T07:45:32Z
false
false
unknown
github
[]
Zig Error-ABI An Error-ABI library for the Zig language. See example folder for an example of use. This library allows error values to be propagated across the ABI boundary, allowing zig error unions to be returned from static and dynamic libraries.
[]
https://avatars.githubusercontent.com/u/1562827?v=4
zig_benchmarksgame
travisstaloch/zig_benchmarksgame
2020-01-09T04:26:10Z
benchmarksgame implementations
master
1
8
0
8
https://api.github.com/repos/travisstaloch/zig_benchmarksgame/tags
GPL-3.0
[ "benchmarking", "zig" ]
24
false
2024-02-02T23:06:55Z
false
false
unknown
github
[]
zig_benchmarksgame benchmarksgame implementations in zig https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/summary.html Until I figure out how to publish these solutions on the benchmarksgame website, I will keep them here. measurements Some very naive performance measurements. These are simply first run timings. <code>OS: Debian GNU/Linux 10 (buster) x86_64 CPU: Intel i7-4790 (8) @ 4.000GHz</code> nbody ```sh $ time ./nbody.gcc-8.gcc_run 50000000 #c -0.169075164 -0.169059907 real 0m2.501s user 0m2.479s sys 0m0.012s ``` ```sh $ time ./nbody.zig-1.run 50000000 #zig -0.169075164 -0.169059907 real 0m2.483s user 0m2.483s sys 0m0.000s ``` spectralnorm ```sh $ time ./spectralnorm.gcc-5.gcc_run 5500 #c 1.274224153 real 0m0.636s user 0m4.562s sys 0m0.028s ``` ```sh $ time ./spectralnorm 5500 #zig 1.274224153 real 0m0.586s user 0m4.291s sys 0m0.052s ``` ```sh $ time ./spectralnorm.go.run 5500 #go 1.274224153 real 0m1.141s user 0m4.514s sys 0m0.004s ``` ```sh TODO: make this concurrent $ time ./spectralnorm.go.zig.run 5500 #zig 1.274224153 real 0m4.399s user 0m4.377s sys 0m0.016s ``` pidigits <code>sh $ time ./pidigits.gcc-1_run 10000 #c ... real 0m0.646s user 0m0.645s sys 0m0.000s</code> <code>sh $ time ./pidigits-gmp 10000 #zig ... real 0m0.642s user 0m0.638s sys 0m0.004s</code>
[]
https://avatars.githubusercontent.com/u/1006268?v=4
ziguid
goto-bus-stop/ziguid
2019-06-25T11:59:15Z
GUID parsing/stringifying with zig
default
0
8
0
8
https://api.github.com/repos/goto-bus-stop/ziguid/tags
NOASSERTION
[ "guid", "zig" ]
41
false
2025-03-24T06:52:29Z
true
false
unknown
github
[]
ziguid GUIDs for zig. Usage ```zig const guid = @import("ziguid"); const GUID = guid.GUID; const at_comptime = GUID.from("14aacebd-2dfe-4f5c-a475-d1b57b0cb775"); const generate_at_runtime = GUID.v4(); var string_buffer = [_]u8{0} ** 38; generate_at_runtime.toString(string_buffer, .Braced, .Upper); // "{B10BC49E-E79A-478B-B180-0A7093E2D1BE}" ``` The GUID struct is 16 bytes large and has an identical layout to the GUID struct in the Windows C API. License <a>Apache-2.0</a>
[]
https://avatars.githubusercontent.com/u/46252311?v=4
OidaVM
deingithub/OidaVM
2019-09-28T15:36:47Z
A minimal bytecode VM implemented in Zig
master
2
8
0
8
https://api.github.com/repos/deingithub/OidaVM/tags
MIT
[ "zig" ]
81
false
2024-04-18T01:25:56Z
true
false
unknown
github
[]
OidaVM A (not that, anymore) minimal bytecode VM implemented in Zig with integrated debugger. Usage Run <code>oida run youroidasmfile</code> to run your program, optionally specifying an entry point in hex after the filename. To debug oidaVM programs, use the internal debugger oiDB, which you can invoke using <code>oida dbg youroidasmfile</code>. It has a GDB-<em>inspired</em> REPL and internal help accessible via <code>?</code> or <code>h</code>. Specs <ul> <li>4096 16-bit words of memory, each freely interpretable as instruction or data</li> <li>Two (2) internal registers, <code>ACC</code> and the instruction pointer.</li> </ul> ISA Global Opcodes (four bits) These can target the entire memory space of the VM. There are six possible opcodes in this category. <ul> <li><code>0x0 noopr</code> <em>No Operation</em>: Skips instruction.</li> <li><code>0xa pgjmp</code> <em>Page And Jump</em>: Selects highest four bits of address as page and unconditionally continues execution at address.</li> <li><code>0xb fftch</code> <em>Far Fetch</em>: Copies memory value at address into ACC.</li> <li><code>0xc fwrte</code> <em>Far Write</em>: Overwrites memory at address with copy of ACC.</li> </ul> Paged Opcodes (eight bits) These can target all addresses on the current page, which represents one 16th of the full memory. There are 144 possible opcodes in this category. <ul> <li><code>0x11 incby</code> <em>Increment By</em>: Adds value of address in memory to ACC. Overflow gets truncated to 65535; if no overflow occurs the next instruction is skipped.</li> <li><code>0x12 minus</code> <em>Minus</em>: Substracts value of address in memory from ACC. Underflow gets truncated to 0; if no overflow occurs the next instruction is skipped.</li> <li><code>0x20 fetch</code> <em>Fetch</em>: Copies memory value at address into ACC.</li> <li><code>0x21 write</code> <em>Write</em>: Overwrites memory at address with copy of ACC.</li> <li><code>0x30 jmpto</code> <em>Jump To</em>: Unconditionally continues execution at address.</li> <li><code>0x31 jmpez</code> <em>Jump If Equal To Zero</em>: If ACC is 0, continues execution at address, otherwise skips instruction.</li> </ul> Extended opcodes (sixteen bits) These can't target memory and take no arguments, so they are either used for I/O or operations on ACC. There are 144 possible opcodes in this category. <ul> <li><code>0xf00f cease</code> <em>Cease</em>: Halts execution.</li> <li><code>0xf010 outnm</code> <em>Output, Numeric</em>: Writes the content of ACC to stderr, as a decimal number.</li> <li><code>0xf011 outch</code> <em>Output, Character</em>: Writes the lower eight bits of ACC to stderr, as ASCII character.</li> <li><code>0xf012 outlf</code> <em>Output Linefeed</em>: Writes <code>\n</code> to stderr.</li> <li><code>0xf013 outhx</code> <em>Output, Hexadecimal</em>: Writes the content of ACC to stderr, as a hexadecimal number.</li> <li><code>0xf020 inacc</code> <em>Input To ACC</em>: Awaits one word of input from user and writes it into ACC.</li> <li><code>0xf030 rando</code> <em>Randomize ACC</em>: Writes a random value (backed by the default PRNG) into ACC.</li> <li><code>0xf040 augmt</code> <em>Augment ACC</em>: Increases ACC by one. Overflow gets truncated to 65535; if no overflow occurs the next instruction is skipped.</li> <li><code>0xf041 dimin</code> <em>Diminish ACC</em>: Diminishes ACC by one. Underflow gets truncated to 0; if no underflow occurs the next instruction is skipped.</li> <li><code>0xf042 shfl4</code> <em>Shift Left Four</em>: Shifts the value of ACC four bytes to the left.</li> <li><code>0xf043 shfr4</code> <em>Shift Right Four</em>: Shifts the value of ACC four bytes to the right.</li> <li><code>0xf044 shfl1</code> <em>Shift Left One</em>: Shifts the value of ACC one byte to the left.</li> <li><code>0xf045 shfr1</code> <em>Shift Right One</em>: Shifts the value of ACC one byte to the right.</li> </ul> oidASM oidASM is the assembly language for OidaVM. It has five fundamental elements: Directives, Variable Definitions, Blocks, Instructions and Comments. Each element takes up one line. Comments start with <code>#</code> and are ignored by the assembler. Directives start with <code>@</code> and pass metadata to the assembler. Variable definitions start with <code>$</code> and bind a value to a symbol for later reference. Blocks start with <code>:</code> and delineate sections of the program that can be jumped to. Instructions appear after a block marker and consist of a five-char mnemonic and optionally an address (either as <code>$variable</code> or <code>:block</code>). Each program needs at least a <code>@entry</code> directive to set the entry point of the program to a block and one block to execute. The <code>@page</code> directive sets the current working page of the assembler. If no directive is specified, the assembler assumes page <code>0</code>. For some examples, look into the oidASM/ folder. Why? Yes.
[]
https://avatars.githubusercontent.com/u/196042?v=4
daya
michaelo/daya
2019-12-04T13:40:21Z
Text based graphing service
master
0
7
0
7
https://api.github.com/repos/michaelo/daya/tags
MIT
[ "diagram", "diagramming", "dot", "text-based", "zig" ]
471
false
2022-07-13T20:59:20Z
false
false
unknown
github
[]
daya: Rapid text-based graphing tool Example usage of compiler: <code>// Generate a png daya myfile.daya output.png // Generate an svg daya myfile.daya output.svg // Generate only the intermediary dot daya myfile.daya output.dot </code> daya is a tool and library to convert from the .daya format to regular .dot, .png or .svg. The daya-format is intended to allow for rapid diagramming from text sources. Mostly relationship-like diagrams such as UML's activity- and component-diagrams etc. There are currently no plan to add features for sequence-diagrams and such. It can be thought of as "a subset of dot with custom types" (*). "Type" here are, due to the visual nature of it all, more comparable to CSS classes than types from strictly typed programming languages: they provide templates for how different parts shall appear. The subset of features, attributes and such is highly opiniated, and very much subject to change as we move toward v1.0. (*): This is also to be read as; There are many, <em>many</em> diagram-situations which are not intended to be solved by daya. Getting started: Prerequisite: have graphviz (https://graphviz.org/download/) installed and dot available in path on your system. Create a .daya file - e.g "gettingstarted.daya": <code>// Create one or more node types node User; node System; // Create one or more edge types edge controls; // Create instances based on node types emperor: User; deathstar: System; // Create relationships based on instances and edge types emperor controls deathstar; </code> then run: <code>daya gettingstarted.daya gettingstarted.png</code> to create a diagram and save it as output.png for your viewing pleasures: Daya advanced format example: file: common_types.daya: <code>// Define common node-types node Interface { label="&lt;Interface&gt;"; shape=diamond; fgcolor=#666666; bgcolor=#ffddaa; } node Module { label="[Module]"; shape=box; fgcolor=#000000; bgcolor=#ffffff; } // Define edge-/relationship-types edge implements { label="Implements"; edge_style=dashed; target_symbol=arrow_open; } edge depends_on; // rely on defaults edge relates_to { source_symbol=arrow_open; target_symbol=arrow_open; } </code> file: mygraph.daya <code>// imports the file as described above. Limitation: path can't contain newline @common_types.daya // Set title of diagram label="My example diagram"; // Declare the module-instances, optionally grouped IIterator: Interface { note="You can add notes to instances"; } group Core { note="You can add notes to groups"; // Groups are by default label-less (for now) label="Core"; MySomething: Module; MyElse: Module; } SomeDependency: Module { // An instantiation can override base-node fields bgcolor="#ffdddd"; } // Describe relationships between modules MySomething implements IIterator; MySomething depends_on SomeDependency; MySomething relates_to MyElse { // A relationship can override base-edge fields target_symbol=arrow_filled; } </code> Result: Daya grammar Types of statements: <ul> <li> Declare a node-type: <code>// Using only default properties node NodeType; // or override particular properties node OtherNodeType { label="Custom label"; shape=diamond; } </code> </li> <li> Declare an edge-type <code>// Using only default properties - a simple, one-directional arrow when used in a relationship edge owns; // or override particular properties - to render e.g a two-way arrow edge twowaydataflow { source_symbol=arrow_filled; target_symbol=arrow_filled; } </code> </li> <li> Create a specific instance of a node <code>// Will inherit the properties of the given node type myinstance: NodeType; // And optionally override particular ones for this given instance otherinstance: OtherNodeType { shape=circle; } </code> </li> <li> Specify a relationship between two node-instances using an edge <code>// Using the default style of the particular edge myinstance owns otherinstance; // Or override particular properties for the edge used in this given relationship otherinstance twowaydataflow myinstance { label="Overridden label for edge"; } </code> </li> </ul> For the different types there are a set of allowed parameters that can be specificed: <ul> <li>For node or instance:<ul> <li>label: string - supports in-file newlines or \n</li> <li>bgcolor: string/#rrggbb, forwarded directly to dot.</li> <li>fgcolor: see bgcolor.</li> <li>shape: string, forwarded directly to dot: https://graphviz.org/doc/info/shapes.html</li> </ul> </li> <li>for edge or relationship:<ul> <li>label: string</li> <li>source_symbol: none|arrow_filled|arrow_closed|arrow_open. default: none</li> <li>target_symbol: see source_symbol. default: arrow_open</li> <li>edge_style: solid|dotted|dashed|bold. default: solid</li> </ul> </li> <li>An instance automatically inherits the parameters of their node-type. The labels are concatinated with a newline, the remaining fields are overridden.</li> <li>If no label is specified, the name is used</li> <li>The parameters of an edge can be overridden pr relationship-entry</li> </ul> Installation See releases in repo, or Build-section below. To install a release, download the platform-appropriate archive, decompress it, and put the resident daya-binary somewhere in your path. Build Development is done using quite recent zig 0.10.x builds. Build and run (from /compiler): <code>$ zig build run -- --help </code> or (e.g.) for installation on Unix-like systems (from /compiler): <code>$ zig build -Drelease-safe --prefix /usr/local </code> Run tests for libdaya (from /libdaya): <code>$ zig build test </code> Components / inner workings The system is split into the following components: * Compiler library (/libdaya) - the core compiler, can be linked into e.g compiler exe, web service, and possibly in the end as WASM to make the web frontend standalone. * Compiler executable (/compiler) * Web service (not started) * Web frontend (not started) Compiler The main logic of the daya-compiler is organized as a library located under /libdaya. Then there's a simple executable-wrapper located under /compiler. libdaya The core component of it all. Provides functionaly to parse .daya, validate the results, output valid .dot + eventually directly execute system-installed dot to generate a graphical representation of the diagram. Service / backend Two parts: 1. An endpoint which takes daya and returns dot, PNG or SVG. 1. Provider of the static frontend Frontend Minimal, single-page, input-form to provide daya data and desired output-format (dot, png, svg). Web component for easy inclusion into sites ... Design goals <ul> <li>Overall:<ul> <li>Value rapidness and sensical defaults over exact control</li> </ul> </li> <li>Internals:<ul> <li>Reproducible builds - as far as possible, ie.: up until dot</li> <li>If the compiler hasn't complained, then dot shall succeed. ie.: if the compiler hasn't detected an error, then the intermediary dot-data shall be valid.</li> </ul> </li> </ul> TODO <ul> <li>Integrate dot / libdot statically linked<ul> <li>including libs for png and svg?</li> </ul> </li> <li>Ensure all include-paths are relative to the containing file.</li> <li>Currently a lot of the defaults is handled within dot.zig - this is error-prone if we were to change graphing-backend</li> <li>Support lifting notes to top level of generated doc? E.g. now, if added to an instance wihtin a group, the note also gets rendered within the same group</li> <li>Support multiple files as input (glob?) + a parameter to specify output-format, which will reuse the respective input-names with added extension for output</li> <li>Design and implement scoping strategy</li> <li>Support monitor/auto-build?</li> <li>.daya<ul> <li>TBD: Implement more advanced (composed) shapes? E.g. an UML-like class with sections?</li> <li>Include-functionality:</li> <li>Need to explore specific use cases to determine full functionality set here. Leaves as-is for now (in-place + common global scope).</li> <li>Reconsider scoping to avoid unwanted collisions between subdiagrams + but still accommodate convenient definition-reuse.</li> <li>Explicitly define behaviour wrt duplicate definitions; shall the latter be invalid behaviour, or shall they be fused? Either simply adding children, or explicitly checking for type and override values.</li> <li>Simplify syntax: allow } as EOS. Don't require quotes around #-colors. Consider removing ; alltogether. Nl can serve the same purpose.</li> </ul> </li> <li>Finish v1 daya-syntax: what is scope?<ul> <li>Ensure compilator supports entire daya-syntax</li> </ul> </li> <li>Lower importance:<ul> <li>Implement web service</li> <li>Implement frontend</li> </ul> </li> <li>Nice-to-haves:<ul> <li>Accept a list of "instantiations" to only render whatever relates to them. Accept "degrees of separation" as well?</li> <li>Support "playback"-functionality? Render node-by-node as they are instantiated, ordered by source?</li> <li>Mode to allow anonymous types? E.g. don't require predefined nodes/edges, more simular to how dot behaves.</li> <li>Allow edges to specify valid source/target-node types?</li> </ul> </li> </ul> Attributions <ul> <li>graphviz - daya currently uses graphviz/dot as the low level graph tool</li> </ul>
[]
https://avatars.githubusercontent.com/u/52030888?v=4
ts
onyxlang/ts
2019-09-18T20:39:36Z
An Onyx compiler implementation in Typescript
master
8
7
0
7
https://api.github.com/repos/onyxlang/ts/tags
MIT
[ "compiler", "deno", "onyx", "zig" ]
109
false
2023-01-29T21:43:51Z
false
false
unknown
github
[]
Onyx <em>Enjoy the performance.</em> 👋 About Onyx is a fresh programming language with efficiency in mind. This repository contains the reference Onyx compiler implementation. Brief history Ever had that feeling of creating a game, but then remembering how painful it is to write in C++? Any other language doesn't seem just the right tool? Want something new? The first idea of Onyx came to me in 2020, at the very peak of my Open Source career. Coming all the way from Warcraft® III™ map editor to Crystal, I am still struggling to find the most comfortable language for daily use. What I want is a language which I would consider perfect. A language with a perfectly built ecosystem and organization. A language with infinite possibilities. ✨ Features Formally speaking, Onyx is an inference-typed imperative multiparadigmal computer programming language. Onyx is inspired by <a>Typescript</a>, therefore comparing it would be enough for a brief introduction. First of all, Onyx is designed to be compiled to native machine code, still allowed to be evaluated dynamically. A Typescript bytecode compiler is hard to implement due to its dependence on EcmaScript, at least for version 4.5.4. Native compilation paves a way to directly interact with a lower-level language in form of <a>FFI</a>. This immediately makes Onyx a higher-level language, the concept of which is defined in the form of multiple safety levels: <code>unsafe</code>, <code>fragile</code>, <code>threadsafe</code>. <code>nx extern #include "stdio.h" unsafe! $puts($"Hello, world!") # The string has inferred type `` $`const char`* ``, # mapped to the C `const char*` type</code> The code snippet above would be an error without <code>unsafe!</code> because the top-level scope has <code>fragile</code> safety by default (can be changed per compilation). Another powerful feature of Onyx is macros, which are evaluated during compilation. The ultimate goal is to write macros in the Onyx language itself. ```nx %{ # You're inside an Onyx macro. # console.log("Debug = #{ $DEBUG }") # Would output the C macro during compilation [("roses", "blue"), ("violets", "red")].map((pair) =&gt; { emit("unsafe! $puts($\"#{ pair[0] } are #{ pair[1] })\"") }) %} Would be compiled exactly as: unsafe! $puts($"Roses are blue") unsafe! $puts($"Violets are red") ``` Onyx encourages the use of exact typing when you need to, e.g. <code>Real</code> over <code>Float</code> over <code>Float&lt;64&gt;</code>. The type system covers, among others, tensor and hypercomplex number literals and operations. Generally, Onyx doesn't look at EcmaScript in terms of standard types. <code>[1, 2] : Int32[2] : Array&lt;Int32, 2&gt;</code> is, for example, a static array of fixed size, not a dynamic list. The <code>struct</code> type in Onyx resembles a pure passed-by-value data structure. A <code>class</code> type data is an automatically-managed reference to a non-static memory, similar to such in Typescript. There is no <code>interface</code> type in Onyx, but <code>trait</code>, which allows exclusively function declarations <em>and</em> definitions. Unlike Typescript, there are no <code>async</code> and <code>await</code> keywords on the language level. Instead, <em>any</em> function may be called asynchronously with a scheduler of your choice (or the standard one). The will to make Onyx a compile-able language imposes some restrictions, of course, compared to Typescript. For example, a lambda has explicit closure. ```nx import Scheduler from "std/scheduler.nx" import { Mutex } from "std/threading.nx" final list = new List() final mutex = new Mutex() final promise = Scheduler.parallel(<a>list</a> ~&gt; { # The context here is implicitly <code>threadsafe</code>. # # list.push(42) # =&gt; Panic! Can't call <code>fragile List&lt;Int32&gt;::push</code> # from within a threadsafe context! mutex.sync(() =&gt; list.push(42)) # OK, the access is synchronized, # <code>Mutex::sync</code> call is threadsafe }) ``` These are just a few of the differences when compared to Typescript. Further documentation to come! 🚧 Development A <em>stage</em> is defined by the a set of rules in no particular order. Currently, the compiler is at the <strong>stage I</strong> implementation effort. Stage I: ⬅️ <ol> <li>Compiler logic (i.e. <em>frontend</em>) is written in <a>Typescript</a>, utilizing <a>Peggyjs</a>.</li> <li><a>Zig</a> is used as the <em>backend</em>: Onyx source code is translated to Zig source code.</li> <li>Host machine is expected to have Zig installed on it.</li> <li><a>Deno</a> is assumed the development environment.</li> <li>Development speed &gt; runtime performance &gt; correctness.<ol> <li>Macros are not implemented.</li> <li>Panics are shallow and incomplete.</li> </ol> </li> <li>May assume that target is a mainstream Windows, Linux or MacOS machine.</li> <li>Target may rely on Zig standard library.</li> </ol> Stage II: <ol> <li>Compiler logic (i.e. <em>frontend</em>) is written in Onyx.</li> <li><a>Zig</a> is used as the <em>backend</em>: Onyx source code is translated to Zig source code.</li> <li>Host machine is expected to have Zig installed on it.</li> <li>Development speed &gt; correctness &gt; runtime performance.<ol> <li>Macros are not implemented.</li> </ol> </li> <li>May assume that target is a mainstream Windows, Linux or MacOS machine.</li> <li>Target may rely on Zig standard library.</li> </ol> Stage III: <ol> <li>Compiler logic (i.e. <em>frontend</em>) is written in Onyx.</li> <li><a>Zig</a> is used as the <em>backend</em>: Onyx source code is translated to Zig source code internally.</li> <li><em>(Extraneous)</em> Host machine is expected to have Zig installed on it.[^1]</li> <li>Correctness &gt; development speed &gt; runtime performance.</li> <li>Target may rely on Zig standard library.</li> </ol> [^1]: By that time Zig could become linkable as a static library. Stage IV: <ol> <li>Compiler is written in Onyx.</li> <li>Correctness &gt; (developer happiness = runtime performance).</li> </ol> 📜 License Any contribution to this repository is MIT licensed in accordance to <a>GitHub ToS § 6</a>.
[]
https://avatars.githubusercontent.com/u/4605603?v=4
zstack
tiehuis/zstack
2019-06-16T09:47:24Z
Line-race tetris mode in Zig
master
0
5
1
5
https://api.github.com/repos/tiehuis/zstack/tags
MIT
[ "zig" ]
1,078
false
2024-06-19T11:44:18Z
true
false
unknown
github
[]
Line-race mode tetris variant. <code>zig build ./zstack </code> See src/config.zig for available options. There are two graphics backends available, SDL and OpenGL. OpenGL is used by default, to use SDL, build with <code>zig build -Duse-sdl2=true </code>
[]
https://avatars.githubusercontent.com/u/380158?v=4
zig-mimetypes
frmdstryr/zig-mimetypes
2019-12-20T21:46:14Z
A mimetypes module for Zig
master
0
5
0
5
https://api.github.com/repos/frmdstryr/zig-mimetypes/tags
MIT
[ "zig" ]
28
false
2022-03-23T07:55:34Z
true
false
unknown
github
[]
Zig Mimetypes <a></a> <a></a> A mimetype module for Zig. Usage ```zig const mimetypes = @import("mimetypes.zig"); var registry = mimetypes.Registry.init(std.heap.page_allocator); defer registry.deinit(); try registry.load(); if (registry.getTypeFromFilename("wavascript.js")) |mime_type| { assert(mem.eql(u8, mime_type, "application/javascript")); } ``` <blockquote> Note: It currently does not support Windows </blockquote>
[]
https://avatars.githubusercontent.com/u/5253988?v=4
druzhba
yvt/druzhba
2019-07-09T14:53:43Z
Experimental statically-composed component framework written in Zig
master
0
5
0
5
https://api.github.com/repos/yvt/druzhba/tags
Apache-2.0
[ "component-based", "zig" ]
39
false
2022-12-21T13:46:26Z
true
false
unknown
github
[]
Druzhba [ˈdruʐbə] with a rolled R An experimental statically-composed toy component framework written in <a>Zig</a>. ```zig const druzhba = @import("druzhba"); const Counter = @import("components.zig").Counter; const addApp = @import("components.zig").addApp; fn addSystem(comptime ctx: *druzhba.ComposeCtx) void { // Instantiate a cell (the smallest unit of encapsulation and message passing) const counter = ctx.new(Counter).withAttr(100); const counter_in_count = counter.in("count"); <code>// Instantiate a subsystem const app = addApp(ctx); // Wire things up ctx.connect(app.out_count, counter_in_count); ctx.entry(app.in_main); </code> } // Realize the system const System = druzhba.Compose(addSystem); var system_state: System.State() = undefined; // → RAM const system = comptime System.link(&amp;system_state); // → ROM pub fn main() !void { // Initialize the system and call the entry point (<code>app.in_main.main</code>) system.init(); system.invoke("main"); } ``` Usage <strong>To run the example app</strong>: <code>zig build run</code> <strong>To use it in your application</strong>: Since Zig <a>doesn't have a package manager yet</a>, import this repository as a Git submodule. Add <code>exe.addPackagePath("druzhba", "path/to/druzhba.zig")</code> to your <code>build.zig</code>. What is this? Statically-composed component framework <blockquote> “[Component-based software engineering (CBSE)] is a reuse-based approach to defining, implementing and composing loosely coupled independent components into systems.” — <a>Component-based software engineering - Wikipedia</a> </blockquote> Component-based development is realized with the help of a software framework such as AUTOSAR, COM, and JavaBeans. Traditionally, they have been designed for run-time composition of components, meaning components and connections between them are constructed at run-time. For systems that don't change at run-time, this is an unnecessary overhead — it increases the system boot time, reduces the opportunity for compiler optimization, defers error checks, prevents the use of ROM (which is more abundant than RAM in microcontrollers), reduces the system security, and makes memory consumption harder to predict. Statically-composed component frameworks are designed to address this problem. Components are instantiated based on a system description provided in a format the framework can process without a run-time knowledge. Their memory layouts are statically determined, and method calls between components are realized as direct function calls (when possible), only leaving run-time data that is absolutely necessary. There are <a>a few academic</a> focusing on such frameworks, showing their benefits for real-time and/or embedded systems. Zig <a>Zig</a> is a system programming language with a powerful compile-time reflection and evaluation feature. One possible way to explain it is that Zig is a fresh take on C/C++ metaprogramming — it provides access to low-level memory operations (including unsafe ones) like C/C++ do, but instead of C's lexical macros and C++'s template metaprogramming as well as gazillions of its retrofitted features, Zig offers a simple yet powerful feature set for metaprogramming that does the same or better job. This project (ab)uses it to create a statically-composed component framework. I did not choose Rust for this project because it would not be interesting. Rust is much limited on regard to metaprogramming. Macros in Rust are just macros after all and do not have access to the information outside the locations where they are used. A build script could be used to generate code, but it lacks novelty as it is no different from what existing solutions do. Furthermore, whichever way I choose, I would have to implement its own module resolution system when the language already has one. Style guide Naming convention (preliminary) <ul> <li><code>PascalCase</code> for signatures (constructed by <code>druzhba.defineSig(struct { ... })</code>, having type <code>druzhba.Sig</code>)<ul> <li><code>Sig != type</code>, so this is different from <a>the standard naming convention</a>.</li> </ul> </li> <li><code>PascalCase</code> for classes (constructed by <code>druzhba.defineClass().build()</code>, having type <code>druzhba.Class</code>)<ul> <li>Ditto.</li> </ul> </li> <li><code>addPascalCase</code> for subsystems (functions receiving <code>comptime ctx: *druzhba.ComposeCtx</code>)</li> </ul> This does not apply to the internal implementation of this library. License This project is dual-licensed under the Apache License Version 2.0 and the MIT License.
[]
https://avatars.githubusercontent.com/u/1327032?v=4
zig-editor-core
GoNZooo/zig-editor-core
2019-11-13T08:45:45Z
Eventually the core of an editor, interactive shell put on top.
master
0
5
0
5
https://api.github.com/repos/GoNZooo/zig-editor-core/tags
-
[ "editor", "vim", "zig", "zig-package", "ziglang" ]
482
false
2023-09-02T23:14:58Z
true
false
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/5175499?v=4
h264_dump
mattyhall/h264_dump
2019-11-23T20:39:35Z
A tool for debugging h264 files written in Zig
master
0
4
0
4
https://api.github.com/repos/mattyhall/h264_dump/tags
-
[ "h264", "zig" ]
514
false
2023-05-25T13:04:55Z
true
false
unknown
github
[]
h264_dump Dump the NAL units of a .264 file. Should have a similar output to the ffmpeg command: <code>ffmpeg -i &lt;file&gt; -c copy -bsf:v trace_headers -f null - 2&gt;&amp;1</code>
[]
https://avatars.githubusercontent.com/u/3768010?v=4
zig-wyhash
ManDeJan/zig-wyhash
2019-04-10T13:41:00Z
Zig implementation of https://github.com/wangyi-fudan/wyhash
master
1
4
1
4
https://api.github.com/repos/ManDeJan/zig-wyhash/tags
Unlicense
[ "hash", "wyhash", "zig" ]
16
false
2021-12-03T18:48:42Z
true
false
unknown
github
[]
zig-wyhash What is this I build this library to learn the Zig programming language. My implementation is adapted from https://github.com/wangyi-fudan/wyhash and https://github.com/eldruin/wyhash-rs. I have not benchmarked my implementation and do not know how it performs compared to the C/C++ or Rust implementation, this is something that I would like to do in the future. There are also no tests, once I figure out how to test I'll add tests. I am currently not recommending this code for production use. Feel free to suggest improvements or make pull requests. The project is licensed under The Unlicense so feel free to use or modify it however you like &lt;3.
[]
https://avatars.githubusercontent.com/u/11783095?v=4
zig_kernel_module
nrdmn/zig_kernel_module
2019-06-02T12:18:05Z
A 'hello world' linux kernel module in Zig
master
0
4
0
4
https://api.github.com/repos/nrdmn/zig_kernel_module/tags
-
[ "kernel", "linux", "zig" ]
2
false
2023-01-28T12:15:18Z
false
false
unknown
github
[]
Zig Kernel Module This is a 'hello world' kernel module in <a>Zig</a>. <ol> <li>Build with <code>make</code>.</li> <li>Try it: <code>$ sudo insmod my_module.ko $ sudo rmmod my_module.ko $ dmesg | tail -2 [90804.834449] hello [90806.285959] bye</code></li> </ol>
[]
https://avatars.githubusercontent.com/u/396420?v=4
kate-highlight-zig
ElementW/kate-highlight-zig
2019-12-21T12:11:45Z
Kate syntax highlighting for Zig
master
0
4
1
4
https://api.github.com/repos/ElementW/kate-highlight-zig/tags
-
[ "kate-editor", "kate-syntax", "syntax-highlighting", "zig", "ziglang" ]
12
false
2024-07-30T02:55:25Z
false
false
unknown
github
[]
Zig syntax highlighting for Kate Based on default C syntax highlight rules. No, this won't be committed upstream. See <a>my comment on KDE Invent for why</a>. Installing Drop <code>zig.xml</code> into <code>~/.local/share/org.kde.syntax-highlighting/syntax/</code> for user install, or in <code>/usr/share/org.kde.syntax-highlighting/syntax/</code> for system-wide install.
[]
https://avatars.githubusercontent.com/u/6687211?v=4
compute_graph
adam-r-kowalski/compute_graph
2019-12-04T17:27:59Z
null
master
3
3
0
3
https://api.github.com/repos/adam-r-kowalski/compute_graph/tags
-
[ "deep-learning", "differentiable-programming", "machine-learning", "tensors", "zig" ]
1,118
false
2023-05-03T22:55:31Z
true
false
unknown
github
[]
compute_graph
[]
https://avatars.githubusercontent.com/u/28556218?v=4
zig-termbox
joachimschmidt557/zig-termbox
2020-01-30T13:48:36Z
A termbox implementation in zig
master
0
3
1
3
https://api.github.com/repos/joachimschmidt557/zig-termbox/tags
MIT
[ "zig", "zig-package" ]
68
false
2025-04-04T18:07:52Z
true
true
unknown
github
[ { "commit": "master", "name": "wcwidth", "tar_url": "https://github.com/joachimschmidt557/zig-wcwidth/archive/master.tar.gz", "type": "remote", "url": "https://github.com/joachimschmidt557/zig-wcwidth" }, { "commit": "master", "name": "ansi_term", "tar_url": "https://github.com/ziglibs/ansi_term/archive/master.tar.gz", "type": "remote", "url": "https://github.com/ziglibs/ansi_term" } ]
zig-termbox termbox-inspired library for creating terminal user interfaces Works with Zig 0.14.0. Concepts <code>termbox</code> is a <em>double-buffered</em> terminal library. This means that when you call functions to draw on the screen, you are not actually sending data to the terminal, but instead act on an intermediate data structure called the <em>back buffer</em>. Only when you call <code>Termbox.present</code>, the terminal is actually updated to reflect the state of the <em>back buffer</em>. An advantage of this design is that repeated calls to <code>Termbox.present</code> only update the parts of the terminal interface that have actually changed since the last call. <code>termbox</code> achieves this by tracking the current state of the terminal in the internal <em>front buffer</em>. Examples ```zig const std = @import("std"); const termbox = @import("termbox"); const Termbox = termbox.Termbox; pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); const allocator = gpa.allocator(); <code>var t = try Termbox.init(allocator); defer t.shutdown() catch {}; var anchor = t.back_buffer.anchor(1, 1); try anchor.writer().print("Hello {s}!", .{"World"}); anchor.move(1, 2); try anchor.writer().print("Press any key to quit", .{}); try t.present(); _ = try t.pollEvent(); </code> } ``` Further examples can be found in the <code>examples</code> subdirectory.
[]
https://avatars.githubusercontent.com/u/2389051?v=4
zig-hash-map-bench
squeek502/zig-hash-map-bench
2019-06-06T06:19:49Z
Benchmarks for Zig's std.HashMap
master
0
3
1
3
https://api.github.com/repos/squeek502/zig-hash-map-bench/tags
Unlicense
[ "benchmark", "hash-map", "zig" ]
5
false
2023-10-15T09:30:50Z
false
false
unknown
github
[]
zig-hash-map-bench Benchmarks for <a>Zig</a>'s <code>std.HashMap</code>. Will be expanded on in the future. Based loosely on some of the benchmarking of C++ hash map implementations here: - https://probablydance.com/2017/02/26/i-wrote-the-fastest-hashtable/ - https://tessil.github.io/2016/08/29/benchmark-hopscotch-map.html - https://martin.ankerl.com/2019/04/01/hashmap-benchmarks-01-overview/ - https://github.com/ktprime/emhash#other-benchmark Running Insertion without ensureCapacity: <code>zig run insert.zig -OReleaseFast -lc</code> <code>zig run insert-strings.zig -OReleaseFast -lc</code> Output will be in the format: <code>num_elements,nanoseconds_per_element 1,68 2,40 3,32 5,25 7,21 10,19 ...</code>
[]
https://avatars.githubusercontent.com/u/1348560?v=4
sublime-zig
Tetralux/sublime-zig
2019-08-06T23:20:42Z
My own, more lightweight, syntax highlighting for the Zig Programming Language.
master
0
3
1
3
https://api.github.com/repos/Tetralux/sublime-zig/tags
MIT
[ "basic", "highlighting", "language", "lightweight", "programming", "sublime", "syntax", "zig" ]
38
false
2023-06-14T04:18:56Z
false
false
unknown
github
[]
sublime-zig My own, more lightweight, syntax highlighting for the Zig Programming Language.
[]
https://avatars.githubusercontent.com/u/1327032?v=4
gotyno
GoNZooo/gotyno
2020-01-06T11:51:51Z
A type definition language and type compiler that generates type definitions and validation functions for them in different languages.
master
0
3
0
3
https://api.github.com/repos/GoNZooo/gotyno/tags
-
[ "type-definitions", "typescript", "zig" ]
382
false
2022-06-28T19:18:02Z
true
false
unknown
github
[]
gotyno A type definition language that outputs definitions and validation functions in different languages (eventually). Other version <strong>Active development of this project has continued in a different implementation:</strong> <a>gotyno-hs</a> The reason for this, initially, was that I wanted to re-implement this in Haskell and see how it'd turn out. The result was that adding things like "compile on modification" was a lot easier, so the primary repository for the compiler is now switched over. Features/fixes currently missing from this implementation <ul> <li>Compile on modification / Watch mode</li> <li>"Declarations" (references to external data definitions)</li> <li>{U,I}{64,128} typed as bigints &amp; encoded/decoded as strings</li> <li>Python output</li> </ul> If you don't need any of the above, this repo should be as good to use as it was before. I do still recommend switching to <code>gotyno-hs</code>, since it's a lot more active. I may backport some/all of the above features, but I can't promise that it'll be done soon or at all. Supported languages <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> TypeScript <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> F# <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> OCaml <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> Haskell <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> PureScript <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 (partial support) <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> Zig TypeScript example <a>basic.gotyno</a> has an example of some types being defined and <a>basic.ts</a> is the automatically generated TypeScript output from this file. Behind the scenes it's using a validation library I wrote for validating <code>unknown</code> values (for the most part against given interface definitions). F# example <a>basic.gotyno</a> has an example of some types being defined and <a>basic.fs</a> is the automatically generated F# output from this file. The F# version uses <code>Thoth</code> for JSON decoding, as well as an additional extension library to it for some custom decoding helpers that I wrote. The Language All supported type names are uppercase and type definitions currently are enforced as such as well. Annotations/Types <ul> <li><code>?TypeName</code> signifies an optional type.</li> <li><code>*TypeName</code> signifies a pointer to that type. In languages where pointers are hidden from the user this may not be visible in types generated for it.</li> <li><code>[]TypeName</code> signifies a sequence of several <code>TypeName</code> with a length known at run-time, whereas <code>[N]TypeName</code> signifies a sequence of several <code>TypeName</code> with a known and enforced length at compile-time. Some languages may or may not have the latter concept and will use only the former for code generation.</li> <li><code>TypeName&lt;OtherTypeName&gt;</code> signifies an application of a generic type, such that whatever type variable <code>TypeName</code> takes in its definition is filled in with <code>OtherTypeName</code> in this specific instance.</li> <li>Conversely, <code>struct/union TypeName &lt;T&gt;{ ... }</code> is how one defines a type that takes a type parameter. The <code>&lt;T&gt;</code> part is seen here to take and provide a type <code>T</code> for the adjacent scope, hence its position in the syntax.</li> <li>The type <code>"SomeValue"</code> signifies a literal string of that value and can be used very effectively in TypeScript.</li> <li>The unsigned integer type is the same, but for integers. It's debatable whether this is useful to have.</li> </ul> Structs ```gotyno struct Recruiter { name: String } struct Person { name: String age: U8 efficiency: F32 on_vacation: Boolean hobbies: []String last_fifteen_comments: [15]String recruiter: ?Recruiter spouse: Maybe } struct Generic { field: T other_field: OtherType } ``` Enums <code>gotyno enum Colors { red = "FF0000" green = "00FF00" blue = "0000FF" }</code> Unions Tagged ```gotyno union InteractionEvent { Click: Coordinates KeyPress: KeyCode Focus: *Element } union Option { None Some: T } union Result{ Error: E Ok: T } ``` Untagged Sometimes a union that carries no extra tags is required, though usually these will have to be identified less automatically, perhaps via custom tags in their respective payload: ```gotyno struct SomeType { type: "SomeType" some_field: F32 some_other_field: ?String } struct SomeOtherType { type: "SomeOtherType" active: Boolean some_other_field: ?String } untagged union Possible { SomeType SomeOtherType String } ``` In TypeScript, for example, the correct type guard and validator for this untagged union will be generated, and the literal string fields can still be used for identifying which type one has. Setting the tag key and embedding it in payload structures The above can also be accomplished by setting the tag key to be embedded in options passed to the <code>union</code> keyword (we can also set which key is used): ```gotyno struct SomeType { some_field: F32 some_other_field: ?String } struct SomeOtherType { active: Boolean some_other_field: ?String } union(tag = type_tag, embedded) Possible { FirstConstructor: SomeType SecondConstructor: SomeOtherType } ``` This effectively will create a structure where we get the field <code>type_tag</code> embedded in the payload structures (<code>SomeType</code> &amp; <code>SomeOtherType</code>) with the values <code>"FirstConstructor"</code> and <code>"SecondConstructor"</code> respectively. Note that in order to embed a type key we obviously need the payload (if present) to be a structure type, otherwise we have no fields to merge the type tag field into. Both checks for existence of the referenced payload types and checks that they are structures are done during compilation. Note about MacOS releases Cross-compilation from Linux/Windows doesn't yet work for MacOS so sadly I have to recommend just downloading a current release of Zig and compiling via: <code>bash zig build -Drelease-fast</code> And running: ```bash ./zig-cache/bin/gotyno --verbose --typescript = --fsharp = inputFile.gotyno or ./zig-cache/bin/gotyno -v -ts = -fs = inputFile.gotyno ``` Optionally you can also specify a different output directory after <code>-ts</code>/<code>--typescript</code>: ```bash $ ./zig-cache/bin/gotyno --verbose --typescript other/directory/ts --fsharp other/directory/fs inputFile.gotyno or $ ./zig-cache/bin/gotyno -v -ts other/directory/ts -fs other/directory/fs inputFile.gotyno ``` The output files for TypeScript/F# output will then be written in that directory, still with the same module names as the input file.
[]
https://avatars.githubusercontent.com/u/18158656?v=4
zb2b
yvern/zb2b
2019-04-20T17:54:26Z
A cli/interactive number base converter. A toy made while learning Zig.
master
0
3
0
3
https://api.github.com/repos/yvern/zb2b/tags
-
[ "zig" ]
4
false
2023-11-12T11:45:40Z
false
false
unknown
github
[]
zb2b A cli/interactive number base converter. A toy made while learning Zig. <a>Zig</a> is quite lower-level than languages I am used to, but it still felt quite simple most of the time. There are 2 usage modes: * Direct/cli mode, where you expect to convert only one value, as in <code>echo 1001 | ./zb2b 2 10</code>, which outputs <code>9</code>. * Interactive mode, where you can keep converting values, as in <code>bash $ ./zb2b 10 2 $ 33 = 100001 $ 99 = 1100011 $ = bye bye!</code>
[]
https://avatars.githubusercontent.com/u/46252311?v=4
zig-reload
deingithub/zig-reload
2020-01-16T14:57:14Z
proof of concept shared library code reloading with zig
master
0
2
0
2
https://api.github.com/repos/deingithub/zig-reload/tags
-
[ "zig" ]
4
false
2022-02-16T07:36:53Z
true
false
unknown
github
[]
zig-reload Based around the idea of <a>this</a>, this is a proof-of-concept for code swapping using zig. Accordingly ugly. Depends on a POSIX libc with inotify support. To run, first start the main program with <code>zig build; cd zig-cache/bin; ./run</code>, then edit the function <code>do_the_thing</code> in libreload.zig and rebuild the project using <code>zig build</code>. If everything works out, the program will reload the library and run the new function.
[]
https://avatars.githubusercontent.com/u/4459413?v=4
zig-robotstxt
mstroecker/zig-robotstxt
2019-09-02T21:30:45Z
Lightweight docker image for serving a disallow robots.txt file using the zig programming language.
master
1
2
1
2
https://api.github.com/repos/mstroecker/zig-robotstxt/tags
MIT
[ "disallow-robots", "docker", "robots", "zig", "zig-programming-language", "ziglang" ]
20
false
2022-02-20T22:42:15Z
true
false
unknown
github
[]
Zig robots.txt Docker image <a></a> <a></a> <a></a> This project implements a small(5.7 KB) and lightweight http-server, just serving a disallow-robots.txt file using the Zig programming language(https://ziglang.org/). Run using docker run: <code>bash docker run -p 80:8080 mstroecker/zig-robotstxt</code> Kubernetes Example Kubernetes configuration example: ```yaml apiVersion: v1 kind: Namespace metadata: name: myservice apiVersion: v1 kind: Service metadata: name: robotstxt namespace: myservice spec: type: LoadBalancer ports: - port: 81 targetPort: http name: http selector: app: robotstxt apiVersion: apps/v1 kind: Deployment metadata: name: robotstxt namespace: myservice spec: replicas: 3 selector: matchLabels: app: robotstxt template: metadata: labels: app: robotstxt spec: containers: - name: robotstxt image: mstroecker/zig-robotstxt ports: - containerPort: 8080 name: http apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: robotstxt namespace: myservice spec: rules: - host: localhost http: paths: - path: /robots.txt backend: serviceName: robotstxt servicePort: http ``` Docker Compose Example Compose configuration example with traefik: ```yaml version: '3' services: traefik: image: traefik:1.7 command: - "--docker" - "--docker.watch=true" ports: - "80:80" labels: traefik.enable: 'false' volumes: - /var/run/docker.sock:/var/run/docker.sock:ro robotstxt: image: mstroecker/zig-robotstxt labels: - "traefik.port=8080" - "traefik.robotstxt.frontend.rule=Host:localhost;Path:/robots.txt" ``` Result message: ```http HTTP/1.1 200 OK Content-Length: 26 User-agent: * Disallow: / ```
[]
https://avatars.githubusercontent.com/u/1327032?v=4
zig-humantime
GoNZooo/zig-humantime
2019-08-07T14:41:51Z
Mini library for expressing integer time values in more human readable ways
master
0
2
0
2
https://api.github.com/repos/GoNZooo/zig-humantime/tags
MIT
[ "zig", "zig-package" ]
8
false
2021-09-23T09:52:12Z
true
false
unknown
github
[]
zig-humantime This library exports two functions to convert human readable time strings into integer values: ```zig test "1h2m3s" { const time = comptime seconds("1h2m3s"); // @compileLog(time) -&gt; 7446 testing.expectEqual(time, 3723); } test "2h4m6s" { const time = comptime seconds("2h4m6s"); testing.expectEqual(time, (3600 * 2) + (4 * 60) + 6); } test "1h2m3s in milliseconds" { const format_string = "1h2m3s"; const time = milliseconds(format_string); // @compileLog(time) -&gt; runtime value testing.expectEqual(time, comptime seconds(format_string) * 1000); } test "5d4h3m2s" { testing.expectEqual(seconds("5d4h3m2s"), 446582); } ```
[]
https://avatars.githubusercontent.com/u/17973728?v=4
language-zig
GrayJack/language-zig
2019-11-27T04:31:28Z
Atom package for Zig programming language
master
1
2
0
2
https://api.github.com/repos/GrayJack/language-zig/tags
MIT
[ "atom", "atom-editor", "atom-package", "atom-plugin", "zig", "ziglang" ]
16
false
2021-09-23T09:52:53Z
false
false
unknown
github
[]
language-zig Atom package for Zig programming language
[]
https://avatars.githubusercontent.com/u/7064?v=4
zigwasm
whatupdave/zigwasm
2019-06-16T04:47:48Z
Trying out game development in zig targeting the web
master
13
2
0
2
https://api.github.com/repos/whatupdave/zigwasm/tags
-
[ "gamedev", "zig" ]
3,900
false
2023-06-13T19:06:45Z
true
false
unknown
github
[]
zig + wasm Experimenting with zig web game development. Check out its majesty: https://whatupdave.github.io/zigwasm/ Run In one tab run zig compiler on watch: <code>$ fswatch src/main.zig | while read f; do clear; zig build install --prefix web &amp;&amp; echo $(date); done</code> In another tab start parcel to build web: <code>$ yarn start</code> The game should now be running at http://localhost:1234 and will auto reload if zig or javascript changes.
[]
https://avatars.githubusercontent.com/u/48141240?v=4
benchmark.unicode
mikdusan/benchmark.unicode
2019-03-26T22:50:31Z
A command-line tool written in Zig to measure the performance of various UTF8 decoders.
master
0
2
0
2
https://api.github.com/repos/mikdusan/benchmark.unicode/tags
MIT
[ "benchmark", "zig" ]
7,231
false
2022-03-23T07:56:43Z
true
false
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/23638589?v=4
aoc
lewis-weinberger/aoc
2019-12-08T15:45:02Z
Advent of Code
master
0
2
1
2
https://api.github.com/repos/lewis-weinberger/aoc/tags
MIT
[ "advent-of-code", "advent-of-code-2019", "advent-of-code-2020", "c", "factor", "golang", "iolanguage", "nim", "rust", "scheme", "zig" ]
233
false
2022-12-14T23:09:23Z
false
false
unknown
github
[]
<a></a> <a></a> <a></a> <a></a> Attempts at some of the <a>Advent of Code</a> problems in a variety of languages. Usage See <a>2019</a>, <a>2020</a>, <a>2021</a> or <a>2022</a> for detailed installation instructions. Solutions can be run with the <a>aoc</a> shell script, e.g.: <code>sh ./aoc 2020 1 zig d1.txt # 2020 day 1 in zig using puzzle input d1.txt</code> For more info try <code>./aoc</code> without any arguments. License <a>MIT</a>
[]
https://avatars.githubusercontent.com/u/4605603?v=4
advent-of-code-2019
tiehuis/advent-of-code-2019
2019-12-03T09:50:54Z
https://adventofcode.com/2019
master
0
1
1
1
https://api.github.com/repos/tiehuis/advent-of-code-2019/tags
-
[ "advent-of-code-2019", "zig" ]
45
false
2022-08-21T18:15:28Z
false
false
unknown
github
[]
All solutions are self-contained and contain the appropriate input. <code>zig run 1_1.zig</code>
[]
https://avatars.githubusercontent.com/u/28556218?v=4
zigfd
joachimschmidt557/zigfd
2019-06-07T21:25:11Z
[WIP] Recursively find files and directories with a regex pattern
master
0
1
0
1
https://api.github.com/repos/joachimschmidt557/zigfd/tags
MIT
[ "zig" ]
116
false
2022-03-23T07:52:58Z
true
true
unknown
github
[ { "commit": "2cfabf04872ce334fd1f2cd392fda8a4fab68663.tar.gz", "name": "lscolors", "tar_url": "https://github.com/ziglibs/lscolors/archive/2cfabf04872ce334fd1f2cd392fda8a4fab68663.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/ziglibs/lscolors" }, { "commit": "c9190dbfc34d5dbe449bcd2146bfd5649d3fe362.tar.gz", "name": "walkdir", "tar_url": "https://github.com/joachimschmidt557/zig-walkdir/archive/c9190dbfc34d5dbe449bcd2146bfd5649d3fe362.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/joachimschmidt557/zig-walkdir" }, { "commit": "05a50fe7fe833059db8550c34bc69fedd8bb0af8.tar.gz", "name": "clap", "tar_url": "https://github.com/Hejsil/zig-clap/archive/05a50fe7fe833059db8550c34bc69fedd8bb0af8.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/Hejsil/zig-clap" }, { "commit": "70afaabdf372de130f7d22a1d9000e99ef3ff9b9.tar.gz", "name": "regex", "tar_url": "https://github.com/tiehuis/zig-regex/archive/70afaabdf372de130f7d22a1d9000e99ef3ff9b9.tar.gz.tar.gz", "type": "remote", "url": "https://github.com/tiehuis/zig-regex" } ]
zigfd Recursively find files and directories with a regex pattern. Inspired by <a>fd</a>. 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> Ability to ignore files (needed in <code>zig-walkdir</code>) <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> Execution of commands to run on search results <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> Case (in)sensitive searches <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> Exclude entries <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> Follow symlinks <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> Glob search Dependencies Until <code>zig</code> has a package manager, this project will use Git submodules to manage dependencies. <ul> <li><a>zig-walkdir</a></li> <li><a>zig-regex</a></li> <li><a>zig-lscolors</a></li> <li><a>zig-clap</a></li> </ul> Installation <code>shell $ git clone --recurse-submodules https://github.com/joachimschmidt557/zigfd $ cd zigfd $ zig build</code> Command-line options <code>-h, --help Display this help and exit. -v, --version Display version info and exit. -H, --hidden Include hidden files and directories -p, --full-path Match the pattern against the full path instead of the file name -0, --print0 Separate search results with a null character --show-errors Show errors which were encountered during searching -d, --max-depth &lt;NUM&gt; Set a limit for the depth -t, --type &lt;type&gt;... Filter by entry type -e, --extension &lt;ext&gt;... Additionally filter by a file extension -c, --color &lt;auto|always|never&gt; Declare when to use colored output -x, --exec Execute a command for each search result -X, --exec-batch Execute a command with all search results at once</code>
[]
https://avatars.githubusercontent.com/u/25501014?v=4
maybeuninit
DutchGhost/maybeuninit
2019-08-10T18:43:02Z
MaybeUninit in Zig.
master
0
1
0
1
https://api.github.com/repos/DutchGhost/maybeuninit/tags
EUPL-1.2
[ "maybeuninit", "zig" ]
31
false
2022-07-17T17:09:16Z
true
false
unknown
github
[]
maybeuninit <a></a> This is a userlevel implementation of the <code>undefined</code> keyword in Zig. It is inspired by <a>MaybeUninit</a> in Rust. Minimum supported <code>Zig</code> <code>master</code> Each day will be tested in CI whether this project still builds on Zig master. Recent changes <ul> <li>0.6.1<ul> <li>Add <code>withByte</code> as initializer function.</li> <li>Remove all use of <code>inline</code>, as the usage of <code>inline</code> was considered wrong.</li> </ul> </li> <li>0.6<ul> <li>Rename <code>assume_init</code> to <code>assumeInit</code>.</li> <li>rename <code>as_ptr</code> and <code>as_mut_ptr</code> to <code>asPtr</code> and <code>asMutPtr</code>.</li> <li>rename <code>first_ptr</code> and <code>first_ptr_mut</code> to <code>firstPtr</code> and <code>firstPtrMut</code>.</li> </ul> </li> <li>0.5.2<ul> <li>Only support Zig's Master branch.</li> </ul> </li> <li>0.5.1<ul> <li>Add a private constant uninit intializer, to get around https://github.com/ziglang/zig/issues/3994.</li> </ul> </li> <li>0.5<ul> <li>Do not call <code>@memset</code> in <code>MaybeUninit(T).zeroed()</code> if <code>T</code> has a size of 0.</li> </ul> </li> <li>0.4<ul> <li>Prevent <code>MaybeUninit(noreturn)</code> from being created. See https://github.com/ziglang/zig/issues/3603.</li> </ul> </li> <li>0.3<ul> <li>Change the return type of <code>first_ptr_mut</code> from <code>*Self</code> to <code>*T</code>.</li> <li>Adds a test that calls <code>first_ptr_mut</code> on an empty slice.</li> </ul> </li> <li>0.2<ul> <li>Change the definition of <code>MaybeUninit</code> from <code>packed union</code> to <code>extern union</code>, due to <code>packed union</code>'s setting the alignment always to 1.</li> </ul> </li> <li>0.1<ul> <li>Initial library setup.</li> </ul> </li> </ul> Issues At the point of writing, it is impossible to create an uninitialized <code>MaybeUninit(T)</code>, and later initialize it at compiletime. This is an issue of the compiler, which tracks the current active field of packed and extern unions when used at compiletime, while it shouldn't. The issue is reported to the Zig compiler, and can be followed <a>here</a>.
[]
https://avatars.githubusercontent.com/u/47629329?v=4
zig-template
dryzig/zig-template
2019-06-15T05:50:41Z
Template repository for public-domain libraries written in the Zig programming language.
master
0
1
0
1
https://api.github.com/repos/dryzig/zig-template/tags
Unlicense
[ "dryproject", "template-project", "zig" ]
2
false
2019-06-22T18:39:34Z
false
false
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/4072364?v=4
adventofcode
erplsf/adventofcode
2019-12-04T18:24:29Z
null
main
0
1
0
1
https://api.github.com/repos/erplsf/adventofcode/tags
-
[ "advent-of-code", "adventofcode", "zig" ]
429
false
2025-02-18T10:17:37Z
false
false
unknown
github
[]
404
[]
https://avatars.githubusercontent.com/u/7064?v=4
streamplot
whatupdave/streamplot
2019-05-28T00:53:31Z
plot streaming histograms
master
0
1
0
1
https://api.github.com/repos/whatupdave/streamplot/tags
-
[ "bash", "bash-script", "shell", "zig" ]
7
false
2019-06-09T20:57:55Z
true
false
unknown
github
[]
streamplot <a></a> <strong>streamplot</strong> is a command line app that plots a histogram of streaming data. Example: show histogram of wikipedia updates <code>$ git clone [email protected]:whatupdave/streamplot.git $ cd streamplot &amp;&amp; zig build $ curl -sN https://stream.wikimedia.org/v2/stream/recentchange \ | sed -n 's/^data: \(.*\)$/\1/p' \ | jq --unbuffered --raw-output '.type' \ | ./zig-cache/streamplot</code>
[]
https://avatars.githubusercontent.com/u/7283681?v=4
zig-docsearch
lun-4/zig-docsearch
2019-06-28T16:41:39Z
[WIP] search over zig stdlib doc comments (with rudimentary html gen)
master
3
1
1
1
https://api.github.com/repos/lun-4/zig-docsearch/tags
MIT
[ "documentation-generator", "zig" ]
56
false
2024-12-27T23:59:05Z
true
false
unknown
github
[]
zig-docsearch <strong>NOTE: zig master now has in-progress docs! see https://github.com/ziglang/zig/issues/21</strong> search over zig stdlib doc comments (and generate a simple html file with what's possible) WIP: using -fdump-analysis using <code>bash zig build install --prefix ~/.local/</code> ```bash build the state out of the std file in your zig installation zig-docsearch ./state.bin build /path/to/zig/source/std/std.zig search through zig-docsearch ./state.bin search 'mem' make a single html file zig-docsearch ./state.bin htmlgen index.html ```
[]
https://avatars.githubusercontent.com/u/6025293?v=4
advent-of-code
oskarnp/advent-of-code
2019-05-05T19:54:44Z
My solutions to the "Advent of Code" programming challenges in various languages.
master
0
1
0
1
https://api.github.com/repos/oskarnp/advent-of-code/tags
-
[ "ada", "ada-lang", "advent-of-code", "advent-of-code-2019", "advent-of-code-2020", "advent-of-code-2021", "adventofcode", "odin", "odin-lang", "odin-programming-language", "zig", "zig-lang" ]
158
false
2023-02-13T10:19:15Z
false
false
unknown
github
[]
Advent of Code 2021 | | <a>Odin</a> | |----|----------------| | 01 | <a>✓</a> | | 02 | <a>✓</a> | | 03 | <a>✓</a> | | 04 | <a>✓</a> | | 05 | <a>✓</a> | | 06 | <a>✓</a> | | 07 | <a>✓</a> | | 08 | <a>✓</a> | | 09 | <a>✓</a> | | 10 | <a>✓</a> | 2020 | | <a>Ada 2012</a>| <a>Odin</a> | |----|----------------|---------------| | 01 | <a>✓</a> | <a>✓</a> | | 02 | <a>✓</a> | <a>✓</a> | | 03 | | <a>✓</a> | | 04 | | <a>✓</a> | | 05 | | <a>✓</a> | | 06 | | <a>✓</a> | | 07 | | <a>✓</a> | | 08 | | <a>✓</a> | | 09 | | <a>✓</a> | | 10 | | <a>✓</a> | | 11 | | <a>✓</a> | | 12 | | <a>✓</a> | | 13 | | <a>✓</a> | | 14 | | <a>✓</a> | | 15 | | | | 16 | | | | 17 | | | | 18 | | | | 19 | | | | 20 | | | | 21 | | | | 22 | | | | 23 | | | | 24 | | | | 25 | | | 2019 | | <a>Odin</a> | <a>Zig</a> | |----|----------------|---------------| | 01 | <a>✓</a> | <a>✓</a> | | 02 | <a>✓</a> | <a>✓</a> | | 03 | <a>✓</a> | | | 04 | | <a>✓</a> | | 05 | | <a>✓</a> | | 06 | | <a>✓</a> | | 07 | | | | 08 | <a>✓</a> | <a>✓</a> | | 09 | | | | 10 | | | | 11 | | | | 12 | | | | 13 | | | | 14 | | | | 15 | | | | 16 | | | | 17 | | | | 18 | | | | 19 | | | | 20 | | | | 21 | | | | 22 | | | | 23 | | | | 24 | | | | 25 | | | 2018 2017 2016 2015
[]
https://avatars.githubusercontent.com/u/11783095?v=4
uefi-pixelflut
nrdmn/uefi-pixelflut
2019-11-01T05:12:20Z
bootable pixelflut server
master
0
1
0
1
https://api.github.com/repos/nrdmn/uefi-pixelflut/tags
-
[ "pixelflut", "pixelflut-server", "uefi", "zig" ]
10
false
2023-01-28T12:15:18Z
true
false
unknown
github
[]
UEFI Pixelflut Server Disclaimer This is a proof of concept. It's very slow and it currently requires my fork of zig. Usage <ol> <li>Edit main.zig and set the preferred screen resolution.</li> <li>Compile with <code>zig build</code> and copy efi/boot/bootx64.efi to a FAT formatted device.</li> <li>Run on a network that responds to router solicitations</li> <li>Send UDPv6 packets on port 1337 to the device's autogenerated IPv6 address.</li> </ol>
[]
https://avatars.githubusercontent.com/u/28556218?v=4
zig-walkdir
joachimschmidt557/zig-walkdir
2019-06-26T07:40:29Z
Provides functions for walking directories recursively
master
1
1
0
1
https://api.github.com/repos/joachimschmidt557/zig-walkdir/tags
MIT
[ "zig", "zig-package" ]
45
false
2025-03-08T22:25:54Z
true
true
unknown
github
[]
zig-walkdir A zig package providing functions for recursively traversing directories. Works with zig 0.14.0. Todo <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> Breadth-first search <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> Depth-first search <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> Tests <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> Following symlinks <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> Correct error handling
[]
https://avatars.githubusercontent.com/u/1327032?v=4
zig-windows-process
GoNZooo/zig-windows-process
2020-06-21T13:08:51Z
Toolset for interacting with Windows processes in Zig
main
0
16
1
16
https://api.github.com/repos/GoNZooo/zig-windows-process/tags
-
[ "processes", "win32", "windows", "zig", "zig-package", "ziglang" ]
1,071
false
2025-04-16T11:52:37Z
true
false
unknown
github
[]
zig-windows-process This repo is meant to hold tools for tinkering with Windows processes (though I might extend it in the future) to allow for a higher-level interface for injecting DLLs and such. The primary motivation is that I'd like to have a basic toolkit for dealing with things that usually come up in game hacking and exploration. The library code The library code is primarily in <code>main.zig</code> so if you were to add the package it would be from that file, as follows: <code>zig exe.addPackagePath("windows-process", "dependencies/windows-process/src/main.zig");</code> Example usage DLL injection <code>inject_dll.zig</code> contains a main file for a program that will take a DLL path and inject it into a given process. One needs to make sure that the process has the same bitness as the DLL. Finding/enumerating processes <code>find_process.zig</code> uses the process enumeration API to find processes matching a given executable name. More stuff and more ways to do these things I'm not an expert on any of these things and there are way more things to add here. I'd love suggestions for tools to add, techniques to facilitate through this package. Having a general module that allows interaction with Windows processes in general is the point, after all.
[]
https://avatars.githubusercontent.com/u/265903?v=4
PeerType
alexnask/PeerType
2020-11-19T12:57:04Z
Zig peer type resolution at comptime, ported from the compiler source code
master
0
15
3
15
https://api.github.com/repos/alexnask/PeerType/tags
MIT
[ "metaprogramming", "zig", "zig-library", "zig-package" ]
31
false
2023-03-15T18:05:08Z
false
false
unknown
github
[]
PeerType API <code>zig /// types must be an iterable of types (tuple, slice, ptr to array) pub fn PeerType(comptime types: anytype) ?type; pub fn coercesTo(comptime dst: type, comptime src: type) bool; pub fn requiresComptime(comptime T: type) bool;</code> License MIT
[]
https://avatars.githubusercontent.com/u/53199545?v=4
asp3_in_zig
toppers/asp3_in_zig
2020-06-03T05:42:41Z
TOPPERS/ASP3 Kernel written in Zig Programming Language
master
14
15
4
15
https://api.github.com/repos/toppers/asp3_in_zig/tags
-
[ "asp3", "toppers", "zig" ]
1,670
false
2024-04-13T17:28:28Z
false
false
unknown
github
[]
asp3_in_zig TOPPERS/ASP3 Kernel written in Zig Programming Language このレポジトリには,asp3_in_zigをビルドするために必要なファイルの中で,TECSジェネレータは含んでいません。ビルドするためには,TECSジェネレータを,tecsgenディレクトリに置くか,リンクを貼ってください。 ビルド&amp;実行方法(例) <code>% mkdir OBJ-ARM % cd OBJ-ARM % ../configure.rb -T ct11mpcore_gcc -O "-DTOPPERS_USE_QEMU" % make % qemu-system-arm -M realview-eb-mpcore -semihosting -m 128M -nographic -kernel asp </code> Zigのコンパイラは,Release 0.8.0を利用してください。古い版では動作しません。最新版で動作するとは限りません。 その他の依存しているソフトウェアの動作確認バージョンは,次の通りです。 <code>arm-none-eabi-gcc 9.3.1 20200408 arm-none-eabi-objcopy 2.34.0.20200428 tecsgen 1.8.RC2 ruby 2.6.3p62 make GNU Make 3.81 qemu-system-arm version 5.0.0 </code> 利用条件 このレポジトリに含まれるプログラムの利用条件は,<a>TOPPERSライセンス</a>です。 参考情報 <ul> <li>小南さんが,以下のページに,関連するソフトウェアに関する情報を詳細に記述くださっています。</li> </ul> https://github.com/ykominami/asp3_in_zig/blob/master/README.md
[]
https://avatars.githubusercontent.com/u/2389051?v=4
micro-zigfmt
squeek502/micro-zigfmt
2020-05-29T00:03:48Z
micro editor plugin that provides zig fmt integration
master
0
15
1
15
https://api.github.com/repos/squeek502/micro-zigfmt/tags
Unlicense
[ "micro-editor", "zig", "ziglang" ]
8
false
2024-12-06T23:00:30Z
false
false
unknown
github
[]
micro-zigfmt Plugin for the <a>micro editor</a> that provides support for: <ul> <li><code>zig fmt</code> on save</li> <li><code>zig fmt --check</code> integration with the official linter plugin</li> </ul> for <a>Zig</a> files. Installation Using the plugin manager: <code>micro -plugin install zigfmt</code> Or from within micro (must restart micro afterwards for the plugin to be loaded): ``` <blockquote> plugin install zigfmt ``` </blockquote> Or manually install by cloning this repo as <code>zigfmt</code> into your <code>plug</code> directory: <code>git clone https://github.com/squeek502/micro-zigfmt ~/.config/micro/plug/zigfmt</code> Usage See <a>the help file</a> Or, after installation, from within micro: ``` <blockquote> help zigfmt ``` </blockquote>
[]
https://avatars.githubusercontent.com/u/17795572?v=4
ZigWindowManager
Eloitor/ZigWindowManager
2020-11-10T14:13:51Z
A basic window manager written in Zig.
main
0
14
1
14
https://api.github.com/repos/Eloitor/ZigWindowManager/tags
Unlicense
[ "windowmanager", "zig" ]
42
false
2025-03-21T20:44:50Z
false
false
unknown
github
[]
ZigWindowManager <ul> <li>Tiling and floating</li> <li>Non reparenting</li> <li>Single screen support</li> <li>Simple code</li> </ul> Based on <ul> <li><a>katriawm: The adventure of writing your own window manager</a></li> <li><a>tinywm</a></li> <li><a>dwm</a></li> <li><a>How X window managers work and how to write One</a></li> </ul> A basic window manager written in Zig <ul> <li>This window manager doesn't capture keypresses... We need a key daemon. For example <a>sxhkd</a></li> </ul>
[]
https://avatars.githubusercontent.com/u/22677068?v=4
zig-vector-table
markfirmware/zig-vector-table
2020-05-04T23:34:37Z
zig bare-metal vector table stack
master
0
13
2
13
https://api.github.com/repos/markfirmware/zig-vector-table/tags
MIT
[ "bare-metal", "gitpod", "zig" ]
97
false
2025-03-15T18:13:32Z
false
false
unknown
github
[]
<a></a> It starts at the vector table which specifies the initial stack and the reset entry point. <a>main.zig</a>/[1]<a>Section 2.3.4 Vector table, p37)</a> <code>export var vector_table linksection(".vector_table") = packed struct { initial_sp: u32 = model.stack_bottom, reset: EntryPoint = reset, </code> The reset function prepares memory (copies initial data from flash to ram and sets other data to 0.) It then prepares the uart and timer and displays the up-time every second. <a>main.zig</a> <code>fn reset() callconv(.C) noreturn { @import("generated/generated_linker_files/generated_prepare_memory.zig").prepareMemory(); Uart.prepare(); Timers[0].prepare(); Terminal.clearScreen(); Terminal.move(1, 1); log("https://github.com/markfirmware/zig-vector-table is running on a microbit!", .{}); var t = TimeKeeper.ofMilliseconds(1000); var i: u32 = 0; while (true) { Uart.update(); if (t.isFinishedThenReset()) { i += 1; Terminal.move(2, 1); log("up and running for {} seconds!", .{i}); </code> The system is comprised of 256KB of flash and 16KB of ram memories: <a>system_model.zig</a>/[2]<a>Memory Organization, p21</a> References [1] <a>Cortex-M0 Devices Generic User Guide</a> [2] <a>nRF51822 Product Specification</a> [3] <a>nRF51 Series Reference Manual</a>
[]
https://avatars.githubusercontent.com/u/1915?v=4
htmlentities.zig
kivikakk/htmlentities.zig
2020-08-18T07:39:24Z
HTML entity data for Zig
main
0
12
4
12
https://api.github.com/repos/kivikakk/htmlentities.zig/tags
MIT
[ "html", "zig" ]
83
false
2025-04-20T03:38:04Z
true
true
0.14.0
github
[]
<a>htmlentities.zig</a> The bundled <a><code>entities.json</code></a> is sourced from <a>https://www.w3.org/TR/html5/entities.json</a>. Modelled on <a>Philip Jackson's <code>entities</code> crate</a> for Rust. Overview The core datatypes are: ```zig pub const Entity = struct { entity: []u8, codepoints: Codepoints, characters: []u8, }; pub const Codepoints = union(enum) { Single: u32, Double: [2]u32, }; ``` The list of entities is directly exposed, as well as a binary search function: <code>zig pub const ENTITIES: [_]Entity pub fn lookup(entity: []const u8) ?Entity</code> Serving suggestion Add it to your <code>build.zig.zon</code>: <code>zig fetch --save https://github.com/kivikakk/htmlentities.zig/archive/bd5d569a245c7c8e83812eadcb5761b7ba76ef04.tar.gz</code> In your <code>build.zig</code>: <code>zig const htmlentities_dep = b.dependency("htmlentities.zig", .{ .target = target, .optimize = optimize }); exe.root_module.addImport("htmlentities", htmlentities_dep.module("htmlentities"));</code> In your <code>main.zig</code>: ```zig const std = @import("std"); const htmlentities = @import("htmlentities"); pub fn main() !void { var eacute = htmlentities.lookup("&eacute;").?; std.debug.print("eacute: {}\n", .{eacute}); } ``` Output: <code>eacute: Entity{ .entity = &amp;eacute;, .codepoints = Codepoints{ .Single = 233 }, .characters = é }</code> Help wanted Ideally we'd do the JSON parsing and struct creation at comptime. The std JSON tokeniser uses ~80GB of RAM and millions of backtracks to handle the whole <code>entities.json</code> at comptime, so it's not gonna happen yet. Maybe once we get a comptime allocator we can use the regular parser. As it is, we do codegen. Ideally we'd piece together an AST and render that instead of just writing Zig directly -- I did try it with a 'template' input string (see some broken wip at <a><code>63b9393</code></a>), but it's hard to do since <code>std.zig.render</code> expects all tokens, including string literal, to be available in the originally parsed source. At the moment we parse our generated source and format it so we can at least validate it syntactically in the build step.
[]