HACKER Q&A
📣 slindsey

Better language than C for playing with pointers


In over 20 years of software development, I've only worked with languages that don't use pointers. Each time I delve into pointers in C, I run into problems referencing and de-referencing, passing them around, etc. I understand pointers well enough. I've read countless tutorials and really do understand them at the machine level.

Can anyone recommend a language other than C that uses pointers, so that I might understand actual manipulation better? I'm not interested in a discussion of why they are bad and how we should use Rust. This is purely for my own education to get past this weird block I seem to have when I try to use them in real applications.


  👤 olodus Accepted Answer ✓
Zig maybe. While it is still in a quite early phase it in my eyes keep much closer to C syntax and language feeling than C++, while still having smart new solutions. Some of these are in the pointer domain.

For example it has a couple of different pointer types for the different ways arrays can be handled in C, such as Null terminated, compile-time-known size or runtime-known size. This could help you think about how pointers and collections go together.


👤 catacombs
Golang uses pointers and is a descendant of C, so you should feel at home.

👤 jki275
c++11!

Really it's just a matter of actually doing it. I read books, I studied, I "knew" how they worked, but until I wrote a linked list from scratch and actually used it for a while I really didn't understand it.