All Scheme Search is a Google based search engine for “Everything about the Scheme Programming Language”.
If seven pages of search results for “keyword arguments” is any measure, this looks pretty interesting :).
Addendum: 01/05/08
Here are two more: Scheme from the Florida Keys (actively updated) and Search PLT Scheme (not actively updated).
Author: grant
SCIgen – An Automatic CS Paper Generator
SCIgen is a program that generates random Computer Science research papers, including graphs, figures, and citations. It uses a hand-written context-free grammar to form all elements of the papers. Our aim here is to maximize amusement, rather than coherence.
One useful purpose for such a program is to auto-generate submissions to conferences that you suspect might have very low submission standards.
There are seemingly a number fun things that you could do with this!
Automata via Macros
Last year I asked a question about Automata via Macros to the PLT Discussion List. The paper is about an extended example of a problem posed by Shriram Krishnamurthi at the Lightweight Languages 1 conference. I was trying to understand how one might use the same FSA language to generate different outputs. Many folks explained how that would work and the thread finished. It didn’t finish for me, though. To say my understanding of the solution was superficial would be an overstatement. I knew I didn’t “get it”, and kept it on my list to revisit once I had a better grasp on things. That was a year and a half ago.
Over my holiday I revisited the paper and found, for lack of a better way to say it, that it “made sense”. In the past year I’ve tried to: read a lot, write a lot of code, read other people’s code, and most importantly do so with some discipline and attention to detail that I had not applied before. That seems to have paid off; as it felt like I was reading the paper with brand new eyes.
This time around, I also listened to a recording of the presentation itself and watched the PowerPoint that went along with it. This was especially valuable because it drew attention to various tidbits that appeared in the paper but were much easier to delineate by virtue of Shriram pointing them out in context of the presentation. It was those comments, along with what I had learned in the past year that really got me thinking about things again.
In a conversation with Aaron Hsu, he once said something to the effect that “Scheme is hard because it is subtle.”, and that sort of rang true with my intuition, but I had a difficult time verbalizing exactly why I thought that to be true. Outwardly Scheme appears to be “simple”, but the more you learn about it and the deeper you dig, you start to see that it is Deceptively Simple.
Scheme seems to take only a few days to learn, but a few years to master; but why? I don’t know yet, but what I do know is that some of the ideas and topics presented in this paper and presentation are surely some of the aforementioned “subtleties” that serve as landmarks on this multi-year path towards understanding Scheme. For my own reference, and for others who may be studying Scheme and wondering exactly why “Subtlety is hard”, perhaps this paper will serve to shed some light on things.
My advice: read LAMBDA: The Ultimate Imperative and LAMBDA: The Ultimate GOTO first.
Abstract
Lisp programmers have long used macros to extend their language. Indeed, their success has inspired macro notations for a variety of other languages, such as C and Java. There is, however, a paucity of effective pedagogic examples of macro use. This paper presents a short, non-trivial example that implements a construct not already found in mainstream languages. Furthermore, it motivates the need for tail-calls, as opposed to mere tail-recursion, and illustrates how support for tail-call optimization is crucial to support a natural style of macro-based language extension.
Key notes from the audio
These are mostly my notes and summaries for some key points that rang true with me. The ideas that they represent may or may not be contained within my summary as it would be too far outside the scope of this blog post to address them. Such work is better done by other papers and presentations.
- 09:00: Without the hidden gems, syntax, macros, and tail calls, it all falls apart.
- 11:16: What you generate must fit well into the language.
- 18:00: It is really tail-transfer (tail-calls) that matter, not tail-recursion.
- 21:00: Scheme is really an indentation based language.
- 23:00: Macro languages belong in modules; you can use your data (DSL) where you wish.
- 25:30: If you claim to be smart, leverage the work of others.
- 26:10: Scheme is subtle. Takes years to understand what is beautiful. You can look at a book but you won’t notice. The language hides it jewels.
- 26:45 If you don’t get tail calls, you don’t get it.
Key notes from the paper
- P2P3: “A macro gives the programmer a consistent, representation-independent means of describing the datum
while still resolving the representation before compilation.” - P7P4: Macros are likely to be used to optimize the abstraction that the data represents.
- P8P3: Scheme’s macro system could be called “a lightweight compiler API”.
- P9P2: Tail-calls ought to be called tail-transfer per Steele. I wonder why they didn’t push that definition more.
- P9P3: Here is a good explanation of tail calls.
- P9P5: “languages represent the ultimate form of reuse, because we get to reuse everything from the mathematical (semantics) to the practical (libraries), as well as decades of research and toil in compiler construction (Hudak, 1998).”
- P13P2: “it shows how features that would otherwise seem orthogonal, such as macros and tail-calls, are in fact intimately wedded together; in particular, the absence of the latter would greatly complicate use of the former.”
The automaton language
; An automaton that recognizes the language c(ad)*r
(define m
(automaton init
(init :
(c → more))
(more :
(a → more)
(d → more)
(r → end))
(end : accept)))
Envy Code R: A Programming Font
Envy Code R is a new monospaced font that I’m trying out. I find it a hard on my eyes, but perhaps you will like it. Lucida Console it remains.
Sandbox improvements in PLT Scheme
Dynamically avoiding duplicate identifiers in PLT Scheme
In this thread on the PLT discussion list, the original poster was encountering a problem while implementing a DSL where definitions were getting defined more than once in the code that he was generating. The problem is that the define function will not define the same name twice:
(define x 10)
(define x 12)
=> duplicate definition for identifier in: x
The solution would be to check if the given name is already bound before defining: if it was not defined, the define function should be used, otherwise the set! function should be used:
(define x 10)
(set! x 12)
Here is Andre’s solution from the thread:
(define-syntax define-if-not
(λ (stx)
(syntax-case stx ()
[(_ var val)
(with-syntax ([set!define (if (identifier-binding #'var 0)
#'set!
#'define)])
(syntax
(set!define var val)))])))
identifier-binding returns true unless the name is a top level binding or is not bound at all. If the name is already bound, use set!; otherwise use define.
Unicode in Emacs
From what I can see, Emacs supports Unicode just fine. I had asked about it on the PLT discussion list, where it was explained that set-language-environment function will configure Emacs to use Unicode wherever possible. Here is the documentation:
(set-language-environment LANGUAGE-NAME)
Set up multi-lingual environment for using LANGUAGE-NAME. This sets the coding system priority and the default input method and sometimes other things. LANGUAGE-NAME should be a string which is the name of a language environment. For example, “Latin-1” specifies the character set for the major languages of Western Europe.
Here is how to get a list of valid LANGUAGE-NAMEs:
(sort (mapcar (lambda (linfo) (car linfo)) language-info-alist) 'string<)
(Execute the command C:u before evaluating it with xe to import the result into the buffer)
Here is how to set it to Unicode:
(set-language-environment "UTF-8")
Is Unicode in the code taboo?
MzScheme supports UTF-8 encoded files. Combine that with DrScheme, which makes it pretty easy to type in Unicode symbols, and somewhat suddenly, and surprisingly, you have the opportunity to work with symbols in your code beyond the standard 95 character ASCII set that we all know and love. What are the implications to you as a programmer?
The simplest implication is that you now have the ability to work with 100,000+ characters. In case you felt limited by the inability to use the characters of your native tongue like Tamil or perhaps Braille, you are restricted no more. Scientific programmers may enjoy using Greek letters; and who of us wouldn’t like to use the letter π to represent Pi? For Schemers, perhaps you would use → rather than ->.
The common theme among these atypical examples is that they facilitate communication. Without getting into the deep theories and concepts behind the value of communication and how the limitations of a language affect it; I would share a quote relevant to us as programmers regarding how we communicate to each other with our code:
Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.
— Donald Knuth
It seems like Unicode might facilitate that communication, but Unicode in code today is not at all common. Why might that be?
The usual suspects are that our tooling (IDEs and text-processing tools) doesn’t support Unicode well. Perhaps that is the case, but I am had pressed to believe that if people thought it had any value they wouldn’t simply add support to their tooling for Unicode. Fonts seem to be the biggest practical issue; lack of a supporting font usually results in an ugly box in place of the character. In the end I suspect that the worst culprit here is simply that Unicode in the code is a taboo: people simply won’t give it a try until a thought leader or two sheds light on the power to facilitate communication that Unicode brings.
Until then, you will have to be happy with Emacs and DrScheme.
Software repository mining with Marmoset
Most computer science educators hold strong opinions about the “right” approach to teaching introductory level programming. Unfortunately, we have comparatively little hard evidence about the effectiveness of these various approaches because we generally lack the infrastructure to obtain sufficiently detailed data about novices’ programming habits.To gain insight into students’ programming habits, we developed Marmoset, a project snapshot and submission system. Like existing project submission systems, Marmoset allows students to submit versions of their projects to a central server, which automatically tests them and records the results. Unlike existing systems, Marmoset also collects finegrained code snapshots as students work on projects: each time a student saves her work, it is automatically committed to a CVS repository.We believe the data collected by Marmoset will be a rich source of insight about learning to program and software evolution in general. To validate the effectiveness of our tool, we performed an experiment which found a statistically significant correlation between warnings reported by a static analysis tool and failed unit tests.To make fine-grained code evolution data more useful, we present a data schema which allows a variety of useful queries to be more easily formulated and answered.
Here is the ACM portal page.
(via the PLT Discussion List)
Sugar – Release 8.2.0
Sugar is the UI portion of the Linux build that runs on the OLPC XO.
It is a radical departure from what we would call “typical” user interfaces in 2008; and it really took some “getting used to it”. With the release of 8.20, it looks like they have made some “user friendly” Sugar and a few other things, too:
- A nice looking User Manual
- Better Power Management
- Significant changes to the UI “to improve the user experience”.
It took guts to come up with Sugar, and perhaps even more to make these kinds of changes. As minimal as they seem, they are not insignificant.
Disclaimer: I have not yet tried out this build as my XO is currently out on loan.
(via OLPC News)