Fork me on GitHub
#dev-tooling
<
2023-07-06
>
oyakushev11:07:57

Hi again, @bozhidar! I've taken a look at https://github.com/nrepl/nrepl/blob/master/src/clojure/nrepl/util/completion.clj, and I have a few thoughts about it. If I remember correctly, there was a need in nREPL to have some basic completion that does not rely on external dependencies and is compact. Totally understand that. But I see now that it has grown to 250 lines of code (yet, still less than compliment's 1000+ lines). While some of its code is very straightforward and easy to reproduce without pulling in an external solution, some things like classpath scanning and parsing out Java classes is not so trivial, and are already not 1:1 with Compliment (for example, if I read the source code right, it won't complete java.base classes in JDK9+). So with that in mind, do you consider the current approach of having to be the optimal one? I personally think that it is completely (hehe) fine, but there might also be some alternatives, depending on what are your primary criteria: • Is having 0 dependencies obligatory for nREPL? I'd say yes, cutting down on dependencies is overall a great practice. • Is using tools like mranderson undesirable for nREPL? • Is having all completion code as a single file obligatory? • Should the code for completion in nREPL live inside nREPL repository?

oyakushev11:07:56

Depending on what is your stance on those questions, I could think of several approaches to increasing the reuse and consistency between Compliment and nrepl.util.completion. This also includes just keeping the current setup, but I would pay more attention to the nREPL's completion implementation and just backport Compliment fixes/important changes into it.

bozhidar11:07:18

> Is having 0 dependencies obligatory for nREPL? I'd say yes, cutting down on dependencies is overall a great practice. Yeah, that's a hard requirement.

bozhidar11:07:54

> Is using tools like mranderson undesirable for nREPL? I'd say - yes. The rewritten deps inflated cider-nrepl a lot in some case and forced extra complexity down the road like delayed middleware loading and so on. Perhaps for compliment it wouldn't be a big deal as it doesn't have deps itself, but I'd rather just copy the code from time to time than deal with MrAnderson's setup.

bozhidar11:07:25

> Is having all completion code as a single file obligatory? Nope, this a problem for REPLy, but for nREPL it's all the same whether something is in one file or in multiple files.

bozhidar11:07:13

Btw, there's one item to consider and this is REPLy itself - part of the reason I needed some simpler completion library was that we failed to get compliment working with it (I guess you remember this) and the original clojure-complete was kind of dead.

👍 1
oyakushev11:07:26

> Are you talking about something git submodules? Partially, yes, but I don't have a good success story with using submodules, so it depends whether you thought of it as a viable idea.

bozhidar11:07:44

You might have noticed that I copied nREPL's completion code to one standalone library that I used to replace clojure-complete in REPLy.

oyakushev11:07:00

Ah, no, didn't see that

bozhidar11:07:04

> Partially, yes, but I don't have a good success story with using submodules, so it depends whether you thought of it as a viable idea. I'm not a big fan myself.

oyakushev11:07:31

The main fuzzy thing I have in mind right now is producing something like compliment-lite which could be somehow automatically derived from Compliment itself (Compliment can be refactored to accommodate that), which would not contain overcomplications like contexts and completion docs, and which could just live as a file artifact in the repository, not necessarily pushed as a JAR even.

oyakushev11:07:31

> https://metaredux.com/posts/2021/08/17/introducing-incomplete-a-simple-clojure-code-completion-library.html I see! That makes it another place where the code gets duplicated and has to be maintained. Which is not the biggest problem in the world, I agree, it's all pretty much bike-shedding. But if I could tackle this without complicating things for other people, and you think it is something worth doing, I'd be willing to try.

oyakushev11:07:02

I was also thinking such refactoring/reimagining can be coupled with finally moving Compliment under cider or even nrepl umbrella. I doubt it makes much sense to keep it a standalone project, given that most tool/IDE implementors just use nrepl or cider-nrepl directly and don't want to pull another third-party library.

bozhidar11:07:51

That would be fine by me - I'm all for reducing code duplication. I'm assuming that with enough work we can change REPLy to work with compliment normally (e.g. we can just inline in there as well and remove the problematic dynamic load functionality).

oyakushev11:07:27

Cool, then I'll work on a prototype and come back once I have something to show.

oyakushev11:07:05

One more question, is there a reason why nrepl.util.completion is not 1:1 copy of incomplete? Do you take some notion of "complexity" into consideration as well?

bozhidar19:07:40

@alexyakushev I'm guessing I forgot to update something after the initial release. I can't remember at this point, but I think I intended for them to be essentially the same.

mauricio.szabo19:07:12

@alexyakushev well, I use Compliment and Suitable without nRepl now, and I kinda want to keep doing it...

mauricio.szabo19:07:30

ClojureScript support with the shadow API is way better than over nRepl

mauricio.szabo19:07:33

And having the completion libs working without nRepl means that I don't loose functionality by deciding to use a different REPL implementation

bozhidar19:07:44

@mauricio.szabo That's not going to change.

bozhidar19:07:17

We're just discussing if we can use somehow compliment with nREPL directly, instead of its simplified completion mechanism.

oyakushev19:07:57

@mauricio.szabo Thanks, that's good to know! I have no intention of removing Compliment as a standalone dependency, just some possible stewardship/repository changes

bozhidar19:07:00

> moving Compliment under cider or even nrepl umbrella Think here simply of the GitHub org, not the projects themselves. 🙂

mauricio.szabo19:07:41

Wonderful, thanks for the clarification 😄

mauricio.szabo19:07:27

It's basically because I kinda bet on the idea of "tooling over socket-repl" and that bit me in the end, so now I'm scared/traumatized of implementing something that will not work in the future :rolling_on_the_floor_laughing:

cfleming21:07:13

I’d like to know more about this! Cursive has a socket REPL that works really well, but I did implement a prepl-like framing mechanism over it. Do you mean streaming REPLs rather than something more structured?

flowthing21:07:59

I’m also interested. 🙂