This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-19
Channels
- # announcements (3)
- # beginners (29)
- # biff (10)
- # calva (33)
- # cider (1)
- # clara (8)
- # clerk (10)
- # clj-kondo (6)
- # cljs-dev (5)
- # clojure (40)
- # clojure-dev (3)
- # clojure-europe (43)
- # clojure-gamedev (1)
- # clojure-nl (1)
- # clojure-norway (19)
- # clojure-uk (2)
- # clr (3)
- # cursive (12)
- # datomic (4)
- # devcards (3)
- # gratitude (3)
- # honeysql (13)
- # hoplon (25)
- # humbleui (3)
- # hyperfiddle (38)
- # malli (26)
- # pathom (38)
- # practicalli (2)
- # rdf (6)
- # reagent (8)
- # shadow-cljs (13)
- # xtdb (1)
Currently using emacs+cider for clojure development. One thing I miss from python is being able to drop into a debugger when there is an error. Is there something similar for clojure? Would also love to hear any other tips on debugging since it's turning into the bottleneck for development 🙂
Does any of this help? https://docs.cider.mx/cider/debugging/debugger.html
I don't think this type of debugging exists atm. I checked https://calva.io/debugger/ too and no luck.
I'll be honest, I haven't felt the need for a "debugger" in the classical sense -- in over a dozen years of working with Clojure in production. But with the REPL, especially being able to use it in remote processes, and tools like Portal (and Reveal and Morse/REBL), I find it pretty straightforward to debug problems...
...that said, I believe there are libraries that can open up a new REPL when an exception is raised and so you get full, interactive access to the error context (again, I've never felt the need for such things).
I used to rely on classical debuggers a lot back when I did C++ and in the early days of working with Java (I switched to Java in '97).
I'll check out those tools, thanks for sharing! It must be my code and workflow that needs to change. Curious, when your developing with clojure what do you find to be the biggest bottleneck in the development process?
The development workflow with Clojure is unlike that of any other language and it takes a bit of getting used to.
I don't really have any bottlenecks. I always have a REPL running. My apps run in my REPL. I use Portal to visualize data and display values from tap>
calls that I add when I'm debugging a problem.
I made this video several years ago showing what my workflow was like, for analyzing and fixing a bug in a library: https://www.youtube.com/watch?v=UFY2rd05W2g
I've changed editors and workflow a fair bit since then but the essence is mostly the same.
These days I use Calva/VS Code and generally have two Portal windows running inside the editor, but the core is still: always run a REPL, eval every change you make, use tap>
liberally for debugging and tracing, use some sort of tap>
-friendly tool for visualization.
@dingelsz3 take a look at https://github.com/jpmonettas/flow-storm-debugger a debugger for Clojure and ClojureScript that is IDE independent, show up in #flow-storm if you have any questions
@dingelsz3 evaluating forms is not cutting it?
do you use calva? https://calva.io/debugger/
He said he uses Emacs, not VS Code.
I linked him to the CIDER debugging stuff to see if that helps.
Yeah I'd be open to using calva but I don't think it supports this either. What I'm looking for is the ability for the debugger to run whenever an exception is thrown without me having to find where to put the breakpoints
> What I'm looking for is the ability for the debugger to run whenever an exception is thrown without me having to find where to put the breakpoints @dingelsz3 this is covered by #C03KZ3XT0CF
Also soon to be supported in Cider / Calva! https://github.com/clojure-emacs/cider-nrepl/pull/769/
If i want to do (last smth), should i prefer a list or a vector. I always struggle to remember, which is better for what. Does someone have a mnemonic for it? ;)
Last is always O(N), use a vector and peek if that matters. But why does it matter?
The intuition I have for these kind of problems is “core functions operating on general sequences will always walk the sequence”. This is at least true of map
, filter
, reduce
*, last
, butlast
, take
, drop
, and so on.
Functions like pop
and peek
, on the other hand, depend on sequences satisfying specific protocols or have special treatment in the Clojure runtime. (In CLJS, it’s always a protocol; e.g. pop
and peek
is specifically for objects implementing IStack
).
* technically not true if you return reduced
at any point in the reducing function, but that’s besides the point and if you understand this, chances are you already have some intuition for most core functions
@UK0810AQ2 it only matters for my interest. I read that list and vectors behave different in terms of performance if you work on the end or on the top of the list. So doing a bit digging in different sources, I found a quite short but maybe helpful answer in stack overflow, which sorts out my "mind-confusion". My confusion comes from a misunderstanding: it's maybe not to interesting for accessing, but for adding / removing elements. Short cite: > [12:21] <Raynes> Vectors aren't seqs, right? > [12:21] <rhickey> Raynes: no, but they are sequential > [12:21] <rhickey> ,(sequential? [1 2 3]) > [12:21] <clojurebot> true > [12:22] <Raynes> When would you want to use a list over a vector? > [12:22] <rhickey> when generating code, when generating back-to-front > [12:23] <rhickey> not too often in Clojure https://stackoverflow.com/questions/1147975/in-clojure-when-should-i-use-a-vector-over-a-list-and-the-other-way-around
so my takeaway for now is: use vectors. thanks @UK0810AQ2 and @U0479UCF48H