<div><div dir="auto">A couple years ago Paul Fernhout did start working on a Morphic environment in Python. He tried the live coding too, but couldn't get it to work. This was prompted by Alan Kay suggesting the need for a live coding environment for OLPC. Guido van Rossum himself stepped in and created a module that lets you replace most things on the fly. I don't recall how it worked exactly, but I'm sure you can find it. But it never found much acceptance in the Python community, AFAIK.</div><div dir="auto"><br></div><div dir="auto">Another approach is the one taken by HPI's RSqueak VM which is built on top of PyPy and lets you develop, run and debug Smalltalk and Python code (<a href="https://conf.researchr.org/profile/MoreVMs-2017/fabioniephaus">https://conf.researchr.org/profile/MoreVMs-2017/fabioniephaus</a>).</div><div dir="auto"><br></div><div dir="auto">- Bert -</div><br><div class="gmail_quote"><div>On Wed 11. Oct 2017 at 14:50, Ben Coman <<a href="mailto:btc@openinworld.com">btc@openinworld.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 11, 2017 at 8:11 PM, Dimitris Chloupis <span><<a href="mailto:kilon.alios@gmail.com" target="_blank">kilon.alios@gmail.com</a>></span> wrote:<br></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>on the subject of<div>"<span style="color:rgb(33,33,33)"> </span><span style="color:rgb(33,33,33)">In Pharo the VM recompiles a method and replace it’s old instance with a new one while code executes"</span></div><div><span style="color:rgb(33,33,33)">I was wrong, the rest it correct in the live execution of the code and other objects.</span></div><div><br></div><div>Pharo VM will update the class objects (together with other type of objects) but it wont update instance objects.Probably this is done on purpose for not overriding and losing on reload the existing live state and live code (in this case instance methods), because module reloading is not made specific for live coding as I explained in the thread. So a class object will be replaced but not an instance. What led me to this wrong assumption was that the code I am working on is reinitialising my objects for debugging purposes because currently live state is not my concern as I am working on a GUI and some other technical reason. I did not realise that it was my reinisitialisation that was updating my instance objects(method wise, state was lost obviously) and not Python VM. Hence in my code the instance objects were always updated to the latest code as I was changing it. However now I enter the stage that I need to also update the live state without a full reinitialisation. </div><div> </div><div>Its possible to update the instance object manually . So far I have found two ways of doing this<br></div><div>a) Reinitialisation and take the state from the old one (instance variables and their values are stored as a dicitionary) and copy them to the new one and discard the old instance or</div><div>b)  take the methods (methods in python are objects and so are functions so they can be referenced) from the new one and copy them to the old one and discard the new instance. </div><div>I have tested both, both work as expected. Now I am in the process of finding how to detect that a class changed in a module so i dont have to reinitialise all classes (I know the overall solution to this as well) in a module and because reloading works per module at least I have avoided the other instances. But that is not my problem.</div><div><br></div></div></blockquote></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>My problem is what other challanges I have to face which I am not aware of live coding wise. Because I never tried implementing live coding enviroment in another language (my experiements are focused only on live execution of code because at the time the idea was to keep using Pharo for live state data) before it would be great if experts give me an insight about Pharo's live coding internals. This way I can "steal" cool ideas that I may not be aware they exists and make my live coding environment library progressively closer to Pharo.  </div></div></blockquote></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><br></div><div>Hence, I need guidance for the advanced stuff.  </div></div></blockquote><div><br></div></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><div><div>I'm not sure if this matches what you want, but I remember finding these articles enlightening about VM internals...</div><div>* <a href="https://clementbera.wordpress.com/2013/08/09/the-cog-vm-lookup/" target="_blank">https://clementbera.wordpress.com/2013/08/09/the-cog-vm-lookup/</a><br></div></div><div>* <a href="http://www.mirandabanda.org/cogblog/2011/03/01/build-me-a-jit-as-fast-as-you-can/" target="_blank">http://www.mirandabanda.org/cogblog/2011/03/01/build-me-a-jit-as-fast-as-you-can/</a><br></div><div><br></div><div>Alternatively, with your background and focus on Python, maybe you can learn something from RSqueak? ...<br>* <a href="http://scg.unibe.ch/archive/papers/Bolz08aSpy.pdf" target="_blank">http://scg.unibe.ch/archive/papers/Bolz08aSpy.pdf</a><br></div><div>* <a href="http://stefan-marr.de/2014/02/how-to-get-a-jit-compiler-for-free-implementing-som-smalltalk-with-rpython-and-truffle/" target="_blank">http://stefan-marr.de/2014/02/how-to-get-a-jit-compiler-for-free-implementing-som-smalltalk-with-rpython-and-truffle/</a><br></div><div><br></div><div>cheers -ben</div></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br><div class="gmail_quote"><div>On Wed, Oct 11, 2017 at 2:09 PM Nicolai Hess <<a href="mailto:nicolaihess@gmail.com" target="_blank">nicolaihess@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail_extra"><div class="gmail_quote">2017-10-11 12:14 GMT+02:00 Dimitris Chloupis <span><<a href="mailto:kilon.alios@gmail.com" target="_blank">kilon.alios@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br><div>Hey there as it says in the title I am trying to recreat live coding Pharo chracteristics in Python .</div></blockquote><div><br></div></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><div>Now I am confused, I thought you already did this? In the other thread you wrote:<br><br>"From my experience around  100 lines of code are enough to offer most of Pharo’s basic live coding functionality" </div></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><div><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div> One of the issues I have is live replacing of a method to an existing instance. </div></blockquote><div><br></div></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><div>And in the other thread you wrote:<br><br><div dir="auto">"Well live coding is a simple process of reloading code. 
In Pharo the VM recompiles a method and replace it’s old instance with a
 new one while code executes. </div><div dir="auto"><br></div><div dir="auto">Python
 you basically reload the module. Because Python does not compile per 
method but per module which means executing code lively. This happens 
because when you import a module in Python, Python does nothing special 
than executing the source code. Not before compilation but during 
execution. Hence live coding, the Python VM replaces objects lively. 
Python can also compile any size of code including individual methods. </div><div dir="auto"><br></div><div dir="auto">That happens with one line of code importlib.reload(mymodule) "<br><br></div><div>So, if python can already reload code and replace the instances, what is missing ?<br></div><div dir="auto"><br><br></div></div></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><br></div><div>I know how to do this in Python but that shown me I would benefit greatily from a more deeper understanding of Pharo live coding internals than I have at the moment which is only at the user level. This will help me avoid common pitfalls in a field that I am not experienced with. </div><div><br></div><div>Have you guys written any paper , article or blog post in this area, explaining the internals of the VM to that regard ? </div><div><br></div><div>I am also interested in time machine livde coding, meaning live coding that does not keeps you in the present but also can send you back in the past restoring the live state of old object instances in a specific time moment. </div></div></blockquote><div><br></div></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><div>I remember a project that developed some tools for back-in-time debugging and testing <br><a href="https://www.hpi.uni-potsdam.de/hirschfeld/trac/SqueakCommunityProjects/wiki/pathToolsFramework" target="_blank">https://www.hpi.uni-potsdam.de/hirschfeld/trac/SqueakCommunityProjects/wiki/pathToolsFramework</a><br></div></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><br></div><div>Generally any guidance on the art of implementing live coding will be greatly appreciated. </div><div><br></div><div>I don't care how this can be done in Python because I have already recreated a very basic live coding enviroment in Python and there is a lot of documentation about Python overall what I am interested only is the Smalltalk way of doing live coding but from the perspective of the implementors not the mere users. </div></div>
<br></blockquote></div></div></div></blockquote></div>
<br></blockquote></div></div></div></blockquote></div></div>