Welcome to Dr Iggy’s coding adventures

Coding header image

Redesigning Zig IO Api

Input-output being one of the most fundamental systems in any programming language was probably one of the first that was designed in Zig’s standard library. As Zig grew and gained additional features it had a few redesigns but it is still not without issues so here I want to analyze how it is currently implemented and if we can now do better. Note There are additional language improvement proposals aiming to improve this exact area like this and this but here I will only present what can be done with Zig today.
Read full post

Mixins in Zig

What are mixins? Mixins are a way to mix in some common functionality into multiple structs. For example if you have a File and TcpSocket and they have their own different implementations of read(buffer: []u8) method and you want to add convenience methods like readInt(), readStruct() and similar that just call the read() method and format the result, you would usually have to write those methods in one struct and then copy them to the other.
Read full post

Basics of Allocating and Using Memory

Many of the top used programming languages today use garbage collection and with them we are always taught how manual memory management is hard. I get the feeling that many new programmers don’t even try to understand it today. I want to show here how manual memory management can be not only very easy but also very fun. Lesson 1: Let Operating System Do It There is a big class of programs that work as command line utilities.
Read full post

Optimal Logging API for C#

There are often situations where logging can affect performance. It is probably rare in the server world but it comes quite often when we try to log stuff in our Unity game. There its effect can be quite visible. That is why, so far, we disabled all logger calls in our production builds by using a [Conditional("USE_LOGGING")] attribute on logger methods and not defining the USE_LOGGER symbol in the build. You can read about that attribute here.
Read full post

Png Reader in Zig

Although there is already a solid zigimg image loading library it didn’t quite tick all the checkboxes for me. It doesn’t provide the flexibility that I am aiming for and it is using far more allocations than is necessary. Also since I already wrote a png reader in DLang it felt like a good project for learning zig to try to reimplement it and try to improve on my original design.

Read full post

How do I stay motivated

I am doing programming for 24 years now and I don’t see myself getting bored with it. There is always one more thing to learn or to solve and I really want to know everything .

The goal I am most interested in is making my own game engine. But I don’t want to take the SDL library, some image and 3D data loading library and just write rendering logic. I want to learn how it all works.

Read full post