Uncategorized

Experiments in Emacs

Posted in Uncategorized on July 26th, 2008 by Lorenz Pretterhofer – 2 Comments

One of the most difficult challenges facing me when beginning to work with both Erlang and Haskell, was the significant lack of good IDEs… Well, at least that was the theory, anyway. Instead it turned out to be a real motivator to finally get around to investigating the only IDE that counts.

The real problem wasn’t that I couldn’t use Emacs for basic editing, rather I didn’t really have any idea how to use any of the extra features. Essentially it was like working with a semi-decent TextEdit.app, with code highlighting and unfamiliar keyboard shortcuts. Even after reading some of Steve Yegge’s essays I still didn’t really have any idea what I was doing.

Ok, so basically I’m now writing this in Emacs’ SGML mode and carefully trying to get around the perverse limitations of Wordpress. (Where the heck did the allow raw HTML checkbox go for author text?) Ironically I don’t think I’ve yet gained the productivity advantages from my efforts yet, but honestly that can probably just be attributed to a slow down in my typing speed and the rather unexpected work schedule I’ve been (you never realize just how much you appreciate sleep until you don’t get enough).

If I haven’t gained any real productivity, the question becomes why then am I still using Emacs to write this post? Well, as it turns out its not actually too bad for even when you don’t know all of the keyboard commands (all commands come from the keyboard, and most important commands really never migrate to them menu or at least don’t indicate they’re keyboard equivelent).

Even more importantly perhaps is the gains that I’ve achieved in other tasks…writing blog posts in Emacs may not be any faster for me (although I do seem to see much more of the post at any one time)…but writing code sure is. I seriously doubt that I’d change from using things like XCode for Cocoa applications or DrScheme for PLT Scheme applications (although I may change my mind on Scheme), but at least I have direct access to the REPL in Haskell and Erlang.

The way most of the editing modes in Emacs actually work, it essentially will even load up a file your working directly into a REPL running side by side in another text buffer. From there you can test smaller parts of your program or even just run the whole thing from the top if you needed to. Anyone who’s worked with a Lisp dialect or even Python or Erlang (among others) should be able to apreciate that.

There are a couple of things that have been bugging me so far. The first is the lack of a spell checker. Emacs does have built-in support for ispell, but as you probably guessed, it doesn’t work on my machine (actually it isn’t even installed on my cygwin install). Too make matters worse, I still need to teach Emacs how to find my Cygwin install and use programs from it before the windows paths…ugh…

And the other thing doesn’t even have anything to do with Emacs, but rather, its a limitation with the Haskell code I’m working on. Essentially I don’t have a framework for OpenGL work that allows me to substitute the code on my side of the framework after the application has been started…or more to the point I can’t stop the application after it has started, forcing me to quit the entire REPL every time I test the Game.

Of course the simple workaround is to just keep restarting the REPL or move out of Emacs into a Cygwin shell, but its still very inconvenient (damn you GLUT).

All in all I can only really see how it goes, but at the very least it should make life just that little bit easier. At worst, I’ll just have to resort to my aging Mac Powerbook (for the BSD layer).

Until next time…

– Lorenz

FoNC Wiki

Posted in Uncategorized on June 6th, 2008 by Lorenz Pretterhofer – Comments Off

If your’re interested in post-Smalltalk research, or more specifically the implementation of such technologies then you might be interested in keeping an eye out on the work being done by Ian Piumarta, et al.

Well, the good news is that a wiki has been setup for increased public communication about the project.

You can check it out over at…linky

–Lorenz

Cygwin…Mingw…’.a’…WTH!!?

Posted in Uncategorized on June 4th, 2008 by Lorenz Pretterhofer – Comments Off

Recently I decided to pick up an apparently fantastic book on Erlang, written by Joe Armstrong (Programming Erlang). Now personally, I’ve never been particularly impressed by the man himself…too much of that functional programmer arrogance if you ask me. For some reason however, the hype got the better of me, especially after stumbling on a conversation between Armstrong and a couple of other functional programming ‘nuts’…uh…enthusiasts.

Perhaps of interest, is that I’m also quite a fan of functional programming myself, but I’d rather think of myself as avoiding a particularly insidious case of accidental complexity rather than using a fundamentally better language. I should explain… While functional programming languages does reduce a lot of the complexity accrued due to side effects and shared memory; they don’t deal with some of the other almost equally dangerous forms of accidental complexity.

Note: The actual problem I have with these functional language guys is the assumption that it’s a natural way of thinking about problems. Its not…it’s just, plain and simple, another way of learning how to solve problems. And its generally not one of the easiest to learn (basic anyone?)

I’m talking about compatibility of course, which brings me to the point of this post.

Cygwin…Mingw…’.a’…WTH!!?

After learning Erlang, and believing (perhaps even jumping the gun slightly), that I would be up to a real challenge, I realized that one thing was missing. A decent flexible, portable, Erlang code only FFI interface.

My challenge…write a real-time, computer game using Erlang. The likely candidate would be a space combat sim, within the vain of a Freespace2 style game (graphics and gameplay wise…hopefully the story will actually give our hero an actual name this time:)

Unfortunately the existing FFI in Erlang is either to use a network port to a C program linked to the candidate library, or to use a “linked-in driver”, attached to the VM and talking the VM’s data-structures in order to facilitate communication. Damn.

Talking to VM’s in case you’ve never tried it (although that seems unlikely if your reading my blog ;), is always a major pita. You effectively skewered between two of the most awkward types of interfaces known to programming kind, and worse yet, your only weapon of choice is what C gives you…or worse…a code generator (SWIG be damned).

No… What I need is something like the Pythoneers, imo brilliant, library…CTypes. And for C interfacing, the ctypes library uses a C level library called libffi (sort of anyway).

While this libffi based library of mine will no doubt be the topic of a future post, it does bring up a rather gruesome topic that I’ve been avoiding for quite some type now…Cygwin and Mingw.

After many hours of searching the web I’ve finally found what appears to be the solution.

Cygwin, as we all know is just a *nix/POSIX subsystem running over the windows COFF binaries (afaik), which allows us to blend windows and bash tasks during our development process (like using Windows compatible GNU/Make makefiles).

Mingw is where I got confused. You can find it in the installer for Cygwin, which put me under the assumption that it was more or less the default for this stuff…it isn’t.

Mingw is simply a cross-compiling target for GCC, which targets COFF binaries and the win32 C library (I can’t remember which one…I believe its the one in C:\windows however).

This means that to compile a binary for windows…one that doesn’t depend on cygwin.dll, or infact any of the cygwin dependent libraries you simply need to tell GCC to use the Mingw target…uh…sure…that sounds easy.

Actually, it turns out that this process is so involved sometimes (cross-compiling) that the mingw guys (or is that the Cygwin guys?) decided to make it easy. All you have to do, as mere mortals, is pass –mno-cygwin to GCC (“CFLAGS=’-mno-cygwin’ ./configure;make), and that’s it!

Fantastic…now back to the real challenge…using libffi to create my “Erlang C Types” library…

– Lorenz