8 ms·
My coworker recently showed me this plugin [1] that fades out all Rust code that is unrelated to the variable under the cursor. Think of it as a more powerful v
by tschumacher 1y ago
My coworker recently showed me this plugin [1] that fades out all Rust code that is unrelated to the variable under the cursor. Think of it as a more powerful version of the "click to highlight all appearances" you can do in most IDEs but it actually does information flow analysis on the code.
[1]: https://github.com/willcrichton/flowistry https://github.com/willcrichton/flowistry
- wakawaka28 1y agoThis sounds good but if you need it, you probably can and should refactor the code.
- mcphage 1y agoYou know what would be great for refactoring the code? Some way to easily see what parts reference the variable you’re trying to refactor.
- skydhash 1y agoUnless you have spaghetti code or have built an abstraction tower, a variable is probably scoped/namespaced neatly. Often, it's just a quick grep to find it. In Emacs, if a variable is only used within a file, you can just `M-x occur` and do the editing there. Where those tools fail, is when you have ecosystems that tries to be clever (JavaScript with its transpilers, Java with its annotations)
- everybodyknows 1y agoCheck out 'M-x multi-occur' -- same as 'occur', but scans all of the frame's open buffers. So useful I aliased it to 'M-x mo'
- 1313ed01 1y agoThanks! So I learned something new about Emacs again. It never ends. Aliasing something to make it easier to M-x sounds like the next step after running out of letters to use with C-c? I have not reached that point yet, but that was another thing I never considered that could be useful to remember.
- dspillett 1y ago> Unless you have That is a big "unless". We aren't all working on pristine code written to high standards…
- wakawaka28 1y agoYes, but not everyone uses features like this to make code easier to read. Instead, features like this make less readable code become tractible. The same can be said about autocomplete and documentation popups too. I remember Uncle Bob saying once that his 5 line function limit was facilitated by an editor feature he had that could easily display the code of functions that are called. So it stands to reason that the recommendation should be 25 lines if you don't have such a feature, I think. We don't need to go back to Hungarian notation but certainly using a bunch of fancy features to read the code makes it inherently less readable on the surface level (unless you are very anal and also self-aware and can stick to clean principles). I'm surprised my comment was downvoted so bad for making an astute observation. It happens to me all the time. A lot of the users of this site suck.
- ycombinete 1y agoAnd this comment will most likely be flagged now for whining about getting downvotes. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html: "Please don't fulminate. Please don't sneer, including at the rest of the community." "Please don't comment about the voting on comments. It never does any good, and it makes boring reading."
- wakawaka28 1y agoLol well where else am I supposed to talk about it? I get irritated about this stuff daily, so I don't really care if my short quips bore a person here or there. Being interesting is what gets me downvoted!
- ycombinete 1y agoWell, I guess you're not supposed to talk about it haha. But since it's irritating you I had a quick look at your comment history. I would say that the downvotes are because a high percentage of your comments are argumentative, and occasionally just flat out insulting. Within that your tone is often condescending and dismissive.
- yen223 1y agoOh wow, this is actually useful
- ivape 1y agoNeed this for every language …
- kccqzy 1y agoIt can't. It uses ownership types in Rust to do the analysis. It can be fooled by Rust's interior mutability. Other languages don't have a type system that enables this.
- eru 1y agoYou merely explain why you can't copy the implementation strategy. But that says nothing about providing the same value to the user in other languages via different means.
- kccqzy 1y agoYou merely assume an alternative implementation strategy exists and that it provides the same value to the user. But that says nothing about whether it actually can exist.
- eru 1y ago> You merely assume an alternative implementation strategy exists [...] Huh, where am I making that assumption? > But that says nothing about whether it actually can exist. Yes, I expressed no opinion on that.
- throw10920 1y ago> Huh, where am I making that assumption? You didn't, and you didn't express any opinion on whether or not it can exist, either - GP is arguing dishonestly to shill Rust.
- eru 1y agoWhich is really a shame. Rust is a nice enough language that it doesn't need dishonest shilling.
- kazinator 1y agoAnd, so, does syntax highlighting interfere in that? No. The information channel is shareable.
- CGamesPlay 1y agoThat’s basically the first paragraph of the article.
- kazinator 1y agoI don't see that; it doesn't acknowledge that the channel can be multiplexed and thus isn't wasted by dedication to syntax.
- kstenerud 1y ago"Color distinguishes things. And we just use it to distinguish syntax. Nothing wrong with distinguishing syntax. It's the "just" that bothers me. Highlighting syntax is not always the most important thing to us. The information we want from code depends on what we're trying to do." It then goes on to talk about rainbow parentheses, which is information multiplexed on the color channel with the syntax highlighting.
- billyjmc 1y agoWill Chrichton gave a talk at Jane Street about his research that led to the development of this plugin. It’s a pretty good talk: https://www.janestreet.com/tech-talks/rust-for-everyone/ https://www.janestreet.com/tech-talks/rust-for-everyone/ As I recall, he also explains how Rust is uniquely positioned to enable this kind of syntax formatting.