I am not sure if this question has been asked already, but is there any way to import and initialize libraries from REPL console to a sketch running into Live Coding / Hot Swap Mode?
I mean, I am running a Processing sketch into REPL mode (not from REPL console but from the main environment) in live coding mode, and at some point I need to import a library without closing the rendering window, is it possible to do it somehow from the REPL console or the two are completely isolated from each other?
I am not sure. Perhaps @neilcsmith might have some experience with the livecoding affordances and limits of Processing? I believe I’ve seen previous threads related to that topic.
@kesson I don’t know a lot about how the Processing mode is using HotSwap but I can guess some problems. Can you be more specific about library and how you’re trying to initialize it?
The library will at least have to be installed beforehand, assuming the mode doesn’t provide a custom classloader that allows for this.
The major limitation of not being able to add fields or rerun setup() could be a problem. I can think of a few hacky workarounds, but not without knowing the specific library and initialization you need.
@neilcsmith what I was trying to achieve is merging HotSwap in Processing with REPL mode. In REPL mode you can do anything on the fly without reloading the rendering window (also importing libraries or initializing variables). Just I don’t feel confident and sometimes crashes (for example trying to initialize FFT analysis in Minim, I think is because it is a big array of floats). From REPL then you can codify whatever you wrote in a Processing function, and what I was trying to achieve is taking the function obtained from REPL console in the running code in Hot Swap without reloading the main sketch. In REPL console is possible, so I assumed that you can combine both and do real on the fly programming.
I am not an expert in this, that’s why I was asking, and I would need it more in a context for art installations.
I’m not sure the Processing HotSwap has any ability to control the parent classloader. Without that you won’t be able to add libraries at runtime, but you should be able to add the import ... statement if the JAR is already part of the running project. Theoretically PraxisLIVE supports adding JARs into a running program, although there’s a bug in some cases I’m working on at the moment.
I’m not sure what the REPL mode is doing differently - never looked at it.
It shouldn’t be crashing because of a big array, but how are you creating this (or not creating it 60x a second)? You can’t add fields or methods using HotSwap.
I do live visuals with REPL mode and, actually i’m investigating about it, looking for a way to declare new methods, new global variables or just avoiding hang up the visuals if i cast the wrong type.
If you’re using anything that uses Java’s built-in hotswapping this will not be possible. Unless you use tools that extend that (somewhat hackily) like JRebel, which is commercial, or a completely different JVM - eg. DCEVM.
Or you could use a tool that’s been designed to do live coding with Processing from the ground up, like PraxisLIVE (I’m biased obviously! ). Or if you don’t mind using Ruby instead, there’s also Visor.