News for hackers. Stuff that matters.
Re:Hotcaml: An OCaml interpreter with watching and reloading by sitkack on Thursday January 20, 2022 @03:23AM (#30006253)
I was going to make a similar comment about reload() in Python. One dev technique out of the many available is to have your code being edited in your editor while in another terminal window, using an ipython repl to drive it. Currently one would need to `from importlib import reload` and of course ipython itself has

https://ipython.readthedocs.io/en/stable/config/extensions/a...

Launch ipython like you would `pdb`

https://pypi.org/project/ipdb/

*edit to @dwohnitmok as the author of Crafting Interpreters mentioned, it really works pretty well in practice. And for cases where I was changing enough state that it bails out, you can either set a breakpoint in a test or create a little closure to build up the right state and then pass back an fn to step through in ipython.

Infact, this dev style reinforces an immutable nearly functional data centric programming model. With that model, changes to code won't impact the data, so reloads are actually rare. Have shallow reference chains, use value types in simple containers and lots of problems kinda melt away.

Ha! https://news.ycombinator.com/item?id=29965226 the highest rank post on Google search for that quote is less than 3 days old. Know we know why results are so bad!

Re:Hotcaml: An OCaml interpreter with watching and reloading by dwohnitmok on Thursday January 20, 2022 @02:18PM (#30013354)
Fascinating.

So the main thing I'm curious about is the exact mechanics of this:

> And for cases where I was changing enough state that it bails out

What exactly does "bailing out" entail?

Re:Hotcaml: An OCaml interpreter with watching and reloading by sitkack on Thursday January 20, 2022 @11:01PM (#30018972)
It isn't something I explored that deeply. When a reload fails, you know about it and you just reload the program and continue. It could manifest itself in lots of ways, any of which I don't have off the to of my head.