Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I freaking love his guides, I'm currently reading through his C guide: https://beej.us/guide/bgc/

It's very entertaining to read though which holds my attention well, and is well suited to people with existing programming experience. I've tried to read K&R but I keep coming back to Beej's.



I really want to like Beej, and I get that he wants to make things easy for people to understand, but his guides are full of unnecessary shortcuts which are actually wrong.

For example, he doesn't seem to understand the difference between arrays and pointers -- at [1] he says:

You can’t [get the length of an array] ish. C doesn’t record this information [footnote 50]. You have to manage it separately in another variable.

[footnote 50] says "Since arrays are just pointers to the first element of the array under the hood, there’s no additional information recording the length"

And then later he says:

There is a trick to get the number of elements in an array in the scope in which an array is declared. But, generally speaking, this won’t work the way you want if you pass the array to a function [footnote 51]

[footnote 51] says "Because when you pass an array to a function, you’re actually just passing a pointer to the first element of that array, not the “entire” array."

Footnote 51 is correct, and contradicts footnote 50.

There is a simple, and correct, way to explain this:

Arrays and pointers are distinct types in C but arrays are converted to a pointer to their first element, except when it is the operand of the sizeof operator, the _Alignof operator, or the unary & operator, or is a string literal used to initialize an array.

Yes, it's more wordy, but it's what's actually going on. Arrays aren't pointers, but he insists on claiming they are throughout. Footnote 51 shouldn't be a footnote, it should be prominent in the text.

[1] https://beej.us/guide/bgc/html/split/arrays.html#fnref50

P.S. Not going to go into it here, but his "unix" network programming guides used to be full of linux-specific things (without pointing this out), but I think it's improved over the last 10 or so years.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: