This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-23
Channels
- # aws-lambda (2)
- # beginners (40)
- # calva (9)
- # cider (17)
- # clojure (84)
- # clojure-europe (13)
- # clojure-nl (1)
- # clojure-norway (77)
- # clojure-uk (26)
- # conjure (1)
- # cursive (7)
- # datomic (7)
- # events (1)
- # exercism (1)
- # gratitude (2)
- # hyperfiddle (4)
- # improve-getting-started (10)
- # jobs-discuss (12)
- # malli (4)
- # missionary (12)
- # off-topic (22)
- # other-languages (4)
- # pedestal (3)
- # portal (6)
- # reagent (6)
- # reitit (1)
- # releases (1)
- # ring (4)
- # shadow-cljs (2)
- # thejaloniki (2)
- # tools-build (27)
- # tools-deps (4)
- # vim (6)
I got this comment on my latest video about interactive programming: > Would you mind making a video please where you point out EVERY nuance of REPL driven development and nuances of interactive programming that languages like Python and Ruby can not do but Clojure can? > > I am new to programming itself and I have not chosen yet my first programming language. > > I am tempted by Clojure but at the same time I can not find any videos or articles that truly point out the obvious for nonprogrammers when it comes to Clojure’s interactive development and Repl driven development that Python and Ruby can not do and why it matters for every nuance one by one, what you gain in productivity or some other UX aspect. > > All videos or articles I find keep assuming you’re already a experienced programmer and they don’t make it obvious enough what are the actual advantages of Clojure compared to Python/Ruby besides it enforcing functional programming paradigm. > > Clojure seems on a downtrend compared to Elixir. I have yet to decide what language to choose. I don’t know what Elixir community is doing right year by year because it always seems to get more and more popular yet Clojure in the last 3-4 year seems to be less and less popular. > I do understand that Clojure is mature enough to not die out but still it saddens me that it does not seem to be able to keep up the pace with growth that Elixir and other functional programming languages seem to have lately.Read more
I more or less promised to create the video asked for. 😃 > That’s a great idea! I will definitely start sketching on such a video. At least the “point out every nuance” part. I think that often many programming language CAN do the same things, and it is more of a tradition in LISP. At least with JavaScript, I think this is the case. ClojureScript compiles to JavaScript, after all. When choosing a main programming language there are of course also other aspects to consider, but since interactive programming is the most important one for me, I think I really want to create the video you suggest. I’ll start thinking! Meanwhile, since interactive programming has spurred your curiosity, maybe this video is of interest: https://www.youtube.com/watch?v=d0K1oaFGvuQ Now I need y’all’s help.
What are the nuances? I know @U04V70XH6 has presented about this and pointed out things that I probably haven’t. And what’s a good structure? I’m thinking live coding should be only a part of this. Maybe I could do it more as a presentation? Something I can bring to non-Clojure events and hopefully catch som fish.
I'm not good with video as a medium so I don't have much to suggest. I think the things to emphasize are that in Clojure's REPL: a) code is compiled just like "regular" execution -- the runtime semantics are identical (not true for any language REPL that uses an interpreter or provides different/limited semantics which most do), b) we start the REPL then we start our application from the REPL, c) we can modify the program live while it is running, d) with Clojure 1.12, you can add new dependencies to the running program via the REPL without a restart (and there have been other ways to do this for several years). So you can start from an empty project and a "bare" REPL, and develop your application without restarting anything or running any external commands -- at least in a Clojure/JVM world (I don't know how smooth/possible that all is with ClojureScript). The other pretty much unique thing about a Clojure REPL is that you can run a REPL in any compiled, packaged Clojure program (via the Socket REPL JVM property at startup, or programmatically if you're using nREPL) -- and then you can connect to that REPL while the application is running and evaluate code into it, calling functions, even redefining them on-the-fly (with some caveats around direct-linking of AOT'd code). The mostly-code-demo talk I did for London Clojurians shows me starting with an empty project, and a bare REPL, and without restarting anything I develop a small web app by adding deps and redefining functions on the fly.
The big things I see are different are: 1. Doing Repl Driven Development (RDD), you are modifying a running program. For instance, if you are building a web app, the web server is running, and your compiler runs in inside it. Every effort is made to make it easy to redefine everything. This is not the case in Node, where there is no notion of redefining top level variables defined with const. I believe you can redefine functions, but how to do that within other modules I do not know. 2. A notion of "place" like you have in the Unix shell (working directory). You can move around between namespaces, list the functions, etc. Namespaces are loaded and referrable by name. I don't think you can do this in Python or Node. Instead, there is a notion of "import", but I don't think you can modify the code once it's loaded. 3. In Node, Python, Ruby, etc., you do get one thing that is rather common in RDD in Clojure, which is you can try out small snippets of code. The difference in Clojure is that you also have all of your code, the included libraries, and the state you've set up. This sounds like a useful video, showing what you can and can't do in Python, Node, Ruby, etc.
I know many languages do workarounds. In Haskell, for instance, there is an interpreter with a repl. They can redefine things but if the type changes, it won't work, and I'm not sure if functions that call what you redefine will call the new one. So they often write a new function with a new name. It's more limited, but it's useful to know what they do instead.
I'd love to invite on a rubyist to get their take on it.
Doesn’t it sound like a great episodes of your podcast, to reason around it in a general way like you do here, @U050P0ACR? The comment also mentions Elixir, which I imagine could offer similar, and sometimes even more powerful dynamics, to Clojure. (Without having any knowledge about it.)
I’ve experimented a (very tiny) bit with creating a Clojure-repl-like experience for JS. Ran into the problem with not being able to redeclare consts, and cheated my way around it. I have a few untested ideas around how to do it with less cheating and also support namespacing better. • https://twitter.com/pappapez/status/1718618293324374462 • https://twitter.com/pappapez/status/1721913122909221171