28 Feb 2010

DAGs vs Trees

posted by Robby Findler

As I wondering whether or not there is a better layout algorithm for the module browser window, I looked into tree maps. Of course, the modules in a program form a DAG, not a tree, so I wondered just how big the tree would get if all of the shared structure in the DAG were replicated. Hey, I figured, if a tree map can handle showing me my entire filesystem, maybe that could work.

… yeah, no. Turns out to be hopeless. In the spirit of a geeky take off on a jelly bean counting contest, lets see if you can guess just how big these things get. Consider the module graph from the program #lang scheme (ie, the graph that just contains an empty program). This program loads 170 modules with 917 connections between modules (counting the main file that just contains the #lang scheme).

So, the question: how many nodes are there in the unsharified tree? First one to come within 1 billion of the right answer gets all of the fame and glory that this blog brings to bear (har har). I’ll post the answer in the comments in a few days (and no fair cheating, those of you that know enough to be able to get your hands on the DAG).

more →

29 Jan 2010

Benchmarks

posted by Matthew Flatt

First, the usual disclaimer:

That said, I’ve run the latest version of PLT Scheme on two sets of benchmarks:

  • Benchmarks in the PLT sources – vs. Bigloo, Chicken, Gambit, Guile, Ikarus, Larceny, MIT Scheme, and Scheme48; safe operations and generic arithmetic only

  • Benchmarks in the Gambit sources – vs. Bigloo and Gambit; generic vs. fixnum-/flonum-specific arithmetic, safe vs. unsafe operationsThe second set is why I started running benchmarks. Fixnum-/flonum-specific arithmetic and unsafe operations are new in PLT Scheme 4.2.4. The benchmark results suggest that the new operations in PLT Scheme offer roughly the same performance benefits as in Bigloo and Gambit. There’s room for improvement, but it’s a good first cut.

For the other results: PLT Scheme is rarely the fastest implementation on a given benchmark. For most purposes, though, it’s in the same ballpark – except for programs that spend all their time capturing and invoking continuations.

It’s fun to run benchmarks occasionally. Now, back to working on language design, libraries, documentation, usability…

more →

28 Jan 2010

PLT Scheme v4.2.4

posted by Eli Barzilay

PLT Scheme version 4.2.4 is now available from http://plt-scheme.org/

  • The scheme/flonum and scheme/fixnum libraries provide flonum- and fixnum-specific operations. In the case of flonum-specific operations, the JIT compiler can recognize combinations of operations (including local bindings) and improve performance by “unboxing” intermediate results.
  • The scheme/unsafe/ops library provides arithmetic and other operations that are implemented without dynamic checks. Avoiding checks can sometimes improve performance, but at the expense of safety.
  • 2htdp/universe: We have severed the connection between universe and an image library and made a few other, minor changes. Most programs will now have to change to require the htdp/image library explicitly. For the full details, see the new Porting World Programs section of the documentation.
  • The 2htdp/image library continues to grow. In this release, it is supported by 2htdp/universe, equality changed to be based on how the images are drawn, cropping and curves were added, and support for more kinds of pens were added.
  • htdp/world: The old world teachpack remains deprecated. HtDP/2e exclusively uses the new 2htdp/universe library. For backwards compatibility, the world teachpack will remain in the distribution until the coming summer.
  • The scheme/class library now provides this%, which refers to the class of the current object (i.e. this).
  • scheme/generator has convenient functions for infinite generators, and for converting a generator to a sequence for iteration.
  • PLT Scheme’s add-on directory can be customized by the $PLTADDONDIR environment variable or --addon/-A command-line flags. This controls where downloaded Planet packages and their compiled Scribble documentation are installed.
  • Additional extensions include: saving errno in foreign calls, much improved sort speed, normalized results from procedure-arity, and more.
more →

02 Jan 2010

Scheme Videos (Lectures and Talks)

posted by John Clements

