RSSAmplifier

Blog

Hexops' devlog

Recent content on Hexops' devlog

devlog.hexops.orgRSS feed ↗22 posts

Latest posts

Announcing pkgmirror: self-host your own Zig mirror

pkgmirror is an open-source, self-hosted Zig toolchain and package mirror service so your builds no longer rely on third-party services or Microsoft GitHub. Mach now hosts its own pkgmirror at pkg.hexops.org . Features Zig toolchain mirroring : acts as a caching reverse proxy for Zig toolchain downloads from ziglang.org Package mirroring (optional) - instead of writing GitHub URLs in your…

Building the DirectX shader compiler better than Microsoft?

This is a story nightmare about the messy state of Microsoft’s DirectX shader compiler, and trying to wrangle it into a nicer experience for game developers. In some respects, we now build the DXC compiler better than how Microsoft does. Setting the stage For Mach engine we’ve been building an experimental graphics API called sysgpu using Zig, aiming to be a successor and descendant of…

Mach v0.3 released - Zig game engine & graphics toolkit

Mach is a Zig game engine & graphics toolkit for building high-performance & modular games, visualizations, and desktop/mobile apps. Learn more We are working towards Mach 1, and have just released v0.3 which includes 6 months of work - here are the highlights! Coming soon: intro to 2D gamedev workshop The first-ever intro to 2D gamedev workshop using Mach will be hosted at the Software You Can…

Announcing Mach nominated Zig versions

Today we’re announcing Mach nominated Zig versions, a sweet-spot between stable Zig and nightly Zig which offers a different balance of latest-and-greatest features and fixes, and less of a moving target. If you are in the Zig community, you likely fall into one of two categories: You target Zig nightly, a target which moves every day You target Zig stable, which may be released once or…

Mach v0.2 released - Zig game engine & graphics toolkit

Mach is a Zig game engine & graphics toolkit for building high-performance, truly cross-platform, robust & modular games, visualizations, and desktop/mobile GUI apps. Learn more We’ve been developing Mach for ~2 years; this release includes over a year of work, thousands of commits, and fixes 300 issues . On your machine in just ~60 seconds With this Zig nightly version you can run the above…

Mach: providing an ecosystem of C libraries using the Zig package manager

Andrew Kelley gave a keynote speech at Software You Can Love 2023 in Vancouver last week (a recording will be available later), the outline was: How to Build Software From Source […] then I’ll take things in a completely different direction, by showing you how to rip apart a project’s build system and replace it with the zig build system. This will make building things from…

Zig tips: v0.11 std.build API / package manager changes

We’ve just updated Mach engine to use the latest Zig nightly version, which includes a fair amount of improvements and breaking changes to the std.build API used in build.zig files, and figured now would be a good time to share the general changes you may need to make if you want to update your own code. Package manager: incoming! Zig is finally starting to see its package manager and build…

Debugging undefined behavior caught by Zig

Mach engine uses Zig as the C/C++ compiler for almost everything. Unlike other toolchains, Zig enables many more safety checks by default - such as clang’s undefined behavior sanitizer. Using Zig, we’ve caught undefined behavior in established projects like GLFW[ 1 ], the DirectX Shader Compiler[ 2 ], and more. Undefined behavior is everywhere, often relatively innocuous, and hard to…

Perfecting WebGPU/Dawn native graphics for Zig

We’ve just finished a complete rewrite of mach/gpu (WebGPU/Dawn bindings for Zig), with 700+ commits, ~7.4k LOC, and 100% API coverage. WebGPU (not to be confused with WebGL) is a modern graphics API, acting as a unified API to the underlying Vulkan/Metal/DirectX APIs. Despite it’s name, it is also designed for use in native applications via its C API. Dawn is the C++ implementation of…

Packed structs in Zig make bit/flag sets trivial

As we’ve been building Mach engine , we’ve been using a neat little pattern in Zig that enables writing flag sets more nicely in Zig than in other languages. What is a flag set? We’ve been rewriting mach/gpu (WebGPU bindings for Zig) from scratch recently, so let’s take a flag set from the WebGPU C API: typedef uint32_t WGPUFlags ; typedef WGPUFlags WGPUColorWriteMaskFlags…

Let's build an Entity Component System (part 2): databases

In this series we build the Mach engine Entity Component System from scratch in the Zig programming language . In part one, we looked at how ECS intersects with data oriented design , starting without any foundational understanding of how ECS typically works and instead working from first-principles to arrive at what would probably be the most computationally efficient implementation. In this ~24…

