Earlier quoted context omitted.
Why can't you practice Rust in a non-business environment?
Programmers always spend too much time on studying which hammer is better, but they forget what they really want to do, right?
Three months of Rust
91–100 of 120 posts
Re: Three months of Rust
#92Earlier quoted context omitted.
Traits are typeclasses :) Uh, the coherence rules are complicated and I forgot them. It's a mixture of where the impl, type, trait, and type parameters are.
The general the coherence rules stop you from defining an implementation that could be possibly defined elsewhere. The important take away implications are: - you can not implement a trait defined in another crate for a type defined in another crate, unless the trait is parametrized by a type from the current crate - you can't define overlapping implementations
Re: Three months of Rust
#93The take-away for me is this: "Despite the restrictions of the type system, I am more productive in Rust than I am in either Javascript or Haskell. It manages somehow to hit a sweet spot between safety and ease of use." When I toyed with Rust last year (so, I'll admit my knowledge is outdated, I need to refresh it), I had a pleasant experience on the productivity side. The big reward for me, coming from C/C++, is tha…
Doesn't using C++ RAII eliminate some of that? Or you use raw pointers often?
Re: Three months of Rust
#94Earlier quoted context omitted.
I think the opposite is true. Modern hardware is so complex[1], made even more so by its constant interaction with a complex OS, that any sense of familiarity with the actual performance model is illusory, unless you're doing something very controlled and very specific (like, say, DSP). Modern hardware itself is an abstraction, hiding its operation away from you. We can no longer hope to tame hardware with meticulous…
Most of us don't have the time for meticulous control over instructions but those who do can certainly use it to good effect eg http://www.reddit.com/r/programming/comments/hkzg8/author_of... My aversion to piles of opaque heuristics is not because I'm against smart compilers, just that for certain projects I want to be form a mental model of what code I should write to get a certain effect. The trend of modern langu…
And how do you do that with hyperthreading, virtual memory, power management that may decide to power down your core because what you're doing doesn't seem important enough (and that differs greatly from one processor to another) and cache effects on code, data and TLB (all are strongly affected by other threads and processes running on your machine[1])?
While those effects didn't exist much before the 90s, and they don't exist today in GPUs and small embedded devices, on desktops and servers those effects may be much greater in magnitude than any difference you're able to get by better control over generated code. Not running a hypervisor, turning off virtual memory, pinning threads and isolating cores have a much more profound effect on predictability than which language or compiler you're using. Focusing on compilation before taking care of those much more powerful sources of unpredictability is like trying to get a faster car by reducing the weight of the upholstery fabric.
> so that a program that runs fine today might be unusably slow tomorrow.
I think that slowdown actually applies to assembly programs much more than to, say, Java. As CPU architecture changes, it's actually easier to keep higher-level code performant. I mean, why do you assume that compiler changes will hurt your code performance more than CPU changes?
> You can still have an LLVM-smart compiler underneath but you get to make the first pass.
There are many ways to produce good machine code (my favorite is Graal, HotSpot's next-gen JIT), but none of them really give you a good mental model of what's going on. You may like one approach over another for personal aesthetic reasons, one approach may actually produce better results for some workloads than others, and some approaches really are more predictable -- but no approach produces categorically predictable results, and more predictability doesn't buy you better performance (though it still requires more effort).
It used to be that if you knew what instructions your compiler would emit, you knew how your program would perform. That is just no longer the case (well, it is to some degree, but other effects are stronger). A single instruction may perform anywhere within 7 orders of magnitude (L1 cache hit to virtual memory miss) depending on effects outside the program's control! (of course, those high-volatility costs are usually amortized, but so is a less unpredictable compiler output).
[1]: That is the key to cryptographic attacks that let a process sense what a cryptography algorithm running in another process is doing by the way the cryptographic computation affects the performance of the first process.
Re: Three months of Rust
#95> The Rust community seems to be populated entirely by human beings. :D Regarding your borrow checker example, note that your code is now prone to blowing up if `step` is modified too much. You have created the necessity of an invariant (step should not pop out of the vector) which may be broken by later cleverness. See http://manishearth.github.io/blog/2015/05/17/the-problem-wit... for more details. Note that in thi…
Is the Rust community really made of humans? I always thought it consisted mostly of crustaceans.
Re: Three months of Rust
#96Earlier quoted context omitted.
linux kernel takes 20 minutes to build on my workstation, a plan9 kernel takes something tiny like 60 seconds on a raspberry pi. This is due to a few reasons. 1. Plan9 C does not allow headers to include more headers, this speeds up compilation, as there is far less useless preprocessor churn. 2. Plan9 C/Go does not do heavy optimisation, but does a decent job. 3. The system has less code overall, something like 1 mi…
> 2. Plan9 C/Go does not do heavy optimisation, but does a decent job. That's not good enough for Rust. > 3. The system has less code overall, something like 1 million lines of code for something like gcc seems like bloat to me, They don't remove useless features and dated features as fast as they pile it on. Those GCC optimizations matter . You simply cannot get away with competitive performance with an AST-to-assem…
Re: Three months of Rust
#97Earlier quoted context omitted.
Most of us don't have the time for meticulous control over instructions but those who do can certainly use it to good effect eg http://www.reddit.com/r/programming/comments/hkzg8/author_of... My aversion to piles of opaque heuristics is not because I'm against smart compilers, just that for certain projects I want to be form a mental model of what code I should write to get a certain effect. The trend of modern langu…
> I want to form a mental model of what code I should write to get a certain effect And how do you do that with hyperthreading, virtual memory, power management that may decide to power down your core because what you're doing doesn't seem important enough (and that differs greatly from one processor to another) and cache effects on code, data and TLB (all are strongly affected by other threads and processes running…
I take a program, measure it's performance on a wide range of real-world workloads across multiple different machines. Then I change some numeric routine to use unboxed integers instead of boxed integers. I measure it again on a wide range of real-world workloads across multiple different machines and find that it is significantly faster in all cases. My approximate mental model of how the machine works allowed me to make a change that empirically improved performance. My model is not perfect so I do have to measure carefully, but it is what allows me to make sensible decisions about which changes to measure rather than just changing things at random.
In a language where the compiler controls unboxing, my mental model is much more approximate. I have to figure out how to influence the heuristics to lead them into making the correct choice, and the solutions tend to be hacks that are highly sensitive to small changes to the heuristics, leading to conversations like https://groups.google.com/forum/#!topic/clojure/GvNLOrN3lGA .
Performance for non-tuned code may be better on average but my ability to tune important areas is reduced. If the compiler was more predictable, or had a interface that allowed me to add information, or if I could make my own passes then that trade-off would go away. I'm not against smart compilers, I'm against smart compilers that don't talk to me.
Re: Three months of Rust
#98Re: Three months of Rust
#99Earlier quoted context omitted.
> 2. Plan9 C/Go does not do heavy optimisation, but does a decent job. That's not good enough for Rust. > 3. The system has less code overall, something like 1 million lines of code for something like gcc seems like bloat to me, They don't remove useless features and dated features as fast as they pile it on. Those GCC optimizations matter . You simply cannot get away with competitive performance with an AST-to-assem…
Imo compilers should only optimize specific functions which are known to be a code hotspot.
Re: Three months of Rust
#100Earlier quoted context omitted.
Programmers always spend too much time on studying which hammer is better, but they forget what they really want to do, right?
I actually agree with you in general, but in this case we spent six months hammering in nails with a wet sandwich because the only available hammer has a chainsaw for a handle ("it's perfectly safe, just don't ever press the on-switch"). This blog post is me seeing something that looks like an actual hammer and suspiciously looking for a trap.