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?)
But it doesn't have to, because you call AboutToUpdateCode and the LSP doesn't return until it's safe, and then you update code and call DoneUpdatingCode.
Yes, it does because the physical code update is asynchronous. Or you'd have to do a roundtrip for every little edit, resulting in unusably slow experience.
I don't know what you're talking about. What is "physical code"? A function call roundtrip costs nothing, that's the reason we are saying it should be function calls.
A function call costs nanoseconds. You can sprinkle them literally everywhere. A JSON-formatted TCP round trip to localhost costs, I'd guess conservatively, at least ten microseconds, 1000x slower.
octoberfranklin · · focus · HN ↗
LSP is an example of utterly horrid technical design.
Stop letting Microsoft design protocols and APIs. They are so. bad. at. it.
duttish · · focus · HN ↗
mitxela · · focus · HN ↗
cyberax · · focus · HN ↗
A synchronous function can also have obsolete indexing information if it races with the code updates.
mitxela · · focus · HN ↗
cyberax · · focus · HN ↗
mitxela · · focus · HN ↗
cyberax · · focus · HN ↗
But running the LSP itself is slow. It's not instant, and you can't run it in a blocking way for each keypress.
mitxela · · focus · HN ↗
cyberax · · focus · HN ↗
> func doLspStuff() { sleep(60000); }
Now sprinkle them after each keypress. Do you see the issue now?