Earlier quoted context omitted.
Yes, thanks. Last I checked, you still lose features if you use manual memory management, betterC or no. Has this changed recently?
You loose builtin arrays and hashes and need to use a container library instead. Same goes for newing aggegates which can be replaced with smart pointers. Escaping closures (delegates) no longer works, but you can explicitly capture context in a struct. Those choices for builtin language features date back to the early inspiration from Java, but are increasingly being replaced with library implementations. We've adde…
RustBelt: securing the foundations of the Rust programming language
101–109 of 109 posts
Re: RustBelt: securing the foundations of the Rust programming language
#102Earlier quoted context omitted.
> > The most ironic part is that so many restrictions and problems are likely to provoke people to rely on whatever option happens to work, which might not be the best/safest one > Programs written in Rust are empirically safer than programs written in C or C++. But Rust defines safety as being safe from the kinds of errors that the Rust compiler is capable of making one safe from (buffer overflows, race conditions,…
> Rust is great for writing high-performance code Some high-performance code is CPU bound. To approach advertised FLOPS figure on any modern CPU, you must manually write SIMD code (typically SSE, AVX, and/or NEON). It’s only in Rust nightly, and is very limited. Without SIMD, you’ll only use a small fraction of CPU’s computational power. The only programming languages great for high-performance code are C and Fortran…
Later additions, SSE2, SSE 4.1, SSSE3, add double-precision floating point, and 8-16-32-64 bit integers support. Some of them come with unsigned and saturated versions (the latter clips to min/max when overflown).
In C++, I use these for performance-critical functions doing integer computations, bit manipulation, image processing (saturated integer math is especially useful for the latter). While it adds some complexity to the code esp. when it benefits from SSE 4.1 or SSSE3 instructions (I must implement SSE2-only workarounds for older CPUs), the performance improvement IMO justifies that.
Re: RustBelt: securing the foundations of the Rust programming language
#103Earlier quoted context omitted.
Until we have as much code written in Rust as is currently implemented in C, experience hasn't shown anything. The same claims and promises have been made for C++ in relation to vanilla C for ages, and it's just not true. An experienced C coder (which arguably takes longer to achieve) will perform as good as a C++ coder of equal skill level. All they do is trade complexity and convenience for simplicity and flexibili…
This working group literally just proved that a significant subset of Rust is safer than any comparable subset of C++. This isn't a matter of opinion. What more proof do you actually want than a formal proof? I seriously wonder what people think the whole point of this paper was.
Re: RustBelt: securing the foundations of the Rust programming language
#104Earlier quoted context omitted.
> > The most ironic part is that so many restrictions and problems are likely to provoke people to rely on whatever option happens to work, which might not be the best/safest one > Programs written in Rust are empirically safer than programs written in C or C++. But Rust defines safety as being safe from the kinds of errors that the Rust compiler is capable of making one safe from (buffer overflows, race conditions,…
> Rust is great for writing high-performance code Some high-performance code is CPU bound. To approach advertised FLOPS figure on any modern CPU, you must manually write SIMD code (typically SSE, AVX, and/or NEON). It’s only in Rust nightly, and is very limited. Without SIMD, you’ll only use a small fraction of CPU’s computational power. The only programming languages great for high-performance code are C and Fortran…
You might be thinking of the `simd` crate, in which case, you're right. But we are getting closer and closer to exposing a large set of vendor intrinsics: https://github.com/rust-lang-nursery/stdsimd --- You can use it today on Rust nightly. This includes runtime CPU feature detection!
ripgrep is an example of a program that is written in Rust, is CPU bound and uses explicit SIMD in various places to speed up text search. (It hasn't moved to stdsimd yet and is still using the `simd` crate and the old platform intrinsics system exposed by rustc. But ripgrep will move to stdsimd soonish.)
Re: RustBelt: securing the foundations of the Rust programming language
#105Earlier quoted context omitted.
> Rust is great for writing high-performance code Some high-performance code is CPU bound. To approach advertised FLOPS figure on any modern CPU, you must manually write SIMD code (typically SSE, AVX, and/or NEON). It’s only in Rust nightly, and is very limited. Without SIMD, you’ll only use a small fraction of CPU’s computational power. The only programming languages great for high-performance code are C and Fortran…
> and is very limited You might be thinking of the `simd` crate, in which case, you're right. But we are getting closer and closer to exposing a large set of vendor intrinsics: https://github.com/rust-lang-nursery/stdsimd --- You can use it today on Rust nightly. This includes runtime CPU feature detection! ripgrep is an example of a program that is written in Rust, is CPU bound and uses explicit SIMD in various plac…
Finally, someone in Rust community realized we don’t want higher-level abstractions, we just want whatever the hell our hardware can do. If that thing will go stable, I will consider Rust for a next project (BTW, doing CAD/CAM stuff for Windows).
Feature detection is no big deal, it’s just a couple of lines in C.
But I’m curious how well that thing gonna work in practice? In C++ we have low-level control over memory layout allowing to place these SIMD vector values in STL containers with correct alignment. We have function pointers with vectorcall calling convention that enable implementing CPU-dependent routines very efficiently. The compiler inlines a lot of that SIMD code. Maybe you know how much of that applies to rust + stdsimd?
Re: RustBelt: securing the foundations of the Rust programming language
#106Earlier quoted context omitted.
> Rust is great for writing high-performance code, or code that needs to be parallelised within a single process. However if performance is not a concern then a statically typed language with a GC is usually a better choice. Are there Rust programmers who disagree with that?
It depends on context. I don't think many would disagree that it would be easier , but better is very broad. Better in what way? For what purpose? For example, if you already know Rust, then "easier" may (or may not, depending on what sense of easy you mean!) not be a compelling argument. Rust is certainly not the best tool for every single task, but it also has broader applicability than "I can't possibly accept a G…
Re: RustBelt: securing the foundations of the Rust programming language
#107Earlier quoted context omitted.
> and is very limited You might be thinking of the `simd` crate, in which case, you're right. But we are getting closer and closer to exposing a large set of vendor intrinsics: https://github.com/rust-lang-nursery/stdsimd --- You can use it today on Rust nightly. This includes runtime CPU feature detection! ripgrep is an example of a program that is written in Rust, is CPU bound and uses explicit SIMD in various plac…
Very good. Finally, someone in Rust community realized we don’t want higher-level abstractions, we just want whatever the hell our hardware can do. If that thing will go stable, I will consider Rust for a next project (BTW, doing CAD/CAM stuff for Windows). Feature detection is no big deal, it’s just a couple of lines in C. But I’m curious how well that thing gonna work in practice? In C++ we have low-level control o…
That's great, but please consider that this is an unfair characterization. stdsimd has been in the works since 2016, and many people have been involved. It's not like nobody "realized" we needed to expose vendor intrinsics before then, but it just hadn't been worked on. It's a ton of work.
> Feature detection is no big deal, it’s just a couple of lines in C.
It's only a few lines in Rust as well. But this is spoken like someone who uses it instead of someone who was involved in making it available. :-) It's not just about querying the CPU, but enabling functions to compile with specific target and also reasoning through Rust's safety story there, which is non-trivial.
> But I’m curious how well that thing gonna work in practice? In C++ we have low-level control over memory layout allowing to place these SIMD vector values in STL containers with correct alignment. We have function pointers with vectorcall calling convention that enable implementing CPU-dependent routines very efficiently. The compiler inlines a lot of that SIMD code. Maybe you know how much of that applies to rust + stdsimd?
I don't see any reason why any of that would be a problem with Rust. Inlining is just as important to Rust as it is to C++, and so is control over memory layout. You should try it out and give feedback. :-) Now would be the time!
Re: RustBelt: securing the foundations of the Rust programming language
#108Earlier quoted context omitted.
Very good. Finally, someone in Rust community realized we don’t want higher-level abstractions, we just want whatever the hell our hardware can do. If that thing will go stable, I will consider Rust for a next project (BTW, doing CAD/CAM stuff for Windows). Feature detection is no big deal, it’s just a couple of lines in C. But I’m curious how well that thing gonna work in practice? In C++ we have low-level control o…
> Finally, someone in Rust community realized we don’t want higher-level abstractions, we just want whatever the hell our hardware can do. If that thing will go stable, I will consider Rust for a next project (BTW, doing CAD/CAM stuff for Windows). That's great, but please consider that this is an unfair characterization. stdsimd has been in the works since 2016, and many people have been involved. It's not like nobo…
It had been... in 2015. :)
Re: RustBelt: securing the foundations of the Rust programming language
#109Earlier quoted context omitted.
> Finally, someone in Rust community realized we don’t want higher-level abstractions, we just want whatever the hell our hardware can do. If that thing will go stable, I will consider Rust for a next project (BTW, doing CAD/CAM stuff for Windows). That's great, but please consider that this is an unfair characterization. stdsimd has been in the works since 2016, and many people have been involved. It's not like nobo…
> It's not like nobody "realized" we needed to expose vendor intrinsics before then, but it just hadn't been worked on. It had been... in 2015. :)