Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Thanks for introducing me to `add-lib` This is going to be a huge time saver :) More info here: https://insideclojure.org/2018/05/04/add-lib/

Hopefully there will be some way to just "reload" your whole `deps.edn` though

"If you get an error, the execution stops by default and you get a stack trace."

I'd say the other missing piece of REPL development is that while you get a stack trace, you don't get a program state like you do with GDB or ELisp. Maybe I'm "holding it wrong" but this causes a lot of friction and lost time. I'd be curious how others approach this. And that all being said, the CLI doesn't relaly offer a better alternative here.

For entirely replacing the CLI I think that since Clojure is a general purpose language there ends up being a tad more boiler plate than you'd like.. It's not at the point where you're gunna just run `clj`, load in some library with `add-lib` and start messing around b/c things are just a tad too clunky.

For instance if you wanna read in a CSV file (I had to look this up)

    (-> "my-csv-file.csv"
    (io/file)
    (.getCanonicalPath)
    (io/reader)
    (csv/read-csv :separator \,)
    (#(into [] %)))))
Uhh.. so you're prolly gunna want to wrap that up in a helper function. I personally end up making a dummy "project" where I keep a bunch of helper functions and then doing my REPL "scripting" and messing around in that. It feels a bit wrong.. but at least to me it looks like a solvable limitation. Given a nice set of helper libraries you could probably get to a point where a bare `clj` REPL would be as ergonomic as a more explicitely interactive language like R/MATLAB/etc.


This should work just as well:

    (csv/read-csv (slurp "my-csv-file.csv"))
Or if you prefer the threading-macro style:

    (-> "my-csv-file.csv" slurp csv/read-csv)


Oh thanks. Yeah. I thought maybe I was noobing it up :)

Always nice to learn something new


CIDER ships with a perfectly adequate debugger if you want it. Might require a bit more manual labour than some environments but you’re never stuck just staring at a stack trace if that’s what’s bothering you.

I think using external dev dependencies and rich dev/user.clj files is pretty common on Clojure projects. Your REPL isn’t just somewhere to interact with the current codebase directly, it’s a framework for building that software and managing its environment more generally.


I need to play with the debugger again.. Does it give you the state along with a crash stack? I remember that unfortunately the debugger couldn't be turned on globally. You need to instrument particular functions. And this turned out to be a major inconvenience in my usecase (a GUI app)

But I'll take another look in my next project


Yeah you’re right, that’s what I mean by manual labour, there’s no ability last I checked to break on any exceptions. But in any case of a reproducible issue you’re not stuck, is all I mean.


> Maybe I'm "holding it wrong" but this causes a lot of friction and lost time.

It is a completely non-problem for functional code. It is a big problem for imperative code.

You can't just write all of your code in a functional style, but depending on what you are doing the limit gets larger or smaller. So it's normal that this will be a showstopper for some people, and irrelevant to others.


I don't really follow.. How is it a non problem in functional code? For instance you have some recursive idempotent function that blows at some point. Wouldn't you wanna see the state at which things broke?

Just because things are functional doesn't mean you always knows the inputs at all times


What does this have to do with imperative state?

Take this program:

  compute x = 1 `div` (x - 3)
  map compute [1,2,3,4]
Would seeing that it crashed in `compute` in `map` be enough info to debug, or finding out that `x` was 3 when it did also help?

Edit: fixed to use integer division so we actually crash .




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: