Better HN
topnewbestaskshowjobs
Log inSign up

aw1621107

4,653 karma · joined Apr 24, 2017 (9y ago) · 1,481 submissions

Submissions

comment 5d ago · link · parent

Were you seeing slow trait resolution times with the old or new solver? If the latter I think you're more likely to get a dev response if you open an issue [0] with more details than posting here.

[0]: https://github.com/rust-lang/rust/issues

comment 5d ago · link · parent

> or even -O5

-O4 and higher are (currently) equivalent to -O3

> I don't depend on serde because I knew it is bloated but didn't know serde_json was so bloated too.

serde_json depends on serde though?

> I don't think there are any template use in either project except things like hashmaps and slices etc. I don't use traits except to interact with dependencies in rust.

If you're interested in investigating further it might be worth trying cargo bloat [0] or similar to get a bit more data about what is consuming space. rustc's self-profiling framework [1] might be another way to get data.

[0]: https://github.com/razrfalcon/cargo-bloat

[1]: https://github.com/rust-lang/measureme

comment 1w ago · link · parent

Manually implementing the Drop trait, perhaps, but the same can't be said for the drop operation, which you always get at the end of scope unless you opt out (which is very much a rare thing to do).

comment 1w ago · link · parent

I'm not super familiar with Lua so just to make sure I'm understanding you correctly are you referring to to-be-closed variables?

If so, I think the difference is that in C++/Rust RAII is the default and is quite pervasive as a result. To-be-closed variables seem like IDisposable in C# or try-with-resources in Java in that they allow the programmer to use RAII-like semantics but are opt-in.

comment 1w ago · link · parent

At least from what I can remember the work is in an early enough stage that multiple proposals being considered. IIRC dedicated syntax is in the cards as well.

comment 1w ago · link · parent

> Well, in Rust, you can't make your own Box without using #[lang = "owned_box"] and #[fundamental], plus it has special orphan rule handling.

Sure, but are those "just" characteristics of Rust's current implementation or are those inherent to a constructor-less model in general? The latter is the more interesting question to me in this particular context, and I think it's similar to the question you express.

comment 1w ago · link · parent

Even if you assume that's true that seems more like "constructors are needed for implementation inheritance" than "constructors are needed for RAII".

I'm not even sure about the former? The important bit is that base class invariants can't be observed in an invalid/inconsistent state, and regular visibility/privacy/etc. rules seem technically sufficient for that? I'm not sure where exactly the boundaries of "constructor-like concept" are supposed to lie.

comment 1w ago · link · parent

Rust doesn't really have a good answer for guaranteed copy elision or in-place initialization at the moment. The devs are working on it, though (https://github.com/rust-lang/rust/issues/153825).

comment 1w ago · link · parent

You don't really need C++-style constructors for RAII though. Rust implements similar semantics as C++ in that regard and constructors aren't a thing there.

comment 1w ago · link · parent

Both those feel a bit like circular arguments? They need constructors because that's how they are currently defined, but that doesn't say anything about whether they could also be defined without constructors.

The latter was what I was interested in, and I apologize for not making that clear. For instance, in Rust terms both those seem replaceable in principle via calls to appropriate trait functions like Default::default() or From::from().

comment 1w ago · link · parent

That feels a bit like begging the question? Library types only need constructors to replicate built-in types if built-in types use constructors themselves. But do built-in types need constructors? What is lost by just using regular functions?

Also I was under impression that Rust at least has a similar goal?

comment 1w ago · link · parent

Do you mind elaborating more on the "core assumptions" and/or the optimizations they preclude? Don't think I've heard anything yet about things LLVM can't do as opposed to things it can't do yet.

comment 1w ago · link · parent

> So I would not frame it as "Rust devs don't see the need for this" but "the Rust devs have not yet convinced enough industrial backers to support a real ecosystem around the language".

Those don't seem mutually exclusive to me. If the Rust devs don't think they need such things then I wouldn't be surprised if they don't bother trying to get industrial support for them as well. Basically everything is a tradeoff, after all, those things included.

It's also unclear to me what novel things are missing from Rust's current ecosystem that a "real ecosystem" enabled by a Rust backend would have. Cranelift exists, after all, and I'm not aware of such an explosion of features/projects to call Rust-with-Cranelift a "real" ecosystem while the ecosystem for Rust-with-LLVM isn't "real"

If anything, I'm not sure the choice of language for the compiler makes that much of a difference for a language ecosystem, if any at all, since the ecosystem is generally concerned with... well, the language, not compiler internals, much less the backend specifically. For example, I don't think the C/Fortran ecosystems particularly care that their main compilers are now written in C++. Similarly, I don't think the TypeScript ecosystem particularly cares that its main compiler is now written in Go instead of TypeScript. All they care about is that there is a compiler.

A similar line of argument applies for "less serious", I suppose, though that is a bit more subjective.

comment 1w ago · link · parent

> Actually there literally is a command line flag to disable the borrow checker, since it’s slow

