8 ms·
I'm glad to see that Apple is putting work into making their tooling better and easier to work with, but I'm still not clear on the benefits of this change. Wou
by saagarjha 9y ago
I'm glad to see that Apple is putting work into making their tooling better and easier to work with, but I'm still not clear on the benefits of this change. Would someone care to enlighten me? Currently, the benefits of libclang that I see are that I can easily drop it into a project without requiring a lot of dependencies, and I don't need to figure out how to get permission to run different processes and manage interprocess communication between them–if anyone doubts that this will be an issue, on iOS neither of these is really supported at all. In addition, I don't require a daemon to constantly be running to analyze my code. (Why is this bad? Take a look at Swift's sourcekitd.)
- vhbit 9y ago> if anyone doubts that this will be an issue, on iOS neither of these is really supported at all What for you might need it on iOS? Server is meant to run on a development machine.
- JDevlieghere 9y ago> What for you might need it on iOS? Server is meant to run on a development machine. While I totally agree, I can see the author's point. Think for example about Swift Playgrounds.
- saagarjha 9y ago> Server is meant to run on a development machine There's no reason to discount iOS as a development machine–it's perfectly fine for coding, as Swift Playgrounds shows. (Actually, there are some issues with executing code in third party apps, but I'm working on a way to bypass the restrictions around this. Check back again soon!)
- pjmlp 9y agoTo be able use it from any editor that is able to understand LSP, instead of having everyone writing their own bindings to libclang, specially if the editors are written in type safe languages.
- JDevlieghere 9y agoYes, exactly this. If you have 3 different editors and 3 different languages, you potentially end up with 9 different implementation. LSP means that the same can be achieved by one implementation per language and one plugin per editor.
- kuschku 9y agoWith LSP, you end up with one subpar implementation, and you need to duplicate all refactoring functionality for each language. While with common IDE plugins, you have one implementation of the refactoring functionality, and each language plugin just exposes an AST. So LSP actually leads to more duplicated code and worse editors. VS Code will never be able to match the functionality of IDEA unless each language server reimplements all the functionality slightly differently. What a mess.
- girvo 9y agoAnd no other editor can implement IDEA’s feature set except from scratch. What a mess.
- kuschku 9y agoOr they can start off with reusing IDEA’s stuff, and building an LSP 2.0 based on it.
- Analemma_ 9y agoLSP is already on version 3.7, and publishing an update every few months: https://microsoft.github.io/language-server-protocol/specification#version_3_7_0 https://microsoft.github.io/language-server-protocol/specifi... Is your complaint that they're not iterating fast enough? Because this is something I'd prefer they take their time and get it right, especially once we get past the low-hanging fruit and into complex things like debugging.
- gjem97 9y agoI'm no expert, but one major distinction I can see is that libclang would be used in (editor) process, and a clangd server would operate outside the editor process and communicate over a protocol with the editor.
- terhechte 9y ago// Why is this bad? Take a look at Swift's sourcekitd. Actually, if this were just a lib in Xcode, then instead of sourcekitd crashing, Xcode would crash all the time. Would you really prefer that?
- saagarjha 9y agoYou're always free to spawn your own process, which links with libclang, if you really want to and communicate with it over XPC. But then again if this crashed Xcode all the time maybe Apple would have more incentive to fix it ;)
- yzmtf2008 9y agoLSP converts a M x N problem (M editors, N languages) into a M + N problem.
- DannyBee 9y agoJust to clear what seems to be some confusion in what you wrote: Clangd already exists (it was contributed and mainly maintained by Google, IIRC), and works great. It supports LSP, and works fine with vscode. What apple is investing in is making it their default tooling. So the benefits of this change are exclusive to apple xcode (ATM) :) The benefits to using clangd in general are (among poher things) editor agnosticism and scaling. If everyone uses libclang, libclang must scale to every codebase (or a least, the interface, and then you'd have to replace/relink it). If everyone uses LSP, you just need something that speaks LSP, and scales to your codebase. At the scale of Google's codebases, for example, the first is untenable, the second is doable.
- kenferry 9y agoWell, I mean, it's a little more than that unless clangd is straight up finished software. Apple will now be contributing to clangd as well, which benefits all clients of clangd.
- DannyBee 9y agoThat is why I said "at the moment". It also depends heavily on what extensions are contributed and how and whether they are standardized, etc. Certainly missing LSP functionality helps everyone, but the rest depends quite a lot on approach and details.
- r4nt3r 9y agoThe main problem with libclang is actually that it puts another abstraction on top of the AST that nobody really had time to maintain. That's not made better by the amount of work changing libclang requires just due to its backwards compatibility promises.