|
|
|
|
|
by joshlemer
1358 days ago
|
|
I found it pretty easy to set up a Python REPL in VS Code, which would allow me to do similar things to the Clojure REPL such as highlighting some text in the editor and evaluating. All in all it was pretty close. I guess the only thing that is really different is that it was not connected to the same process I'm debugging, but a different python process. Is that the main thing you're missing? |
|
In a Clojure REPL, you navigate "modules" like directories. And each directory has "files", or vars you've defined. Basically 'cd' and 'ls', but for module-level structures.
So you 'cd' to one "directory", query an AWS service or read a CSV file, and save results in that namespace ("my_namespace/my_results"). While you're at it, you save the results to a JSON file ('echo ... > tests/saved_results.json').
(You type this all into a REPL, no need to save this one-time command in a file. You can always re-run it by pressing UP like in bash.)
Then, you write a function called 'save_to_db()' in your text editor in the "database" namespace that accepts the input and writes to a database. You send that function to the REPL, and in the REPL, run the function on the results you saved from the first step in the var ("database.save_to_db(my_namespace/my_results)".
While you're at it, you 'cd' to your "tests" namespace in the REPL, and write a quick test in your test editor that parses 'tests/saved_results.json' and calls your "save_to_db" function and verifies the database. Send test to REPL (keyboard shortcut), run the test (another keyboard shortcut), fix the code, send updated code to REPL, rinse and repeat.
And this is all in one process, so you only "start up" Java once. Everything else is basically instant.
There's a ton of Youtube videos on using Clojure REPLs. It's really a game changer...