Why building a Rust LSP is hard

(rust-glancer.github.io)

16 points | by agluszak 2 days ago

2 comments

  • mitxela 59 minutes ago
    Using a JSON TCP connection for what on Windows would be direct function calls (COM) or in Eclipse would be direct function calls between Java modules always felt a bit gross.
    • throwaway17_17 11 minutes ago
      I agree, the only reason LSP exists as it does is for a world running on electron based applications. Plug-ins and application extensions are not new technology and they are nearly universally more efficient in the forms designed and used prior to 2005-ish. I understand why VSCode exists and why it is used so often by developers, but it is certainly a downgrade from more language specific options that could exist.

      There are some arguments that do carry water in favor of using a client/server protocol transmitting JSON, in particular, the ability for a nearly complete decoupling of analysis of code and the displaying and editing of that code. Also, LSP was (to my knowledge) the first language/platform/usecase agnostic protocol intended for use in code editors.

      I get why this is where a big chunk of developers have ended up, but I do bemoan the lost potential for a language to grab mindshare and popularity on the usability and performance of its tooling and developer experience via-a-vis a custom designed and hyper specific code editor. I mean, Rust and Elm received endless praise for their error messages as a massive boon to developer experience, so it is a facet of language design and implementation that can act as great advertisement. I just hate that the prevalence of LSP at this point precludes custom editors as a first choice in the current zeitgeist.

  • octoberfranklin 44 minutes ago
    Enter hell: LSP assumes that it's the source of truth, but you still need to access the filesystem yourself, and do it in a synchronized way

    LSP is an example of utterly horrid technical design.

    Stop letting Microsoft design protocols and APIs. They are so. bad. at. it.

    • tredre3 23 minutes ago
      > Stop letting Microsoft design protocols and APIs.

      Unfortunately nobody else stepped up to do it.

      I'm glad that the code editors out there didn't wait for your theoretical better designed protocol and decided to adopt LSP. Otherwise we'd still have editor that only support one language properly, and the rest is treated like text. If the price to pay is that it sucks for the handful of people who have to work with it, so be it. For every LSP developer that suffers there are tens of thousands of downstream users who benefit from better language support in their favorite editor!

    • duttish 42 minutes ago
      I've never looked into LSP, how would you design it?
      • packetlost 41 minutes ago
        Well for one I wouldn't design it so both the LSP and the editor need a synchronized view of the underlying file.
      • mitxela 41 minutes ago
        Start with synchronous function calls instead of JSON. Microsoft knows how to do that - they invented COM and OLE. Function calls enable whatever data sharing is necessary to maintain a coherent view. Imagine trying to do OLE with JSON - just wouldn't work. (Does OLE still exist?)
        • cyberax 7 minutes ago
          Moreover, it's not just stupid, it also does not actually solve _anything_.

          A synchronous function can also have obsolete indexing information if it races with the code updates.

        • cyberax 19 minutes ago
          Stupid idea.

          So the LSP crashes and/or goes into a runaway memory consumption loop. And your main application dies with it.

          Or what if you want, you know, to be able to use the same LSP from TWO different applications at the same time?

          Never mind issues with other managed runtimes not expecting to deal with something else in their address space.