This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-06
Channels
- # bangalore-clj (7)
- # beginners (51)
- # bigdata (1)
- # cider (97)
- # cljsjs (2)
- # clojure (41)
- # clojure-dev (2)
- # clojure-dusseldorf (5)
- # clojure-nl (16)
- # clojure-russia (43)
- # clojure-spec (13)
- # clojure-uk (59)
- # clojurescript (24)
- # community-development (16)
- # datomic (18)
- # defnpodcast (1)
- # editors (96)
- # figwheel-main (6)
- # fulcro (13)
- # jobs-discuss (2)
- # jobs-rus (8)
- # off-topic (8)
- # onyx (11)
- # pedestal (3)
- # re-frame (18)
- # reitit (2)
- # shadow-cljs (158)
- # spacemacs (7)
- # tools-deps (3)
- # vim (3)
@pez No, nothing special. We’ve been polishing the Elisp bencode code for quite a while and it’s pretty reliable at this point.
@pez just a quick theory, if your network callbacks aren't complete, then perhaps you're receiving chunks? e.g. di6e
followed by i3ee
I don’t remember at this point to be honest. Haven’t touched this code since the early days of the project.
Only a clojure programmer would have made the mistake, empty lists are falsey in python 😄
I do remember that the Emacs bencode also didn’t handle negative numbers in the beginning.
https://github.com/clojure-emacs/cider/pull/616/files I see something here for handling incomplete streams. @pez
t seems that when the result is large it is chunked up, yes, but the chunks are not encoded correctly, by what I can see. That is probably my error, when adding stuff to the buffer. Hmmm… Thanks for that question, @dominicm!
I wrote a lot of C code as a teenager, I now have a bit of a sixth sense for network problems and race conditions. It's a little trigger happy, but I like it that way 😄
In fact I get decode errors for some non-large result values as well, but I haven’t looked at that yet, I do think empty lists and negative numbers are handled, though. 😃
@pez I found generative testing amazing for this. I can highly recommend pairing your encode/decode functions in a generative test.
It ironed out all of the problems in python-nrepl-client (from what I can tell, anyway)
(In case it isn’t obvious I am still very much a Clojure (and functional) noob. I can even admit to not having groked functional fully yet. Still waiting for that “click”… But that is why I am rewriting Calva in ClojureScript, eventually it has to happen!)
I had been waiting a very long time for a chance to use it 😄 It doesn't come up so often.
I suspect that's a function of the way the codebases I work on are written too though.
Most of it is side effecting, and very little of it is data pushing & business logic.
I am trying to factor the Calva code so that ClojureScript is doing almost only data pushing and business logic, and then keep the side effecting out in the TypeScript glue into VS Code.
I am pretty sure it is. But I haven’t even looked at spec yet, so I have some learning to do. Guess I should be happy there is still so little of Calva ported to CLJS yet. 😃
I must find a way to test this programmatically anyway, the manual way I am doing it now is driving me mad.
I've just been trying to wrap tests around pack (uberjarring command line tool I wrote). It's surprisingly hard. I wanted something that ran the CLI and tested that the jar behaved correctly. I've found so many bugs in shell-based harnesses. It's really hard to integration test non-http things. Vim does have some harnesses about, but I haven't tried writing tests for replant yet, in the fullness of time I suppose I should though 🙂
I don’t like spec in its current form, that’s true, but I don’t hate idea in general. Although I do feel that it goes against the nature of dynamic programming languages to a large extent.
I don’t have anything against gen testing, but in my experience the touted benefits are rarely strongly pronounced.
https://lispcast.com/testing-stateful-and-concurrent-systems-using-test-check/ That is a lot of effort for just k/v, I suspect the complexity here is exponential, so that's a lot of work for most systems.
@dominicm I haven’t looked much at testing in VS Code. For Calva Formatter (a separate extension) I have unit tests on the CLJS side, but I can’t leverage them fully because I have stubbornly stuck to keeping my tests together with the functions they are testing and cljs,test do not discover them. I might give up un that, but have so far now and then tried to figure out how to get the testrunner to see them… Sometimes I wish I was less stubborn about things.
I found Eric Normand’s talk about making composable abstractions very interesting, even though most of it flew over my head. He is specing his way forward in the process: https://youtu.be/jJIUoaIvD20
Btw, @pez, I think that probably you and other people who can work directly with JS or CS in their editor would probably benefit a lot from a native JSON/EDN transport in nREPL.
It’s as simple as implementing a function like https://github.com/nrepl/nREPL/blob/master/src/clojure/nrepl/transport.clj#L84
Bencode was chosen for the default transport with the assumption it would be easy for many editors to support it.
My experience with JSON and ClojureScript is that it can be slow, but EDN makes total sense.
I think that for the small messages that are typically encoded probably any format will do. 🙂
Going from JSON to Transit sped up the initialization of SPA I am working with (for food) magnitudes.
The problem is that ideally nREPL should not have 3rd party deps, as they can conflict with something in the project of the people using it.
But yeah, we just need a different transport function that uses say EDN and that’s it.
It will also be an opportunity to extend http://nrepl.readthedocs.io/en/latest/design/#transports 😄
it would be quite neat if there was a cli-friendly way to inject a transport :thinking_face:
OTOH, using bencode everywhere is super beneficial as it means you can connect to any arbitrary nrepl server.
@pez Just a normal Clojure project. Nothing special about it. There’s a section on hacking in the manual, but it’s pretty basic.
@dominicm Well, if there were more bundled transports that wouldn’t really change anything. After all each transport defines it’s own protocol, so you can use all of them depending on your preference.
@bozhidar as long as all are loaded, sure. But you end up with people saying "Oh, emacs uses bencode, I'll start that" and http/edn never gets loaded.
As for the injection of transports - that shouldn’t be hard, but I think something like an json or edn transport should probably be built-in.
I just remember that had something built-in for XML, so probably they caught on the json front as well. 😄
> But you end up with people saying “Oh, emacs uses bencode, I’ll start that” and http/edn never gets loaded.
Choice is okay, except when you want to try and have a uniform interface. Then you get things like content negotiation. At that point we should use http 😄
There’s another reason why more transports (json in particular) have been on the back of my mind - which such a transport it’d be easy to expand nREPL to an LSP implementation. 🙂
Overall, bencode has been surprisingly good. It's got limited expressivity which sucks (transit over bencode anyone?) but writing a bencode decoder/encoder is difficult primarily because of handling streaming in the language, which is quite fundamental anyway, you'd have to do the same with JSON. I'm quite a simple programmer, and bencode is well within grasp for me to write a parser/encoder for. Json, not so much.
No argument here. But there’s also the point it’s unlikely you’ll have to write a json parser yourself. 🙂 Anyways, Let’s bench the json idea for now and only focus on edn.
I'm just thinking out loud really. I wonder if an json streaming parser exists for most languages.
My computer goes super hot and then becomes quite unresponsive working with the nREPL project. Seen something like that, @bozhidar?