
Rust-analyzer – an IDE backend for Rust - steveklabnik
https://rust-analyzer.github.io/blog/2020/04/20/first-release.html
======
_bxg1
I 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
I 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
Yes. 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.

~~~
oconnor663
I'm not a compiler writer myself, but my impression is that designing a
compiler "the traditional way" and designing one "the IDE way" look really
different. Most people who learned to write compilers 10 or more years ago
learned the traditional way. As a new language, Rust benefited from a lot of
obvious-in-hindsight things, but "design your compiler for an IDE first" just
hadn't reached quite the same level of obviousness by 2010.

~~~
_bxg1
As someone who knows very little about compiler implementation but has some
interest in it, I'm curious what makes the difference between the two in terms
of architecture

~~~
pjmlp
Basically the IDE one needs to take into account that your program is broken
all the time, yet you want code completion for everything else that is
actually correct.

Also it needs to respond immediately after asking for completion, as anything
beyond 2s is frustrating development experience.

You also want to get real time errors and warnings, just for the parts that
are actually broken, not a wall of text like many batch compilers that fail to
understand the remaining of the file.

Also you want to be able to do code refactorings, regardless of the
compilation state.

So basically you want a Smalltalk/Lisp Machines like experience.

Anders has a nice interview about this,

[https://channel9.msdn.com/Blogs/Seth-Juarez/Anders-
Hejlsberg...](https://channel9.msdn.com/Blogs/Seth-Juarez/Anders-Hejlsberg-on-
Modern-Compiler-Construction)

~~~
_bxg1
So would you typically maintain a separate compiler for each use-case, or try
and make one that serves both?

~~~
steveklabnik
IMHO, one that serves both. The IDE case is a superset of the batch case.

------
Signez
I'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!

~~~
circuit8
I couldn't agree with you more. It's seriously increased my enjoyment of
programming. Kudos to the creators!

------
a_humean
One 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
I 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.

------
cdbattags
I 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
If InteliJ is amazing then using Smalltalk or Interlisp-D/Lisp Machines is
like out of this world.

~~~
matklad
I'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
It seems full of empty praise words without giving any example how it is
better.

------
zxv
The 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
I 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)

------
sgonz
Does 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.

~~~
binarycrusader
Personal 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.

------
blinkingled
I 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
Wouldn't that be the text editor's fault?

~~~
blinkingled
Not sure about that - doesn't seem to be a problem with any other extensions.

------
013a
Is 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
The 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
Excellent to hear. This was not obvious from the blog post, and I should have
done more digging before jumping to conclusions.

~~~
raziel2p
From the article:

> We build the rust-analyzer binary, an implementation of the language server
> protocol, which can provide a basic IDE experience for Rust today.

------
empath75
Is 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.

~~~
weiming
I 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!

------
dang
A 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
What'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
The '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
I 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.

------
miltonlaxer
I 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-327...](https://github.com/rust-lang/rls-
vscode/issues/706#event-3273465782)).

Very excited to give this a try in WSL2.

~~~
miltonlaxer
Okay 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!

------
umanwizard
Is there any good reason to migrate to this from IntelliJ/CLion ? Do people
have any experiences with both and can compare?

------
krzat
I 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
It 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!

------
stevehiehn
I 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
Do 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
I 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
I 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.

~~~
tsing
The rust plugin updated today with debug support for IntelliJ IDEA Ultimate

~~~
isbjorn16
That is fantastic news! I was curious when they added it and it looks like:
[https://github.com/intellij-rust/intellij-
rust.github.io/com...](https://github.com/intellij-rust/intellij-
rust.github.io/commit/d3cda698be5dabfe2ce91932cc506c38ea9b1a5a)

So yeah - nevermind about CLion! I do think it works better than IntelliJ, but
it's a subtle, not-easily-quantifiable thing, and it's probably not worth
buying it if you're just dabbling and also have IntelliJ Ultimate.

------
saagarjha
Is the best way to install rust-analyzer still by downloading a binary
manually, or is available through rustup or similar now?

~~~
Argorak
The 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
I don't use Visual Studio Code, unfortunately. I'm currently using rls through
my editor's support for LSP implementations.

~~~
est31
You can also compile rust-analyzer yourself. It doesn't need any custom stuff
from what I saw, and supports Rust stable.

------
sideeffffect
Would 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
I've never heard of it.

------
irishcoffee
Anyone 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-...](https://sudonull.com/post/3132-QtCreator-and-its-use-as-IDE-for-Rust)

------
mamcx
Is 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
A Rust REPL would be nice :)

~~~
Klasiaster
There 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
Any idea why it’s named that way?

------
adamnemecek
Sometimes 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.

~~~
Hedja
You 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.

------
user1988_203
I just tried today. Its super fast when compared to RLS. Types inferred are
better. I hope one day we will have release v1.0.

------
ken47
This is the trigger for the beginning of my studies of Rust. Can't wait to try
it out.

------
HeavyStorm
Very nice to see VS Code taking such prominence in the rust community.

------
mkchoi212
Is it just me or all the videos not playable in the link?

~~~
OberstKrueger
They'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.

------
jgrant27
Misleading title. Alpha releases aren't considered general releases.

