10 ms·
Rust-analyzer – an IDE backend for Rust
- miltonlaxer 7y agoI started learning rust 2 days ago and I was struggling with RLS in WSL using VSCode. I think it just doesn't work very well with WSL (https://github.com/rust-lang/rls-vscode/issues/706#event-3273465782 https://github.com/rust-lang/rls-vscode/issues/706#event-327...). Very excited to give this a try in WSL2.
- miltonlaxer 7y agoOkay it's been 3 minutes since I made this post and I've already uninstalled RLS and started using rust-analyzer. It just works out of the box and all my issues with RLS are gone. THANK YOU!
- zxv 7y agoThe performance and stability improvements in rust-analyzer over the last six months have been remarkable. Kudos to matklad and the whole team behind this. I'm using it full time now.
- Argorak 7y agoI can definitely say that having carved out a space where rust-analyzer is a job for matklad and some of the contributors boosts such things. (I'm managing the open collective and I'm so happy for all the support, in money or just in kind words)
- Signez 7y agoI'd just chime in to say that Rust-Analyzer is an awesome tool that really helped me as a Rust beginner. Having your text editor show the types of everything, highlighting the mistakes you made or suggesting functions right after you keypressed a dot is awesome to discover all the features Rust offers you as a developer. Can’t wait for rust-analyzer to graduate as an even more fully featured LSP – it has the potential to really changes the daily life of thousands!
- blinkingled 7y agoI tried it recently and I know it's just alpha right now but something feels a little fundamentally annoying about the way it changes things in the editor while you're typing. One example is that it seems too eager to claim something is a syntax error before you've really finished really typing it.
- metalliqaz 7y agoWouldn't that be the text editor's fault?
- blinkingled 7y agoNot sure about that - doesn't seem to be a problem with any other extensions.
- k__ 7y agoAs long as it does this with single digit millisecond latency, I'd be okay with that.
- blinkingled 7y agoTrouble is it will eagerly try to auto complete the wrong thing while you are trying to fix up your typo.
- k__ 7y agoAh, I had this problem with all languages. Don't know how to get around this :/
- matklad 7y agoOut of curiosity, which editor are you using? I've hit a similar problem when trying out upcoming neovim lsp support: https://github.com/neovim/nvim-lsp/issues/195 https://github.com/neovim/nvim-lsp/issues/195
- 7y ago
- empath75 7y agoIs there a tutorial for how to get this working in vscode? I installed the extension, but it doesn't seem to be doing anything. I tend to have a workspace with a bunch of folders in it, and it seems like rust analyzer only works with a single rust folder in your workspace and nothing else? At least it's throwing a lot of errors indicating that.
- hamaluik 7y agoI had to uninstall RLS in VSCode, install the "default" profile for my toolchain (nightly), and then when I opened a folder with a `Cargo.toml` file, in the bottom right it prompted to install the rust-analyzer server, which I did. Then it started checking everything and I was off to the races.
- Argorak 7y agoCould you please file a bug at github.com/rust-analyzer/rust-analyzer, describing your current situation and an outline of your project structure. Installing and running should be as easy as activating the plugin, or at least the error message should be clear.
- weiming 7y agoI also had trouble getting VSCode workspaces to work (i.e. multiple project roots.) Also at times, when adding a new crate dependency to Cargo.toml or installing a rust-analyzer update, it seems necessary to reopen the VSCode project (not restart VSCode itself) to get it to work again. This said RA has been indispensable over the last few months, thank you to the authors!
- _bxg1 7y agoMany plugins, in various languages, only work when your editor "workspace" is your actual project root.
- miltonlaxer 7y agoFor WSL2 * Uninstall RLS * Install Rust-Analyzer * Reload Workspace * Click prompt to install rust-analyzer-server * Start Coding
- 7y ago
- stevehiehn 7y agoI started ramping up on a Rust codebase last week. Intellij is my default IDE so I just continued with it. The plugin seems reasonable enough. It does all the basics like checking types etc.
- runevault 7y agoDo you have access to CLion or just Intellij? I ask because CLion has real debugging support that, to my knowledge, Intellij does not have (CLion has built in ties to GDB that the other lacks).
- stevehiehn 7y agoI pay for the 'Ultimate' edition which means the different language support is available via plugins. At my day job I toggle between GO & Typescript and some JAVA side projects so setup works well enough for me. I can't speak to CLion. I use the Go debugger daily and I don't have 'GoLand' perse, just the plugin.
- isbjorn16 7y agoI can speak for you; you won't get a debugger with the Rust plugin with IntelliJ. I'm going from memory here, and it's been a few months, but I believe the person working at JetBrains on the Rust plugin said it wasn't going to come out for IntelliJ. My company is good about buying us tools, so they got me CLion (or, rather, the entire Jetbrains Ultimate Pack or whatever it's called). CLion has made Rust development almost infinitely better than it was just using the Rust plugin on IntelliJ (and this is coming from someone who just uses the Python plugin in IntelliJ even though like 50-75% of his code is Python). I'm a JVM dev masquerading as a Python dev and using Rust for some stuff that Python just isn't up to snuff on (and using the super sweet pyo3 package to make native python modules for it, too). The point is, I get the <3 for IntelliJ; I pay for the super ultimate edition for home use just because I like it _that_ much. But CLion and debugging has made my life so much better than doing it with the Rust plugin in IntelliJ or using VS Code. Some people are content with log statements, but I'd rather stab myself than debug via logs. It's just not my jam! Edit: I just thought to note that the CLion + Windows + Debugger game is weaksauce. There may be a way to get it to work in windows, but I don't know a single thing about the Visual Studio build tools or how to get everything to play nice or whatever that might be necessary, so I tried to get it to work through WSL. It worked sometimes, and not others, and I got so frustrated I picked up a Mac for my work refresh rather than another surfacebook, mostly because I was tired of having to jump through hoops to sometimes have a mostly working eventually kinda debugger.
- jgrant27 7y agoMisleading title. Alpha releases aren't considered general releases.
- _bxg1 7y agoI used RLS 1.0 (through the VSCode RLS plugin) for a year or so before discovering rust-analyzer, and I just want to say, even in pre-alpha it is an astonishingly huge improvement. If you do Rust development, do not wait to upgrade. Type checks are instant. Inferred types get previewed inline, also instant. Autocomplete works as expected. Type errors are localized, which might have been my biggest frustration with the old RLS. In terms of developer experience it's like using a whole other language.
- fb03 7y agoI wholeheartedly agree. I tried Rust a few months ago and I was a little dumbfounded on how little 'modernity' I felt (regarding the IDE experience) compared to what several articles told me I should expect when using Rust with, for example, Visual Studio Code. Last month a project with requires the development of a high performance event collector came in, and I decided it was time for us to go to the Rust side. Again, I redid my dev setup with VSCode but this time I used rust-analyzer, and oh boy. "What, I now have practically instant inlay typings as I type a line of code??" e.g: "let x<: type> = ..." type inlay changing dynamically as I instantiated the object on the right hand side. So if you just like me got little winded at the sheer complexity of the whole Rust thingy and decided to wait a little more to dive in, let me tell you: rust-analyzer makes the whole thing way more palatable. Fast forward a WEEK later and I have a multithreaded message passing, postgresql consuming backend prototype to show the guys. It is very performant and consumes about 2 megabytes of ram while running and providing a continuous streaming websocket info feed to the to-be-developed dashboard that we are doing. Rust is awesome. and better tooling is going to make it soar even higher.
- _bxg1 7y agoYes. And the thing is, because Rust is such a complex-to-compile language, and because there's all this discussion around its slow compilation times that they're working to improve, I just assumed the whole time that "well I guess this is the cost of having such a powerful type system". I didn't question how terrible the editor experience was. But now I see how much better it could've been! I know the Rust team is hard at work, and I know they have a lot on their plate, and I'm very grateful for the work that they do. But I think it was a mistake to de-prioritize the editor experience for so long. It may have permanently turned off lots of people to Rust because they tried it and assumed the language was just too hard, when in reality they were flying blind. The compiler messages may be known for being great, but many people, especially newer devs figuring out a language, don't sit there with a compiler open while they explore what is and isn't allowed. There's much more to the dev experience than the compilation experience.
- a_humean 7y agoOne thing I find astounding about this project is the breakneck pace of development. I keep up with the weekly changelogs and subscribe to the nightly builds. Its genuinely impressive how much this project has achieved and the rate of new features being produced. Thinking back to some of the RLS blogposts about the need for something like rust-analyser from about a year ago I'm pretty sure nrc (Nick Cameron) said it would take about 2-3 years to reach this point. However, I'd say rust-analyser has been usable and better than RLS for many months now.
- steveklabnik 7y agoI think that year comparison doesn't work super well; some of the work done in the compiler over the past 2-3 years contributed here. rust-analyzer (in my mind) would not have been possible in the same way at the time the rls was built. It would have needed to do a lot of the work that's been ongoing in the background since.
- 013a 7y agoIs rust-analyzer's relative modernity a symptom of intrinsic limitations behind Language Server, or tactical limitations of RLS? I was very hopeful about the bright future of language server, and its ability to solve that N^2'd problem between editors, addons, and languages. But, if it can't provide truly great experiences outside of Typescript (which has been my unfortunate experience), it does not bode well for the project.
- Argorak 7y agoThe latter. rust-analyzer implements the language server protocol like RLS. RLS was implemented using the compiler as a library, which meant it inherited the compilation model of the compiler, which isn't really well-suited for IDEs. That was done in full knowledge of that drawback. The advantage for RLS is that it has perfect parity with the language. This may be fixed by using rust-analyzers libraries within the compiler. RFC here: https://github.com/rust-lang/rfcs/pull/2912 https://github.com/rust-lang/rfcs/pull/2912
- 013a 7y agoExcellent to hear. This was not obvious from the blog post, and I should have done more digging before jumping to conclusions.
- matklad 7y agoI must say I don't fully understand your original question, so I can't answer it directly. However, I can share my (very hand-wavy) thoughts on the general LSP ecosystem, and it looks like that might actually answer your question. I personally don't believe that NxM is a real problem. If you have an editor, which has bespoke APIs for providing completion, and a language server, which speaks bespoke protocol, binding the two together is not hard. A single person can do that and if, say, at least 1000 people use editor X with language Y, it doesn't seem like a waste of effort to me. The problem is that writing a language server that works is hard. "Rewrite your entire compiler from scratch" kind of hard. Before LSP, only JetBrains delivered these kinds of compilers consistently. Notable non-JetBrains tools from before LSP era are Roslyn and Dart Analyzer. The Dart Analyzer project is particularly interesting -- it's the same "separate server process speaking JSON" kind of architecture. The details of protocol are different (as it predates LSP) and it doesn't try to be language agnostic. Dart support in IntelliJ is powered primarily by this server. In my mind, the main value of LSP is social: it pushes language designers and compiler writers to think about editing and refactoring incomplete code, which is a very different problem from compiling mostly correct code.
- cdbattags 7y agoI love the homage to IntelliJ Rust in this article! As a newbie computer science major who "grew up" in the era of Eclipse/IntelliJ conversion, IntelliJ will never cease to amaze me in how much more productive I became with IDE tools and the general "power behind the compiler". Mad props to the plugin interface JetBrains has provided and the novel solutions that have come out of this style of thinking that far outpaces the experience in something like Xcode.
- pjmlp 7y agoIf InteliJ is amazing then using Smalltalk or Interlisp-D/Lisp Machines is like out of this world.
- matklad 7y agoI'd love to read an article that compares capabilities of the two! Martin Fowler seems to think otherwise: > I was known for my annoying habit of stating how Smalltalk's IDE was better than anything I'd seen. No longer. For me IntelliJ was first leap forwards in IDEs since Smalltalk. https://martinfowler.com/bliki/PostIntelliJ.html https://martinfowler.com/bliki/PostIntelliJ.html
- pjmlp 7y agoIt seems full of empty praise words without giving any example how it is better.
- enitihas 7y agoCan you give 5 features of such IDEs which aren't found in IntelliJ?
- pjmlp 7y ago1 - Proper refactoring of dynamic languages due to the image nature. IntelliJ gets it most of the time. 2 - No continuous indexing of source code, stuff is just there. 3 - During execution of REPL statements or debug sessions, an errors jump into the debugger, fix the issue and continue as if nothing had happened 4 - a REPL that integrates the code being written, with inline images and graphical representation of data structures 5 - The complete developer experience is available to the developer and can be customised at any time without rebooting it. 6 - Code components can be integrated into other documents as live objects (this is where OLE and Taligent got their ideas from)
- saagarjha 7y agoIs the best way to install rust-analyzer still by downloading a binary manually, or is available through rustup or similar now?
- Argorak 7y agoThe best way to install it is by installing the VSCode plugin, it will download the binary for you. rustup may arrive in the future and make things better for other plugins.
- saagarjha 7y agoI don't use Visual Studio Code, unfortunately. I'm currently using rls through my editor's support for LSP implementations.
- est31 7y agoYou can also compile rust-analyzer yourself. It doesn't need any custom stuff from what I saw, and supports Rust stable.
- livre 7y agoThank you for letting me know about that. Last time I gave it try it required building the analyzer and then installing the extension manually. The process is much less tedious now.
- mpolun 7y agoIt's not part of rustup. At least for the VSCode plugin, it'll prompt you to download when it first runs. As long as you've got a working rust installation it'll work pretty seamlessly in my experience.
- ken47 7y agoThis is the trigger for the beginning of my studies of Rust. Can't wait to try it out.
- jannikw 7y agoTry harder
- sgonz 7y agoDoes anyone know how the Rust-Analyzer compares to the Rust Intellij plug-in? From the article it seems that Intellij uses their own custom solution. I've been playing with Rust for the past couple of weeks, and I've really enjoyed the working with the language. The documentation and community are top-notch. The biggest downside from moving from a language like Java or Typescript (which I use in my day job) is the IDE experience. Things like code completion for other crates (which you'd take for granted in some of the other languages) don't seem to work.
- gizmondo 7y agoI would say rust-analyzer has less features, but is more performant. For instance, RA works on rustc codebase, while intellij doesn't (the last time I checked).
- binarycrusader 7y agoPersonal Anecdote: Every time I've tried using rust-analyzer in another editor I've ended up going back to CLion (an IntelliJ-based IDE from JetBrains). The CLion experience is far superior in my personal experience. The speed difference is barely noticeable on my system while the completions, etc. are far more accurate with CLion. For example, with rust-analyzer on one of my projects, it sometimes suggests hundreds of possible completions for in a certain context whereas CLion (accurately) only suggests a handful. The integrated debugger support has been quite nice too.
- necubi 7y agoI use CLion (same rust plugin as IntelliJ + debugging support) for rust development, and overall I would say the experience is pretty good. Certainly basic things like code completion from crates works; something is wrong with your setup if that's broken. I've also seen huge improvements in the plugin over the past couple of years, such that most stuff just works now. Still some issues with macros (a hard problem in general, limited refactoring support, and occasional analysis failures, but I find it's a hugely productive environment. (Also, as a bit of history, Aleksey Kladov who was the main developer on the intellij rust plugin went on to create rust-analyzer.)
- adamnemecek 7y agoSometimes rust-analyzer stops working. It seems to be related to how many projects you have open. I wish there was like a ui that would allow me to disable it for some projects and enable it for others.
- jayflux 7y agoI only ever have 1 project open at a time then switch to which ever other project I need to (RLS had the same issues), vscode makes this easy to do with ctrl+r but I don’t know what IDE you’re using.
- Hedja 7y agoYou can. Projects in VSCode are called "Workspaces". Every time I install an extension, I first "Disable" it, which is global. Then I switch to the workspace that needs it and choose "Enable (Workspace)". That way you only have the extensions you need per project.
- krzat 7y agoI gave up on Rust 5 years ago because IDE experience was so inferior to C#, maybe it's time to try again. I really hope that Rust team will focus on developer experience more, it's astonishing how thinks like code completion or hot reload improve the enjoyment of writing code.
- indolering 7y agoIt has been a main point of every public roadmap since they started producing them: 2017: https://blog.rust-lang.org/2017/02/06/roadmap.html https://blog.rust-lang.org/2017/02/06/roadmap.html 2018: https://blog.rust-lang.org/2018/03/12/roadmap.html https://blog.rust-lang.org/2018/03/12/roadmap.html 2019: https://blog.rust-lang.org/2019/04/23/roadmap.html https://blog.rust-lang.org/2019/04/23/roadmap.html Improving UX requires them to restructure the compiler and add new features (like NLL) while maintaining backwards compatibility. This is hard and takes time! Also note that C# is twenty years old and backed by one of the largest corporations in the world. It's pretty rare to get an OSS analyzer that can compete with the likes of Intellij!
- mamcx 7y agoIs my impression or this could lead to a kind of "rust-in-time" compiler? If the idea is to have a "roslyn" kind of backend then generate on the fly rust code and run it directly is feasible? This could be wonderful!
- saagarjha 7y agoA Rust REPL would be nice :)
- monocasa 7y agoA REPL for Rust is pretty difficult, even conceptually. Like, how does the ownership model interact with an env with as unclear scoping as a REPL?
- Klasiaster 7y agoThere is https://crates.io/crates/evcxr_repl https://crates.io/crates/evcxr_repl Also some others exist like https://crates.io/crates/papyrus https://crates.io/crates/papyrus but I didn't try this one.
- saagarjha 7y agoAny idea why it’s named that way?
- mamcx 7y agoYeah, but I'm talking is about generating (transpiling) code.
- mkchoi212 7y agoIs it just me or all the videos not playable in the link?
- OberstKrueger 7y agoThey're webm, so if your browser doesn't support that format, it won't play. Safari being the last main one to not support it, so if you're on that, that's why.
- umanwizard 7y agoIs there any good reason to migrate to this from IntelliJ/CLion ? Do people have any experiences with both and can compare?
- dang 7y agoA thread from 3 months ago: https://news.ycombinator.com/item?id=22212503 https://news.ycombinator.com/item?id=22212503 And one from 2018: https://news.ycombinator.com/item?id=18699627 https://news.ycombinator.com/item?id=18699627
- steveklabnik 7y agoWhat's the reason the title was changed? I'd prefer to not fall afoul of whatever rule it is in the future, and I think this title removes the interesting part.
- dang 7y agoThe 'misleading' horn of the title guideline. It's obviously not a first release if there have been major threads involving people using it! Not saying it's a bad submission, by the way—and I hope that including those links didn't make it seem that way.
- steveklabnik 7y agoI see. Previously, those people had to compile from source, and very very recently, it moved to providing easy installation. So I think that it's not misleading, but I think a reasonable person could differ. Nah, it was the title change. I'm a super big fan of the previous discussion links; I know they have a weird controversial history on HN, or at least they did a long time back, but I've always thought it was a nice touch.
- sideeffffect 7y agoWould anybody here know, if there is an implementation of the Build Server Protocol around Cargo (or perhaps in a Rust-Analyzer submodule)? https://build-server-protocol.github.io/ https://build-server-protocol.github.io/ If not currently, is it planned?
- steveklabnik 7y agoI've never heard of it.
- irishcoffee 7y agoAnyone tried using this with qtcreator? Link below shows how to use rls with it. https://sudonull.com/post/3132-QtCreator-and-its-use-as-IDE-for-Rust https://sudonull.com/post/3132-QtCreator-and-its-use-as-IDE-...
- pot8n 7y agoThis looks a very promising and serious project. RLS is a memory hog. I hope Rust-analyzer is taking performance and memory usage seriously.
- HeavyStorm 7y agoVery nice to see VS Code taking such prominence in the rust community.
- user1988_203 7y agoI just tried today. Its super fast when compared to RLS. Types inferred are better. I hope one day we will have release v1.0.