# A Rust Developer Learns C: Null-Terminated Strings, Magic Integers, and Raw Pointers

Original title: C for Rust Programmers

> Hacker News story 50005743 · language: en · submitted 2026-10-08
> Web version: https://zeli.app/story/50005743
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 171 · by [xyproto](<https://news.ycombinator.com/user?id=xyproto>) · 💬 199
[original](<https://bd103.dev/blog/2026-10-07-c-for-rust-programmers/>) · [HN discussion](<https://news.ycombinator.com/item?id=50005743>)

## Summary

A Rust programmer documents the quirks of C: booleans only became primitive in C23, strings rely on null terminators, integer widths vary by platform, and error handling depends on magic return values and errno. Arrays decay to pointers when passed to functions, and raw pointers replace references, leading to buffer overflows and out-of-bounds writes. The author argues for encoding requirements in the type system so the compiler can catch mistakes.

## Key quote

> C places full trust in the programmer to do things right™ and gives few facilities for contracts or safe abstractions.

## HN discussion (199 comments)

### [uecker](<https://news.ycombinator.com/item?id=50032235>)

> Any tutorial for C should explain compiler warnings and other tools that help make code safer.  In C, you do not rely on the language specification but on tooling.  Especially for Rust programmers, this needs to be explained more explicitly.  And of course, you can build abstractions using types in C. So a tutorial should also focus on that, and perhaps not start with a low-level string reversal function.

### [phamilton](<https://news.ycombinator.com/item?id=50033128>)

> Re: arrays are pointers.
>
> One of my favorite things to show just how bare this is in C is to show array access commutativity.
>
> char c = {1,2,3}
>
> c[1] == *(c + 1)
>
> *(c + 1) == *(1 + c)
>
> c[1] == 1[c]
>
> C is wonderfully simple at times.

### [bennettnate5](<https://news.ycombinator.com/item?id=50035678>)

> Some fun quirks I never learned until years after first getting into C:
>
> \- zero-initialization via `= {0};` will still leave padding and any data not covered by the smallest elements of unions uninitialized, so serializing data structures zeroed via that method is unsafe
>
> \- A pointer that increments any more than 1 past the end of a valid memory region (e.g. the end of a buffer) is instant undefined behavior even if the pointer is never dereferenced
>
> \- strict aliasing is on by default for pointers of differing types, but not for void/char/uchar. This means that having `struct sockaddr` and `struct sockaddr_in` pointers pointing to the same struct is UB.
>
> The more I learn, the more I run from C.

### [jan_m_savage](<https://news.ycombinator.com/item?id=50038808>)

> real programmers don't build identities around languages (i.e. don't call themselves a ___insert__language programmer).

### [rini17](<https://news.ycombinator.com/item?id=50035728>)

> My biggest bewilderment with C is that malloc has to store the buffer size otherwise free could not work...but nobody in decades thought to make this information accessible to the programmer! If you want to keep track of buffer bounds in C, you have to do it artisanally. Despite it's, in most implementations, stored right there next to the data and thus in L1 cache already.

### [ReDress](<https://news.ycombinator.com/item?id=50032145>)

> I'm going to go out on a limb here and make a wild guess.
>
> That boolean is actually mostly an extension of the integer system whereby we now have an integer type that stores only one bit.
>
> Whereby the bit stored either results in a 'true' or 'false' value.
>
> Anyways, I know booleans are useful in systems development when you have strict memory / storage constrains / bandwidth (networks).
>
> Yeah, that works for me.

### [layer8](<https://news.ycombinator.com/item?id=50033783>)

> \> Woah, iterating over pointers instead of indexes! […] However, I'm not sure how good an idea that is.
>
> I’d recommend anyone (including the author) wanting to understand C to read K&R’s “The C Programming Language”, which among other things will illustrate how iterating over pointers is idiomatic in C (though not quite in the way the author’s example does it).

### [bjackman](<https://news.ycombinator.com/item?id=50032597>)

> It's beautiful to see this perspective! The fact that we are at "whoa, C is fucked up compared to my expectations" instead of "look at Rust's fancy safety stuff" shows that as a field we've started lifting the baseline.
>
> Nowadays I actually believe I'll likely see a world without memory corruption within my lifetime.

---

## Cite

- Page: https://zeli.app/story/50005743
- Date: 2026-10-08
- Source: bd103.dev (https://bd103.dev/blog/2026-10-07-c-for-rust-programmers/)
- Hacker News: https://news.ycombinator.com/item?id=50005743

## Other languages

- zh: https://zeli.app/zh/story/50005743 · markdown: https://zeli.app/zh/story/50005743.md
- ja: https://zeli.app/ja/story/50005743 · markdown: https://zeli.app/ja/story/50005743.md
- ko: https://zeli.app/ko/story/50005743 · markdown: https://zeli.app/ko/story/50005743.md
- de: https://zeli.app/de/story/50005743 · markdown: https://zeli.app/de/story/50005743.md
- es: https://zeli.app/es/story/50005743 · markdown: https://zeli.app/es/story/50005743.md
- ru: https://zeli.app/ru/story/50005743 · markdown: https://zeli.app/ru/story/50005743.md