Scheme Videos (Lectures and Talks)(thanks to Geoffrey Knauth and Hari)Following a mailing-list request, it turns out that there are quite a lot of Scheme-related lectures and talks floating around out there in video format. The following list was compiled by Geoffrey Knauth, with contributions from Hari and Michael Sperber, and at least one insertion from me, right at the front.

  • My sequence of introductory videos on YouTube, recorded long after this post was made.

  • There’s the SICP course Abelson & Sussman gave to [HP, I think] in the mid–1980s: http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-lectures/

  • MIT OCW / 6.001 using SICP, Spring 2005: http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6–001Spring–2005/VideoLectures/index.htm

  • All the ICFP 2009 videos (man this made my day!!): http://vidiowiki.com/feature/list/fnu/ICFP_2009

  • Daniel P Friedman - A Celebration (this too!): http://www.cs.indiana.edu/dfried_celebration.html

  • DrScheme v4.0 Tour: http://www.youtube.com/watch?v=vgQO_kHl39g&fmt=18

  • Similar, if you understand Russian:

  • http://www.youtube.com/watch?v=wECY7s9k-V0

  • http://www.youtube.com/watch?v=2CVJjqOT6WM

  • Matthias Felleisen - Programming at Northeastern: http://www.savevid.com/video/matthias-felleisen-programming-at-northeastern-university.html

  • Matthew Flatt - Processes without Partitions: http://www.researchchannel.org/prog/displayevent.aspx?rID=3892

  • Shriram Krishnamurthi on WeScheme: http://vidiowiki.com/watch/cydr9yk/

  • Robby Findler - Macros Matter: http://www.mefeedia.com/video/26348171

  • Using PLT Scheme in the Game Industry: http://www.youtube.com/watch?v=2CVJjqOT6WM

  • Stanford Lecture (Kawa): http://www.youtube.com/watch?v=_cV8NWQCxnE

  • Bluetooth communication using PLT Scheme: http://www.youtube.com/watch?v=pmR_dIXm6sY

  • SICP at UCB: http://webcast.berkeley.edu/course_details.php?seriesid=1906978454
  • http://www.aduni.org/courses/sicp/ from ADUni by Holly Yanco. It comes with pretty good lecture notes and problem sets.

  • Michael Sperber’s DMdA lectures (in German, natch): http://timms.uni-tuebingen.de/List/List01.aspx?rpattern=UT_200[89]_____00[12]info1_000

more →

07 Dec 2009

Futures: Fine Grained Parallelism in PLT

posted by Robby Findler

We’re pleased to announce the initial release of parallel futures, a construct for fine-grained parallelism in PLT. Roughly speaking, a programmer passes a thunk to ‘future’ and it gets run in parallel. That “roughly” holds a few gotchas, partly because we’re just getting started and partly due to the technique we’re using. See the documentation for more details:

http://pre.plt-scheme.org/docs/html/futures/

If you’ve got a multicore machine where you can’t keep the cores busy or your office/machine room is a bit cold, try this program:

#lang scheme
(require scheme/future)
(define (loop) (loop))
(for-each
 touch
 (for/list ([i (in-range 0 (processor-count))])
  (future loop)))

Note that you have to build mzscheme with futures; it isn’t enabled by default, but see the docs above for how to do that. Beyond the above, we’ve also gotten a few parallel kernels going and are seeing good scalability up to 8 cores (the biggest machine we have around for the time being).

more →

01 Dec 2009

PLT Scheme v4.2.3

posted by Eli Barzilay

PLT Scheme version 4.2.3 is now available from http://plt-scheme.org/

  • The unit test framework for the teaching languages provides check-member-of and check-range for checking “random functions”, i.e., “functions” that may produce several different results for one and the same argument.

  • Added a new image library, 2htdp/image. Significant changes from htdp/image:

  • copying and pasting does not introduce jaggies

  • equal? comparisons are more efficient

  • added rotation & scaling

  • got rid of pinholes (new overlay, beside, above functions based on bounding boxes)

  • The scheme/vector library provides common vector operations (also reprovided by scheme).

  • The scheme/promise library provides several new kinds of promises with alternatives execution strategies.

  • New port-reading utilities: in-port, port->list, file->list.

  • A new require-macro, path-up, for requiring a file that is higher in the directory tree.

