Hi, I'm Incubo4u

Software Engineer @ Software Mansion

Master's Student at Warsaw University of Technology

> Bonjour! October 4, 2024

This page is a work in progress where I plan to list some of the books I've read and believe are worth sharing, as well as some random thoughts I need to write down somewhere.

> Ptr dereference sugar confusion May 2, 2025

I will start with a disclaimer that this is just my opinion, and I encourage you to disagree with me or even better, explain to me why you think I'm wrong if you do.


So let's keep this short.
During my adventure with low-level languages, I saw a lot of people confused by pointers.
They sound scary, they are not present in many higher-level languages, and sometimes they cause problems.
But the reality, as you probably know, is that even if sometimes dealing with pointers is hard (especially if you are dealing with some obscure pointer arithmetic or using some forgotten-by-God trick to achieve something using pointers), most of the time pointers are not scary at all.


But I think the syntax is pretty awkward, at least in C or C++.


examples -> pointers-iii-pointers-to-pointers-and-more (beej.us C book)


But things are changing in the modern languages that are rising in popularity, like Zig.
I think the Zig syntax for dereferencing is much better than the C one:


ptr.*

But still, I'm pretty pissed off by one syntax sugar that is embedded in almost all languages I used in my fairly short adventure:

Accessing a field of a struct/class through a pointer.


ptr.x.* // Zig
ptr->x // C/C++

Why? Why can't it just be more explicit?


(*ptr).x

I mean, I know that technically we can use the above syntax, but no one does.
Wouldn't it be much easier, especially for beginners, to use the explicit form instead of the language automatically dereferencing the pointer?


Maybe I'm wrong and this is not such a big deal, but I saw so many people being confused about it that I just think this is not worth it.