News for hackers. Stuff that matters.
Re:Why is strlen so complex in C? by MadWombat on Monday August 26, 2019 @06:51PM (#20804530)
This is kind of the point of C. It maps directly to the hardware. There are very few decisions the compiler has to make about the code. And it is for that reason that C does not allow for higher level abstractions. On one hand, it is a pain to write. On the other hand, you know exactly what is going on under the hood and nothing is ever going to stop you from shooting yourself in a body part of your choice :)
Re:Why is strlen so complex in C? by ncmncm on Monday August 26, 2019 @08:08PM (#20804977)
C gives the illusion of mapping to the hardware. Hardware manufacturers have moved heaven and earth to help maintain the illusion. It finally got too hard and they had to admit atomics and cores ro the model. The next watershed will be along soon enough, but the ability to present as a C machine has long been the gateway to success or failure of a new hardware architecture. Myriads of arguably superior machine designs have foundered on "but can I code for it in C?"
Re:Why is strlen so complex in C? by kllrnohj on Monday August 26, 2019 @07:19PM (#20804696)
> This is kind of the point of C. It maps directly to the hardware.

No it doesn't. It didn't in the past, it was a high-level abstraction. And it doesn't today, because CPUs don't behave at all like C's defined virtual machine.

Re:Why is strlen so complex in C? by justinmeiners on Monday August 26, 2019 @07:24PM (#20804731)
> CPUs don't behave at all like C's defined virtual machine

What "virtual machine" are you referring to?

Re:Why is strlen so complex in C? by anticensor on Sunday September 08, 2019 @03:47PM (#20912936)
One that ISO 9899 refers to as its abstract machine.
Re:Why is strlen so complex in C? by saagarjha on Monday August 26, 2019 @07:32PM (#20804787)
The one defined in the standard.
Re:Why is strlen so complex in C? by tinus_hn on Monday August 26, 2019 @10:05PM (#20805709)
How can it map directly to the hardware and be portable at the same time?