3 ms·
It's a little unfortunate that some of the cool features of Rust need to be put into the "use sparingly" category. I know that polymorphism, async, etc. should
by nerdponx 7y ago
It's a little unfortunate that some of the cool features of Rust need to be put into the "use sparingly" category. I know that polymorphism, async, etc. should be used judiciously anyway, but still.
One recent case we saw a similar tradeoff was the observation that the unicase dep adds 50k to the binary size for pulldown-cmark. In this case, the CommonMark spec demands Unicode case-folding, and without that, it’s no longer complying with the standard. I understand the temptation to cut this corner, but I think having versions out there that are not spec-compliant is a bad thing, especially unfriendly to the majority of people in the world whose native language is other than English.
In the Python world, you can install an "extra" along with a package. So you can make the deliberate decision to omit Unicode case folding from your CommonMark parser. Maybe something like that is possible with a crate?
That said, I think this is a non-feature in the spec, if anything. I see the value in recommending (but not requiring) Unicode normalization, but I don't see the added value of Unicode-aware case-insensitivity. Maybe it's more important in non-Latin text.
- romaaeterna 7y ago> I don't see the added value of Unicode-aware case-insensitivity. Maybe it's more important in non-Latin text I believe that -- to give one example -- this is something that Chrome implements, but Firefox does not. It's a huge pain to have to match accents perfectly in a text search on a page when you often want your search to be accent and case insensitive. This sort of thing is very important for any text search workload, I imagine.
- dbaupp 7y agoPython extras are pretty much equivalent to cargo "features": https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section https://doc.rust-lang.org/cargo/reference/manifest.html#the-... The article mentions a few places that use cargo "features" for exactly that sort of thing.
- pornel 7y agoI don't see the "use sparingly" conclusion. It's a complex trade-off of runtime performance, code clarity, productivity, safety, binary size, and compile times. Rust tries hard to eat all the cakes and have them too, but it can't do miracles. And looks like the author is on the right track to tackling the problem — moving less common functionality behind feature flags, pregenerating data "offline", profiling and trimming code with the help of cargo-bloat.
- msbarnett 7y ago> It's a little unfortunate that some of the cool features of Rust need to be put into the "use sparingly" category. This is just the reality of engineering -- there are no silver bullets. Sure, it'd be nice if any language could give you the space efficiency of dynamic dispatch with the runtime efficiency of monomorphized generics, but those two things are fundamentally in tension. Neither Rust nor any other language can fix that. Rust at least gives you a fairly easy choice of which you want in any given circumstance. Most languages just pick one or the other universally.
- heavenlyblue 7y agoOne way to fix it is jitting. I am wondering if Rust has a project of shipping Rust compiler embedded in your executable, so that one could compile sym into code.
- msbarnett 7y ago> One way to fix it is jitting. Also not a silver bullet, because there's non-zero costs in memory, CPU overhead, I$, etc to the statistics gathering, stop-and-jit-the-dynamic-call-and-change-the-call-sites and so forth. In long running server processes this can mostly amortize out nicely over a very long run, but for interactive applications it can add noticeable lag.
- pierreyoda 7y ago> In the Python world, you can install an "extra" along with a package. So you can make the deliberate decision to omit Unicode case folding from your CommonMark parser. Maybe something like that is possible with a crate? This is definitely possible in Rust with Cargo crate features! [0] For instance in a game library like quicksilver you can opt in to WebAssembly support, images, fonts, audio handling, etc. Then the image or audio library themselves can put formats and codecs behind feature flags for instance. Each crate then uses conditional compilation to branch out these features at compilation time. More commonly as an end-user, test modules use a special conditional compilation macro [1]. [0] https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section https://doc.rust-lang.org/cargo/reference/manifest.html#the-... [1] https://doc.rust-lang.org/stable/rust-by-example/testing/unit_testing.html https://doc.rust-lang.org/stable/rust-by-example/testing/uni...
- leshow 7y ago> I know that polymorphism, async, etc. should be used judiciously anyway, but still. I don't really see this recommended anywhere, especially re: polymorphism. Async _maybe_, but it's pretty situational.