News for hackers. Stuff that matters.
Re:What Every C Programmer Should Know About Undefined Behav... by lmm on Thursday January 05, 2017 @05:29AM (#13326086)
Why would anyone who didn't want these optimizations be using C in this day and age? Your link briefly mentions Rust, D and Go, but only to say the author hasn't really looked at them, when they seem to be exactly the solution the author wants.
Re:What Every C Programmer Should Know About Undefined Behav... by qwertyuiop924 on Thursday January 05, 2017 @07:43AM (#13326657)
Here's why: C is dang near as close to the hardware as you can get without touching it, it runs everywhere, and it has so little abstraction that it's hard to incur unexpected costs. Rust is closer to C++ here, and the other languages on your list are so far outside the ballpark that they can't even touch the edge of it.

It's not the only language of this sort, but C also has a lot of code written in it, which is a major advantage.

Re:What Every C Programmer Should Know About Undefined Behav... by dragonwriter on Thursday January 05, 2017 @09:39AM (#13327384)
> C is dang near as close to the hardware as you can get without touching it

Not really; it's structurally nothing like assembly, which is as close as you can get to the hardware without just handcoding machine code.

Now, C -- for a structured language with static typing -- provides very little in terms of safety features that get in the way of direct hardware manipulation, whereas lots of languages with superficially similar structure aim to be safe in some ways by default which makes some hardware manipulation more difficult, or at least more verbose, than it would be in C. So, in some ways it gets less in the way of freedom to manipulate the hardware than some other structured programming languages.

But it's not particularly close to the hardware at all.

Re:What Every C Programmer Should Know About Undefined Behav... by nickpsecurity on Thursday January 05, 2017 @10:27AM (#13327819)
To support your argument, p-code is closer to what a portable, assembly language looks like. It's an abstract machine that can be trivially targeted to about any CISC or RISC machine. Let amateurs without compiler knowledge port Pascal/P to around 70 architectures in 2 years.

https://en.wikipedia.org/wiki/P-code_machine

Linoleum was another:

http://anynowhere.com/bb/layout/html/frameset.html

The closest in C land was C-- by Jones et al which still looks heavy compared to p-code:

http://www.cs.tufts.edu/~nr/c--/index.html

Re:What Every C Programmer Should Know About Undefined Behav... by qwertyuiop924 on Thursday January 05, 2017 @10:03AM (#13327578)
>Not really; it's structurally nothing like assembly, which is as close as you can get to the hardware without just handcoding machine code.

Here, assembly is touching the hardware. If you write your code in assembly, it's not portable to other architectures, even hypothetically.

>provides very little in terms of safety features that get in the way of direct hardware manipulation

Exactly. So it's a heck of a lot closer to the hardware than most 3GLs.

Re:What Every C Programmer Should Know About Undefined Behav... by lmm on Thursday January 05, 2017 @09:26AM (#13327278)
> C is dang near as close to the hardware as you can get without touching it

Not really true in the context of the optimizations done by modern C compilers (e.g. autovectorization).

Re:What Every C Programmer Should Know About Undefined Behav... by qwertyuiop924 on Thursday January 05, 2017 @10:06AM (#13327602)
In some ways. But, as I discussed (dragonwriter brought it up) in a cousin comment, C still does direct hardware access better than most other 3GLs. And that matters sometimes.
Re:What Every C Programmer Should Know About Undefined Behav... by dbaupp on Thursday January 05, 2017 @12:39PM (#13329307)
C itself isn't that close. Vendor extensions and relying on the compiler to pattern match certain code are needed to get access to actual hardware features, like, for instance, rotating the bits of an integer, vector instructions and efficient integer overflow detection.