Sunday, March 4, 2007

Forget Cygwin and VMware, run coLinux


Until a week ago I would have said that Cygwin was the best available way to hybridize Windows and *nix. I was relatively happy with my xterms and ssh. But that was all that I could use it for. Running X applications compiled for Cygwin was unusably slow. So I had to use VNC to connect to run X11 apps. Well, I no longer have Cygwin on my machine, it has been replaced by Cooperative Linux.

I don't know what rock I've been hiding under for the past two years but I had not heard of Cooperative Linux until a few weeks ago. Cooperative Linux is a recompilation of the Linux kernel as a Windows executable. All of the native posix commands get remapped to the Windows kernel. And it's fast. It's unbelievably fast. Once the kernel is running, it can run native Linux binaries. In other words, you can boot your Debian/Gentoo/*buntu/etc. distribution while in Windows without any binary recompilation a la VMWare or Virtual PC.

I've configured coLinux as a service so that when I login my Debian unstable distribution loads in the background. When I need to access it I load up Putty to ssh in. The only connection between coLinux and the Windows install is the local networking, so you can either ssh into it or open up the coLinux terminal window. Since coLinux does not have access to native graphics hardware, I export X11 over the internal network to the Windows XServer (Xming). Some of the graphics updates are imperfect, but it's a small price to pay to have Emacs, Kile, and all of my other favorite Linux applications running at what feels like 95% speed.

If you are interested in trying coLinux out, I grabbed my copy here. I used the 20070302-Snapshot release. It can be confusing to get it started, check out their wiki as a resource. The biggest hurdle is networking. If you don't have Linux experience then I recommend having a friend help who does. Good luck, it's completely worth it.

Monday, February 26, 2007

Emacs finally catches up to the rest of the debugging world



In a Unix environment, I use emacs for basically all of my development work. It's keyboard friendly which I appreciate, but emacs goes to the extreme. There are quite possibly thousands of emacs commands that look something like "control+x+k" to close a file and "control+shift+-" to undo the last change. It's a bit ridiculous. I can probably remember 2-3 hotkeys per normal application and if I'm really willing to commit some brain cells then perhaps 10-15.

Emacs does provide a method to type out the function that you would like to run, such as "Meta+x+compile" to compile your code, but I find that most of the functions I'm searching for do not match their names. For instance, to turn on syntax highliting you type "Meta+x+fontify-buffer" or something similar to that. There is no possible way that I could figure that out without first doing a google search. And thus, it's somehow easier to remember an absurd hotkey than it is to remember the function's name.

There are times when a mouse is useful, and debugging is one of them. Finally, the emacs developers have seen the light and Emacs 22 supports visual debugging. Yes yes, emacs has always had integrated debugging in the sense that an arrow points at your current line of code, but this is better. With 22, you get a real debug environment. Just type "alt+x+gdb" and then click on Gud->GDB-UI->Display Other Windows. Presto, a real debugging environment. Notice in the picture that we can see stack frames, breakpoints, values of variables in scope, the current line of code, and you can even open up a watch window to watch the values of variables you're particularly interested in. AND there is a simple button menu up top for stepping through your code. No more typing "control+x+s" to step a line of code.

Emacs 22 is not yet available as a binary package in many distributions, so if you need a copy just compile it yourself. It has ridiculously few dependencies so building it is really easy. Visual debugging is just a ./configure ; make ; make install away!

I've found the pretest releases to be very stable. I've yet to come across a single bug. You can grab it for yourself here: ftp://alpha.gnu.org/gnu/emacs/pretest/