News for hackers. Stuff that matters.
Re:C++ design goals in the context of Rust (2010) by personZ on Saturday June 21, 2014 @12:11PM (#7925327)
A good example of how bad it has become is that modern processors have a rather good understanding of the 'string' concept, and offer instructions to process them. C offers a char.

The x86 string functionality that I'm aware of was directly derived from C string functionality, and any decent library of course uses them. You don't directly map to those underlying opcodes because that would be silly, and would completely undermine any platform independence you might have.

The same for vectorization. You don't explicitly express vectorization in your code, but of course all decent C compilers can easily and robustly generate such code.

C isn't close to the hardware (beyond very high level notions like "contiguous memory"). But it's a simple enough language that it's very heavily optimizable.

Re:C++ design goals in the context of Rust (2010) by ramchip on Saturday June 21, 2014 @12:57PM (#7925445)
> all decent C compilers can easily and robustly generate such code

From what I've seen auto-vectorization is anything but robust, often you need non-portable annotations to get anything decent. See e.g.: http://locklessinc.com/articles/vectorize/ where there's an interesting case where using "if" instead of a ternary operator is enough to prevent optimization.

Re:C++ design goals in the context of Rust (2010) by ori_b on Saturday June 21, 2014 @07:02PM (#7926311)
> The x86 string functionality that I'm aware of was directly derived from C string functionality, and any decent library of course uses them.

The string instructions tend to be slower than using generic instructions, especially in the presence of SSE.

Re:C++ design goals in the context of Rust (2010) by plorkyeran on Saturday June 21, 2014 @04:44PM (#7926014)
I have never encountered a C compiler which can reliably vectorize code not specifically written for its "auto"vectorizer, and it's sometimes easier to just write some asm than to persuade the compiler to vectorize a loop.
Re:C++ design goals in the context of Rust (2010) by pixelglow on Saturday June 21, 2014 @08:59PM (#7926521)
The problem with vectorization is that it cannot be applied to arbitrary code. You have to consciously design your algorithms, data and libraries to be SIMD-friendly.

I once wrote a SIMD C++ template library based on valarray: http://www.pixelglow.com/macstl. Sadly it has languished over the years but I would love to work on it again. It had novel (at the time?) vectorized trigonometric functions, for example.

Re:C++ design goals in the context of Rust (2010) by zanny on Saturday June 21, 2014 @08:49PM (#7926510)
> But it's a simple enough language that it's very heavily optimizable.

The simplicity of C means you can't make many assumptions of how it is handled. Same problem in C++. You can make a lot of optimizations to assembler if you can guarantee a value won't change, or if the relative location in memory needs to remain static because anything can rip the address and do awful pointer arithmetic with it.

I like to compare to asm.js - it is a reduced language in that it restricts the environment from doing things it can't easily optimize away, except in that case its to assembler. Reduced set versions of C exist to do the same already, but it would be nicer if you just had a fast language default with straightforward rules with ways to just declare wonderland functionality that can mess things up that means the compiler needs to preserve the machine assumptions rather than the language structures.