Falsehoods Programmers Believe About Null Pointers

2025-02-01
Falsehoods Programmers Believe About Null Pointers

This article debunks common misconceptions about null pointers. It explores fallacies ranging from the simple (dereferencing a null pointer doesn't always crash the program immediately) to the bizarre (the null pointer's address isn't always 0). The author argues against relying on compiler optimizations or hardware specifics, highlighting the dangers of assuming consistent behavior across platforms. The article emphasizes that C should be treated as a higher-level language, not just "portable assembler," and encourages leveraging modern languages' memory safety features for more robust and portable code.

Read more
Development null pointer

Debunking the RAM Myth: Optimizing Memory Access

2024-12-19
Debunking the RAM Myth: Optimizing Memory Access

This article challenges the common misconception about modern computer memory—the RAM myth—that assumes memory access is always random and uniform. By analyzing data sharding algorithms, the author demonstrates that simple linear algorithms are inefficient for large datasets due to frequent cache misses. To address this, an optimized strategy based on radix sort is proposed. Techniques like pre-sorting data, using generators, and pre-allocating memory significantly improve data sharding efficiency. Experimental results show that the optimized algorithm achieves a 2.5 to 9x speedup when processing large datasets.

Read more