PLT Scheme provides a graphical toolkit for implementing GUIs called MrEd. At least on Windows, the result looks like a native application and was used to implement the IDE, DrScheme. As usual, the documentation is excellent.

When an application is running, it can be useful for it to output diagnostics that report on what it is currently doing, e.g. which database it connected to, or the id of a transaction that may have failed. This is normally output to a file, but it can also copy the output to a logging window, e.g. the Transcripter in Squeak, or the Java Web Start Console. How easy is it to implement a simple transcripter in PLT Scheme?

As usual, it is a good idea to decide on your API first as encapsulating everything behind an API means that we can easily change the implementation later on. I will simply provide a function (log s) where s is a string but you would probably want to have various logging levels which can be enabled or disabled at runtime.

(require (lib "42.ss" "srfi")) ;; First of all, create a text area inside a window (frame) (define *frame* (instantiate frame% ("Transcript"))) (define *text* (instantiate text-field% () (label "") (style '(multiple)) (parent *frame*))) ;; We need the editor belonging to the text area in order to append text to it (define *editor* (send *text* get-editor)) ;; The 'API' for accessing the Transcripter ;; This is a somewhat unrealistic implementation, but good enough for a quick example (define (log s) (send *editor* insert s)) ;; A test method, displaying 200 numbers on the transcripter ;; - this is the same as we did in Squeak (define (200-nums) (time (do-ec (:range i 1 201) (log (string-append (number->string i) "n"))))) (instantiate button% () (label "Execute") (parent *frame*) (callback (lambda (button event) (200-nums)))) (send *frame* show #t)

A couple of things. First of all, performance: When I ran this initially, the display numbers test took ~60ms. However, when I expanded the Transcripter window to a reasonable size, it took ~2000ms (2 seconds!) When I retried the same in Squeak it took around 5700ms although I’m certain it had earlier taken more than 10 seconds. This is a different computer and a different image but maybe the Squeak Transcripter isn’t so bad after all.

Secondly, it was fairly straight-forward to construct the GUI. Of course, such a simple example doesn’t really give any idea how hard it is to use MrEd to create moderately complex GUIs, but the existence of DrScheme indicates that it is at least possible.