6 ms·
I always wonder why repl driven development is not as popular as it (in my opinion) deserves to be? Am I missing something here?
by lukashrb 6y ago
I always wonder why repl driven development is not as popular as it (in my opinion) deserves to be? Am I missing something here?
- pjmlp 6y agoToo much attachment to UNIX CLI programming models by some developers. Here is a nice example of REPL driven development with Smalltalk. https://avdi.codes/in-which-i-make-you-hate-ruby-in-7-minutes/ https://avdi.codes/in-which-i-make-you-hate-ruby-in-7-minute...
- imglorp 6y agoI feel like working in the Unix CLI is absolutely REPL programming with the same workflow, using pipes and filters and small programs. 1. mess around with some program, echoing things to it and looking at outputs 2. up-arrow in shell, edit previous experiment 3. repeat, adding more onto pipeline, until happy 4. save the good version to a script, eg echo "!!" > foo 5. add a #! line and chmod +x to promote it to a command
- PuercoPop 6y agoThe Unix CLI is most definitely a REPL. But it is a system-level REPL. So instead of running functions you run programs. You can't interactively develop a program in the UNIX CLI. Especially not in Python, JS, Ruby, etc. You can try to establish a REPL like flow in the CLI, by using a watcher like entr and doing something like $ cat test-input.txt | python ./my-script.py but the granularity of this approach is too coarse for the programming _language_. It is the ideal granularity for orchestrating shell scripts and CLI programs.
- pjmlp 6y agoThat is a poor man's REPL. - No graphical display - No support for displaying interactive structure data (Lisp Machines REPL/commercial Common Lisp/modern notebooks) - No debug-break, fix, redo workflow - No partial selection of command statements and "Do this" - No interactivity with running graphical applications and scripting them (via COM, DLLs, OS IPC)
- kamaal 6y ago>>I always wonder why repl driven development is not as popular as it (in my opinion) deserves to be? It's not mainstream, so one knows how to. Basically somebody needs to show people how repl driven development works, and will be useful. May be YouTube tutorials or gifs as to how to do this.
- reddit_clone 6y agoMost people never get to experience developing in lisp family languages and just miss out on the whole REPL experience. They have to write reams of unit testing code , mocking and faking the world just to see some code executed.
- deleted 6y ago[deleted]
- deleted 6y ago[deleted]
- kgwxd 6y agoI think it clicks quickly for some people but not others (me). I don't get to use Clojure for work currently (.NET shop) but I really like it. In my spare time I remake a lot of things I do at work to learn Clojure using real world scenarios. I've read this guide several times over the past few years, watched a bunch of the videos and I still find myself stoping/starting the repl very often because it feels difficult to keep the current state of the environment in my head, or something isn't updated as I expected, there's an error I can't decipher in the REPL that the compiler gives better info on. I feel I need to restart constantly, it's still my main workflow. I'm not sure what it is that's not clicking for me, but I keep trying. Either way, I'm no worse off than with my C# workflow.
- randompwd 6y agoIf there was a way to visualise everything that's loaded in the repl, it would be great. As in, let me easily & visually explore the world of the repl right now. Ditto with other langs, I just started with Spring Boot & Kotlin & geez, Spring annotations are poison chalice material. Googling how to debug spring leads you to 'just turn on debug logs' which dont tell you 1/1000 of what you'd need to know to debug annotation issues.
- The_rationalist 6y agoAs you might be aware, Kotlin has a nice repl for kotlin script files. If there was a way to visualise everything that's loaded in the repl, it would be great. yeah, I don't think that exist
- filoeleven 6y ago> As in, let me easily & visually explore the world of the repl right now. That sounds great! I’m envisioning something that for each loaded namespace would show: - fns that match saved files - fns that differ: - newer in file / not in REPL - newer in REPL / not in file I guess that would have to be an IDE-level thing, since it needs to know about file changes and REPL contents. A namespaced list of all public var names can be thrown together pretty quickly, but it seems less helpful: (->> all-ns (ns-name) (map (juxt identity clojure.repl/dir)) (into {})) (I’m on mobile so I haven’t checked that!)
- nickjj 6y agoI think it's maybe related to 2 things, especially for web development. 1. Unless you strictly design functions that are decoupled from any type of UI (such as your back-end "business logic"), it's not straight forward to do REPL driven development on its own. 2. If you're going to go down the path of using the REPL, you might be inclined to do TDD instead because now your efforts are saved to repeatable tests rather than a short lived REPL.
- dgb23 6y agoTDD and REPL driven development are not mutually exclusive.
- Scarbutt 6y agoYes, the problem is too many skip the tests because "they already tested at the REPL".
- Jtsummers 6y agoThe thing those people miss is that "tested in the REPL" means tested once, and tests are there to be rerun many times, basically any time something is changed. You write your first test in the REPL, and then you transfer those tests to a proper test suite so you can reevaluate them all quickly. And because you ran it in the REPL, you also have a way to easily grab what should be the correct value.
- oweqruiowe 6y agoI'm guilty of this :/
- Gunax 6y agoIs there a reason it's always functional languages? Despite being HNs favourite paradigm, functional languages really are an obscure to most people. As soon as there is a (convenient, useful) REPL for Java or c#, it will get picked up. I know Java added a repl a few versions ago, so maybe we will start to see this in the Java world.
- Jtsummers 6y agoIt's not just functional languages. It's dynamic languages that tend to have a better REPL experience, because nearly the entire language can be used within the REPL, and nearly everything written in the REPL can be placed into conventional source files and used there without alteration. Additionally, both languages you listed (Java and C#) are batch-oriented. They assume you're compiling large units of code (at least a whole source file, which in Java means the entire class and all its methods and constructors). Translating that to a REPL is challenging. You now have to leave class definitions open (which is not the normal Java behavior, a class cannot be altered without jumping through hoops outside its initial definition). So you make those hoops available via special REPL-only constructs, your REPL is no longer a Java REPL, it's a partial-Java REPL with additional things. My primary REPL experiences have been with these languages: Python, Common Lisp, Erlang, Matlab. 2 of those are functional (as a primary part of their design, Common Lisp is multi-paradigm). Python has some functional elements, but is an OO/imperative language. And Matlab (at least when I used it) was definitely an imperative language. But the thing they all have in common is that nearly every line of code could be moved between the REPL and a source file without alteration (Erlang is deficient here in that you can't define functions in the same way in the REPL as in the source code, and I think Matlab had the same issue but it's been 15 years). Another thing that languages with a good REPL tend to have is a general trend towards being expression-oriented rather than statement oriented. What's the return value of an if statement in Java or C#? It doesn't have one, how would you interact with that in a REPL, then? In Common Lisp, if expressions return a value (the result of evaluating either the true or the false branch).
- The_rationalist 6y agoKotlin has a first class REPL and even has scripting mode.
- jonahbenton 6y agoThere is a non-virtuous (vicious not the right term) cycle at play. Many problems are only solvable with compiled languages, for performance, correctness, or other non-functional considerations. Many people are first taught on compiled languages, and bring those approaches to dynamic languages. The popular dynamic languages, in their standard/common toolchains, do not have robust repl support (looking at you Python and Javascript). The absence of a robust repl workflow means people who are exposed to it in those languages aren't really impressed by it. Really too bad.
- randompwd 6y agoNot a JVM expert but the fact that it's all JVM bytecode for both comiled and dynamic langs should help.
- Jtsummers 6y agoCompiled doesn't have to mean batch compiled. Most modern Common Lisp systems are compiled, but you can compile smaller units (down to individual functions). The problem with the way we're taught (or I was taught, circa 2000), was that it was still in the batch-oriented mode: "Gather all your source files, and run them all through the compiler together." "But I only changed one thing." "That's fine, `make` will do the right thing for you." "But I also have to close the program." "Well, yeah, there are ways around that but we won't teach you, maybe your future coworkers or employers will."
- puredanger 6y agoClojure is a compiled language btw. It's just compiled on the fly. When you're evaluating new functions at the repl, Clojure is generating Java bytecode and dynamically loading it.
- jonahbenton 6y agoThank you Alex, I know, "compiled" in my post was lazy shorthand for something like "low abstraction, batch compiled" which in the context of the non-virtuous cycle limiting the reach of the repl/conversational workflow also touches on the historical and pedogogical legacy of people being smarter than the machines and needing brains to work at low levels of abstraction. Now that's rapidly, though unevenly, becoming a myth. Your work over the years on Clojure is so deeply appreciated and my post was also to some degree coming from a place of lament that more people don't know about it and benefit from it. Thank you for it.
- Scarbutt 6y agoBecause it's no different than running tests in a language with a fast code/run cycle. Clojure by necessity, needs to have a REPL, without one it would be unusable. The reason: Clojure startup time is pretty bad.
- goatlover 6y agoThe difference is the live environment.