Hello Zig!

We want to share with you our experience of introducing zig during a hackathon with zig neophytes and just share some of the joy we had the day of our hackathon.

We are The Dev Effect, a research engineering (think engineering ML and science) consulting group. Our beloved team member, Ryan, has decided to part ways and focus more on the gaming space (prospective employers out there, he’s on the market). Ryan decided that as part of his going away party he’d love it if we could all do a game jam for the day. He had been collaborating on a fun little library zigzag, and the whole team was really pumped to try it!

Without further ado, here is a nice animation from the culmination of our 1 day game jam. (We are honestly super proud of what the team accomplished, especially since almost no one on the team knew any zig going into it):

The Team

Only two people on the team had ever used zig. Here is a quick breakdown of the office that day:

Jackie - Junior engineer mostly familiar with languages like python and javascript. 

Aryan - Junior engineer mostly familiar with languages like python and javascript. He has an interest in rust. 

J.Pat - A senior engineer with a background in java, but a jack of all trades who has used most languages out there... excluding zig.

Brett - A senior engineer with no strong language preferences. Has beginner level zig knowledge and contributed to zigzag.

Alec - A neuroscientist and research engineer who has a background in python.

Ryan - The man of the hour. A senior engineer with a strong background in java, but knows many other languages. Additionally he has worked in Unity and modding minecraft.

Mike - A research engineering manager with experience in dynamic languages like python and javascript.

Note: we had a variety of OSs and environments to develop on. Mac, Linux, and Windows were all utilized and it all worked!

The team in action in our office during the game jam:

The Game

Goal

Ryan is trying to survive the seemingly endless onslaught of landborne-fish, goomba-inspired wildlife, and amoeba that endanger him when he stands in the way of their relentless pursuit for the northeast corner of the map. 

Instructions

Help Ryan survive by defeating the migrating enemies by using his trusty ephemeral bowling ball that regularly appears (and disappears) by his right side, and magical bullets that can be cast outwards when Ryan moves by pressing or holding "a". 

As you defeat enemies, they will drop hearts, an essential ingredient to Ryan's ongoing survival. Collect enough hearts and you will level up, which will restore Ryan's body to a pristine state, ready to harass even more mobile denizens of this large square environment. 

Keep an eye out for the ethereal fish queue that lingers ever slightly out of reach to the north of Ryan - when all fish have disappeared from the queue, it is said that the spirits of the dead will rise again, in order to continue their pilgrimage to the boundary of the world. 

One last warning: if Ryan becomes surrounded by enemies, his health bar will rapidly decrease, until it disappears entirely. Shortly after that, unless Ryan can secure enough hearts to level-up, Ryan will be struck with a perpetual curse of immobility, rendering his survival far less interesting and interactive, forever.

Note the little guy in the game is a hand crafted Ryan sprite!

Feedback

We collected some informal feedback on how different team members felt about using zig. The short answer is that it was surprisingly easy for people to learn. The fact that we actually finished something is a testament to this. Here is a per team member breakdown:

Aryan - “I really liked how easy it was to develop for wasm… very portable. The syntax… I’d have to spend more time on it to learn the quirks. It was intuitive. I just need to get used to how things were set up. Installing zig was really easy. All the stuff I have read doing some research on zig, was similar to C, but probably a bit safer. The docs could be more clear.”

JPat - “Pretty straightforward. Got up to speed quickly. WASM was a huge win. The feedback the compiler gave was pretty solid. Using the math utils only deal with floats and it would be nice if there were some integer versions.”

Mike - “Zig I really like. Different from experience with python or javascript, java even. Seeing the finished project was awesome and it came together quick. Rust felt like there was a lot more barriers. Rust was more strict. It was easier to figure out how to get across barriers in zig. The only negative is that there is not a lot of information out there. Allocators are something that are less familiar coming from those other languages”

Ryan (Hire me!) - “As someone who isn't too familiar with C (or rust for that matter), I likewise wasn't too familiar with a lot of standard conventions in zig - especially when it came to operations beyond regular math and straight calls to the sdl2 library. Having one concise document outlining the ins-and-outs of zig with plenty of code examples was very useful in helping me be functional in zig without spending a dearth of time teching up beforehand. The compiler errors were often very informative and straightforward to correct, which was another great upside.  The most common issue I struggled with were vague missing file compiler errors when a dependency listed in the build file could not be found; there wasn't anything that pointed me directly to the line that was causing my issues. Another issue I noticed was when we had created arrays of 16k objects, it took exponentially longer to compile a build (up to 15 minutes compared to 15 seconds with only 15 objects). I enabled verbose flags during compilation and it seemed like it was checking various compile-time usages for each of the 16k objects whenever they were used in the code. I'm not sure if there is a way to optimize that, but it could really slow things down when we're jamming. Finally, I had tried using the latest 0.11 release when I started developing on a new desktop earlier this week, but it looks like the wasm compilation features are potentially broken; the wasm files that were produced failed to load”

Jackie - “It was good. It was fun. It was easy to pick up. Rust wasn’t hard either. One thing I didn’t understand was the reference system, but it was cool to learn how it was related to C.”

Brett - “I was really surprised how easily the team took to using zig. I think some of the main stumbling blocks I saw for engineers used to more dynamic languages was the surprise that dynamic data structures tend not be the first solution one may go for. Personally, I am still not sure of the right way to for loop through a range of numbers, and I accidentally introduced a bug with a while loop (I didn’t realize that redeclaring a variable in a while loop’s scope would not “reinitialize it”. All in all I am very impressed by the ergonomics of zig and the wasm features are awesome.”
Alec - “I was initially worried because I have very little experience programming in C, but I found zig highly intuitive. It was easy to get things running quickly, so I could focus on the logic rather than the syntax.”

Final Thoughts

If you made it this far…Thank you for reading! Zig was a blast and it’s super awesome that we ended up with something working after less than 6 hours of hacking around (with 7 people working in different directions). If you are looking for help accelerating your machine learning/science teams please reach out to https://www.deveffect.io/. Also, reach out to Ryan about job opportunities in the gaming space!