Live data from Hacker News

An incoherent Rust

boxyuwu.blog

101–110 of 175 posts

Re: An incoherent Rust

#101
post #100

Earlier quoted context omitted.

That's a conversion, not the same. The naive equivalent to transmute would be int8_t x = 2; bool y = *reinterpret_cast (&x); But reinterpret_cast isn't valid in a constexpr scope.

> But reinterpret_cast isn't valid in a constexpr scope. std::bit_cast is

Oh cool, and it behaves like memcpy, not like pointer aliasing! I'm stuck with C++14 at work so I missed that one.

Re: An incoherent Rust

#102
To me, the correct solution to the problem of being tied to one ecosystem crate for utility features like serialization or logging is reflection / comptime. The problem is not the orphan rule, it’s that Rust needs reflection a lot more than a dynamically-typed language does, and it should have been added a long time ago. (It’s in development now, but it will most likely be years before it ships in a stable version.)

Re: An incoherent Rust

#103

Take a look at https://contextgeneric.dev , it's as close as one can get to solving this issue without modifying rustc.

Highly Expressive Macros

No thanks. Most of the time you do not need macros and adding those is not free.

     CGP enables you to write overlapping and orphan implementations of any trait, breaking free from Rust's coherence rules while maintaining type safety.
I am not sure that I need this. I can't remember to run this issue in the last couple of years.

Isn't it the case that coherence is what makes Rust’s dependency graph sound? So, why would I want to give up that?

Re: An incoherent Rust

#104

Earlier quoted context omitted.

Rust opened the door to innovation in the low-level languages space, but as long as it is already the most theoretically advanced practical language there, it will always attract the audience that actually wants to push it further. I don't know if there is a way to satisfy both audiences.

I think there is: a schism. Another language, inspired, intelligible and interoperable with Rust, but with other goals, likely ease of use or surface simplicity. In my mind it would be pretty much the same as Rust, but whenever a compile error gives you a suggestion in rustc would instead compile (and at most be a warning in this hypothetical language). Migrating from Rust to this language would be changing a single…

There is precedent: with type checkers like pyright you can opt into specific checks, or have a basic, standard, strict setting, each expanding the set of checks done.

How would dependencies work in this schism? E.g. if serde starts using named impls, do all dependencies have to use named impls?

Re: An incoherent Rust

#105

Take a look at https://contextgeneric.dev , it's as close as one can get to solving this issue without modifying rustc.

Highly Expressive Macros No thanks. Most of the time you do not need macros and adding those is not free. CGP enables you to write overlapping and orphan implementations of any trait, breaking free from Rust's coherence rules while maintaining type safety. I am not sure that I need this. I can't remember to run this issue in the last couple of years. Isn't it the case that coherence is what makes Rust’s dependency gr…

> Isn't it the case that coherence is what makes Rust’s dependency graph sound? So, why would I want to give up that?

Read the article that comment is on, it's all about why one would want that.

Re: An incoherent Rust

#106

Earlier quoted context omitted.

Reflection syntax (C++26 I think) has made my 30+ years-of-C++ brain melt. It's not insane, it's just ... melt-inducing.

Yeah, for me reflection and coroutines were the first changes to C++ where the implementation and use mechanics weren't immediately obvious by reading a few references. It requires a bit of proper study to wrap your head around it.

I agree. It was the first time I actually thought 'who the hell writes code like this?'

Re: An incoherent Rust

#107

Earlier quoted context omitted.

Rust opened the door to innovation in the low-level languages space, but as long as it is already the most theoretically advanced practical language there, it will always attract the audience that actually wants to push it further. I don't know if there is a way to satisfy both audiences.

I think there is: a schism. Another language, inspired, intelligible and interoperable with Rust, but with other goals, likely ease of use or surface simplicity. In my mind it would be pretty much the same as Rust, but whenever a compile error gives you a suggestion in rustc would instead compile (and at most be a warning in this hypothetical language). Migrating from Rust to this language would be changing a single…

I'd take `Rust with a GC and specialization` over current Rust any day.

Re: An incoherent Rust

#108
post #2

This isn't a new discussion it was there around the early rust days too. And IMHO coherence and orphan rules have majorly contributed to the quality of the eco system.

can you elaborate on how have they contributed to the quality of the ecosystem?

There are virtually no incompatible dependencies.

Re: An incoherent Rust

#109
post #80

As a non Rust man, how real are the problems in this article? Does it show up in real word or is it just a edge case? I only program in C17, C++ as C with classes and C#. Anyone can give me a good read what Traits even are?

Very real for library developers if the ecosystem started to slow down. Nonexistent for current consumers of libraries and application developers.

Re: An incoherent Rust

#110

Earlier quoted context omitted.

> starting playing around with std::launder and std::byte and strict aliasing rules and lifetime rules, and you'll yearn for the simplicity of Rust Annotations like std::launder, lifetime manipulation, etc solve a class of problems that exist in every systems language. They inform the compiler of properties that cannot be known by analyzing the code. Rust isn't special in this regard, it has the same issues. Without…

> Rust isn't special in this regard, it has the same issues. This is both fundamentally true and misleading. Rust has to solve the same issues but isn't obliged to make all the same bad choices to do that and so the results are much better. For example C++ dare not perform compile time transmutations so, it just forbids them and a whole bunch of extra stuff landed to work around that, but in Rust they're actually fin…

First of all mem::transmute is like bit_cast (which works perfectly fine in constexpr context), not reinterpret cast.

Second, this compiles just fine:

   constexpr int ivalue = 1;
   constexpr bool bvalue {ivalue};
This fails at compile time (invalid narrowing):

    constexpr int ivalue = 2;
    constexpr bool bvalue {ivalue};
Note we don't need bit_cast for this example as int to bool conversions are allowed in C++.
Post reply on HN