News for hackers. Stuff that matters.
Re:The Resurgence of C Programming by overgard on Tuesday December 27, 2016 @02:10PM (#13265308)
C has this mystique of being hardcore, but it's not really that hard. I actually think languages like Ruby are more difficult because they hide so many (important) details from you. I would agree that C can be inconvenient, but its not hard.
Re:The Resurgence of C Programming by Vindicis on Tuesday December 27, 2016 @02:29PM (#13265523)
C's syntax is simple, sure. But there's so many little things that can bite you in the ass very easily, which is why most people think it's hard. For production code, if you don't have a copy of whatever standard, and aren't able to use that to find your answers, you shouldn't be working on that code.

Think of it like this: In python you could be a beginner, and still write effective code to accomplish your goal. And while it might be slow, you also avoid having deal with a great many subtleties, which in C, to write code for a similar function, you could very well need to be high-intermediate to write the same bug-free code.

Faster? Most likely, but if it's error-prone, does speed really matter?

That's my belief anyway, ymmv.

Re:The Resurgence of C Programming by elcritch on Tuesday December 27, 2016 @03:59PM (#13266135)
To reinforce this, I still believe C is one of the most elegant syntax's for a "portable assembler". There are many dark corners of C, take for example pointers: https://kristerw.blogspot.com/2016/03/c-pointers-are-not-har...
Re:The Resurgence of C Programming by bogomipz on Tuesday December 27, 2016 @06:58PM (#13267368)
This is an interesting read, thanks. However I do not understand the opening sentence:

"Pointers in the C language are more abstract than pointers in the hardware, and the compiler may surprise developers that think that pointers in C work in the same way as pointers in the CPU."

What are pointers in the hardware? I am not sure what is being said. Any ideas?

Re:The Resurgence of C Programming by cesarb on Tuesday December 27, 2016 @07:18PM (#13267467)
> What are pointers in the hardware?

Under current "flat address space" architectures, a pointer in the hardware is nothing more than a memory address, represented as an integer. That is, a pointer with value 0x12345678 is the address of the memory 0x12345678 bytes above the start of the virtual address space.

In the C language, pointers are more abstract: they have to point to either within an object, or one past the end of an object. This is because there are architectures like segmented architectures, where a pointer has two parts (segment and offset) and cannot be treated just like an integer, and the same C program should in theory be able to also run in these architectures without change.

Re:The Resurgence of C Programming by bogomipz on Tuesday December 27, 2016 @07:56PM (#13267631)
Thanks for pointing out the alternative of segmented memory, this now makes sense. Cheers.
Re:The Resurgence of C Programming by ArkyBeagle on Tuesday December 27, 2016 @07:06PM (#13267412)
If you need a "copy of whatever relevant standard", then you're in some fairly deep trouble. Use the 10-40% of the language that works all the time, and you'll have no such trouble. Use the language such that constraints are available to be checked against ( i.e. , no blind pointers ) and you'll be healthier.
Re:The Resurgence of C Programming by TheAceOfHearts on Tuesday December 27, 2016 @05:19PM (#13266704)
I think that when people say "C is hard", what they usually mean is "writing portable bug-free code with C is hard".
Re:The Resurgence of C Programming by tyingq on Tuesday December 27, 2016 @09:17PM (#13267941)
At least for some, "C is hard" translates into "pointers and their syntax are difficult to grok, especially around arrays and structs".

The other I've commonly seen is transitioning from a language that allows arbitrary data in a "string" variable. Null-terminated strings are no fun in comparison, and passing buffers around is more work.

Re:The Resurgence of C Programming by ArkyBeagle on Tuesday December 27, 2016 @07:10PM (#13267428)
That's because the dominant ideas about what "portable" means are pretty bad. To wit - the way the Linux kernel does it isn't my first choice...