Hacker News new | ask | show | jobs
by photojosh 3221 days ago
"Finally, not all programs need be fully automated - sometimes the middle ground between manual and automated is exactly what you want. For instance, a REPL is a great environment to run ad hoc queries to your database, or perform ad hoc data analysis, while leveraging all of the automated code you have already written for your project"

This is exactly why I love Python. My Django webapp gets features (DB reports, external API pushes, etc) added as the client's budget allows, and before they are I'll often do them manually. Given that the UI for a new feature is usually the most work, it's been working well.

So the process usually goes: REPL/Django shell -> Django management command -> End-user facing feature. I'll grab what I did the first time in the Django shell, and put it into model logic plus a tentative management command. Then the next time I have to do the task I'll make sure the command works properly. And then when the budget allows I'll add access via the UI.

Ninja edit: I forgot to mention that `import ipdb; ipdb.set_trace()` is invaluable to get to the point in the HTTP response code where you can start adding new stuff or diagnose errors directly.

2 comments

I've dabbed in elixir and clojure for some time now and the ability to gain a REPL into a live system opens many opportunities for live debugging and introspection. It's a great tool when dealing with unknown states and bugs in production.
I follow a similar procedure for an open source community project in Ruby on Rails. There are a fair amount of rare things that need to get done where it's just easier to do them in a reply on the web server. One of the admins of the community actually learnt enough about the rails DSL to write basic queries through the reply and do some of the things I usually would.