Hacker News new | ask | show | jobs
by sklogic 4250 days ago
So far all of the live coding demos were about graphics. I wonder if it's possible to do something similar with something of a much less interactive nature - say, number crunching, compilers, linkers, etc.
2 comments

I absolutely think so.

My ideal environment would have the ability to pause at a certain point, saving the state. Then I want to run to a another point (maybe only a few lines to a couple dozen lines down) and see the variable values and results in between.

Basically I want to live code with some defined input to section off parts of the program and still be able to iterate quickly by seeing results every time what I am typing will compile.

I also want to be able to visualize more data than just single values. I want to be able to see results of flat arrays, and write custom visualizers for more complex data structures. I have actually done a lot in this area, essentially by having a window in a separate thread that I can pass closures to (that run openGL functions on their data to draw it). This works incredibly well to let you see your software run. I don't know how I would have been able to write and debug some very difficult programs without it.

The whole thing is a repl with a graphical and audio engine at your disposal to use as you see fit. As well as writing your program iteratively in the "socratic" repl style, you are free to fluidly create whatever visualizations you wish along the way to help you. As well as this, if you split the process you have implemented into frames (a simple way is with coroutines or closures) you can make whatever visualization you prefer of your number crunching. For example, throw in some yield() calls in your program and every update() do a coroutine.resume(). In render() visualize the state of your program how you wish. The great thing about this is, as you change your program, the effect of your change will be reflected in what is rendered.
Interesting, it's something to think on. Creating such visualisations manually may be prohibitively complicated, but I can imagine some cases where they can be derived automatically (e.g., for compiler passes, an example IR can be displayed before and after).
You might also want to check out live programming, which focuses on interactive debugging rather than the improvised problem solving (as well as live performance) of live coding. Once you get to live programming, techniques like time travel become viable, which otherwise don't make much sense with live coding. You can then better tackle traditional programming problems with better live feedback.