News for hackers. Stuff that matters.
Re:Conflating pointers with arrays: C's biggest mistake? (2009) by bluetomcat on Sunday July 22, 2018 @05:22AM (#17585981)
C requires you to understand its conceptual execution and memory layout model in order to write safe code. That is, how the call stack works, the different types of storage, that each type has alignment requirements, and I'm not even mentioning threading issues.

No amount of syntax sugar on top will prevent you from writing unsafe code, unless that basic model is thrown away.

Re:Conflating pointers with arrays: C's biggest mistake? (2009) by Too on Monday July 23, 2018 @03:15AM (#17591044)
Quite the contrary, it's when people think they understand the memory layout, the callstack, the alignment requirements, etc and abuse that knowledge to "optimize" their code or out of sheer laziness you get all the problems of C. Just ignore how things are stored in memory and treat it like Java and you will be just fine. Only difference should be that you have to think about memory allocation and object lifetime/ownership.
Re:Conflating pointers with arrays: C's biggest mistake? (2009) by pjmlp on Sunday July 22, 2018 @06:22AM (#17586105)
Except that languages even older than C made those issues easier to track down.
Re:Conflating pointers with arrays: C's biggest mistake? (2009) by bluecalm on Sunday July 22, 2018 @10:26AM (#17586913)
You don't need to know anything about alignment to write normal safe C code. Only when to dive deep into performance optimization you start to worry about those things but hopefully by then you care enough to make sure to check what the language spec allows.

Seriously, just don't cast object of one type to another type and you can forget about alignment until you need to optimize.

Re:Conflating pointers with arrays: C's biggest mistake? (2009) by MaulingMonkey on Sunday July 22, 2018 @12:09PM (#17587393)
Compiler generated SSE, and multithreading primitives, etc. will break on unaligned access even on relatively unalignment-tolerant x86 chips - to say nothing of stricter ARM CPUs.

You need to keep this in mind basically any time you're going from byte buffers to more complicated types. Basically anything touching allocation or IO needs to be aware of it, IMO, even before optimization.