Skip to content

Ideal Beginner Editor+REPL Setup #44

Closed
MarcelRaschke/calva
#8
@jefffriesen

Description

The editor + REPL is a significant hurdle to beginners. There are plenty of people advocating for Clojure and REPL-driven development and showing results, but those are people who already get it. They were either really persistent or had peers to help them navigate all of the incidental complexity of setting up an app, editor and REPL to become productive. If Clojurist want broader adoption, we need to simplify the setup.

I would consider myself a Clojure beginner - I've read books, watched videos, done all of the 4Clojure problems, made simle Re-frame apps. Often with a REPL. But it's been a struggle - not from the language but from the setup. So I'm going to take my beginner mindset and lay out some of the problems I've run into and imagine the setup that I would have loved to discover when I started (and would still probably use).

Alternate Universe Beginning Clojure Experience

  1. Create a re-frame or backend app scaffolding from command line. Just like we have now with lein new [TEMPLATE] NAME. We might consider this done.
  2. With a single command-line command, handle with dependencies and start the app and REPL. Right now, this can happen but often is at odds with working with the code in an editor.
  3. Open the project in an editor (VSCode?). Execute code inline or send to a REPL - no explicit dependencies, no profiles.clj, no magic incantations in the command line, no confusion of starting the REPL in a terminal or editor. It just works.
  4. When you change files, the REPL changes it's namespace automatically. You could switch to another ns just like you can now with (in-ns '...). As an experienced user, you can also turn off the auto-tracking the files. But the default REPL always represents the file you are working in.
  5. The new REPL doesn't care if the file is CLJ or CLJS code. As a user, you don't really care - you just want to execute the code you're working on.
  6. The REPL never gets out of sync or stale compared with the file you're working on. As soon as the file is saved, the REPL's namespace updates to reflect that.

I'm sure this may be too inflexible for some experienced users. But they already have very customizable, complicated tools that they use. And that's not really VSCode+Calva's target audience. Calva could expose options to turn some of these features off. But the idea is that beginners would get an amazing, productive experience right away.

It's steps 2 and 3 that gloss over so many implementation details and potential problems. Some things, as a beginner, that I don't want (yet) to know or care about:

  • Do I start the REPL from the command line or from the editor?
  • What's Piggyback? What is fighweel sidecar?
  • What's the difference between nRepl and figwheel? Do I care about socket REPLs?
  • What's the REPL port that I need to connect to?
  • What commands from the REPL (nREPL?) do I need to issue to start the CLJS REPL?
  • What's Cider?
  • What's my .lein/profiles.clj file and how do I get that set up to begin working in Clojure?

I don't know how you would implement step 3. Maybe it's a single dependency that is added to either profiles.clj or the project. If that was all that would be cool. Or maybe that dependency is effectively built into the editor. I really don't know.

Part of the problem is that there is a lot of mixed information out there that is out-of-date. For example:

  • Create a re-frame template from these: https://github.com/Day8/re-frame-template then run lein dev. But that's not actually how most people would do it - they want REPL integration with their editor. Which requires you to not run lein dev but run something else that is editor dependent.
  • Here's how to set up an nREPL with Figwheel: https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl. It's very long and there is old and new ways to do it. They keep saying it's "super advanced". It's not actually that hard, but requires a lot of trial and error and filtering out many outdated sources on the web. And REPL-driven development one of the greatest strengths of Clojure, so ideally it shouldn't be advanced at all.

There are a lot of people who put a lot of time into tools to make things easier. Like you guys. But it's still hard. I have a sense of why - the REPL(S) run independently of the editor, even though that's not how people generally use it. But there is still the editor/REPL divide. How do we cross it? How do we make professional tools that are easy to get started with?

It seems like you guys are thinking of similar issues and why you are putting so much work into Calva. So I thought I would share these ideas and see what you think. Are steps 1-3 unrealistic? Are 4-6 something beginners would want?

Is this an idealized version of a Clojure/Clojurescript beginner experience? Or does it look like something else?

Thanks for all of your hard work.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions