Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
dbaupp
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
100 ms
·
961.
▲
by
dbaupp
11y ago
You can , e.g. struct Foo; impl Foo { fn bar(&self) {} } fn main() { let x = Foo; Foo::bar(&x); } What you may be encountering is you can't pass a `Foo` when a `&Foo` is expected (why I n
962.
▲
A type-safe and zero-allocation library for reading and navigating ELF files
(ncameron.org)
2 points
by
dbaupp
11y ago
|
0 comments
963.
▲
by
dbaupp
11y ago
Rust's ownership model does more than just allow avoiding a garbage collector. It allows managing arbitrary resources more easily, so it is clear who is control of things at any point of time, e.g. if a function takes a File, who shoul
964.
▲
by
dbaupp
11y ago
I don't see how Rust can get the same syntax as C++ without having the implicit performance sink I mentioned: creating vectors and hashmaps needs to allocate, and so letting this happen implicitly is not great. In fact, the syntax was
965.
▲
by
dbaupp
11y ago
Initialistion from initializer lists in C++ basically rely on the = operator being able to do arbitrary work, e.g. allocations and generally manipulating the heap in arbitrary ways. Rust tries to avoid implicit performance sinks like that,
966.
▲
by
dbaupp
11y ago
You personally don't have to write the macro: cargo makes it super easy to use ones others have written, e.g. https://crates.io/crates/maplit/ .
967.
▲
by
dbaupp
11y ago
A lot of people care: e.g. the Rustonomicon[1] spends a lot of time caring about unsafe code (that is one of the main reasons for it to exist), and the massive RustBelt project[2], which Ralf (author of the blog post) is part of, is because
968.
▲
by
dbaupp
11y ago
As people keep saying, one only has to verify functions that can break invariants, e.g. if you define a type that has invariants needed by `unsafe` blocks, then one has to take a close look at any functions that can modify its internals (
969.
▲
by
dbaupp
11y ago
&mut vs. & isn't fundamentally about mutability: having unique access (as in &mut) does imply that mutation will be "safe" (as in, act of mutating won't cause problems, although it may violate invariants in w
970.
▲
by
dbaupp
11y ago
I'm not really sure what the problem is here: having to formally verify a module doesn't seem fundamentally different to formally verify a single function. I mean, sure, it's some more code, but there's still well-define
971.
▲
by
dbaupp
11y ago
Yeah, they're compound but don't have to be serial, due to the VPMIN/VPMAX instructions, but definitely much nicer on x86. For instance: int all(uint32x4_t v) { uint32x2_t x = vpmin_u32(vget_low_u32(v),
972.
▲
by
dbaupp
11y ago
What overplayed drama? The discussion happened on Firefox bug 366559, 'bro' was raised in comment 146 and 'br' was proposed/"accepted" by 152. There was of course a lot of complaints/trolling after th
973.
▲
by
dbaupp
11y ago
Haskell's GHC offers optimisations-in-libraries via its RULES pragma[1], which allows specifying rewrite rules. These are an important part of the deforestation[2] that makes, for instance, lists and vectors fast. [1]: https:/&#x
974.
▲
by
dbaupp
11y ago
Yes, on the RFC: https://github.com/rust-lang/rfcs/pull/243#issuecomment-1633...
975.
▲
by
dbaupp
11y ago
Rust (e.g. starting with the book[1]) will also teach you about RAII, generics, polymorphism, and ownership and move semantics... the latter two in a far more explicit and clearer (IMO) way than C++ too. That said, of course, without C/
976.
▲
by
dbaupp
11y ago
That can still be done without a GC, e.g. the following is sketch of lazy evaluation in Rust: use std::mem; enum Lazy<T> { Thunk(Box<Fn() -> T>), EvalInProgress, Forced(T), } impl<T> La
977.
▲
by
dbaupp
11y ago
Some algorithms are tricky, but there's a lot one can do without a GC via epoch-based reclamation schemes: http://aturon.github.io/blog/2015/08/27/epoch/ (I guess this could very well be regard
978.
▲
by
dbaupp
11y ago
Using 'relaxed' (or acquire/release) for performance without some vague understanding of the semantic implications (of relaxed especially, and the memory model more generally) is a recipe for disaster and some confusing bugs.
979.
▲
by
dbaupp
11y ago
It's more than exotic/legacy hardware: ARM[0] and, to a (much) lesser degree, x86 have non-SC memory models. [0]: http://preshing.com/20121019/this-is-why-they-call-it-a-weak...
980.
▲
by
dbaupp
11y ago
Dereferencing nil is not an unsafe memory access in Go, just like a null pointer exception in Java isn't unsafe. Both are well-defined operations (sure, they yield errors, but they do so with 100% reliability and complete control), the
981.
▲
by
dbaupp
11y ago
Floating point is (usually) about "closest representable value". That is, the normal floats form a finite subset of the real numbers, and a calculation like x + y will pick the closest element to the true result. In this case, add
982.
▲
Finite state machines as data structure for representing ordered sets and maps
(blog.burntsushi.net)
213 points
by
dbaupp
11y ago
|
25 comments
983.
▲
Bare Metal Rust 2: Retarget your compiler so interrupts are not evil
(randomhacks.net)
140 points
by
dbaupp
11y ago
|
16 comments
984.
▲
by
dbaupp
11y ago
> Handling memory allocation failure is trivial The problem I'm talking about is allocation failure and OOM are not the same: handling out-of-memory reliably is a lot more than just checking for NULL in `malloc`, as I demonstrat
985.
▲
by
dbaupp
11y ago
It's definitely very important for some domains, but handling OOM "properly" is a really vague/impossible concept for most non-bare-metal programming. Modern operating systems will over-allocate/over-commit memory v
986.
▲
by
dbaupp
11y ago
> all the core team for one Not all (Yehuda and me, Huon), although both of us have been paid by Mozilla at some point in the past.
987.
▲
by
dbaupp
11y ago
To emulate the parent exactly e.g. maybe it is just the prefix of the "dict_breaker" function and other things happen later if the key can't be found.
988.
▲
by
dbaupp
11y ago
The latter isn't actually the typical Python style. As the article discusses, Python generally prefers "EAFP"[1] to "LBYL"[2], e.g. def dict_breaker(some_dict): try: return parse_some_items(some_
989.
▲
by
dbaupp
11y ago
> "Swift is a successor to both the C and Objective-C languages." Saying something doesn't automatically make it true... however, I believe it is in this case, but maybe not to the degree the quote/you imply: it see
990.
▲
by
dbaupp
11y ago
Well, my rephrasing was meant to be more than just s/validity/liveness/: I find that removing quantifiers (like for-all) often improves my understanding, as it usually gives more obvious context/motivation for what the g
More ›