4,653 karma · joined Apr 24, 2017 (9y ago) · 1,481 submissions
comment 5d ago · link · parent
-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.
comment 1w ago · link · parent
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
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
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
comment 1w ago · link · parent
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
Also I was under impression that Rust at least has a similar goal?
comment 1w ago · link · parent
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
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
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
comment 1w ago · link · parent
comment 1w ago · link · parent
[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
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
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
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
And even then, it's probably better in the long run to secure the foundations of our tech.
comment 2w ago · link · parent
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.