Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
Gankro
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
9 ms
·
61.
▲
by
Gankro
10y ago
You should add language pads to your sick sleeve. Never4get.
62.
▲
by
Gankro
10y ago
No, `let _ = x` is the official way to ignore a value explicitly. The lint ignores it. (My code does have an error because I forgot to wrap the result in Ok)
63.
▲
by
Gankro
10y ago
Almost every control flow mechanism in Rust is redundant: `if (let)`, `while (let)`, and `for` are all encodable with loop/match/break. Even `return` and `continue` are arguably redundant. Control flow is also probably the biggest
64.
▲
by
Gankro
10y ago
I tip my hat to you for remaining committed to one of the oldest Rust trolls there is.
65.
▲
by
Gankro
10y ago
Unwinding is an implementation of exceptions. You can implement them as returns, or, in the case of Swift, passing in a pointer for the Error type.
66.
▲
by
Gankro
10y ago
It's all the same stuff, man. Rust just: * makes you be explicit about call sites which throw * makes it easy to reify fallible computation (so it can be stored in e.g. a Future) For instance: fn foo() -> Result<Value, IoEr
67.
▲
by
Gankro
10y ago
It's been a long time since I wrote it; iirc it's a fair bit out of date, and is missing key insights (the speed benefit of maintaining parent pointers being the major one).
68.
▲
by
Gankro
10y ago
Yeah totally agreed. Swift is rife with way more special behaviours/magic to try to smooth over sloppy programming and just make stuff work. There's even a standard term for pushing a problem into the compiler: compiler heroics.
69.
▲
by
Gankro
10y ago
Hello world is large primarily because it statically links in jemalloc and libunwind, which are obviously fixed overhead. Both can be removed (and indeed I would expect jemalloc to be turned off by default sometime soon because each jemallo
70.
▲
by
Gankro
10y ago
I am fairly certain I successfully got binary trees deleted from the standard library. If you monsters added it back, so help me god... (BTrees, on the other hand, thrive)
71.
▲
by
Gankro
10y ago
These benchmarks are out of date -- Rust recently updated its SipHash impl from Sip2-4 to Sip1-3, making it actually the fastest for 8-64 bytes in some workloads (looking at the hashers outside of the context of using them in a map gives de
72.
▲
by
Gankro
10y ago
The only real difference between a weak and strong pointer is that weak pointers are less prone to leaking memory (in exchange for the possibility of "sorry I'm dead" being a response to accesses). As soon as you upgrade such
73.
▲
by
Gankro
10y ago
It's also a terrible comparison of hash functions for the purpose of hashmaps, because it tries to reduce the performance characteristics to a single number. The performance characteristics of a hash function varies over the size of
74.
▲
by
Gankro
10y ago
This post only touches on the theory, not the implementation. I never got around to writing about the implementation as there was some pending churn at the time.
75.
▲
by
Gankro
10y ago
Not being memory-safe is a bit of a bummer. Do you have a story for taking advantage of all the tooling thats been built up to defend against C's pervasive unsafety? Sanitizers being the most notable. On balance even without them this&
76.
▲
by
Gankro
10y ago
C++ close enough? https://github.com/mystor/rust-cpp
77.
▲
by
Gankro
10y ago
I can't seem to find any details on safety other than > Safe: Optimality may be sitting in the driver's seat, but safety is sitting in the passenger's seat, wearing its seatbelt, and asking nicely for the other passengers
78.
▲
by
Gankro
10y ago
> In terms of API stability, they seem willing to drop features within a major release cycle or two. I don't think any feature/api that was at one point marked as stable post 1.0 (when they started making any guarantees) has ev
79.
▲
by
Gankro
10y ago
Great read, but the initial description of the inefficiencies in gif are off. They touch on it a bit at the end but make it vague so I'll explain it here (because I love gif because it's a hillarious mess). Gif is actually a mosai
80.
▲
by
Gankro
10y ago
Honestly parametric polymorphism is a big slippery slope feature. There's always Just One More Thing -- higher rank/order/kinded types, where clauses, dependent types, specialization... or else you force people to use dynamic
81.
▲
by
Gankro
10y ago
Generic traits can be implemented multiple times, as long as the params differ. This is generally used to establish relationships between types, which can naturally be M:N. Comparison and conversion are standard use cases: impl Partia
82.
▲
by
Gankro
10y ago
Each chain produces a different static type. If you want to do a dynamic amount of chains (which seems strange to me? Got an example?) you would need to allocate and use dynamic dispatch, yes. Basically `MyFuture.map(x)` => `Map<MyFut
83.
▲
by
Gankro
10y ago
Rust does let you communicate variance (it's very important for lifetimes). Variance is determined based on a type's composition, and PhantomData can be used to specify variance that doesn't immediately follow by providing an
84.
▲
by
Gankro
10y ago
Unless someone's recenrly bothered to implement it, I believe Rust doesn't currently bother to optimize your struct layout. It can and it surely will but not yet (this is a dangerous state of affairs since people may start to
85.
▲
by
Gankro
10y ago
No you're just making stuff up. https://doc.rust-lang.org/nomicon/repr-rust.html The bulk of this section is describing how Rust has reserved the right to reorder and pack stuff. The first example happens to be
86.
▲
by
Gankro
10y ago
You're correct, it can be changed to `min(a, b)`. A rough proof: * assume WLOG `a = min(a, b)` * `a & b` takes the set bits of `a` and produces a subset of them * the value of an integer is `SUM 2^j` where the j-th bit is set * rem
87.
▲
by
Gankro
10y ago
It's the exact same analysis as ensuring all paths of a function do return the right type -- you just make sure all paths call a divergent function (typically unconditional panic) or enter a loop {} that never breaks/returns. Th
88.
▲
by
Gankro
10y ago
Swift encodes this with a noreturn attribute, and I think it's a "standard not standard" C attribute as well. (in case you were wondering who else does this)
89.
▲
by
Gankro
10y ago
Oh you know, just some silly little use cases like... * building on not-linux -- you know, where almost all personal computers exist. Gee, wouldn't it be nice if most computers could actually compile your code? * Having only one build
90.
▲
by
Gankro
10y ago
I imagine a basic proof amounts to: the result (base) is monotonically increasing (even in intermediate calculations) and the length of the slice fits in a usize, so if the correct result is always produced with infinite precision there
More ›