9 ms·
Language Server Protocol, Rust and Emacs
- rayiner 9y agohttps://lists.gnu.org/archive/html/emacs-devel/2017-04/msg00741.html https://lists.gnu.org/archive/html/emacs-devel/2017-04/msg00... ("I am urging the GCC developers to work on implementing the language server."). Interesting statement from RMS, given LSP is a Microsoft technology, but it makes sense. The software on both sides of the reference implementation is under a GPL-compatible license. Also, LSP doesn't expose enough information to allow expropriation of GCC's frontend, which was RMS's concern with previous such efforts. Really says something about Microsoft's evolution if you think about it.
- jackmott 9y agoLSP is such a good idea, it is hard to ignore.
- teacup50 9y agoNo, it's merely a work-around for two very distinct and self-inflicted problems: - The pain of exposing language-native compiler/language AST and indexing APIs to a JavaScript IDE. - RMS' inability to accept that GCC might need to expose an AST to external consumers, and his paranoia regarding how that might undermine his GPL-everywhere ideals. Using JSON for local IPC -- and requiring IDE language support to funnel itself across that high-overhead IPC connection -- is fey.
- barrkel 9y agoLSP is sensible for the same reason that the middle end in a compiler is sensible - it turns an MxN problem into an M+N problem. For compilers, M is source languages and N is target platforms. For LSP, M is source languages and N is editors. They both have the same downside. The more esoteric the language feature, the lower the fidelity of support in the common middle.
- teacup50 9y agoLibraries solve the problem of said middle end in a compiler, and in an IDE. If you insist on using IPC, then you've incurred a great deal of friction in a place that it matters. If you insist on using JSON IPC, then you've incurred a great deal of overhead in a place that it matters.
- jblow 9y agoThis times 1000. AN API IS ALREADY A PROTOCOL but it doesn't require external processes, serialization, extra failure modes, etc, etc. The fact that the HN community seems to have jumped aboard this idea, "yeah let's just require a server to do something simple like format text in your editor", is completely flabbergasting. People just seem to have NO IDEA how much complexity they are adding, and don't care. Maybe in 5 years our machines will be running 10,000 processes at boot because people will want a server for every operation...
- yorwba 9y agoDo you know how these IDE features are currently implemented in editors like vim? Unless there is built-in support (e.g. ctags), most plug-ins that provide language-specific features do so by running an external tool, sometimes going so far as scraping the compiler output. This means that on every single change, a new heavyweight process is created, communication happens over unspecified textual formats, and everything is likely to break with the next update because there is no stable interface. JSON IPC with a continuously-running process using a well-specified protocol is a huge step up in comparison.
- jblow 9y agoJust because the current way it's done is terrible, doesn't mean you should "upgrade" to a bad way instead of a good way.
- StavrosK 9y agoWhat would a good way be? Why is having the code completion and parsing in a self-contained library a bad way? Or are you just opposed to using TCP instead of an ABI?
- kibwen 9y agoLSP--or rather the general idea of a common interface between IDEs and language-specific static analyzers--is a very good idea regardless of GCC or VSCode. Which isn't to say that LSP made universally correct design decisions (e.g. it's fair to be grumpy at JSON), and also isn't to say that it represents the be-all end-all of IDE integration (the fact that it necessarily represents a lowest-common-denominator interface is well-understood). But having such a standard to establish a baseline of support between languages and editors with the minimal amount of work possible is something that needed to be done.
- bpicolo 9y agoWhether or not the IDE is JS based is asymmetrical. A common format for any IDE to integrate with is a fantastic idea.
- teacup50 9y agoThat would be an API; JSON IPC is used because of the difficulty in hoisting language-native AST/indexing APIs into JavaScript.
- bpicolo 9y agoThat's true for every combination of language / platform where the languages differ. Rewriting AST parsers for every language would be nuts. Overall this vastly increases accessibility / choice when it comes to languages. That's purely a good thing. People are still free to make hyper-optimized versions for whatever case they would like to.
- jahewson 9y agoI don't see that as actually being true. There are thousands of native npm modules which work just fine with Electron. There's really no problem exposing native APIs to JS. What VSCode has pioneered, and this is something which Atom got wrong, is a multi-process model, where the various IDE components communicate via IPC. This improves stability and allows isolation of 3rd party plugins, and provides mostly foolproof parallelism. When plugins are such a big part of the experience, this is a very good thing. It's a deliberate design decision, not some attempt to overcome the failings of JavaScript. Couple this with the fact that limiting "API" to mean "C ABI" forces every compiler author to start exposing complex C structures, unsafe pointers and the like - which if their compiler is written in, say Haskell, or LISP is going to be particularly painful, v.s. implementing text-based RPC over a socket in whatever way is best for them. If Language Server had been a C API then I seriously doubt it would have got much traction, as it's just too awkward for many compiler authors to implement. Unsafe C APIs are, frankly, last century's technology.
- pjmlp 9y ago
- radarsat1 9y agoRegardless of those points, having a standard protocol for this kind of thing makes a lot of sense, instead of binding directly to the AST data structures of each compiler.
- jackmott 9y agolet me clarify: shipping along with your language, some kind of API that is standardized so that editors can easily add high quality IDE level features to support new languages is a great idea that this is currently being done via a server + json over pipes or whatever is a suboptimal way to do it, I agree.
- PuercoPop 9y agoHistory says otherwise, they been ignoring Slime's swank for at least a decade
- valarauca1 9y agoIt's a free and open standard. Also a good idea. And technologically on a firm-ish foundation. Ignoring it just because Micro$oft is attached is idiotic.
- fiddlerwoaroof 9y ago> Ignoring it just because Micro$oft is attached is idiotic. True, but to a casual observer it also sounds like something RMS might do.
- Analemma_ 9y agoYou don't need to be so aggressive about this, everyone already agrees with you: nobody, not even the usual Microsoft-haters, is hating on LSP. Not even RMS!
- chubot 9y agoI'm pretty sure RMS said something to the effect that the ship has sailed with Clang. There's no longer any point in trying to prevent people from using proprietary back ends with the GCC front end. If they want to do it, then they can do it with Clang, so there's no point anymore in trying to "adjust" GCC's architecture. I believe a prominent example is NVidia's CUDA compiler. As far as I understand this is just a modest fork of the Clang front end and a big new LLVM back end, and it's proprietary. However Google has developed an open source alternative CUDA compiler, which is also based on Clang/LLVM: https://research.google.com/pubs/pub45226.html https://research.google.com/pubs/pub45226.html Also I would have thought that Clang already has LSP support for C++, but maybe I'm wrong.
- pjmlp 9y agoAnother example are the companies selling compilers for embedded development. Previously they had proprietary compilers or gcc forks that they weren't that happy contributing back. Now they can have their proprietary clang forks and don't contribute anything back. Plenty of slideware examples at LLVM conferences. On one side clang was great for improving the whole safety and tooling story for C and C++. On the other side, if clang was available to Brad Cox, NeXT would never had released Objective-C to the community.
- gumby 9y ago> On the other side, if clang was available to Brad Cox, NeXT would never had released Objective-C to the community. Actually the Stepstone "compiler" was a preprocessor that generated C (like cfront was for C++). Brad Cox never worked for NeXT. The Objective C front end for gcc was written by Steve Naroff at Next. Later he and I persuaded Jobs that that front end should be merged into the official gcc tree, and so we (Cygnus) worked with NeXT to get merge them and, amazingly, produce Objective-C++ in the process. Jobs was focused on the goal. When NeXT (and later Apple) were underdogs he was happy to embrace open standards (e.g. JPEG, MPEG, MPEG-3...) when it would help and outside proprietary standards when he thought it was needed (e.g. paid the rtf license).
- 9y ago
- IshKebab 9y agoJust a warning to anyone expecting auto-completion in Rust to be anything like C++ or Java, or even Typescript. It isn't close to that yet.
- vvanders 9y agoTo counter that I've got a pretty moderate size Rust project that uses hyper, websockets, glium and a bunch of other libraries. RLS + VSCode has been incredible solid. It's come a long way in the last few months, I'd recommend giving it a shot again.
- bpicolo 9y agoThe lack of code-inlined error reporting is still a big miss (unless I'm using the extensions wrong somehow). It's also pretty complicated to get right in rust as the errors tend to link through to multiple files for lifetime issue and such. I started tinkering with a version of this yesterday for vscode. Hoping to get a sane v0 off the ground. Would be cool to have a linter that can run file-by-file as well, though that's tough for clippy as a compiler plugin it seems? Maybe just hacking it to only report on a particular file would work.
- vvanders 9y ago> code-inlined error reporting is still a big miss Do you mean errors next to lines? If so that works today in the RLS variant. You get a red highlight and can mouse-over for details.
- ilurkedhere 9y agoHow does it compare with racer-mode? Does it have roughly the same functionality or is one a subset of the other?
- corybrown 9y agoAs a vim user, I'm very excited about LSP. Neovim (close enough) may add native support, which would be great: https://github.com/neovim/neovim/issues/5522 https://github.com/neovim/neovim/issues/5522 It's possible to do a lot of the nice IDE features in vim (and I'm sure emacs) today w/ all sorts of contortions, but a standard way to get this done would be amazing.
- kuschku 9y agoThe Language Server Protocol is flawed already in its concept, as this article https://perplexinglyemma.blogspot.de/2017/06/language-servers-and-ides.html https://perplexinglyemma.blogspot.de/2017/06/language-server..., which was also on #1 of HN before, argues. It instead proposes to have the language server expose the entire AST and environment that is available at each point, and have the IDE uses that for autocompletion, as this is far more powerful than what is currently doable with LSP. (Currently, the editor just transmits cursor position and content to the LSP, which then does all the highlighting, autocompletion, etc. This is not only less configurable, and less consistent, but also less usable, as often the LSP isn’t able to offer as smart autocompletions) Many IDEs, such as the JetBrains IDEA platform, do exactly this with their language plugins.
- Analemma_ 9y agoI mentioned this at the time too: I think this was a deliberate decision by Microsoft and it is not a deal-breaker. LSP is a Minimum Viable Product that was deliberately kept simple to encourage uptake and not spook people away. Once people are comfortable that it is a good idea and not an EEE play by Microsoft, version 2.0 could be upgraded to support things like ASTs.
- kuschku 9y ago> version 2.0 could be upgraded to support things like ASTs. That’s called "you can create an entirely new API that’s entirely different, but might use the same name". That’s the issue here, LSP is so fundamentally flawed you’d have to scrap it entirely to support what is needed for a real IDE.
- dilap 9y ago> On the initial opening of a project it will hog the CPU and spin up the fans but that doesn't last too long. Sometimes it completely hangs Emacs. Nothing that killall rls followed by a M-x revert-buffer can't fix. Yep, sounds like emacs. (I use emacs, but my god is it a horrible collection of half-broken hacks. Still the most useful editor going, though. If anyone wants to fund me, I'll start a project to make an editor that combines the flexibility of emacs with a rigorous, ruthless obsession with speed and correctness. :)