1. 32
  1.  

  2. 21

    To me, this is a drop in a potential ocean. There are more optimizations that happen in Rust that are effectively due to Rust being like C with restrict everywhere (kind of, not exactly), but those are drops in the ocean too.

    For long have compiler devs been trying to improve alias analysis. It’s usually a global, expensive, and imperfect analysis. It has the potential to be very useful, and is used by compilers to some extent, but it’s not too useful unless you crank it up a notch, and then it takes forever to compile. When I was studying program analysis, alias analysis seemed to be the holy grail amongst the research I looked at. As it should be – it can unlock so many optimizations because it can expand the boundaries of what the compiler is allowed to do. Perfect alias analysis could also be used to make C++ 100% safe, though “perfect” alias analysis may have an undecidability issue. In Rust, you get the aliasing info for free, and it’s local, so easy to analyze. There’s a lot we could be doing with this, though currently we only give LLVM rudimentary analysis (I don’t think LLVM even supports the full extent of aliasing info we could be providing). Alternate backends like Cretonne may explore this space more.

    Edit: roc wrote a followup post which outlines a better drop in said potential ocean. He also brushes on the distinction between C++’s global alias analysis and Rust’s “free” tightly-scoped aliasing information which I mention here.

    1. 9

      Indeed, much of the aliasing information that rustc could provide is currently disabled because of bugs in LLVM.

      1. 7

        FWIW, that’s “could provide to LLVM”, rustc has a lot more aliasing info than is currently expressible in LLVM. We currently only provide aliasing info at function boundaries, and out of that the &mut thing is disabled because it’s broken.

        (Of course, pervasive aliasing info at function boundaries is already quite awesome to have for the optimizer)

    2. 15

      ROC updated this post after a Reddit comment pointed out that the original example is a non-Rust-specific LLVM optimization:

      Actually as dbaupp points out, this optimization example is not specific to Rust. In fact, LLVM is doing it via local analysis (the sort I mentioned above), and clang++ produces the same results for the equivalent C++ code. In fact Rust in general would need to preserve references because you can convert a reference to a raw pointer and compare them for equality.

      More follow-up here including a better example that does depend on Rust semantics.

      1. 1

        The second example is also bad because the function takes the v parameter as a const reference, which doesn’t make sense for a primitive type, and would never be used in practice, especially not if the goal was to optimize. It’s not a secret, and I’m 99% sure it’s covered somewhere in the Effective C++ books.

        Removing the reference and just pass a const uint64_t and the code generated by both gcc and clang is clearly better than the Rust code. https://godbolt.org/g/Fp1cW2

      2. 4

        Oh hey look it’s the Rust Evangelion Strike Force at it again–and, predictably, their actual knowledge is outstripped by their excitement.

        One reason is that C++ has a standard ABI that dictates how parameters are passed; it requires that references are always passed as pointers.

        Oh, does it now? Glad to know that so much of the calling convention bullshit between compilers and linkers was apparently just me imagining things.

        The standard (8.3.2) seems to say that the storage is left undefined.

        For a simple case like this a C++ compiler could do some analysis to show that can’t happen, but those analyses don’t scale (e.g. if foo called, and was called by, unknown code, all bets are off).

        “don’t scale”? The mudball of C++ has been scaling for about 30 years (much to all of our chagrin). True, by default the name mangling of a given compiler doesn’t include enough information to check ownership stuff, but there’s nothing saying it couldn’t be done by a sufficiently advanced compiler implementer.

        ~

        I get that Rust probably makes it more comfortable to help the compiler do good analysis, but this seems like a bunch of bullshit.

        1. 24

          FWIW, the author works on rr, and would definitely be intimately aware of C++ ABIs, I guess he is talking about sysv or linux-only or something? I agree it’s misleading, but the underlying point basically still holds.

          The mudball of C++ has been scaling for about 30 years

          The post didn’t say that C++ doesn’t scale, it says that this specific optimization doesn’t scale. And it doesn’t, there’s tons of research on alias analysis in C++ out there, all of it expensive and imperfect.

          Maybe “that C++ doesn’t do” would have been a better title to this post. Whatever.

          1. 9

            Given the update that C++ actually does do the same optimization for equivalent code, I don’t think that’s a much better title either.

            1. 1

              Fair points–it’s just that Rust is getting a lot of backlash from people (myself obviously included) because authors of articles like this are playing fast and loose with definitions and meanings and critiques.

              There are (as you point out in a sibling comment) perfectly superior ways that Rust provides information to allow for more clever optimizations and safety than C++ vendors typically support: there is no reason to mis-state what C++ does do in order to outshine it in that department. Properly using restrict (and memory barriers in general, oy vey!) is not something most folks in C/C++ get right any time, much less all the time.

              But again, there is this stigma Rust proponents are getting: where it isn’t enough that their pet language is potentially better than C/C++ on technical merits–they instead feel the need to lie and sow confusion about what the legacy languages actually do.

              It’s scummy.

              1. 33

                It’s scummy.

                I’ll tell you what’s scummy: taking the worst possible interpretation of a post that is factually wrong, and accusing the author of purposefully lying without any evidence other than some bullshit Internet meme.

                1. 30

                  Right, but you don’t have to paint this as a malicious “scummy” thing (it isn’t), and you are giving undue importance to misstatements in the post that aren’t actually key to the points being made, which is basically nitpicking.

                  “C++ has a standard ABI” is a pretty valid statement to make in the context of Linux (not standardized or mandated AFAICT, but agreed upon, at least on the basic stuff like this). And even if it wasn’t in that context, passing references works exactly the same way in most if not all C++ ABIs, because of the second point mentioned in that post. You are deliberately assuming the worst of the author, and painting their whole argument as bullshit as a result.

                  People play fast and loose with stuff like this all the time. Half the technical blog posts on the Internet I read give me an urge to nitpick on some point. It’s perfectly clear what the author means there, but they are textually wrong, or at least in my interpretation of the text. It happens all the time. This is not specific to Rust.

                  It seems like folks have now started painting any mention of Rust as “Rust Evangelism Strike Force”. When I first saw this term I thought that there were a lot of people being annoying about Rust on the net. I certainly have seen these occasionally, saying “Rust would have solved this problem”.

                  But, you know what? After asking around it seems to just be totally made up. I care about the community a lot, and wouldn’t want it to fall prey to an attitude like this. So I looked around. I asked folks who were talking about Rust evangelism. I had a look at the site (n-gate) where the term originated from. I went through the recent posts that mentioned said strikeforce.

                  Some of the posts themselves are about Rust, so of course the discussion will involve Rust. None of them have any “evangelism” in them – one is about the roadmap, the other is about wasm with rust. Other posts have minor mentions of Rust in the comment threads (none of it being evangelism; it’s stuff like this); the only post that has significant Rust mentions in the comments is this one, and that post has more mentions of Java – it’s a PL discussion, all kinds of langs will come up. The closest I could find to evangelism was this comment, which besides being downvoted, is from someone who is considering learning Rust over C++, not someone who is evangelizing Rust.

                  This is not to say that there aren’t people who do go around saying “you should rewrite it in Rust” or whatever. But they seem to be few and far between. This “Rust Evangelism Strikeforce” meme seems to be a manufactured one with little basis in the real world, and now everyone looks at anything talking about Rust as “Rust Evangelism Strikeforce”.

                  I’m seeing this same trend here, with you using nitpicks – the kind that many blog posts have – to paint the blog post as dishonest and scummy. So now I’m having a hard time believing that this stigma is actually due to anything Rust folks in particular are doing wrong, but rather to a reaction folks seem to have whenever they see people talking about Rust.

                  1. 7

                    “It seems like folks have now started painting any mention of Rust as “Rust Evangelism Strike Force”. ”

                    That’s not true. We had a bunch of Rust threads on Lobste.rs a while back. They got so numerous and popular that angersock even started one soliciting information about what benefits it has or why it’s worth all the threads. Something like that. Also a consolidation attempt since half the front page was Rust. As I told you before, the Strike Force meme is applied to zealotry or posts containing bullshit inspired by or shared with zealotry. Both Rust proponents and opponents are critiquing the OP. So, I at least see why the meme was applied even if angersock is going too far with the critique. Definitely not an anti-Rust thing in general, though.

                    On the other hand, posts on Rust showing good capabilities demonstrated on interesting apps/libraries tend to get upvotes. Examples that come to mind are bluejekyll’s DNS or burntsushi’s work. Some good discussions happen there. I predict the response to this one would’ve been better if OP wrote something about global vs local alias analysis showing status quo of how it was difficult followed by how Rust’s design improves the situation. Basically, what you said upthread with 11 upvotes as the response. Well-written and positively received at Lobsters unlike zealotry and bad writing.

                    Note: Since you’re new here, I’ll also note this forum’s members also respond to things differently than HN and other places. You’ll usually see a low volume of comments vs votes with comments asking for detailed specifics, critiquing perceived flaws, etc. Most people liking something will just upvote without comment. Sometimes you’ll get no response at all good or bad on something with a ton of views. By that model, this thread is very pro-Rust right now. I understand why you’d fight the Strikeforce tag but I recommend for the general case that any new people observe how Lobsters respond to things a few months before feeling sure about anything.

                    1. 13

                      That’s not true.

                      That’s not what happening in this case (I’m sorry if I gave the impression that I thought it was), but it certainly is what n-gate (the source of that meme) is doing, and what some other uses of the RESF label seem to be doing, which helps normalize the RESF meme as something to bring up anytime anyone does something with Rust. To be clear, I don’t think that lobsters/HN/whatever have some collective thing against Rust, it’s just something that seems to come up too often now (even though like you say overall Rust has a positive reception).

                      Sure, the blog post was wrong or misleading, but it wasn’t malicious. Totally okay to point out how wrong it is; folks on /r/rust did it too; and got upvoted. But the RESF meme seems to be making folks (like angersock above) jump to the conclusion of malice. Like I said, people are wrong like this in posts all the time. angersock’s cricitism wasn’t even about how the main inaccuracy in the post (this was brought up later), it was about some tangential nitpicking of the kind that any post can receive, but it was elevated to the level of malicious evangelism just because it was Rust.

                      This post isn’t zealotry, it’s just wrong. The author corrected themselves in the followup post and provided an alternate example that does work. The bit about ABI wasn’t corrected, but the author later admitted (in other channels) that they were thinking about Linux where Itanium is “standard”. Implicitly talking in the context of linux is something folks do all the time, I’ve made that mistake as well.

                      My issue is that if this blog post wasn’t about Rust, we’d just get comments about how it was wrong on some minor points like the ABI (I’m ignoring the fact that the post was wrong on a more fundamental point, because that wasn’t the subject of angersock’s comment, and I learned about that after writing my comments). This happens in every other blog post with inaccuracies (i.e. like half the technical posts out there). But because it is about Rust, we get massively dismissive comments who paint the whole article as bullshit and evangelism, just because it has some inaccuracies – inaccuracies that don’t affect its point (yes, the post was wrong on its core point too – but that wasn’t what angersock was talking about). This is super harmful if normalized, because it means that now folks writing about Rust will be too afraid of blogging about things lest they get labelled as lying evangelists, because it’s not hard to make mistakes. It’s a harmful trend that I think should be nipped in the bud.

                      I’m not saying that this site (or any other) is biased against Rust – I can see that folks overall seem to love it and Rust posts tend to get upvoted pretty well :) But angersock’s comment is a very disproportionate reaction to someone just being wrong about something (in a way that doesn’t really affect the point in the post), and this isn’t the first time I’ve seen a dismissive comment like this that’s way out of proportion just because it’s Rust.

                      Note: Since you’re new here, I’ll also note this forum’s members also respond to things differently than HN and other places. You’ll usually see a low volume of comments vs votes with comments asking for detailed specifics, critiquing perceived flaws, etc.

                      Thanks! I’d normally be just voting and reading – indeed that’s what I’m doing elsewhere. I’m just really annoyed at the spread of this RESF meme. I blog about Rust often, among other things. I am sometimes wrong, like most people. The way this meme is being applied makes me want to just close shop and not write about Rust anymore.

                      But I’ll try to hold off on being annoyed about this meme on this site in the future :)

                      1. 5

                        I hear you. My comment on not judging too quickly applies to everything but the meme. It’s actually controversial. I see why people argue over it. Other reactions to other topics might not speak for forum as a whole, though, is all Im saying.

                        1. 5

                          Oh, sure, sure :) I want to caution against using the meme as a lens to amplify criticism, but criticism in itself should totally occur! :)

                          And yeah, lobsters overall is a very positive and nice place!

                        2. 1

                          Like I said, people are wrong like this in posts all the time. angersock’s cricitism wasn’t even about how the main inaccuracy in the post (this was brought up later), it was about some tangential nitpicking of the kind that any post can receive, but it was elevated to the level of malicious evangelism just because it was Rust.

                          You’re mis-stating my post, and it’s getting old.

                          My original post linked to the standard for C++ showing that the author was wrong. I also pointed out that the “but but but analysis doesn’t scale” thing was handwavy and went against empirical evidence. My only mistake was mentioning the Rust Evangelion Strike Force (shinji, get in the type checker!) in my opening paragraph.

                          My follow-on post here was saying (and evening agreeing with you, if you actually read it) that the Rust folks are starting to get a reputation about playing fast-and-loose with the facts when they don’t need to.

                          This post isn’t zealotry, it’s just wrong. The author corrected themselves in the followup post and provided an alternate example that does work. The bit about ABI wasn’t corrected, but the author later admitted (in other channels) that they were thinking about Linux where Itanium is “standard”. Implicitly talking in the context of linux is something folks do all the time, I’ve made that mistake as well.

                          Now, you keep coming down to “Well, okay, maybe he got some details wrong in his claims, but that doesn’t matter in this specific case”, and I submit that that is poor argument. The entire point of the bloody article was to say “Hey, language <X> is stunted compared to Rust!”. There is no getting around that fact, hinted at by the choice of blog title. That is evangelism–the only way it wouldn’t be is if it got its facts straight, which it didn’t.

                          (also operating system is not as important as compiler vendor, but apparently Rust threads are a magical facts-free zone so whatever)

                          But angersock’s comment is a very disproportionate reaction to someone just being wrong about something (in a way that doesn’t really affect the point in the post), and this isn’t the first time I’ve seen a dismissive comment like this that’s way out of proportion just because it’s Rust.

                          You are missing the point.

                          You say “doesn’t really affect the point in the post”. Let me spell it out for you: if somebody claims that “this entire category of optimization is off-limits to a language because it is built differently than another language”, because they have misunderstood how the language in question is specified, their entire point becomes invalid.

                          That should be obvious. That shouldn’t require a stretch of imagination. It’s basic critical thinking.

                          You keep saying, over and over, “hurr durr but but but the point is valid even if the facts don’t agree in this case”. That is what I’m lampooning by saying Rust Evangelion Strike Force.

                          ~

                          And no, it’s not because I hate Rust. As @nickpsecurity points out, I’m more than happy to support the good work being done by the community and to try and increase visibility of things.

                          What I can’t abide by is sloppy arguments, and unfortunately that seems to be a recurring problem with the RESF.

                          1. 10

                            What I can’t abide by is sloppy arguments, and unfortunately that seems to be a recurring problem with the RESF.

                            As has been said numerous times, criticism is very welcome.

                            But your criticism was laced with references to a bullshit meme and an accusation that the OP is lying and creating confusion on purpose. That’s the problem folks in this thread have brought up.

                            I’m more than happy to support the good work being done by the community and to try and increase visibility of things.

                            If this is true, then please write constructive comments instead of lacing them with inflammatory language. In other words, I’m asking you to be friendly.

                            1. 6

                              In other words, I’m asking you to be friendly.

                              Fair enough!

                              1. 5

                                Yeah, this is really all I was going for, though I was maybe too verbose about it. Thanks.

                                1. 2

                                  Generally, shorter posts in disagreement are better. I wouldn’t have grumped as much if you’d just done something like:

                                  Hey, angersock, good points on them being incorrect–those’re covered elsewhere. Still, don’t be a jerk and use the RESF thing when you know it just antagonizes folks.

                                  The long post you went with instead went off in the weeds and incidentally made some claims I strongly disagreed with, and at least half my tone was in response to that.

                                  1. 7

                                    Yeah, I guess I’m just annoyed at the recent spread of the RESF meme and it’s usage to turn benign mistakes into Blasphemy of the Highest Order, because it’s something that keeps me from blogging, too. So I’ve gotten a bit verbose about it.

                                    1. -1

                                      Have you all considered embracing the RESF meme? Putting on my troll hat, half the fun is watching just how grumpy people get when it’s used.

                                      Co-opting it instead of getting offended might actually play out better.

                                      1. 4

                                        We have, http://twitter.com/rustevangelism is run by Rust community folks :P

                                        I don’t mind the term per se, I have an issue when it gets used as a tool to over-amplify some other point, and make people sound bad.

                                        1. 1

                                          That’s parody was kind of funny. Highlights being MUMPS and Kermit.

                                        2. 2

                                          Not sure why you’re getting downvoted for (imo) accurately describing how trolls react to people (reasonably) being offended by their behavior.

                        3. 2

                          While it does not have the term “strikeforce” in it, I guess many conflate it with Have you considered Rewriting It In Rust?

                          1. 10

                            Yes, but that too has a handful of examples, and isn’t really indicative of a larger trend. Like I said, this isn’t to say that there aren’t people doing this, they’re just few and far between, and certainly not some organized group as is the image the term invokes. If you see people being annoying and butting in advocating Rust, by all means, ask them to stop. But the spread of this meme now means that any positive talk about Rust is labelled as “the rust evangelism strikeforce”, which is really harmful.

                            And if you look at the examples there too (when I was investigating the origins of the RIIR meme I went through this), there are four on issue trackers/MLs:

                            • two people asking questions on github. I guess these count as asking to rewrite in Rust, even if they aren’t framed that way
                            • one person suggesting Rust in an existing “maybe we should change the language” discussion, which seems like an okay place to bring up other languages
                            • one drive-by issue on Tor asking them to rewrite.

                            The rest are not even on any issue tracker:

                            • one is a question on Quora – a sensible one, as sensible as “why hasn’t Linux moved to C++ yet” (a question which gets asked all the time, both on and off lkml).
                            • Another is an HN thread about an existing rewrite that people are doing. Sensible place to discuss rewriting things in other languages.
                            • And the last is an opinion post on a personal blog. Strong personal opinions are par for programmers. Talking about them on the blog is on par too. It’s not in-your-face or annoying anyone. Why is this one special? The article goes on to say that this blog post exemplifies the talking points of the RIIR crowd. Except – all of the folks asking to rewrite in Rust in the other examples don’t have any talking points and are just drive-by, much like any other drive-by issue on a tracker ever. Of course, these talking points are used when explaining what the merits of Rust are, but that should be totally okay, right? Comparing things and pointing out advantages is a completely normal thing to do when talking about new technologies. Anyway, the mention of this blog post makes the RIIR post seem even more incoherent. shrug

                            That blog post exaggerates the problem at hand. No doubt there are more cases than the ones listed there, but I don’t think there’s any trend, and it’s usage of examples like the quora question make me lose confidence in its assertion of there being a trend since half of its examples are about something other than what it talks about.

                            And, showing up on issue trackers and asking for rewrites? People ask for stupid things on issue trackers all the time. There’s no evidence that Rust is somehow worse when it comes to this. Even in the space of language rewrites, this happens just as often for other new languages (or even C++ – lots of C codebases get asked to switch).

                            So yeah, it’s a problem, but nowhere near as major as folks seem to make it out to be, and not really specific to Rust.

                        4. 22

                          Perhaps people get things wrong because these topics involve fairly complex details that are often implementation- or platform-dependent, and so people misunderstand them, misremember them, or are accidentally unclear or imprecise in communicating their understanding – rather than because they are scummy liars.

                      2. 10

                        Rust Evangelion Strike Force

                        ?