Running REPL with figwheel with an editor


#1

I’ve got a question and then observations about my own process learning Clojure.

In the new series “Understanding Re-frame” series, it recommends running lein figwheel to get things started. That works, but then I only have a REPL in the terminal, not in the editor. I am trying to use Cursive for this, since it supposedly has better support for Clojurescript than Atom proto-repl.

I see this tutorial: https://github.com/bhauman/lein-figwheel/wiki/Running-figwheel-in-a-Cursive-Clojure-REPL

But it requires modifying the project.clj file. This won’t work the way Eric suggests using git checkout -f 013 which wipes out changes every lesson (or dealing with merge conflicts if you don’t use the -f flag.

  • I could use Lighttable (not sure how well this works with figwheel). But Lighttable is pretty limited. I am trying to settle on an editor that I can stick with, customize key bindings and become proficient at.
  • I could learn Emacs - I started that way a couple years ago and gave up. Every experienced Clojure dev has said it’s pretty hard to learn Clojure & Emacs at the same time. I know Emacs is good but I don’t think it’s necessary to be really proficient at Clojure, since there are many examples of proficient devs that don’t use it. It feels like an unnecessary investment. And I have other languages that I would prefer to use my old editor for (Atom) and not have 2 completely different set of muscle memories. I’m not even sure if I learned Emacs this particular problem would be solved.
  • I could use the terminal, but as far as I can tell it’s really clunky. I’m trying to get proficient, not just do a proof of concept. How do you send expressions to it from your editor?

So I don’t know what to do except just watch the videos instead of code along with them.

Now my observations:
This is my 3rd time I’ve seriously tried to learn Clojure over 3 years. I own a software company and I see the value of Clojure and Clojurescript. But I have a business to run and deliver for, so all of the friction I find in Clojure is really blocking it’s adoption in my small world. It’s really frustrating.

I know that the REPL is a remote process and and isn’t necessarily tied to the editor. But as a beginner, I just need to get something successful done relatively quickly. What I want is to open up an capable editor, run lein whatever and be working. I want inline evaluation or sending expressions to the REPL. That sounds like how an experienced Clojure dev thinks and talks about it, but there are so many more steps. When I switch files, why doesn’t my REPL switch for me to that namespace? Why doesn’t my REPL stay in sync with my code (or tell me when it’s out of sync)? If you look at Cursive’s REPL setup - as a beginner I have no idea what that stuff means. I don’t know what the n in nREPL means or why I would pick that. Or if I need a local or remote REPL. I just want my code evaluated as I need it. Part of me feels too entitled to be asking for others to smooth all of this over for me, but I’ve been in the Clojure community long enough to know that in general, people want more people to adopt the language. In companies with other Clojure devs, there are mentors who can pass on all of that nuanced knowledge. But there are many times more people out there that are interested, like me, who don’t have mentors but really want to build software with it. They are relying on this course or online tutorials as the mentor.

Maybe one part of the problem is that bringing it all together isn’t anyone’s domain. There’s the core language, there’s figwheel and lein, there’s the editor. On a technical level, those are nice and decoupled. But from a user perspective, it’s a mess.

I know folks like Zach Oakes is working on this problem. Those editors are cool, but very limited. Nightlight I couldn’t even figure out how to make a new directory. And deep keybinding support is really important to feel productive.

I think the community is great and cares about this a lot. Unfortunately though after 3 years and my 3rd try of really trying to get Clojure projects built, I’m running into the same problems. I’m not giving up this time, I just wish it was a smoother onboarding.


#2

I want to add that I’m posting this in part because I’m stuck but in part because I really hope we can figure out better solutions. I really want to succeed in Clojure and I want the community to grow.


#3

Hi @jefffriesen,

Thanks for the question and expressing your frustration. It’s very common and I’ve had similar issues with setting up tooling throughout my time with Clojure. It’s something we all face and when things don’t work like they’re supposed to, it can be a real strain.

There are a few issues that you bring up

One is that I recommend lein figwheel but you want to use Cider. Cider is actually what I use in the videos, so I’ve tested that the repo does work with Cider. I go through the steps in the video for getting it started in Cider at about 14:15. https://purelyfunctional.tv/lesson/getting-set-up/ It’s also documented in the Readme: https://github.com/lispcast/understanding-re-frame There’s no need to modify the project.clj.

Summary: Open the Readme in Emacs and evaluate the Emacs Lisp that’s there (with cursor just after the code, C-x-e). Then run M-x cider-jack-in-clojurescript.

Please let me know if that doesn’t work for you.

As far as the other issue of this being harder than it should be, it’s true. And we know it. And we’re working on it. It’s tough for us too but totally worth the effort it takes to get the repl integration set up. And, if it’s any consolation, it has gotten better over the years.

That said, I’m very hopeful for Bruce Hauman’s new REPL project. He’s trying to make it so that you can get 80% of the benefit of REPL integration right in the terminal. https://github.com/bhauman/rebel-readline He’s trying to add paren management, autocomplete, and live loading right into the terminal repl.

I’m very hopeful about this project because asking someone who is not totally committed to Clojure to learn a new editor (because basically, you have to use Emacs, IntelliJ, or Atom) just to try out the language is too much. Not only that, getting the editor integration set up is also difficult for experience programmers. There are too many configuration options and things change so quickly, often making things incompatible.

I hope that helps! I’ll help you set up your Emacs if you want :slight_smile:

Rock on!
Eric


#4

The more I think about this, the more I think that you’re right - the new REPL project is a big deal. Question is, can you send commands to the terminal REPL from your editor with keybindings?


#5

Probably not. But there’s a very important use case before people are invested enough to learn a new keybinding.