4 ms·
I love it. Reminds me of the Hotswap feature in Eclipse which Notch seems to use a lot for building his games. I wish there was something like that for UILayer,
by terhechte 14y ago
I love it. Reminds me of the Hotswap feature in Eclipse which Notch seems to use a lot for building his games. I wish there was something like that for UILayer, UIView and OpenGL in Objective-C. I know about the REPL in RubyMotion, but it's Ruby and a REPL is still not the same as having a live preview of editor changes. I really hate the fix-compile-test workflow, and especially for layers and layer animations and so on, I keep myself compiling and restarting an app multiple times until the speed, delay, looks parameters feel right.
I guess it's really difficult to implement something like that in Objective-C though. While it's possible to replace methods through method swizzling with new methods (say from a category), and while Objective-C allows to add categories to a NSBundle and dynamically add that NSBundle to a running app, this doesn't work on iOS as far as I know due to security limitations.
- phn 14y agoWhat notch used is a step further. From what I get this page simply "refreshes" the code and starts the execution anew. Notch is actually hot-swapping code, for example the code in the update function of the game, leaving the game state intact. If he wants to test a change in the init code for example, he would need to restart the program. Either way, very cool way to play around with three.js without having to switch back and forth to the editor.
- jonnycowboy 14y agoIt might be possible to save the variable and ID states in the code before updating, then "pasting" them back in once reloaded.
- phoboslab 14y agoJohn Resig did the JavaScript hot-swapping approach for Khan Academy. Watch the screencast here: http://ejohn.org/blog/introducing-khan-cs/ http://ejohn.org/blog/introducing-khan-cs/
- outworlder 14y agoIs that documented anywhere?
- phn 14y agoI have no idea, I just remember it from the stream from notch. I also experimented a bit with something similar for python. You can find it here: http://www.krause-software.com/hotswap/ http://www.krause-software.com/hotswap/ I think it worked so well for notch because the code he was changing was in a different class than the program's entry point, so the virtual machine had it easy swapping the code. Once again, I don't know the details, it is just my impression from what I saw that time.
- deleted 14y ago[deleted]
- erichocean 14y agoIt's not iOS, UILayer, and UIView, but Blossom[1] supports an equivalent, canvas-based development model and hardware-accelerated layers and transitions in the browser, based on Apple's SproutCore MVC framework. It would work well with mrdoob's editor, and it's all JavaScript (no HTML or CSS to deal with). [1] https://github.com/fohr/blossom https://github.com/fohr/blossom
- mbell 14y agoThe hot-swap capability isn't something specific to Eclipse, its built into the JVM. Its also pretty limited, you can only change method bodies, you can't add methods, classes, class variables, and often things like annotation changes aren't picked up. Eclipse, IntelliJ, etc all use this. There is JRebel which is a custom implementation that allows much more robust code injection, but its not free. Hotswap is great for tweaking values/logic after you've nailed down your method flow but it can have negative effects as well which aren't immediately apparent. I've seen a few hunks of code end up overly complicated as the developer hit a point where they really needed to break the code into more methods but didn't since you can't Hotswap in new methods and they didn't want to wait for the app to restart. I don't really know how you would do this with Objective-C as its compiling to machine instructions. It would be very tricky as you don't have the luxury of a VM that explicitly supports it running your code.
- johnno1962 14y agoObjective-C supports code replacement very well as it "run-time binds" selectors to method implementations. By injecting a bundle with a new implementation in a category it takes precedence over the original implementation as if the method had been "swizzled". The previous implementation linked into the app is taken out of play and ignored. This is all looked after by the application I mentioned. The complications seem to be minimal in my experience as long as you don't change the class interface...
- johnno1962 14y agoCode injection isn't impossible in Objective-C even on iOS, check out http://injectionforxcode.com/ http://injectionforxcode.com/ or the write up by Erica Sadun here: http://www.tuaw.com/2012/05/10/devjuice-injection-for-xcode/ http://www.tuaw.com/2012/05/10/devjuice-injection-for-xcode/