more →

04 Oct 2009

PLT Scheme v4.2.2

posted by Eli Barzilay

PLT Scheme version 4.2.2 is now available from http://plt-scheme.org/

  • DrScheme now, by default, compiles all of the files that are loaded when it runs a program and saves the compiled files in the filesystem. This should lead to faster load times (not faster runtimes) since it avoids re-compiling files whose dependencies have not changed.

  • New Scribble libraries and documentation make it easier to get started with Scribble, especially for uses other than PLT documentation. DrScheme now has better indentation and syntax coloring support for Scribble languages (and generally all @-exp based languages).

  • The new syntax/keyword library provides support for macros with keyword options. A new quick start guide has been added to the documentation for the syntax/parse library.

  • Added support for abstract contracts via the #:exists keywords. This is an experiment to add support for data hiding to the contract system.

  • Added in-producer: a sequence expression makes it easy to iterate over producer functions (e.g., read). A new scheme/generator library creates generators that can use a (parameterized) yield function.

  • HtDP langs: several primitives now consume 0 and 1 arguments in ISL (and up), including append, + and *. In addition, make-list was added to the primitives.

  • The API to Universe has a number of new constructs. All Universe programs should run unchanged. The most important change is the addition of animate as an alternative name for run-simulation. In addition, adding the clause (state true) to a world description now pretty-prints the state of the world into a separate canvas.

  • A number of changes were made to the DeinProgramm / DMdA language levels: The check-property and contract forms were added, define-record-procedures-parametric has changed. See the documentation for details.

  • The test engine in the HtDP languages no longer warns programmers when the Definitions window has no tests.

  • ProfessorJ (and related code) is no longer included in the PLT distributions. It may re-appear in the future as a PLaneT package.

more →

21 Sep 2009

set! vs. set-box! and unbox

posted by Robby Findler

A few weeks ago I was chatting with some PLT folks and was surprised to hear them say that they avoided set! because using set-box! and unbox was easier to see what was going on.

This struck me as wrong since one might pass boxes around and then you can’t be sure which box you’re mutating, but you cannot pass variable references around and thus which variable you’re using is always lexically apparent. (Of course, when you add lambda into the mix that isn’t really true, since you can capture a variable in a closure and pass that around.)

Their point seemed to be that you had to write something special at each use of the box, unlike with set! where you simply write a variable reference and it might be getting a changing quantity and it might not be. This made me realize I could do something to help, at least, and so I changed Check Syntax so that it colored set!’d variables in red, like this:

more →

30 Jul 2009

PLT Scheme v4.2.1

posted by Eli Barzilay

PLT Scheme version 4.2.1 is now available from http://plt-scheme.org/

  • This is the last release that includes ProfessorJ. As of the next release, Kathy Gray who created and maintained the Professor will move the code to planet and maintain only at a minimal level.
  • Typed Scheme 2.0 extends the type system significantly, making it more expressive. For example, predicates applied to selectors, such as (number? (car x)), are meaningful to the type system.
  • Faster installation of Planet packages that trigger install of other Planet packages, because the documentation index is updated only once after a group of packages is installed.
  • The syntax/parse library provides macro writers with an enhanced syntax pattern matcher that reports errors based on the patterns’ declared classes of syntax.
  • Identifier mappings following the v4 dictionary interface and naming conventions are available from the syntax/id-table library.
  • Redex: added define-relation and generalized patterns that appear in “where” clauses to use the full Redex pattern matcher. (This is a backwards incompatible change, but one often requested; see the Redex release notes for details.)
  • The Web Server’s serializable closures are now available for other purposes through the web-server/lang/serial-lambda library.
  • Teachpacks: small changes to universe portion of the “universe.ss” API, plus the addition of a form for launching many (communicating) worlds simultaneously. Bug fixes concerning conversion to strings.
  • It is now possible to create custom scribble readers with a command characters different than @, see make-at-reader/inside and make-at-reader
  • Note: this is likely to be the last release that includes a solaris distribution. If you need these builds, or if you have access to a (Sparc) Solaris machine than can be used in PLT builds, then please let me know.
