Comment by octoberfranklin

8 hours 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.

> 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!

  • we'd still have editor that only support one language properly

    Emacs supported zillions of languages before LSP.

    Zoom out.

    • As someone that got introduced to it in 1996, and was a fan of XEmacs variant, still remembers enough keybindings and Elisp, supported beyond plain syntax highlighting was very much hit and miss, even nowadays.

    • But the effort to do so was then entirely duplicated for other editors. LSP turns an N*M effort into an N+M effort, the upshot of which being far more complete coverage for both editors and languages.

    • I have been an emacs user for over a decade now, and if you think that language “support” was as good before LSP, I have a bridge to sell you.

LSP is not that bad. They tried to decouple IDE features from language features.

Resolving file paths is not trivial because it's language specific.

Syncing source changes on the LSP server side is necessary to keep packet side small and patching is trivial (span, new text).

(I made an LSP-powered text editor and implemented LSP client from scratch)

I've never looked into LSP, how would you design it?

  • Well for one I wouldn't design it so both the LSP and the editor need a synchronized view of the underlying file.

  • One of the largest issues of LSP is that each language implementation needs to do everything separately, and that means each language will work differently.

    Imagine if all the editing tools in microsoft word were specific to the language you used, and if you mixed German and English, each had different tooling.

    Now if you mix Rust, HTML, JS, and CSS, they'll all have separate tooling, seperate "go to definition", and separate refactoring. Worst of all, none of them can see the definitions of the other ones.

    So what you'd actually want to do is parse each language into your AST, with proper annotations as to what is what, and have all the "go to definition", the UI rendering, highlighting, refactoring, etc all done generically by the IDE ontop.

    Which is much much closer to how Jetbrains IntelliJ does it, and why their tooling can handle "find usages" on an HTML element to find matching querySelector in .js files and matching selectors in .css

    And if you subscribe to the AI stuff, you'd also want your AI to operate on this AST so it can learn skills that generalize across all languages.

  • Wouldn't a normalized protocol based on AST vocabulary and tree operations make more sense ?

  • 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?)

    • That doesn't really fix anything. The filesystem is fundamentally a racy shared data structure. If you made the entrypoint API synchronous, any half-way decent editor would shove the LSP queries to the synchronous API into a different thread, because "Do Not Block the UI Thread" is a fundamental principle of good UI programming.

      Once you get past that, JSON-over-TCP is just another kind of asynchronous RPC mechanism, one that has the advantage that you can build it in just about any language with out-of-the-box tools. Trying to make a plugin system or a COM or CORBA or OLE based system really cuts out the ability to build language servers in most languages, because you have to be able to build the code in just the right way.

    • I feel like MS actually learned their lesson with synchronously integrating the language intelligence into the IDE. Old versions of VS would hang or crash based on bugs in the language tooling trying to provide intellisense. You'd restart and it'd work fine till you hit some other weird edge case. Generally this settled to a level of rare-bugginess where you were happy enough with the advantages not to go back to Emacs/VIM, but still annoyed at the occasional restart needed.

      In no way does this mean LSP is a perfect solution, but anything synchronous would be a step backwards.

    • Actually, COM is inspired by DCE/RPC and the initial versions had some similarities.

      Parallel to that, IBM had SOM on OS/2, which was even better allowing for metaclasses and proper class inheritance, it was the key mechanism between Smalltalk and C++ on OS/2, where Smalltalk enjoyed a role similar to .NET on Windows nowadays.

      OLE naturally still exists when using Office natively on Windows, other vendors seem to have forgotten about it.

      COM's role on Windows has grown since Vista, and the Windows team redid many of the Longhorn ideas originally implemented in .NET into COM/C++, with WinRT being an evolution of COM.

      2 replies →

    • > Start with synchronous function calls instead of JSON.

      LSP is a function call protocol. So that is already done?

    • 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.

    • 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.