I think this is misleading? There is a flag to disable the new borrow checker implementation (Polonius) since it can be slower than the old one, but that flag does not disable the old borrow checker implementation.

Furthermore, that flag is nightly-only right now since Polonius has not been stabilized yet. I wouldn't be surprised if it were removed if/when Polonius is stabilized.

IIRC the devs' decision to not have some kind of "lenient" mode was intentional, so I'd be rather surprised if there were an official way to completely disable the borrow checker.

comment 1w ago · link · parent

That's why I asked OP for clarification. To me, if you "need" something that something is a hard requirement to achieve some goal, so what you "need" will depend on your specific goal(s). Rust obviously doesn't need to fully bootstrap itself since... well, it exists, so presumably OP had some other endpoint in mind.

To me, the things you describe might be nice to have, and I certainly could understand a language choosing a set of goals that makes those an actual requirement, but I have yet to hear of Rust devs taking that particular stance.

comment 1w ago · link · parent

In that case I think I'd agree that references are not a silver bullet, especially with modern optimizing compilers.

comment 1w ago · link · parent

Oh, I thought you had something more serious in mind. I wouldn't really call that kind of claim "essential", particularly given the rather wide range of claims made by people with a rather wide variety of expertise that are attributed to the RESF.

comment 1w ago · link · parent

Not in the same way contracts were/are able to be disabled. There's no command line flag or build mode to disable the borrow checker or assert!()s or bounds checks or etc. There is debug_assert!() which is disabled in release mode, but the original code author decides when and where to use that.

comment 1w ago · link · parent

Ah, that makes sense. Thanks for explaining!

comment 1w ago · link · parent

I'm not particularly convinced the presence of C++ in the toolchain is a good deciding factor for whether you can trust the compiler (well, depending on what exactly you mean by "trust", I suppose). If anything, I think people already generally consider the Rust (and C and C++ and Fortran and etc.) compilers built on said backends trustworthy so it's not clear that anything is missing in the first place.

comment 1w ago · link · parent

"Needs" seems like a rather strong word to me. What essential thing is lost by not fulfilling that requirement?

comment 1w ago · link · parent

I'm confused as to what the distinction between "proven them optimal (up to constant factors)" and "prove their runtimes" is intended to be.

comment 1w ago · link · parent

Do you mind elaborating? Modern compilers will definitely optimize out checks for null references [0] (but probably aren't guaranteed to), so checking after the fact seems like an iffy proposition to me at best.

[0]: https://cpp.godbolt.org/z/6ze9ns7cz

    bool pointer(int* p) {
        return p == nullptr;
    }

    bool reference(int& r) {
        return &r == nullptr;
    }
Become

    pointer(int*):
            test    rdi, rdi
            sete    al
            ret

    reference(int&):
            xor     eax, eax
            ret
When compiled with Clang 23.1.0 and -O1.

comment 1w ago · link · parent

> While they help avoid this, because of the way C++ behaves it may result in a null object as well, so a run-time check is still needed.

I think the difference is that with references you can only perform such a check before you create the reference. Pretty sure optimizers can and will elide checks for null references.

comment 1w ago · link · parent

> For standardizing packaging, one would need a different committee, which may or may not align with the C++ revisions.

I don't think you need a separate committee. There were efforts to create a standardized packaging system through the committee, but the author decided to pursue a different path outside of the committee after it was clear that the committee's priorities were elsewhere.

comment 1w ago · link · parent

Contracts as originally designed by the committee were explicitly not meant to enforce memory safety in that way. You were not supposed to be able to rely on the existence of any particular contract check at runtime. This recent change was something that the committee had rejected earlier, and probably begrudgingly accepted this time around as a compromise to try to ensure the NB vote passes

The two features you list don't have to depend on contracts, and in fact didn't do so at first. The dependency was only added later, and there were efforts to undo such a change right to the end.

Furthermore, IIRC hardening only relies on the contracts system to report precondition violations. The actual checks are intentionally not contract assertions and are intentionally not controlled via the same system as other contract assertions (i.e., hardened checks remain even if you use "ignore" as your contract evaluation semantic).

comment 1w ago · link · parent

That would depend a lot on what exactly the proof shows. The consequences of a non-constructive proof that P=NP would probably be different than a constructive one that shows a specific low-order/low-constant-factor algorithm suffices.

And even then, it's probably better in the long run to secure the foundations of our tech.

comment 2w ago · link · parent

Thanks! Looks like some interesting developments indeed, and I will have to update my understanding accordingly.

comment 2w ago · link · parent

> Or check SIGPLAN papers on machine learning based compilers.

Mind providing some examples? My (admittedly probably dated) understanding of how ML is used in compilers is for picking heuristics/thresholds/other things for which there's no known optimal "right" answer (e.g., pass order, inlining thresholds). Everything else was done in the "traditional" manner, which meant that the machine learning bits were, strictly speaking, completely optional. I haven't heard of compilers where ML techniques are integral to the process to the point where removing any ML bits would result in a nonfunctional compiler.

12345
50