Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
dbaupp
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
33 ms
·
361.
▲
by
dbaupp
9y ago
"near linear" is sometimes used to refer to O(n log(n)^O(1)), that is, things that are linear other than a polynomial of log(n). This includes Schönhage–Strassen multiplication, with its O(n log(n) log(log(n))) complexity.
362.
▲
by
dbaupp
9y ago
(...) > While I get what this does, it looks very noisy. Losing the ability to do this in a single construct is fine w/ me if this is the result. FWIW, I agree, just demonstrating that replacing @ in patterns isn't the easy
363.
▲
by
dbaupp
9y ago
> 100% agree, but I think it's probably worth the extra complexity in Rust's implementation to restore familiarity with casting. This is framing it a trade-off between writing something complex once versus forcing everyone to
364.
▲
by
dbaupp
9y ago
> Ehhh I think it's not that bad, no harder than arithmetic expression parsing certainly. It's just one more grammar rule. Plus Rust supports everything that's needed already because of operator overloading. No, it force
365.
▲
by
dbaupp
9y ago
> Rust is often different for no real reason. Casting is a good example of this; what was wrong with `(i8)thing`? What does `as` gain us? Couldn't we have used `as` in a more powerful way, like context managers in Python for exampl
366.
▲
by
dbaupp
9y ago
The only difference between what is "code" and what is "work" is context: in this case, the work of interest is a property of some input code. If you want a framing that matches your notions of input better, just imagine
367.
▲
by
dbaupp
9y ago
> Why? Because underneath all that rust .... is an optimizing compiler, and it happens the author has decided to stay on the happy path of that. There is also an unhappy path there. Is that happy path wider? Maybe I think you've g
368.
▲
by
dbaupp
9y ago
What exactly are you nitpicking? 1000^depth is not a constant: the function here is "f(depth) = number of times the inner loop body executes". f(depth) = O(1000^depth). And, "times" here is serving the same role as &qu
369.
▲
by
dbaupp
9y ago
> I can't see anything that makes it non-conformant to build a rust compiler that dynamically allocates and places all of these on the heap, and is very non-constant time for local variable allocation. This is such a ... pointless
370.
▲
by
dbaupp
9y ago
In this case, the number of iterations (1000) of each loop is being held fixed, and the depth of nesting is varying, i.e. the body of the inner loop executes O(1000^depth) times.
371.
▲
by
dbaupp
9y ago
> AFAIK, stable unsafe Rust doesn’t even has malloc & free functions. It's stable to import the C malloc/free, and it's relatively easy to use Vec as an allocator: https://www.reddit.com/r/rust&#
372.
▲
by
dbaupp
9y ago
> The reason transmute is (particularly) unsafe is because it can be quite difficult to tell whether a variable is bound to a value, a (possibly implicitly-dereferenced) reference or a slice, and so, given transmute's implicit type
373.
▲
by
dbaupp
9y ago
> I don't intuitively know what "transmute" is That's fair, but... it's easily resolved by using Rust/reading the documentation. Humans don't intuitively know what, say, 'float' in C means,
374.
▲
by
dbaupp
9y ago
> are still more ergonomic and, ironically, safer than Rust's poorly-designed `mem::transmute()` API. Eh, I disagree. I find: let x: f32 = ...; let y: i32 = mem::transmute(x); is nicer than float x = ...; in
375.
▲
by
dbaupp
9y ago
That doesn't work. std::weak_ptr is a reference counted pointer matched to std::shared_ptr; there's no concept of weak pointers (i.e. non-owning with dynamic checks) for std::unique_ptr, which corresponds almost exactly to Rust&#x
376.
▲
by
dbaupp
9y ago
No, I am disagreeing with your explicit disagreement with "implementing a data structure like this in a non-garbage collected language without Rust is also quite tricky". Now that I reread for a third time, I suspect you may
377.
▲
by
dbaupp
9y ago
A write-up for the latter: https://isocpp.org/blog/2014/06/stroustrup-lists High level summary: linked lists are usually not the best data structure.
378.
▲
by
dbaupp
9y ago
I'm arguing against your top-level original comment; I have no attachment to any particular scheme for implementing linked lists, they're just examples of things that are almost right, but are wrong enough to result in memory corr
379.
▲
by
dbaupp
9y ago
If you're trying to encourage people to implicitly trust as few things as possible, I'm not sure your suggested steps are enough: there's no connection between the code in pgen on crates.io and that repository. Even setting a
380.
▲
by
dbaupp
9y ago
I am not advocating for it being a great way to implement a linked list, just using it as an example that can be easily understood in a throwaway comment. As an alternative: # Delete all the elements from node 'from' to (but n
381.
▲
by
dbaupp
9y ago
Using the default destructor is broken, yes, but the approach isn't: one can avoid it in the list's destructor using a loop that walks over the list to not let nodes be destroyed recursively (i.e. clearing the next pointers).
382.
▲
by
dbaupp
9y ago
A closure in Rust is just a struct containing its captures either by value or as & or &mut references pointing to the values. Thus, making/avoiding a cycle with them is the same as doing it for "normal" values. One ca
383.
▲
by
dbaupp
9y ago
The difficulty in Rust is reflecting how there's not much difference between a correct doubly-linked list and an incorrect one: it's not too hard to end up with dangling pointers due to bad destruction. It's (very) hard for a
384.
▲
by
dbaupp
9y ago
The fundamentals of pushing a stack frame and jumping is the same, but the details of how arguments are passed (e.g. is a value in registers, or on the stack) and return values returned differ between the calling conventions.
385.
▲
by
dbaupp
9y ago
I don't think encouraging people to download the precompiled Rust binaries and then blindly compile code downloaded from crates.io is that much different in practice to providing your binaries.
386.
▲
by
dbaupp
9y ago
FWIW, 'cargo install' is designed to be for distributing dev-tools, rather than for end-user tools. I believe https://github.com/japaric/trust is designed to make it very easy to publish Github Releases from
387.
▲
by
dbaupp
9y ago
I think the key is the following quote at the end of the article: > I find a bit of solace in the fact that implementing a data structure like this in a non-garbage collected language without Rust is also quite tricky; you need to caref
388.
▲
by
dbaupp
9y ago
I also lived in the South Bay and found ZipCar and/or renting a car for day, weekend and even week long trips worked fine (which one is cheaper depends on your age and whether you can get a discount through your employer or whatever).
389.
▲
by
dbaupp
9y ago
Why is that caused by "just doing the [FPU]"? It's not obvious to me how being in a different part of the chip/board lessens the problems with "rule-breaking" comparisons, could you expand?
390.
▲
by
dbaupp
9y ago
... Which isn't relevant to the clarification of mathematical terms in my comment.
More ›