News for hackers. Stuff that matters.
Re:Optimizing Rust Struct Size by CAMLORN on Saturday April 15, 2017 @06:57PM (#14123303)
Rust doesn't currently guarantee ABI compatibility. You can't load Rust from a shared library without going via repr(C) anyway. I imagine that the algorithm will be frozen whenever we get to this point, but it shouldn't need to change again unless someone tries to take us as far as what Swift does (which would potentially be a much bigger project than this). There's also been discussion of giving you tools to control it more explicitly, but thus far no one has proposed an RFC.
Re:Optimizing Rust Struct Size by phkahler on Saturday April 15, 2017 @10:16PM (#14124000)
>> Rust doesn't currently guarantee ABI compatibility.

And yet they claim it's a systems programming language. While I can see the value in doing this, I can see the value in doing it manually. Another criteria can be putting the most frequently used fields together, so accessing one causes the others to load in the same cache line. In many programs the size of the structure is not important, it's the cache behavior that is and that is dependent on a lot more than the size of the elements alone. It's probably important that it can be disabled with rear(C).

Re:Optimizing Rust Struct Size by kibwen on Saturday April 15, 2017 @11:27PM (#14124174)
> And yet they claim it's a systems programming language.

C++ also doesn't guarantee a stable ABI, and even the C ABI is only de facto standardized on various platforms, nothing is provided by the language standard itself.

Re:Optimizing Rust Struct Size by dom0 on Sunday April 16, 2017 @08:04AM (#14125483)
C and C++ ABI is implementation defined. All major platforms have a standard ABI for both, although sometimes it's broken intentionally. E.g. MinGW uses a GCC/Linux-like C++ ABI and not the MSVC C++ ABI.

Note that "platform" means e.g. Linux-x86-64 and not Linux. Linux-ppc has different rules, for example.

Re:Optimizing Rust Struct Size by jjnoakes on Sunday April 16, 2017 @09:55AM (#14125795)
Not true for c++ unless you include the compiler and version in your "platform".
Re:Optimizing Rust Struct Size by cryptonector on Monday April 17, 2017 @04:29PM (#14134142)
But then again, C++ isn't really a systems programming language, though a subset can be. The C ABIs are basically the ABIs published by each OS on each architecture, and typically they derive these from the ABIs published by the CPU vendors. Third party C compilers are expected to adhere to a platform's C ABI, and generally they do.

Rust absolutely could be a systems programming language, but it will need at least repr(C) and such options to interface with: a) hardware, b) code not written in Rust or compiled with a different version of the Rust compiler. Sometimes (b) means "with itself", e.g., via structs saved in files with no additional encoding.

Re:Optimizing Rust Struct Size by dbaupp on Sunday April 16, 2017 @03:47AM (#14124851)
Your exact concern was raised and discussed earlier: https://news.ycombinator.com/item?id=14123252
Re:Optimizing Rust Struct Size by jeffdavis on Saturday April 15, 2017 @11:34PM (#14124189)
Rather than manually, how about with a tool assist?