News for hackers. Stuff that matters.
Re:What’s to love about C? by alexchamberlain on Monday June 11, 2012 @06:43AM (#4093951)
There's an old adage that a computer only does what you tell it to do. What I love about C? It really does only do what you ask it to; nothing more, nothing less.
Re:What’s to love about C? by anonymoushn on Monday June 11, 2012 @07:07AM (#4094015)
When C does what you ask it to do, you're probably just getting lucky. It's more or less impossible to write a nontrivial C program without relying on undefined behavior.
Re:What’s to love about C? by stephencanon on Monday June 11, 2012 @09:38AM (#4094489)
With the exception of the translation limits (a strict reading of which may allow a compiler that can only compile a single program), it's pretty much trivial to avoid undefined behavior.

Implementation-defined behavior can be harder to avoid, but that's not a problem if you're targeting a known implementation.

Re:What’s to love about C? by qznc on Monday June 11, 2012 @09:21AM (#4094408)
Enable all warnings and fix them!
Re:What’s to love about C? by derleth on Monday June 11, 2012 @06:56AM (#4093981)
> It really does only do what you ask it to; nothing more, nothing less.

Not even assembly language has this property anymore, especially in the presence of an OS.

Which leads me to what I think is C's greatest weakness: It's no longer a thin layer over assembly language. It is so far removed from the current trends hardware design it doesn't even have functions that implement memory barriers as part of the core language, let alone any language features to help you take advantage of whatever SIMD hardware the machine possesses.

Part of this is C becoming a victim of its own success: People expect the same language to compile down to ARM and x86-64 and IBM mainframe (zSeries) and so on and so forth machine code, and do it in an efficient manner. Since low-end ARM chips don't have SIMD, C can't have SIMD, the thinking goes (even though low-end hardware doesn't have FP opcodes, either, but floating-point math is still part of the C standard).

They rely on compilers to make it fast, which is reasonable to some extent but it's also the same thing you rely on when you write in Haskell. It's contrary to the spirit of things.

I'm not advocating a return to assembly language. That would be massively stupid. However, it would be nice to have a language with concise syntax that also allows you access to the processor's status word (the carry flag, for instance).

Re:What’s to love about C? by kzrdude on Monday June 11, 2012 @07:07AM (#4094018)
C has memory barriers now in C11.
Re:What’s to love about C? by gaius on Monday June 11, 2012 @08:39AM (#4094267)
Right, but you would just link against the appropriate library, BLAS or whatever, that is hand-tuned for your platform and exposes a C API.
Re:What’s to love about C? by lmm on Monday June 11, 2012 @09:24AM (#4094427)
For the kind of problem where I can take that approach, I also have a python API onto BLAS, and guess which I prefer to write my programs in.
Re:What’s to love about C? by gaius on Monday June 11, 2012 @09:32AM (#4094461)
There's nothing in the "Python way" that precludes dropping into C as and when it makes sense to do so. A C programmer is able to make that decision independently.
Re:What’s to love about C? by JohannL on Monday June 11, 2012 @06:53AM (#4093979)
I was just typing up a reply saying just that in more words when I saw yours; so for the sake of efficiency I'll just make my post a pointer to yours ^^