Was bash the wrong language for my agent?
I have a small agent that handles one piece of routine work at a time. It looks at what needs doing, picks the thing most worth doing, shows me the plan, and does it if I say yes. Underneath, it is glue: it drives a few command-line tools, calls a model, reshapes a lot of JSON, and prints a readable summary. It was 2150 lines of bash across seven files. It is now Python. So the answer looks like…
The author decided to rewrite their agent from bash to Python, despite initial concerns. The reasoning behind this change was primarily due to a requirement that no build step should be complicated. However, upon further examination, the author realized that the main issue was not performance but expressiveness. They found that 162 calls to jq were used to handle data that should have been easily managed in memory, resulting in 89ms execution time for Python compared to 3ms for bash.
The author also noticed that a significant amount of the code was dedicated to subprocess orchestration, which is where bash excels. The rewrite resulted in a 108-line increase in total line count, but most of these were comments and docstrings, which the author considered valuable. The author also highlighted the benefits of using prompts as separate Markdown files, allowing for easier editing and reading as prose.
In conclusion, the rewrite accomplished nothing in terms of code reduction, but provided better expressiveness and separation of concerns through prompts. The key risk associated with Python is the potential introduction of dependencies, which may undermine the benefits of its simplicity.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.