Live data from Hacker News

Reloadr – Hot code reloading tool for Python

github.com

31–40 of 58 posts

Re: Reloadr – Hot code reloading tool for Python

#31
Cool feature.

Visual Studio seems to have "edit and continue" which I only knew from VB, but seems to be available in C# and C++ too. Not the same, but it shortens the development cycle in a similar fashion.

The feature in Python reminds me on hot code loading in Erlang which I found quite interesting when i first read (never used) about the feature. I wondered which other languages provides (or didn't) an equivalent solution. Back then it felt a bit scary, with not much more than RCS as VCS around :) But I think Erlang implemented it for increased up-time, not for increased development cycle?

To keep the up-time high, today even parts or entire operating systems are patched 'live' (ksplice, kpatch, kgraft, AIX live update) (https://ksplice.oracle.com/) (https://www.ibm.com/support/knowledgecenter/ssw_aix_72/insta...). Here too to prevent downtime and technologically completely different from what is presented here.

Re: Reloadr – Hot code reloading tool for Python

#32
post #9

Earlier quoted context omitted.

Have you tried PHP? :) I jest, but really I feel like we've made things so complicated it just gets in our way. Our Javascript pipeline is huge, complicated, and requires you to sit down and wrap your head around it every time you want to modify it. If I get to greenfield another project, it's going to be so bloody simple.

PHP has to bootstrap everything on every single request. It is definitely great for reloadability and local development but terrible for production performance. Most teams that do not need PHP or love it (Laravel is great I know) have moved to using languages and frameworks that provide a long running application server.

The "run once and die" model of php applications however, it extremely clarifying and simplifying.

It is a bit like the unix philosophy of "simple apps, in sequence" -- in the sense that it clarifies what development should be.

PHP apps, at their best, were multiple "run once and die" endpoints -- the drive to "Front Controller" and "run long" apps throws away much of the value of this paradigm.

Part of the community problem, id say, is that this paradigm was never well-articulated; and always associated with "a mess".

People like rasmus tried: yes have your long-running apps (eg., in Java), but your front-end should be die-quickly.

Re: Reloadr – Hot code reloading tool for Python

#33
post #27

Last commit in Jan 2020. Is this project still active? Also ideally, not needing to decorate would be nice.

For what it's worth, I'm working on my own reloader which does not require decorating anything: https://github.com/breuleux/jurigged (still a WIP, but it works well enough).

Thanks for the good work. I’ll give it a try.

Re: Reloadr – Hot code reloading tool for Python

#34
does this patch existing class instances, if you modify a method for example?

I cobbled together something similar a few years back using the reload stuff from ipython and a script I think GuidoVR wrote that I stumbled on. I like to debug on the cli (pdb++), I made it autodetect changed modules and reload those whenever i entered the 'reload' command. For me having to decorate things first would be a no-no.

My helper worked really nicely for some projects but broke with others. Well done on getting something out there.

Re: Reloadr – Hot code reloading tool for Python

#35

Any pointers on hot code reloading for C++?

There is https://github.com/RuntimeCompiledCPlusPlus/RuntimeCompiledC...

The idea is to use virtual functions, and recompile new classes into a shared library. The shared lib is linked into the running program, and old instances of the classes are deleted and replaced by new instances constructed from the shared library.

I am working on a library called hscpp using the same (stolen) idea here:

https://github.com/jheruty/hscpp

Proof of concept demo:

https://m.youtube.com/watch?v=pjGngeKgni8

hscpp is still very alpha, and I’m sure I’ll find lots of bugs as I work on a “real” demo. In contrast, Runtime Compiled C++ is quite mature and is used in real game projects.

Note that this approach very much limits your architecture. For example, you won’t be able to use statics, as the newly compiled shared libraries won’t see them.

It’s a finicky thing, worth it to me, but not something you can just plop in to an established project.

Re: Reloadr – Hot code reloading tool for Python

#36
post #23
post #9

Earlier quoted context omitted.

Have you tried PHP? :) I jest, but really I feel like we've made things so complicated it just gets in our way. Our Javascript pipeline is huge, complicated, and requires you to sit down and wrap your head around it every time you want to modify it. If I get to greenfield another project, it's going to be so bloody simple.

> If I get to greenfield another project, it's going to be so bloody simple. It's always simple when it starts up. It's after months/years of iterating without having a decent battle plan that it becomes complicated.

I agree things grow to be complicated, and that's somewhat unavoidable (accepting usual constraints), but they don't have to start out complex. I think that's the same point GP is making.

Re: Reloadr – Hot code reloading tool for Python

#37
post #36
post #23

Earlier quoted context omitted.

> If I get to greenfield another project, it's going to be so bloody simple. It's always simple when it starts up. It's after months/years of iterating without having a decent battle plan that it becomes complicated.

I agree things grow to be complicated, and that's somewhat unavoidable (accepting usual constraints), but they don't have to start out com plex . I think that's the same point GP is making.

Fair enough.

Re: Reloadr – Hot code reloading tool for Python

#38

Cool feature. Visual Studio seems to have "edit and continue" which I only knew from VB, but seems to be available in C# and C++ too. Not the same, but it shortens the development cycle in a similar fashion. The feature in Python reminds me on hot code loading in Erlang which I found quite interesting when i first read (never used) about the feature. I wondered which other languages provides (or didn't) an equivalent…

I've never had any success at all with VS's edit and continue, even after tinkering some project settings to try to get it to work better.

To be fair, this was a few years ago now, maybe worth another look?

Re: Reloadr – Hot code reloading tool for Python

#39
post #3

What are some simple use cases for this?

I wrote a (worse) version of this at my first job, because loading and initial manipulation of the data I was doing analysis on took tens of minutes, and I kept wanting to make changes to what I was doing. Saved me a couple hours.

Re: Reloadr – Hot code reloading tool for Python

#40
My project, hupper [1], isn't hot reloading but it's worth mentioning in this thread alongside other code reloaders. It is a general purpose tool to monitor python code and reload the process when code changes. You can use it with any script that you're working on via `hupper -m foo` and your `foo.py` is then reloaded/re-executed everytime you change it. It's used under the hood in other tools to implement things like `pserve --reload` in Pyramid and is used in Warehouse (the codebase for PyPI) to ease development workflows.

It's an improvement on some previous attempts at the solution that would crash when reloading invalid code. Hupper does not have this problem due to its multi process design.

[1] https://docs.pylonsproject.org/projects/hupper/en/latest/

Post reply on HN