Sunday, March 26, 2006

lab 59 - acme SAC


lab 59 - acme stand alone complex


A project that's been on my mind for quite a while is to package Inferno's acme as a stand alone editor. I only had Windows in mind as a target host, but the work should be quite easy to reproduce on other hosts.

I wanted the editor to blend well with the host system, and work as a substitute for other popular programmer editors such as vim, emacs, or jedit. Acme and Inferno being already stable and mature, there were only a few things I felt needed to be in place for this to work.

  • cut & paste between the host and acme (lab 55)
  • acme to resize with the host window
  • dead simple packaging and install of acme on windows.

This lab covers the code to do the acme resize with host windows.

I copied the code from /emu/port/devpointer.c and made devwmsz.c. The code is almost identical except for the name changes. This device holds a short queue of window resize events and serves a file /dev/wmsize that's the same format as /dev/pointer with x and y fields representing the width and height of the host window.

I modified acme directly to support this new device instead of modifying wm modules, which might have been more appropriate, I'm not sure. I added a new thread to /acme/gui.b to listen for resize events and resize the acme window appropriately.

startwmsize(): chan of Rect
 rchan := chan of Rect;
 fd := sys->open("/dev/wmsize", Sys->OREAD);
 if(fd == nil)
  return rchan;
 sync := chan of int;
 spawn wmsizeproc(sync, fd, rchan);
 return rchan;

wmsizeproc(sync: chan of int, 
 fd: ref Sys->FD, ptr: chan of Rect)
 sync <-= sys->pctl(0, nil);

 b:= array[Wmsize] of byte;
 while(sys->read(fd, b, len b) > 0){
  p := bytes2rect(b);
  if(p != nil)
   ptr <-= *p;

/appl/acme/gui.b:/^eventproc/ responds to the new event on the channel from wmsizeproc,

 wmsize := startwmsize();
 for(;;) alt{
 wmsz := <-wmsize =>
  win.image = win.screen.newwindow(wmsz, 
   Draw->Refnone, Draw->Nofill);
  p := ref zpointer;
  mainwin = win.image;
  p.buttons = Acme->M_RESIZE;
  cmouse <-= p;

I copied similar code into /appl/wm/wm.b so the standard window manager resizes with the host window (included in this lab's files). After using it a little I think I prefer it not resizing.

I use Acme:SAC as my main environment now, opening up another Inferno session when I want to do graphics work. I think the smoother integration with the host window system is a big win. It feels more like just an editor, neatly hiding a very powerful operating system behind it. I think Acme is one of the jewels of Inferno. Packaging it in this way may lead more people to discover Inferno through Acme. It could provide an easier introduction to the system and allow new users to start doing real work with Acme within a few clicks of downloading the package.

I've created a page for the Acme:SAC download where I'll post updates as I try to improve the packaging. The download is based on the emu from 20060227 Inferno release and my dried dung inferno tree.

Acme: Stand Alone Complex

Monday, March 13, 2006

lab 58 - dried dung


lab 58 - dried dung


"Even as the clock ticks, better and better computer support for the creative spirit is evolving." - Dan Ingalls.

How does computer support evolve and interact with the creative spirit?

Doug Englebart tackled a related question, "How can a computer support a problem solver's intellect?" Englebart's solution was a form of recursion called Bootstrapping. Build tools to help build better tools. The better tools would augment the programmers abilities to help them on their way to bootstrap the next system. A significant aspect of the bootstrapping philosophy was that the researchers used the tools they build.

The Smalltalk researchers took those ideas to heart. The Design Principles of Smalltalk followed this evolution cycle explicitly:

  • Build an application program within the current system (make an observation)
  • Based on that experience, redesign the language (formulate a theory)
  • Build a new system based on the new design (make a prediction that can be tested)

The point I want to emphasize is that both the system improved and the researchers learned during each cycle. This may be why constructionist learning has figured so prominently in Smalltalk's history. The Smalltalk researchers learned how to build systems by building them. But once completed they had a better system to use to start the process of building the next system: the computer support evolved with them.

Alan Kay and Dan Ingalls, original members of the Smalltalk team, went on to create Squeak. A successor to Smalltalk-80, it was built as a system for kids to build and discover their way to better understanding of math and science. Kay has written about the Story of Squeak, which closely follows the bootstrapping philosophy, including using Smalltalk to implement the Squeak system right down to the VM. And still Alan Kay doesn't see Squeak as an end in itself. Squeak is meant to be discarded, a stepping stone for the person using it to the next system that will provide even better support.

To get back to answering my original question, the creative process is a bootstrapping process. We learn by making things. And in the context of programming, there exists a kind of symbiosis between programmer and computer where the computer also learns new processes as we bootstrap new systems from old ones. The created system then becomes the context for the next system, and so it evolves, and with each evolution better supporting the niche of the creative spirit it is serving.

To further illustrate these ideas and reinforce the point that the computer is "learning" too, I point you to a fantastic talk given by Ken Thompson to the ACM, Reflections on Trusting Trust.

Inferno is several generations along the bootstrap timeline. It was bootstrapped from Plan 9, which was bootstrapped from research UNIX, which was bootstrapped from earlier, more primitive UNIX systems way back to UNIX implemented in assembly.

The question then that begs to be asked is, what's next? This is not just a question about the system but also about the person (or people) developing it.

My first steps along this path have been to start thinking about systems rather than individual tools. I've tried to create an Inferno collection of software that's more tightly aligned with the things I need. I want to reduce the overall size but keeping the same power, or even increasing it. I've been trying to consider all trade-offs in complexity versus benefit.

I'm calling this effort Dried Dung (for whatever reason to remind me to think of systems). It's an attempt to bootstrap myself and the system to get better computer support for the creative spirit, hoping both will evolve as I keep pushing on the system.

I feel I could have chosen Squeak, Plan 9, plan9ports, or a lisp environment as a starting point. But I've developed such a comfort level with Inferno I'd find it hard now to switch. I feel I've already begun to mould Inferno to my needs, even as these needs are changing.

This lab's code is a pointer to the Dried Dung file tree. See Getting Started for obtaining a certificate to logon to the tree. Once you get the certificate mount tcp!!6681 /n/dung and browse the tree. CHANGES describes some of the modifications I've made but a lot of stuff has been described in this notebook, and will continue to be described here.