News for hackers. Stuff that matters.
Re:Compile .NET in your browser using Compilify by greggman on Tuesday April 17, 2012 @12:22AM (#3851096)
It seems cool but, and maybe I'm reading something between the lines that's not really there, we have live code editing built into most browsers.

In Chrome or Safari press Ctrl-Shift-J (on OSX Cmd-Option-J) or Ctrl-Shift-K in Firefox and paste this

    c = document.createElement("canvas");
    document.body.appendChild(c);
    ctx = c.getContext("2d");
    ctx.translate(150, 75);
    ctx.beginPath();
    for (var i = 0; i < 60; ++i) {
        var a = i * 2; 
        ctx.lineTo(Math.sin(a) * 75, Math.cos(a) * 75); 
    }
    ctx.stroke();
This is one of the things I love about programming in JavaScript. Being in the browser means I always have a live "listener" where I can manipulate code on the fly.

Anytime I need to check something simple it's just a moment to try it out. If I want to make something easily inspect-able I temporarily assign it to a global.

   xxx = someObjectIWantToInspect
And now I can type `xxx` to see it live.

Since I do lots of visualizations and games and other things that re-evaluate live it's easy to just manipulate the settings as they run. For example paste this code.

    m = 2;
    c = document.createElement("canvas");
    document.body.appendChild(c);
    ctx = c.getContext("2d");
    ctx.translate(150, 75);
    setInterval(function() {
        var t = +Date.now();
        ctx.clearRect(-150, -75, 300, 150);
        ctx.beginPath();
        for (var i = 0; i < 60; ++i) {
            var a = i * m + t; 
            ctx.lineTo(Math.sin(a) * 75, Math.cos(a) * 75); 
        }
        ctx.stroke();
    }, 100);
Then try typing `m = 1` or `m = 9` etc and watching the shape change live.

Yes, I understand the OP is about C# but like I said, I read something between the lines that suggested maybe some people didn't know this. Sorry if it's off topic.

There are no comments on this comment yet.