more →

23 Jun 2009

Serializable Closures in PLT Scheme

posted by Jay McCarthy

PLT Scheme supports an extensible serialization system for structures. A structure is serializable if it has a prop:serializable property. There are many properties in PLT Scheme for other extensions, such as applicable structures and custom equality predicates.

The PLT Web application development framework uses these features to provide serializable continuations through a number of source transformations and a serializable closure structure.

Warning: This remainder post refers to features only available in the latest SVN revision of PLT Scheme.

I’ve recently made these closures more accessible to non-Web programs through web-server/lang/serial-lambda. Here’s a demo:

#lang scheme
(require web-server/lang/serial-lambda
         scheme/serialize)

(define f
  (let ([z 5])
    (serial-lambda
     (x y)
     (+ x y z))))

(define (test-it)
  (printf "~S~n" (f 1 2))
  (let ([fs (serialize f)])
    (printf "~S~n" fs)
    (let ([df (deserialize fs)])
      (printf "~S~n" df)
      (printf "~S~n" (df 1 2)))))

> (test-it)
8
((2) 1 ((#"/Users/jay/Dev/svn/plt/collects/web-server/exp/test-serial.ss" . "lifted.6")) 0 () () (0 5))
#(struct:7a410aca70b31e88b4c2f0fe77fa7ffe:0 #)
8

Now, let’s see how it is implemented. web-server/lang/serial-lambda is thin wrapper around web-server/lang/closure, which has two syntax transformer functions: define-closure! which defines the closure structure and make-closure which instantiates the closure. (The two tasks are separated to easily provide a user top-level definition syntax for named closures with different free identifires, rather than simply anonymous lambdas with fixed free identifiers.)

make-closure does the following:

  1. Expands the procedure syntax using local-expand, so it can use free-vars to compute the free identifires.

  2. Uses define-closure! to define the structure and get the name for the constructor.

  3. Instantiates the closure with the current values of the free identifiers.

The more interesting work is done by define-closure!. At a high-level, it needs to do the following:

  1. Create a deserialization function.

  2. Create a serialization function that references the deserializer.

  3. Define the closure structure type that references the serializer.

  4. Provide the deserializer from the current module so that arbitrary code can deserialize instances of this closure type.

These tasks are complicated in a few ways:

  • The deserializer needs the closure structure type definition to create instances and the serializer needs the closure structure type to access their fields.

  • The serializer needs the syntactic identifier of the deserializer so that scheme/serialize can dynamic-require it during deserialization.

  • The deserializer must be defined at the top-level, so it may be provided.

  • All this may occur in a syntactic expression context.

Thankfully, the PLT Scheme macro system is powerful to support all this.

The only complicated piece is allowing the deserializer and serializer to refer to the closure structure constructor and accessors. This is easily accomplished by first defining lifting boxes that will hold these values and initializing them when the structure type is defined. This is safe because all accesses to the boxes are under lambdas that are guaranteed not to be run before the structure type is defined.

An aside on the closure representation. The closure is represented as a structure with one field: the environment. The environment is represented as a thunk that returns n values, one for each of the free identifiers. This ensures that references that were under lambdas in the original syntax, remain under lambdas in the closure construction, so the serializable closures work correctly inside letrec. This thunk is applied by the serializer and the free values are stored in a vector. The closure also uses the prop:procedure structure property to provide an application function that simply invokes the environment thunk and binds its names, then applys the original procedure syntax to the arguments.

An aside on the serializer. The deserializer is bound to lifted identifier which is represented in PLT Scheme as an unreadable symbol. Version 4.2.0.5 added support for (de)serializing these.

more →

Made with Frog, a static-blog generator written in Racket.
Source code for this blog.