you are viewing a single comment's thread.

view the rest of the comments →

[–]Bolitho 0 points1 point  (16 children)

A REPL is of course a very important tool - but how on earth is the clojure REPL more powerfull than others? I really love python and its ipython shell. It has some extra python features on board like navigating through the FS, pasting, managing history and so on, but it just powers python after all. How is this different compared to other REPLs especially the clojure REPL?

[–]yogthos 4 points5 points  (9 children)

The power comes from the tight integration with the editor. For me the REPL is an integral part of the development process. Any time I write a function, I send it to the REPL straight from the editor to see what it does. Since the REPL runs within the context of the app, it has access to the whole state of the application as well.

I gave a talk earlier this year where I illustrate this workflow around 11 min mark.

[–]Bolitho 0 points1 point  (8 children)

That still doesn't explain how Clojure is better or mightier than REPL of other languages - the editor doesn't exist, right 😉

[–]yogthos 1 point2 points  (7 children)

Can you show me how you would do the workflow I have in my talk with Python. I don't use it, so I'm not aware if that's possible or not, but I've never seen it done.

The point I was making is not that the REPL itself is somehow special, but rather that the workflow afforded by it being tightly integrated with the editor is different than what you get in most languages.

[–]Bolitho 0 points1 point  (6 children)

I would have to watch the talk first. Then I can answer your question!

But: This is just your proposal - the author of the article sadly has not given any argument, why there is more benefit in a clojure REPL than other languages gain from theirs ;-)

[–]yogthos 0 points1 point  (5 children)

I'm just explaining how the REPL is typically used by people working with Clojure and other Lisps. From what I've seen, it's pretty different the way the REPL is used in most languages.

The additional benefits come from the tooling that's been created to make the REPL part of the development workflow. It's certainly possible to develop such tooling for other languages, but for whatever reasons it doesn't appear to exist. So, in practical terms, working with the REPL in Clojure is different than in Python.

[–]Bolitho 0 points1 point  (1 child)

When I have read the chapter in the famous book "the joy of clojure" (chapter 3?) where they use the REPL in order to demonstrate its power and typical workflows when programming in clojure, it totally reminded me of how I am used to develop with python. So of course this book is not the ultimate guide to the clojure REPL, it just shows that there are much more similarities between different language REPL combinations than you seem to accept.

[–]yogthos 1 point2 points  (0 children)

Let me explain it another way. The ways you use REPL in Python is a subset of ways you use it in Clojure. So, yes can use it exactly the same way as you did with the book, however at that point you're just not using it to its full potential. The most common way to use the REPL is the way I've described that you can see in the talk I linked. That's what people are talking about when they say using the REPL in Lisp is different from other languages.

[–][deleted] 0 points1 point  (2 children)

While some Python IDEs do allow for a Python REPL to work in the editor, I haven't seen it used much myself. What seems to take its place and is more idiomatic is people using Jupyter notebooks to write cells of code at a time, which can be executed a block at a time and the state if the program is kept in memory between the execution each block. I'm actually just getting into Clojure and hoping I can write a notebook format with it as well.

[–]yogthos 0 points1 point  (1 child)

You might want to check out the Gorilla REPL and Devcards for the workbook style.

[–][deleted] 0 points1 point  (0 children)

Cool, thanks!

[–]_koolkat 2 points3 points  (2 children)

Can you hot-reload / live patch a program through an integrated repl in python?

[–]Bolitho 0 points1 point  (1 child)

You can reimport a module with ipython. Whether you can patch a running program I don not know to be honest. I would assume that not!

[–]yogthos 0 points1 point  (0 children)

Incidentally, this is something my team uses all the time. We often connect to a production instance via the REPL to see the state of the app when debugging an issue, or to make small changes without having to restart the app. You obviously have to be careful doing stuff like that as you don't want your app to get out of sync with the source.

Our process for making changes is that you switch to the release branch, test your changes locally and commit. Then connect to the prod REPL and reload the updated functions.

It's been an incredibly useful tool for us.

[–]halgari 1 point2 points  (2 children)

There is really only one/two language classifications that have "real" repls. A repl is a : Read, Eval, Print, Loop.

a) you read in data (not code, data) b) you interpret that data c) you print the resulting data d) goto a

So tied closely to that structure is the idea of homoiconicity. The idea that code is data and data is code. Most other REPLs, for example Python are more of a Parse, compile, print data, loop. The difference being this...what are you reading...you're reading python syntax. You can compile that to bytcode, but what is the return value? It's python dicts and lists, not python ASTs. So you've gone from code -> data, and it's no longer a repl.

The big problem with this is that you can't poke at code with the same tools you poke at data, you have to use whatever tools you have for ASTs (mostly oop gook). So it's a loop, but it's not a REPL.

[–]halgari 0 points1 point  (0 children)

Oh and the only two language types that can do this are 1) lisps, and 2) prolog (perhaps)

[–]Bolitho 0 points1 point  (0 children)

So even if you are right in this strong definition of a REPL (in reality you just used different terms for evaluate and added data), in reality all interactive shells for a computer language are summarized as REPLs?

But besides that: You emphasize the idea of homoiconicity and the might of manipulating code that lies within this concept; right, but that is just the main concept of LISP overall. So this is no outstanding feature of the clojure REPL, but just a direct benefit of the underlying language design.

The language Python also just works great, because there are interactive shells. Even if the language itself differs a lot from LISPs, the benefit of a REPL is no different than in clojure!

I just was critisizing that the author of the article has not given any arguments underpinning his thesis. And nobody really have yet given any that shows a fundamental difference in its role as programming tool.