Mach v0.1 - cross-platform Zig graphics in ~60 seconds

Five months ago we announced some of our vision for Mach & the future of graphics with Zig . Today we’ve reached Mach v0.1 with over 1,100 commits. Cross-platform graphics in 60 seconds If you have Zig v0.10 you can get started with cross-platform graphics in under 60 seconds, try it for yourself: git clone https://github.com/hexops/mach cd mach/gpu zig build run-example (not working? see…

Zig hashmaps explained

If you just got started with Zig , you might quickly want to use a hashmap. Zig provides good defaults, with a lot of customization options. Here I will try to guide you into choosing the right hashmap type. 60-second explainer You probably want: var my_hash_map = std . StringHashMap ( V ). init ( allocator ); Or if you do not have string keys, you can use an Auto hashmap instead: var my_hash_map…

Let's build an Entity Component System from scratch (part 1)

In this multi-part series we’ll build the Entity Component System used in Mach engine in the Zig programming language from first principles (asking what an ECS is and walking through what problems it solves) all the way to writing an implementation in a low-level programming language. The only thing you need to follow along is some programming experience and a desire to learn. In this…

Perfecting GLFW for Zig, and finding lurking undefined behavior that went unnoticed for 6+ years

Today, I am announcing mach-glfw : Ziggified GLFW bindings with 100% API coverage, zero-fuss installation, cross compilation, and more. Building Mach for everyone If Mach engine only benefits people interested in using that engine, and not the broader Zig (and even gamedev) community I would consider that a total failure . Whether you’re interested in using all of Mach, just some of it with…

Mach Engine: The future of graphics (with Zig)

In the coming months, we’ll begin to have truly cross-platform low-level graphics, with the ability to cross compile GPU-accelerated applications written in Zig from any OS and deploy to desktop, mobile, and (in the future) web. Mach engine I’ve been working on Mach Engine for about 4 months now, although it as a project is many years in the making, and I believe in the next 4-6 months…

Unicode data file compression: achieving 40-70% reduction over gzip alone

A little story about how writing a domain-specific compression algorithm in a few days can sometimes yield big benefits, why it’s sometimes worth giving it a shot, and how to tell when you should try. Note: this is about Unicode spec data files, not general purpose text compression. Background Problem Investigation Binary encoding? Differential encoding/compression? Go implementation Zig…

Unicode sorting is hard & why browsers added special emoji matching to regexp

As I work on Zorex, an omnipotent regexp engine I have stumbled into a world of tales about why Unicode text sorting is so annoying in the modern day. Let’s talk about that. Why ASCII sorting is not enough Twitter’s emoji problem - or when Unicode locale-aware sorting Really Matters™ Browsers added special emoji matching to regexp Language comparison JavaScript Collator sorting is not…

My game development journey & why I'm increasing my contribution to Zig to $200/mo

Today, I increased my monthly donation to Zig to $200 a month. Before Zig, I have not contributed financially to any open source project. Before I can explain why I am so extremely excited about the Zig programming language and its community, I need to explain where I come from. I grew up playing Linux games like Mania Drive It wasn’t long before I found that the Mania Drive game engine was…

Zig, Parser Combinators - and Why They're Awesome

In this article we will be exploring what parser combinators are, what runtime parser generation is - why they’re useful, and then walking through a Zig implementation of them. What are parser combinators? Why are parser combinators useful? Going deeper: runtime parser generation A note about traditional regex engines Implementing the Parser interface Compile-time vs. run-time The parser…

Postgres regex search over 10,000 GitHub repositories (using only a Macbook)

In this article, we share empirical measurements from our experiments in using Postgres to index and search over 10,000 top GitHub repositories using pg_trgm on only a Macbook. This is a follow up to “Postgres Trigram search learnings” , in which we shared several learnings and beliefs about trying to use Postgres Trigram indexes as an alterative to Google’s Zoekt (“Fast…

Postgres Trigram search learnings

In this article I talk about learnings I have from trying to use pg_trgm as the backend for a search engine, Tridex, which aims to be a competitor to Google’s Zoekt (“Fast trigram based code search”) Background I work @ Sourcegraph , which provides code search, code intelligence, and other developer tooling. (If you’re one of my Sourcegraph co-workers, hey! Hexops is the…