Announcing hotload: Code Python 'like it's Clojure!

Disclaimer: We won’t be able to match Clojure’s development experience. But we’re getting there!

So! We all love the REPL. It makes it possible to work on pieces so small that errors are trivial. Heard of Kent Beck’s test && commit || revert? Write code. If the test fails, revert your commit. What does that do to your development flow? It makes you code in smaller increments. What’s another good way to ensure that you write code in small increments? Use the REPL! Some things I like about REPL-driven development:

  • Reloads that are so fast in speed that you don’t notice their delay.
  • State persistence between reloads. I can define something off in the background and query it later.
  • A single key press to get a new result.

The last year, I’ve been writing a lot of Python. And I’ve been playing around with how good a Python workflow can get. Turns out, that’s quite far! And now I’m releasing that effort.

hotload watches your files and reloads your Python modules in-place. Please check it out! I’d love comments and feedback.

3 Likes

I’m happy you’re trying to get back some of what Clojure brings while using Python. Hope that helps fight the itch :yum: I’ll keep it bookmarked in case I’m ever forced back to Python.

Just out of curiosity, is data-science your domain? Or did you face challenges making headway convincing coworkers to adopt Clojure over Python?

Hello!

Let my try to give an answer! I don’t have a typical computer science background, but applied data science is a fitting label from a CS point of view. My master’s degree is in computational mechanics – which is how civil engineers do the math to ensure that bridges and other constructions can take the load they should (“finite element analysis” in civil engineering lingo). Under the hood, computational mechanics is a set of equilibrium equations, and data visualization tools that you use to interpret the results (which are often more than 2 GB of data). We have access to quite good products for doing this on the market, which often support both point-and-click to get what you want and some kind of scripting interface.

Lately, I’ve been working at a startup with other people from the civil engineering industry. We have blended the traditional project-deliver-PDFs with some lessons about continuous delivery. For instance we prefer to visualize our current-best results on a web dashboard in the project, to enable better communication.

So where does that leave us? Since we’re not a team of dedicated software engineers, Clojure is a real investment. In addition, commercial software like Abaqus has a Python API, which sets its own requirements! Regardless, I’m toying with this idea that we should all just bite the bullet and do our software-enabled work with Clojure – since Clojure is very well suited to the kind of interactive, improvisation-based work we do a lot of.

If I may ask, what has been your path? I’ve kind-of been guessing that you have a longer experience that involves developing backend systems, and perhaps some Java experience?

Teodor

1 Like

Ah ya, that makes sense. Honestly, it does seem Python might be more fitted for that. Having readily available libraries and tooling integration for practical work projects is a huge win. In those scenarios, going with the path of least resistance is often the right thing. Even though I’m a big Clojure advocate, I’m a pragmatic at heart. For those use cases, even if Clojure had it all, I don’t even think it would improve that much the experience over Python. So all the power to you :facepunch:

Your hunch is correct. I’m your typical big backend enterprise software engineer. I mostly work on distributed systems, backend services, and the occasional front end generally for internal use only. My background is C++, Java, C#, ActionScript 3, Python, JavaScript mostly. My work is a perfect match for Clojure’s strength. Big ETLs, large scale data processing, backend services, SPAs, cron jobs, daemon processes, all those kind of infrastructure-ish level software projects are the ideal match for Clojure. So I’m lucky in that sense.

Keep us posted on how things evolve for you. I think there’s a lot of work happening by motivated individuals trying to prep up Clojure/Script to compete more seriously with Python in the scientific computing and data analysis, visualization and exploration space. So hopefully it can eventually become a more appropriate target language for those domain. In the meantime, I think it’s cool how you’re trying to use Python more interactively.

2 Likes

Hello!

I just completed a (tiny) CLI for hotload. You can now use it like this to watch all your python files without restarting the Python interpreter:

find . -type f -name '*.py' | hotload init.py

This will reload init.py when there are any changes to Python files in the current directory. For me, this meant that I’m now running all my Python code with hotload as I’m developing it, as the usage is simple to remember, and I can install it once on each machine.

Check out the readme for updated installation instructions:

As always, feedback and comments are much welcome!

Teodor

Python is like COBOL, FORTRAN, or C. For a specific time frame, they were the default language. C and C++ sucked big time for web development. It gave us things like Ruby. Python was develop a single language that solved some of the problem. It’s no used in MatLab, R, other sciences. Used in anything that needs a UI, batch jobs. The new perl.

Large companies can buy hundreds of mediocre Python programmers for a few cents a day. It’s so endemic that MIT gave up and is now using it to introduce computing theory. It’s good enough that a company can chose it an not deal with Java/C++ wars.

Hello, @tyohDeveloper,

Thanks for your interest. Yes, Python sure can do a lot of different tasks. I’m finding that when I can’t use Clojure, Python often fits the job. Not that I haven’t seen Python codebases with a mutability soup that makes everything hard to understand. I’ve found that learning Clojure has significantly improved the way I structure my Python code. But I’ve missed quick reloads, and the ability to persist some state across reloads. Which is what I’m addressing here!

I’d love comments on hotload if you’ve tried it out.

Teodor