The prototypeThe picture above is a snapshot of window of working Scheme-OSA. Going from left to right along the window toolbar we can see that:
1. "Interpreter" has been installed (because of the green dot in the on/off button);
2. The name of interpreter is "Petite Chez ...";
3. The interpreter is ready to "Perform", that is, evaluate next command;
4. The "Break" button is disabled because there is nothing to break from yet;
5. The "Decorate" button is (always) enabled. In fact we already used it to colorize the Scheme code in the input text view: comments are green, strings are brownish and keywords are blue.
After pressing the "Perform" button (or command-return keys), Scheme-OSA will initialize evaluation of any selection in the input text view (none selected here), or of all the code in this view.
Consequently, a friendly voice, which you can pre-select from a list of several voices, will ask you to enter your name, then a dialog box will pop up asking you to enter your name (default name "Peter Fonda"). The box will be discharged after pressing "OK", and the voice will ask you again whether your real name is indeed "Peter Fonda", or whatever name you entered. If you happened to press "Cancel", rather than "OK", the Scheme error will be generated instead.
Any time the evaluation takes place the red "Break" button becomes enabled, giving you a chance to cancel longish loops of other such events. This button plays the role of Control-C in Unix terminal.
The goalsScheme-OSA is conceived as Interactive Development Environment for Scheme on Mac OS X platform. It is also a framework, which will hopefully deliver access from Scheme to many facilities and services of that platform, and to many specialized scriptable applications. Because it piggy-backs on Applescript, it should be able to do what regular applescripts do. Play music, talk, create 2D and 3D scientific plots, animate OpenGL goodies, exchange data with professional editors, spreadsheets, etc. -- short of dancing and cooking...
In other words, it should be able to behave as regular Scheme interpreter - but with all those additional goodies available to Applescript. It is still under development, hence many of those promisses seem too far fetched. Some however are already working, other features will, hopefully, appear in the near future.
Take a note: this is just a prototype, and I am not going to distribute any code as yet - with the exception of some Scheme modules to anyone interested, or the Xcode bundles to those who wish to help with reviews, development, testing, documentation or porting Scheme-OSA to the dual universal platform.
The non-goalsI do not plan to build yet another programming editor. Instead I plan to take advantage of the best existing editors in Mac OS X world. Let the others do your job if they can do it better than you can.
Let me explain. More than a year ago I wrote my first predecessor of Scheme-OSA. It did not rely on Applescript, but it provided two services, which one might call "glorified copy" and "glorified paste". It worked as follows: after invocation of that application I would load an interpreter of my choice (usually Petite Chez Scheme or MzScheme), then hide the application away - doing all my work in a programmer's editor of my choice, which happens to be TextWrangler[3].
After selecting a portion of a Scheme code, or entire module, or Scheme's load command, I will copy it directly to running Scheme interpreter via command-9 (visual association with left parenthesis) for evaluation. If I were interested in any Scheme response I would wait a bit then hit command-0 (visual association with right perenthesis), which would copy Scheme response right below the original selection.
That was good enough for me with respect to interaction with a Scheme interpreter. Any other perks that Emacs users love to have are provided by TextWrangler: text coloring, code balancing, extensive search/grep/regex facilities, diffs, buffers vs. files, text formatting, built-in shell scripts, etc. In addition, TextWrangler has fine support for AppleScript, which you can take advantage of to significantly extent its functionalities.
Although I incorportated some of the standard features of programmers' editor to Scheme-OSA, such as text coloring and code balancing, they are not there to completely eliminate a good text editor. I still envision myself doing most of my editing work in TextWrangler. But when I switch to Scheme-OSA I want to have some of the good perks too.
A year has passed and I suddenly realized that I can build a much more powerful tool than my old (still in use) prototype. I have never appreciated Applescript - thinking in terms: "Oh, this must be one of those Mickey Mouse languages". I was wrong - it is a very powerful means for taking advantage of the best applications that Mac OS X can offer today.
The implementationOSA stands for Open Scripting Architecture, which provides framework for one of the forms of inter-application communication on Mac OS X platform and the set of libraries open to anyone wishing to plug her programming language of choice to OSA. The primary OSA language is Apple's AppleScript. There are few other languages that are already OSA-compliant: Python for one, Perl in some form, JavaScript under development.
Scheme-OSA does not plug directly to OSA libraries, but indirectly by riding on the back of AppleScript. I am not sure whether this is the best way to do, but this approach offers several advantages.
1. Short time to delivery. I did not have to go through typical hoops: marshalling of primitives, objects, pointers, then binding to OSA functions and all of that stuff. Instead few very simple conversions were required - more or less the same stuff that is required when implementing XML-RPC.
2. Safety. Communication with Applescript is easy: there are no pointer-related issues, dangerous crashes, and so on. Worst what can happen is its occasional refusal "I do not understand your message" - as in Smalltalk.
3. Ease of development. I can use Applescript to script Scheme-OSA any time either under control of Xcode or outside it. Scripting the product helps in evaluating approaches, trying "what if scenarios", testing, and so on.
Scheme-OSA is being built as "Applescript Studio" product, with significant support from Scheme itself. Most of the code is Applescript, 10-20% of the code is Cocoa (Objective-C). The only third party library is Satimage[1], a freely available product, which I use for regexp oriented tasks.
No apologies for ignoring EmacsI should have loved Emacs, because I used to love Smalltalk, which - similarly to Emacs - tends to behave as an operating system on its own. But I have few reservation with respect to Emacs. (OOPS, I am feeling like loosing few potential friends right now:-)). Obsolete user interface and bloated code aside, the real problem is my own memory: I dislike memorizing all those triple key combinations. This was also a reson I never liked Vi editor (OOPS, another bunch of sympathizers is gone! :-)). I know some easy to remember key sequences: Command-C and Command-V for copy and paste, Command-B for bold, Command-I for italic, but I will be certainly lost in the maze of Emacs shortcuts.
I was happy to discover Aquamacs[5] a year ago. As they claim on their web page:
We support the standard Mac user interface that you've come to love. For instance, in addition to traditional Emacs shortcuts like C-x C-f (open a new file), Aquamacs understands Apple-O. Aquamacs behaves like a modern application on Mac (or Windows) when it comes to selecting, copying, pasting texts within Aquamacs or in between applications. Aquamacs offers nice, smooth fonts. Asian input methods work. It's easy to install and runs out-of-the box with no configuration. And all is built on GNU Emacs, so you can use your favorite Emacs packages!I did spend some time doing some extra customization of Aquamacs, but once I noticed that it becomes more and more obese with each new release, I decided that this tool was not for me. With all due respect, I am really happy with TextWrangler - as it comes to text editing.
No apologies for choosing Mac OS XMac OS X is my platform of choice of the last two years. Mostly as a programmer but also as a user - I crawled on DOS in Basic, C and MASM; managed to program in C on Unix graphic workstations; worked with passion in several self-contained, host-dependent and host-independent Smalltalks; did some angry programming in MS-Windows; then discovered Linux and stayed with it for at least 10 good years - programming in Eiffel, Java, C, Objective-C, Smalltalk and a bunch of other esoteric languages, Haskell including.
I like the Linux's
bazaar approach to sharing the knowledge and building software for the common goals. I learned a lot from Linux community, and I also contributed back a bit. But I dislike randomness in delivered goods: although there are plenty of high quality software packages in the Linux world, there are also many poorly documented and buggy utilities and applications. I have been growing impatient and started valuing my time; I have become tired of fixing somobedy else's bugs and going through countless hours of installations, upgrades, and often fruitless evaluations of third party packages.
So when the NextStep for Intel became available I jumped off the Linux ship for a while; I really liked what I saw and experienced: dazzling user interface - reminescent of Smalltalk; excellent inter-process communication facilities, such as Services; very good documentation, very good software development tools, Unix and Mach kernel under the hood, bug-free applications and friendly community. But there was one big problem: the Company and the Community were too small to keep up with either Microsoft or Linux. There were too few drivers available and because of it installations or upgrades of NextStep OS were tough - I once spent good three days swapping cards until I finally succeded in getting my machine running the NextStep. Software-wise, important applications, such as the web browser, were also lagging behind Netscape or Explorer.
So, for all the goodies I saw in the NextStep OS, I realized that there was not much future in that platform. With all regrets, I moved back to Linux. Sadly, I was right - NextStep went down. Happily, it got reincarnated as Mac OS X. Two years ago I discovered the old friend, and I have not been looking back ever since. I am not going to gloss over advantages of this platform: suffices to say that it suits me well, and I am not going to be apologetic about it.
References:[1] "Satimage Osax"[2] by Satimage-software, www.satimage-software.com
[2] OSA - Open Scripting Architecture
[3] TextWrangler - free Mac OS X editor, by Bare Bones Software,
http://www.barebones.com
[4] BBEdit - commercial Mac OS X editor, by Bare Bones Software,
http://www.barebones.com
[5] Aquamacs - "an easy-to-use, Mac-style Emacs for Mac OS X", http://aquamacs.org/