News for hackers. Stuff that matters.
Re:Google says replacing C/C++ in firmware with Rust is easy by pornel on Sunday September 08, 2024 @12:32PM (#41481336)
Rust superficially looks like C++ to avoid looking weird to existing C/C++ programmers, but semantically it's quite far from C++. Rust's generics are not like C++ templates: they're only type based, and don't use syntax-based matching, don't have tricks like SFINAE. ODR is guaranteed by construction. Trait lookup is simpler: there's no overloading, no inheritance, no implicit conversions, and interaction with namespaces is simple (ambiguity is an error).

Phantom type looks alien if you haven't used it, but for what it does, it's actually a pretty simple. It's there to explain in Rust's terms what an opaque type or a foreign C/C++ type does. You just need to give Rust an example of an equivalent type, and you get a correct as-if behavior, and you don't need to even know that you've just configured type's variance and destruction order checking.

Re:Google says replacing C/C++ in firmware with Rust is easy by throwawaymaths on Monday September 09, 2024 @01:22AM (#41485670)
Rusts generics might wind up adopting constexpr like abilities and also on the docket are keyword generics.