Fork me on GitHub
#other-languages
<
2024-05-02
>
mauricio.szabo16:05:30

Is it too controversial to say I'm liking the REPL-Driven with Ruby so much, that it might be even better than with Clojure? think_beret

Noah Bogart16:05:47

what feels better about it?

mauricio.szabo17:05:00

Ok, so - because Ruby is not "flat" like Clojure, I need to "trace" execution so I can keep local bindings. Ruby have this binding object that's basically an opaque "thing" containing local vars, self, and all context around that specific part of the code - meaning that I don't need to do something like (defn handle-root [req] (def r req) ...) to bind req to something so I can inspect - the binding already does that for me.

mauricio.szabo17:05:22

Because I have this "trace" thing, it also brings me visibility - when something happens, the Ruby interpreter calls back to the plug-in saying "hey, I called a method in this file and line" so I know exactly where to look when I do some interaction in the app

mauricio.szabo17:05:54

Also Ruby is more "dynamic", meaning that if I eval something, it "patches" the class so I don't need to stop servers and start them again to see the results (well, at least in theory - because Ruby without Rails is a myth, Rails hot-reloads things anyway so I don't have to worry about it). And also, bindings work on template things - meaning that I have inline evaluation on HTML templates too

😍 1
didibus18:05:41

Make sense, but it looks like you have a debugger open no? Not a repl? Debuggers can instrument the code and all to do more things. It be cool to have something like that in Clojure, it's just annoying because it involves more the runtime, and that's just JVM.

didibus18:05:31

But ya, Clojure REPL suffers a lot from being a non-interpreted language and running on the JVM. The flip side is Clojure is more performant than Ruby

mauricio.szabo18:05:39

There's no debugger involved, actually. Tracing is something that the Ruby interpreter supports (even on JRuby) and binding is also a Ruby public API thing. I don't "pause" execution of any code, and in fact, I can have multiple "watch points" defined at any time, each representing some old evaluation that called that specific method.

didibus18:05:14

nRepl doesn't support watch points, breakpoints and all that no?

didibus18:05:57

Also, all the tracing you describe no?

didibus18:05:44

I guess my point is, the tracing and watch points and breakpoints would additional debugger features on top of the repl

didibus18:05:23

Features I think it be nice if Clojure did more of that as well. The cider debugger is pretty neat, but it's not getting a lot of improvements.

mauricio.szabo18:05:52

Tracing is this one: https://ruby-doc.org/3.2.2/TracePoint.html#method-c-trace nREPL doesn't - I extended it a little bit to do the same as :out and :err does - but instead of calling back the plug-in with the result of STDOUT and STDERR, it calls back with the "trace" info. For watch points, I defined a new op that gets the watch points for the current file; then I pass which watch point I want to use as an additional parameter for eval op

mauricio.szabo19:05:18

Meaning: I could re-use 90% of Chlorine's code, I just had to write a nREPL implementation and add some new operations 😍

didibus19:05:56

That's neat. I guess I'm just pointing out that those are debugger features added on top of nRepl. And I feel in Clojure, people almost get lazy, thinking you can just tap/println to debug. And they forget how amazing debuggers are. I use the basic cider debugger and tracer all the time, and it's amazing, albeit a little bare bones. So I would like people to acknowledge how awesome debuggers are and maybe we get more investment in them. One big challenge with them is the Java bits though. Nothing new here, all the quirks are from Java haha. Too bad we need it's libraries and amazing VM otherwise we'd have paradise.

didibus19:05:05

I haven't tried flow storm yet. But it looks really good though

💯 1
mauricio.szabo19:05:05

After my experience with this experiment in Ruby, I have some ideas to FlowStorm - maybe we can hack something together soon-ish (we live really close by :rolling_on_the_floor_laughing: :flag-uy:)

mauricio.szabo19:05:42

> the tracing and watch points and breakpoints would additional debugger features on top of the repl Yeah, now I get it. I agree, for example, I use a lot the Chrome Devtools while working with pure Javascript, and it's AMAZING to use actually; to the point I was studying a way to integrate it in my ClojureScript workflow (not that easy, unfortunately). I honestly think we can do better with the tools we have. I remember once hearing about WhyLine (https://www.youtube.com/watch?v=3L4MK2dG_6k), and asking myself why don't we have something for Clojure. With FlowStorm, maybe we can?

👍 1
tengstrand04:06:41

WhyLine looks pretty cool!