9 ms·
REPL-Driven Development (2017)
- hprotagonist 9y agoanecdotally, i tried adding up how many ipython sessions I currently have open for various reasons on my workstation. I stopped at about 15. REPLs are incredibly useful.
- eadmund 9y ago> So Clojure has dynamic classloaders, but it does not have a replacement for classloaders. And so classloader confusion is something that cannot be solved at this level. > But I could imagine if you were coming from Common Lisp, or something like that, and saying "that seems like a wart." And it is a wart that we lovingly embrace, for the mighty power of having access to the whole JVM ecosystem. There's Armed Bear Common Lisp[0], which is a Common Lisp on Java, which gives access to the whole JVM ecosystem. Dunno how it handles classloaders though. [0] https://common-lisp.net/project/armedbear/ https://common-lisp.net/project/armedbear/
- bitwize 9y agoClojure is a Lisp designed from the ground up for the modern era. For new applications, it's a better fit than Common Lisp.
- simonw 9y agoAs a Python and JavaScript developer I live in Jupyter and the Firefox/Chrome devtools (and I'm starting to get into Observable). I genuinely don't know how to be productive in languages that don't have a great REPL. I think REPLs might be why I've never really got excited about IDEs. When you're working in a REPL you can answer questions about your code instantly without needing smart autocomplete or context-sensitive help.
- jdonaldson 9y agoI do a good combination of data science and development. REPLs are nice, don't get me wrong, but they are by nature single entrance, single exit. You are basically riding shotgun on a single unit test. You get a great view along the way, but the problem solving doesn't scale, nor can it handle situations where you need to consider multiple paths through the code. Writing a good test suite, and knowing just where and how to place debug trace statements are two of my best problem solving skills.
- kimi 9y agoREPL are obviously a poor substitute for unit tests; but a unit test is a poor substitute for a REPL.
- simonw 9y agoI happily use both. REPLs are for exploratory development. Unit tests are for ensuring code works (and continues to work in the future).
- carlmr 9y agoI see it along the lines of REPLs being helpful for prototyping code. TDD, strong static type systems and proper separation of concerns let you build larger maintainable systems.
- bonesss 9y agoF# hits a really nice sweet spot for this: scripts with an integrated interactive scripting environment, and complete access to a plethora of unit testing frameworks. That lets you work line-for-line through your code, inspect and analyze each step as needed, edit parameters as wanted, restart and do clean runs through calculations using custom and third party libraries, and also interactively execute any tests/specs you have defined. It's a very tight feedback loop that doesn't compromise any of the long term artifacts you might want in a serious app. In conjunction with .Nets extension mechanisms and some F# language features the setup lets you fire up a basic script, replace/extend anything from your object graph with new code, write accordant tests, and execute any or all parts of the test as desired in an interactive REPL-like session for problem solving and debugging: all in the same file :) This flows really nicely with the single pass compiler, keeping things nice and clean so they integrate into the main app once exploratory development is done. Semi-serious typing, functional composition, and dynamic exploration -- it ain't bad.
- cup-of-tea 9y agoWhy Jupyter? Do you mean iPython? Jupyter isn't a REPL. I find doing actual development in Jupyter to be impossible. It's OK to write the top-level orchestration script, but for writing functions (which is what using a REPL is all about) it's just horrible.
- dagw 9y agoI think you're confusing the old and new naming scheme. The old iPython project split back in 2015 into Jupyter and iPython. Jupyter is the name of the language agnostic part of project that develops the notebook, web apps, repl and messaging protocol parts. iPython is the kernel that provides python support for Jupyter. However since python is by far the most popular language used by Jupyter, people generally just say Jupyter when just say Jupyter/iPython.
- cup-of-tea 9y agoNo, the REPL is still part of iPython. Jupyter is the language-agnostic notebook.
- dagw 9y agoI was pretty sure all the 'GUI' components ended up under the Jupyter umbrella, not just the web notebook. I'll admit I could be wrong. That being said, why do you find iPython so much better than Jupyter? I write probably 80% of my python code in Jupyter and cannot imagine coding without it.
- cup-of-tea 9y agoOne reason is that I can use iPython with a decent text editor like emacs. I've tried to make Jupyter work, but it seems like you're supposed to use the web based editor, which is horrible. But it's also just not a nice workflow. Projects are not linear. I tend to work on a function and get it working in the REPL. Then build up the program by combining together higher level functions. How am I suppose to test functions in Jupyter? Write the test then keep evaluating it and then delete it later?
- repltmp09 9y agoI have used python javascript and clojure and let me tell you that repl driven development is not exactly what you get with python and javascript. The most frustraiting thing after having used a lisp is the fact that you can not connect to your program while it's executing. In node for example i wish i could just connect to the running server and test some functions with the current program state, like database conections etc. In clojure you can do that from your editor and that is awesome it's really powerfull. You can just point to a function and execute it inside the running whole.
- chatmasta 9y agoNode has a built in debugger that allows you to attach to a running process. You can even use chrome dev tools for debugging it.
- icebraining 9y agoIn Python the built-in debugger can't attach to a running process, but it's just a matter of installing one.
- collyw 9y agoI disagree. I have my IDE setup with some scripts to copy a database from production. Set some breakpoints and press the play button and I am debugging. With A REPL first I need to do a load of import statements. Then populate my objects. Then get started with the actual debugging. I personally don't find it anywhere near as efficient as an IDE that has been setup. Plus with the IDE I can stop at a certain point in the code, have numerous variables populated then run "evaluate" in PyCharm, which gives most of the benefits of a REPL as far as I can tell. Admittedly the IDE does take a fair bit more effort to get to a state where it is set up to be useful, but dealing with the whole system as opposed to a small part of it is incredibly beneficial for development. Though I guess a lot depends on the type of problem you are solving.
- TeMPOraL 9y ago> I have my IDE setup with some scripts to copy a database from production. Can't you just run those scripts as the first thing in your REPL session?
- collyw 9y agoThat just copies the data, its doesn't do imports or initial fetching of data - which running the application in and IDE does for me. Having an IDE setup is pretty essential to my job, so I am going to need that for debugging certain errors anyway. Once that is setup, I rarely see the need to start scripting things for a REPL as a debugger feels far more useful to me.
- crdoconnor 9y ago>With A REPL first I need to do a load of import statements. Then populate my objects. Then get started with the actual debugging. No, you absolutely do not. You just need to click around until your code hits the point in the code (or, ideally, run an integration test that gets you to that point) where you want the ability to run methods, inspect objects, etc. Just make sure you've shoved an import IPython ; IPython.embed() in there and you're good to go. No additional imports necessary. I agree that having your environment set up with production data (or as close an approximation as you can get) is a good idea, but I'd rather script that with a test framework where it can be used for regression testing rather than bodge it together using an IDE.
- jasonkester 9y agoIn an IDE, the REPL is often called the "Immediate" panel or similar. It's available whenever you're stopped at a breakpoint. I can't think of any good ide (dating back to vb6 20 years ago) that doesn't have one.
- jasonkostempski 9y agoThose things are specifically not called a REPL because they aren't a REPL. However, there is now a thing called the C# REPL [1] that shipped with VS 2015 Update 1, but I've never used it so I'm not sure if it's true to the name. [1] https://msdn.microsoft.com/en-us/magazine/mt614271.aspx https://msdn.microsoft.com/en-us/magazine/mt614271.aspx
- jasonkester 9y agoYour link has a section titled "The Visual Studio C# Interactive Window" explaining that that's where to find all this REPL functionality in VS.NET. But, as I said above, it's not explicitly labeled as such.
- jasonkostempski 9y agoI got "Interactive" confused with the "Immediate" window. Things like the Immediate Window have been around for decades in most version of VS, but both "Interactive" and "C# REPL" are new to VS 2015.
- pharo70 9y agoIn Smalltalk, the class browser (editor) has always been the REPL. You can highlight any snippet of code you browse, including code you're currently editing, and evaluate it in the context of whatever class you're browsing. For example, if you're editing a method called "fooBar", you can just type (in the same input field) "self new fooBar" ("self" is bound to the class being browsed) or, if it's a class method, "self fooBar", highlight it, and then type the appropriate shortcut (like Cmd+d in Pharo) to evaluate it. This is useful for documentation. You can have a method begin with a comment that shows examples, which a person browsing can highlight and evaluate, and also experiment with.
- lispm 9y agoBut that's not really a REPL. It lacks the 'L' and often also the 'P'. Running code from a text buffer in an editor is one way to interact (many Lisp tools do that), but a REPL is usually a tool and its purpose is to read expressions, evaluate them and print the results. I would be surprised, if Smalltalk did not have that somewhere, too. The REPL has a visible I/O history and is not conflated with other text input fields (like a function being edited).
- pjmlp 9y agoThe 'P' is just another entry on the Smalltalk menu options. One can choose to evaluate, or evaluate and print. The 'L' is the whole Smalltalk environment, as anything that changes the environment is kept in memory or saved along the image on exit. A Lisp like REPL is available as Transcript windows.
- lispm 9y agoThe output goes into the text field where I'm editing. That's not a REPL. Usually printing output to a random text field makes no sense. It can make sense to execute commented code snippets in code, or evaluate code and have the result being inserted. A transcript window is usually a text output window, more like a console output. I'd say the Workspace window is slightly similar to a REPL. But it still does not work like the usual Lisp REPL, where you type to the tool usually textually at the bottom and get the result displayed there. With Smalltalk I usually type to an editor Workspace window and REPL I/O does not need to have a sequential order.
- mbil 9y agoProgramming Clojure applications with CIDER[0] is a really slick experience. By connecting through an nREPL port to a running environment you can capture variable values like function inputs, change and re-evaluate function definitions on the fly, and test hypotheses by calling funcs directly with whatever input you want. Not to mention the speed of prototype iteration. This has been invaluable when trying to quickly track down production bugs. I've lately been working in Python, and even with IPython/Juptyer the workflow isn't quite as magical as Clojure's. [0]: https://github.com/clojure-emacs/cider https://github.com/clojure-emacs/cider
- pimeys 9y agoI've been working with Clojure a lot and some years already, but only a couple of months ago really started working with CIDER. It makes everything so much nicer and it feels like the way Clojure is meant to be developed. I had some grudges about leiningen and the startup speed, but having a CIDER connection, tests ready to run immediately and a REPL where I can test my code in a buffer, writing Clojure is such a joy.
- kimi 9y agoIf you're not into Emacs, IntelliJ has a sick integration that works through a nREPL called Cursive that is a joy to use https://cursive-ide.com/ https://cursive-ide.com/
- swlkr 9y agoFellow Cursive user here. Being able to hit a key, in my case Shift + CMD + P while the cursor is on some text and to see it live in the REPL is pretty incredible. It’s also kind of weird that a lot of other languages do not have this
- dolzenko 9y agoJust a reminder to younger crowd Visual Studio had all this before (packaged in single app hence well-integrated and easy to install) probably for 15 years or longer.
- bjourne 9y agoFor a language with a very good REPL environment, try Factor. :) But there are a lot of kinks with REPL:s that the talk doesn't detail. Most of them have to do with code reloading and all the corner cases that can lead you into. For example, suppose you have started a thread which calls the function "foo" from within a while loop. Then you recompile "foo." Now, what should happen with the thread? Should it switch to the new foo or keep calling the old one? What if you remove the foo function from the module in which it was defined? What if you have a class and you change its definition. What happens with old instances? What if you recompile the REPL? Recompile the compiler? Solving issues like the above is really, really hard. Especially if the solution has to be both efficient and also work as the user would expect.
- escherize 9y agoClojure has dealt with this problem actually. If you are curious check out mount, component, and this blog post: http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-r...
- camtarn 9y agoSince I've mainly used REPLs in a text-only environment, I never thought about the idea of creating little GUI 'sidecars' from the REPL, potentially with the aid of a little utility lib to simplify things such as "make a window containing the value of this var", "graph this var over time", or "make a button that executes this snippet of code". Very cool idea.
- marmaduke 9y agoA while ago I wrote a Vim plugin to send Python code to a running interpreter, redefining and debugging on the fly. Unfortunately that’s not a good fit for Python. Code reloading on classes , data descriptors etc requires adhoc semantics. All in all, hard to reason about. I even find Jupyter notebooks get this a bit, when people eval cells out of order..
- snambi 9y agoThe alternative to REPL is a DEBUGGER with a great IDE. Don't get me wrong, REPL is nice, but IDEs are even better.
- hartator 9y agoI was hoping for an article advocating REPL-driven development versus test driven development, I was a bit disappointed!