Live data from Hacker News

C and C++ Hot-Reload/Live Coding

liveplusplus.tech

61–70 of 102 posts

Re: C and C++ Hot-Reload/Live Coding

#61
post #20

Maybe I'm just old and grumpy, but the subscription business model just puts me off. Nowadays when I read about some development tool (or just any product), I start with the price page. If there are only subscriptions available I stop reading and go on with my life.

No, totally reasonable not wanting to spend your whole life financially beholden to everybody you've ever done business with. "you will own nothing and be happy" is sadly becoming true, as you have pretty much no Rights for any digital and more of the world is becoming digital. When people ask why I don't like copilot and want a worse alternative when copilot "pays for itself", it's not because I don't want to pay, I…

I just want to buy something and have it.

You are buying time. Never pass up an opportunity to do that.

Re: C and C++ Hot-Reload/Live Coding

#62

fyi, "hot reload" is a native part of every operating system (consider, even trivially, forking or https://en.wikipedia.org/wiki/Dynamic_loading ). It's a sign of how bad developer tooling has been that live reload is sold as an add-on feature. DX seems always to see-saw between bill gate's c. 1990 demo of VB, and the compile-time speeds of a N' Wirth. At a guess, when the internet happened, all DX had to be thrown a…

fork() doesn't hot reload much of anything. exec() doesn't hot reload either. Dynamic loading doesn't hot reload either, more like hot load. Debuggers might hot-patch code to insert breakpoints, but that's not the same thing as replacing running code. Sure, the debugger might execute scripts you associate with breakpoints, but that's also not exactly the same thing as replacing the running code. Mind you, debuggers d…

> Debuggers might hot-patch code to insert breakpoints, but that's not the same thing as replacing running code.

Solaris dbx did have this capability -- patch and replace code with newly compiled code from your updated source files -- circa 2000. You just typed "fix" and it worked. I've been wishing for that capability on x86 Linux ever since.

Re: C and C++ Hot-Reload/Live Coding

#63

Earlier quoted context omitted.

One problem is that modern software architectures are highly coupled and stateful, such that it isn't possible to hot reload a component. It would require the host (e.g. when using a DLL) to detect a change, save state, unload, reload, load state. Multi-threading may also make things more difficult, requiring more synchronization during changes. I agree with your sentiment, but it's really hard to communicate it to t…

well, i think the issue is as least as much that the developers who create these architectures do not start from this pov --- consider how these architectures would be designed if must-have condition was sub-100ms iteration -- which should be trivial all-but-for codebases of at least 1mil+ lines; them, well, maybe it's 200ms. This design isnt hard -- what's hard about save_frame(), save_state(), or w/e, and restore_s…

Look, I'm part of the new generation. I think live plus plus is awesome, but don't really want to pay for it.

If what yout talking about is "not that hard" can you show me how to do it?

If it's not that hard, why aren't you teaching anyone? Why isn't it ubiquitous?

Your comments seem so at odds with reality that I'm inclined to think your missing something. But I'm also intrigued. Is it not that hard? And if it's not hard, why is live plus plus successful?

Re: C and C++ Hot-Reload/Live Coding

#64
post #50

Earlier quoted context omitted.

My personal experience with ROOT REPL is that it's quite stateful, some error may make you want to restart the session I avoid it for anything longer than a few minutes of use

This. I haven't used it for a while, but my experience is that this whole idea is not worth the trouble. If you want to rapidly design and test algorithms in a JIT environment, just use Python. It's designed for that. You can always port it to c++ in the end if performance is an issue.

you might be getting downvoted for conflating REPL with JIT, but there's definitely a place for a C++ REPL (and anyway, with ROOT/cppyy you can basically use inline C++ in python REPLs)

Re: C and C++ Hot-Reload/Live Coding

#66

Earlier quoted context omitted.

fork() doesn't hot reload much of anything. exec() doesn't hot reload either. Dynamic loading doesn't hot reload either, more like hot load. Debuggers might hot-patch code to insert breakpoints, but that's not the same thing as replacing running code. Sure, the debugger might execute scripts you associate with breakpoints, but that's also not exactly the same thing as replacing the running code. Mind you, debuggers d…

> Debuggers might hot-patch code to insert breakpoints, but that's not the same thing as replacing running code. Solaris dbx did have this capability -- patch and replace code with newly compiled code from your updated source files -- circa 2000. You just typed "fix" and it worked. I've been wishing for that capability on x86 Linux ever since.

Nice! I never knew, and used dbx lots!

Re: C and C++ Hot-Reload/Live Coding

#68
post #18

In one of the earlier episodes of the Handmade Hero series, Casey Muratori writes a hot-reloading functionality for C from scratch in about an hour (while giving detailed explanations of what he's doing). The following two episodes then improve upon the initial results. https://www.youtube.com/watch?v=WMSBRk5WG58

CToy is an implementation of this concept, using TCC.

https://github.com/anael-seghezzi/CToy

Re: C and C++ Hot-Reload/Live Coding

#69

Earlier quoted context omitted.

well, i think the issue is as least as much that the developers who create these architectures do not start from this pov --- consider how these architectures would be designed if must-have condition was sub-100ms iteration -- which should be trivial all-but-for codebases of at least 1mil+ lines; them, well, maybe it's 200ms. This design isnt hard -- what's hard about save_frame(), save_state(), or w/e, and restore_s…

Way back in the 2000-2004 timeframe, I worked along side a team making a game for the OG Xbox that had a daily workflow like: 1. Come in, get coffee, check out latest code from Visual SourceSafe. 2. Hit F5 to start debugging. 3. Edit and Continue in Visual Studio 6.0 all day long. 4. Hit shift-F5 to stop debugging at the end of the day. 5. Go home. Between that and the OG Pix for Xbox, the development experience has…

MS-DOS, Windows, .NET and Java development for me, during the last 30 years.

One of my university assignments, in the mid-1990's, was to implement a B-Tree library in C, which I used a OOP based approach, and already back then, gdb was powerful enough to use as a poor man's REPL.

I really don't get why people shy away to learn to use their tools properly.

Re: C and C++ Hot-Reload/Live Coding

#70

fyi, "hot reload" is a native part of every operating system (consider, even trivially, forking or https://en.wikipedia.org/wiki/Dynamic_loading ). It's a sign of how bad developer tooling has been that live reload is sold as an add-on feature. DX seems always to see-saw between bill gate's c. 1990 demo of VB, and the compile-time speeds of a N' Wirth. At a guess, when the internet happened, all DX had to be thrown a…

fork() doesn't hot reload much of anything. exec() doesn't hot reload either. Dynamic loading doesn't hot reload either, more like hot load. Debuggers might hot-patch code to insert breakpoints, but that's not the same thing as replacing running code. Sure, the debugger might execute scripts you associate with breakpoints, but that's also not exactly the same thing as replacing the running code. Mind you, debuggers d…

Besides therealcamino answer, Energize C++ and Visual Age for C++ v4 provided a image like development experience for C++, including code replacement and incremental compilation at method/function level.

Sadly too expensive for their day, and eventually died, only for us to start having some of those features almost 30 years later.

Post reply on HN