Ecoji Zig implementation

For my first time using Zig I implemented Ecoji to learn the language and created this project.

keith-turner/ecoji-zig: Ecoji implementation in Zig that provides C and wasm libraries. - Codeberg.org

Using Zig for this project has been great. I opened two Zig PRs based on doing this work 25561 and 25538. I am trying to figure out how to use the zig build system as a next step. Also wondering about using the atman/zg project from codeberg for utf8 decoding, but I am not sure yet what the pros and cons are vs the std library.

I am using this new Zig code on the ecoji.io website because its wasm file is so much smaller than the previous wasm generated by golang. For the wasm file on the website, I built it using ReleaseSafe out of an abundance of caution. If I build w/ ReleaseSmall then the wasm file is really really small, but I wanted to keep safety.

I set up an automated build for the project on codeberg. That is working well. However one concern I have is it pulls zig directly from the ziglang servers w/o using mirrors. It does use caching on codeberg though, so its only done that pull once so far for many builds. Want to improve this.

5 Likes

Nice!
Regarding the pulls directly from ziglang.org, there is a document on their website: Community Mirrors ⚡ Zig Programming Language.

1 Like

std library does not support unicode, it has the bare minimum needed for the compiler.

zg is the defacto standard unicode library for zig.

1 Like

this is peak programmer humour, is there any serious use of ecoji out there ?

Not that I am aware of, its something i created for fun and to learn. I initially came up with the project to learn golang. After posting it, people opened issues and PRs about incorrect usage of unicode and using characters that are too similar or not interesting. Their PRs led to ecoji v2 that fixed those problems. Someone did try to use it in their application and reported that it has too many characters that are similar. They concluded they needed a smaller set of highly distinguishable emojis. Ecoji uses 1024 emojis because at the time of creation there were >1024 and <2048 emojis, so 1024 was a greedy choice. To be useful for something like visual verification of an encoded hash, it would probably need a smaller set than 1024.

Interesting, that points to a GH action. Wonder if that can work in forgejo actions on codeberg. Will look into that.

As an interesting alternative, I came across GitHub - jacobsandlund/uucode: uucode - fast unicode library in zig today and it looks really interesting. From what I can tell it is based on some of the unicode code in Ghostty and doesn’t require allocations which is great.

I was able to use the github action setup-zig on codeberg running forgejo actions by adding the following to the workflow

      - uses: https://github.com/mlugg/setup-zig.git@v2
        with:
          version: 0.15.1