#61write a web-based ui to explore compiler state

  • avatar~clovercommented · 2 years ago
    Author
    Owner

    As I debug this out of bounds panic, I realize the issue with Zig and Data Oriented Design: It is very hard to visualize the state of your application.

    image

    If we used pointers + tagged unions, stuff like this would be easier. Instead, we get stuff like 0x9. This is an index into an array, but all of this data is bitcast and there is lots of indirection, making LLDB useless for showing data.

    image

    I still stand by this as a good design for compiler performance / data locality, but we need better debug tools.

    I declare the new short-term goal of the language is to get it to a point we can use itself to reliably build a Web-UI for visualizing compiler state during+after compilations. Before, I was thinking of a playground for people to test the compiler in the browser, but I am now leaning towards fully leaning towards building a state visualizer. For non-maintainers, this will probably just be very interesting to look at, but for maintainers this will be essential to understanding and debugging bugs.

    This is a large enough project that we will end up developing many useful utilities and libraries; the basis of our Standard Library. It will also be an amazing code sample of how to write a real project with the language. We can find out what patterns work well, and more importantly: We will use this project to prioritize what language features are most important to implement. User feedback will be second priority, and // TODO comments last.

    For the compiler, I'd like to put some work to write a small WebSocket server, to be included in debug builds. This will be used to stream the compiler state during compilations, specifically when stepping through a debugger. Imagine pressing "step over" and then the Web UI flashes with the change made, in a more visual way. Or when Sema is a state machine (#44), we can get a visual Sema debugger where it points at the current instruction and visualizes its state. The possibilities are endless.


    Milestone: 0.3.0.

  • avatar~clover changed the status to Todo · 2 years ago