News for hackers. Stuff that matters.
Re:Introducing Rust Language Server by JoshTriplett on Tuesday October 18, 2016 @07:49PM (#12739768)
I think that's a side effect of making a welcoming community a priority. The Rust Language Server grew out of feedback from the Rust Language Survey, in which many people responded that they wanted good IDE support.

That isn't a glamorous task to work on, especially if you're already comfortable with the level of editor support you have, but it helps bring more people into the community, which has a multiplicative effect.

Re:Introducing Rust Language Server by allengeorge on Tuesday October 18, 2016 @10:06PM (#12740440)
I can't upvote this enough. I found the Rust community incredibly welcoming, and loved the focus on tooling - making our day-to-day lives so much better. So much so, that after a few weeks of working with Rust I contributed a few small fixes to the IntelliJ Rust plugin.

So, yeah - the community inspired me, and I hope the RLS inspires other people to contribute to Rust and the tooling around it as well!

Re:Introducing Rust Language Server by theossuary on Tuesday October 18, 2016 @08:05PM (#12739840)
I think it's a side effect of having a punishing language. Coding Rust is always described as fighting with the compiler, I don't think Rust would have ever taken off if there weren't great tools to fight the compiler with. I think that's a part of it, anyway.
Re:Introducing Rust Language Server by fabrice_d on Tuesday October 18, 2016 @08:15PM (#12739882)
I don't think "fighting the compiler" is an accurate description of the Rust coding experience. There is a learning curve during which you feel like you fight the borrow checker a lot, but once you get it you will find that the compiler is actually helpful.
Re:Introducing Rust Language Server by iopq on Wednesday October 19, 2016 @05:54AM (#12742429)
There's plenty of fighting the compiler.

    error[E0281]: type mismatch: the type `fn(_) -> _ {tool::second::<_>}` implements the trait `std::ops::FnMut<(_,)>`, but the trait `for<'r> std::ops::FnMut<(&'r _,)>` is required (expected concrete lifetime, found bound lifetime parameter )

     --> src\lib.rs:53:11
       |
    53 |            .filter(apply(second, i))
       |                    ^^^^^
       |
       = note: required by `apply`

    error[E0271]: type mismatch resolving `for<'r> <fn(_) -> _ {tool::second::<_>} as std::ops::FnOnce<(&'r _,)>>::Output == _`
      --> src\lib.rs:53:11
       |
    53 |            .filter(apply(second, i))
       |                    ^^^^^ expected bound lifetime parameter , found concrete lifetime
       |
       = note: concrete lifetime that was found is lifetime '_#11r
       = note: required by `apply`

    error: aborting due to 2 previous errors
I now know why I'm getting this error. Would you?
Re:Introducing Rust Language Server by pcwalton on Wednesday October 19, 2016 @12:12PM (#12745088)
That's a bad error message. Please file a bug :)

It sounds like you're returning closures, which is a very recent feature—it only became possible last month with the implementation of "impl Trait" IIRC. It takes time for features to mature.

Re:Introducing Rust Language Server by iopq on Thursday October 20, 2016 @02:33AM (#12750136)
Re:Introducing Rust Language Server by lmm on Wednesday October 19, 2016 @09:55AM (#12743750)
I suspect I would - I'll happily guess if I can take a look at the code (or at least the signatures of "filter", "apply", "second" and "i").
Re:Introducing Rust Language Server by iopq on Thursday October 20, 2016 @12:24AM (#12749720)
`i` is just getting closed over, it's an integer

filter is from the standard lib

apply is defined as

    fn apply<A, B, C, F, G>(mut f: F, a: A) -> impl FnMut(&B) -> C
         where F: FnMut(&B) -> G,
               G: FnMut(A) -> C,
               A: Clone
    {
        move |b| f(b)(a.clone())
    }

second comes from

https://github.com/Stebalien/tool-rs/blob/master/src/sequenc... which means you have to track down its implementation somewhere in macros

Re:Introducing Rust Language Server by iopq on Thursday October 20, 2016 @02:23AM (#12750101)
I put the whole code in a separate branch for you:

https://bitbucket.org/iopq/fizzbuzz-in-rust/src/920bd2bd1267...

this doesn't work, so I want you to tell me why

Re:Introducing Rust Language Server by lmm on Thursday October 20, 2016 @07:17AM (#12751336)
Hmm fair enough, harder than I thought (I don't know Rust, the error just sounded sensible). It reads like the function you're passing into filter is supposed to be "lifetime-generic" taking a parameter whose lifetime comes from the for, but the function returned by apply has a fixed lifetime. But I can't see where it's getting the lifetime for that from, or what to do about it. I guess at that point I'd try adding an explicit lifetime to the return type of apply (or maybe an IDE could show it without having to write it)?
Re:Introducing Rust Language Server by iopq on Thursday October 20, 2016 @05:52PM (#12756509)
The problem is with the function `second` that I get from the other crate. If I replace the `second` function with my own implementation it works. But for the `second` implementation from tool.rs to work, Rust needs better higher ranked lifetime support.

It would also work with a closure, but I wrote my code this way to avoid closures in the first place (I was going for point-free style).

I basically just have to write my own function:

https://bitbucket.org/iopq/fizzbuzz-in-rust/src/58bfa4c58c80...

this compiles, but it seems kind of pointless since I can only use this particular function in my case (because of the extra levels of references)

if I could use the tool.rs version, it would automatically generate all the implementations I need using macros

Re:Introducing Rust Language Server by iopq on Sunday October 23, 2016 @09:33PM (#12776306)
Someone helped me with it:

I had to change the `apply` function to dereference as well, that way it doesn't run into the lifetime issue. It has something to do with higher ranked lifetimes (the inability to express the higher ranked lifetime)

This is the working version:

https://bitbucket.org/iopq/fizzbuzz-in-rust/src/95451868e27f...

Re:Introducing Rust Language Server by vertex-four on Wednesday October 19, 2016 @06:20AM (#12742532)
Closure-related error messages are not one of the strong points of Rust so far, unfortunately.
Re:Introducing Rust Language Server by annnnd on Wednesday October 19, 2016 @07:43AM (#12742911)
Either that, or the Stockholm sindrom kicks in after a while. :)
Re:Introducing Rust Language Server by duaneb on Tuesday October 18, 2016 @08:35PM (#12739974)
Agreed.

Refactoring tools would help address compiler concerns quicker, however.

Re:Introducing Rust Language Server by kbenson on Tuesday October 18, 2016 @09:07PM (#12740146)
> I think it's a side effect of having a punishing language.

Rust is a punishing language in the same way a notifying spell checker is a punishing tool. For someone used to writing without stopping and reviewing at the end, spell checking as you go might at first be annoying. After a while, you integrate it into your style, and choose the best time to deal with the errors when they come up yourself, whether that be immediately, after the paragraph/idea is expressed, or at the very end. In any case, having those handy notifications of what you need to fix is useful for a good 90% or more of the problems you might encounter.

Re:Introducing Rust Language Server by adamnemecek on Tuesday October 18, 2016 @10:03PM (#12740431)
Its not punishing, it's helping. Fixing bugs in development sure beats fixing bugs in production. And most of the things it complains about are in fact bugs.
Re:Introducing Rust Language Server by szemet on Wednesday October 19, 2016 @12:42AM (#12741129)
I agree. At least for me it was a common pattern that by fixing a bug I've introduced another (sometimes suprising one), and by fixing that I've introduced another and so on. I would have given it up without strong editor support giving hints on the fly.

(I don't remember similar experiences learning other languages even with strong static checks (e.g. haskell). Either my errors were 1 level deep there, or the propagation of errors (like changing a type somewhere) was easier to follow/predict to me)

Re:Introducing Rust Language Server by jimbokun on Tuesday October 18, 2016 @09:37PM (#12740302)
Not a Rust developer, but this project sounds sexy to me! :)

I use Emacs as much as possible, but for Java dev use IntelliJ because the Java plugins I've tried were always relatively clunky. Having great language support regardless of editor sounds wonderful!

Re:Introducing Rust Language Server by wst_ on Tuesday October 18, 2016 @10:22PM (#12740507)
You can develop Rust with IntelliJ as well. There's a plugin out there.
Re:Introducing Rust Language Server by sjm on Wednesday October 19, 2016 @12:04AM (#12740986)
I think he's saying he'd rather use Emacs for Java dev, but IntelliJ is a necessary evil. For Rust, there's https://github.com/racer-rust/emacs-racer which seems pretty solid.

P.S. Regarding Java dev on Emacs, ENSIME (http://ensime.github.io) now works with java-mode rather than only Scala. I use it for Android development, and it's not perfect but works well enough.

Re:Introducing Rust Language Server by steveklabnik on Tuesday October 18, 2016 @10:32PM (#12740545)
They gave it a snazzy site: https://intellij-rust.github.io/

One really interesting thing about this effort is that the IntelliJ folks have their own stuff for autocomplete; they're not using racer.

Re:Introducing Rust Language Server by xorxornop on Wednesday October 19, 2016 @03:44AM (#12741862)
Yeah, that seems nearly a constant for them. For example, in ReSharper (and presumably Project Rider), despite C# having the excellent, very fast (and, critically, fully open source!) compiler-as-a-service, Roslyn, they continue to use their own internal compiler service for code autocompletion, refactoring, and correctness analysis.
Re:Introducing Rust Language Server by royjacobs on Wednesday October 19, 2016 @05:50AM (#12742414)
Resharper has been in development far longer than Roslyn and seems to be much more suited to working with partially incorrect code (the kind you have while typing away) and incremental changes.

Does Roslyn have the same support?

Re:Introducing Rust Language Server by drchickensalad on Wednesday October 19, 2016 @06:19AM (#12742529)
Roslyn is built for incomplete/flawed code
Re:Introducing Rust Language Server by royjacobs on Wednesday October 19, 2016 @07:07AM (#12742731)
Ah, excellent!

I guess JetBrains is heavily invested in ReSharper (and the underlying AST code) which would explain why they won't want to switch right away, if at all.

Re:Introducing Rust Language Server by aswanson on Wednesday October 19, 2016 @12:57PM (#12745467)
I really wish I had time to contribute to this language. The community seems awesome.