BYU - Spring 2013 - CS 630 - 6/6 -Discussion

2 views
Skip to first unread message

Matthew Ashcraft

unread,
Jun 7, 2013, 5:13:53 PM6/7/13
to byu-cs-630-spring-2013

Languages as Libraries

As virtual machines and tools have become more prominent in the programming language space, programmers have sought to use these to test new language features. JVM and .Net are just a couple of the platforms that programmers have tried to add on to. Unfortunately for these, extending or testing out new language features requires extensive changes throughout the entire JVM or .Net. A couple of the other languages we discussed were Clojure and Scala. All I got out of that was Clojure claims to be a language for parallel computing, when all it really offers is a parallel for loop. We then briefly talked about Steele who is the founder of Scheme and Java. I don't think I had ever heard of him before.

The Racket community has developed over two dozen frequently used languages. The paper was written using Scibble, a Racket language that acts as a writing tool. One of the Racket features that the work we discussed was dependent on was syntax properties. These syntax properties can hold info on syntax objects, which can later be looked up like a dictionary. Additionally we briefly discussed the syntax property coy, which copies syntax properties from the input to output of macros and functions without changing the properties. Without the syntax property copy the syntax properties would be re-written be every time they are passed through the macro. The #' changes the property location when it is used, contrary to the desire of Typed Racket. As a solution to this problem syntax-loc preforms the same operations as #' except it doesn't change the source location property. It was also mentioned that for typed languages it is important for macros to be able to de-sugar their bodies.

We next moved onto module systems, and the two aspects that are critical to the Typed Racket language. The first is the ability to export static and value bindings. Secondly, each module is compiled with a fresh store. The language L library is also used in Typed Racket, and was briefly mentioned during the discussion. Another important feature of Racket is the module-begin macro. This macro is automatically introduced by Racket, and acts as a wrapper around each macro. The main benefits of Typed Racket are it enriches modules and provides communication between typed and untyped Racket. Typed Racket uses syntax-parse to perform automatic optimization. It uses boxes to perform some of these optimization. The boxes are the most primitive mutable function, which consists of data-structures with one mutable field. As part of the optimization, all of the variables that are not used are placed within boxes. Additionally the point was made that everything in Typed Racket is a pointer. A small tangent was made at this point to talk about types in Java. The example was given that in Java adding a triangle to an array of circles is not allowed, but adding anything that is part of the super-class of the circle is allowed. We then discussed the difference between the fx plus and the unsafe fx plus. I honestly don't remember the details of this part of the discussion.

We then got back to talking about Typed Racket. Typed Racket users want all of the features that have been created for Racket. At the lowest level of these macro languages everything is the same type. This is important because as macros and functions are replaced with primitive language features it is easier to preform type matching. The type information is recorded in a phase data-base, which is populated by the module-begin macro. Another change Typed Racket has made is they have redefined the module-begin to populate the phase data-base. We then discussed some more of the optimization that can be provided by Typed Racket. One of the main optimizations that can be performed by Typed Racket is tag checking. Tag checking checks that all tags are boxed, and removes unneeded ones. This technically can offer improvements of up to 30%, though reaching that large of an improvement is highly unlikely. Another addition they made was interfaces for all untyped functions and macros that are accessed using the required-type. At this point in the discussion, the distinction was made between formals and arguments. Formals are the names of the arguments from inside macros, where as arguments are what are passed into the macros from the outside. Because of many of these changes, Typed Racket is not an extensible language. These changes also make it difficult to scale Typed Racket, though it has been done. Some of the issues they ran into were mutual recursion and complex definitions. As part of a solution to the first issue, Typed Racket must incorporate the type environment into the programs. Regarding their working Type Racket program, it was mentioned that Typed Racket must finish all of its work before it passes anything onto the underlying core Racket language. The amazing part about all of this is that Typed Racket is simply a library that can be used by the Racket language. This is exactly the proof that this paper set out to prove, that Racket is the ideal language for implementing new languages. Additionally they showed that Racket contains complex language features that can provide most of the things needed to create new languages. After all of this we talked about the results section, which basically compared Racket and Typed Racket to a bunch of research languages. This obviously was not very useful. It wasn't until the end of the discussion that I really came to understand the big picture. Racket truly is a powerful language that provides the ability to easily expand what currently exists into any desired language.

A few quesitons came up in writing this summary of topics from the discussion that I don't remember well enough: What are the tags for? Does every variable have a box assigned to it, or just those variable that are not used? Does the original Racket use any type of database to store information on the macros, or is that just for the assistance of typed macros?


Jay McCarthy

unread,
Jun 7, 2013, 5:15:43 PM6/7/13
to Matthew Ashcraft, byu-cs-630-spring-2013
For the GC to know how to look at the bytes of an object in memory

> Does
> every variable have a box assigned to it, or just those variable that are
> not used?

Every variable is boxed if it "escapes" its context, which is very common

> Does the original Racket use any type of database to store
> information on the macros, or is that just for the assistance of typed
> macros?

It does not.

Jay


--
Jay McCarthy <j...@cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93
Reply all
Reply to author
Forward
0 new messages