Grace Workshop Lancaster – Saturday 30 July

The next Grace Workshop will take place on Saturday 30 July, after the ECOOP 2011 conference.

The Workshop will be held at Lancaster University, in the Computer Science Department (Infolab21 building) in room C60a. Here is a map of the campus (Infolab21 is building 62 on South Drive).

We’ll aim to start around 10am.

These workshops are to report progress on the design, to discuss challenges, and hopefully to involve others in the project. At this workshop, we also hope to show some very early prototypes that we are building to test the specification.

So, if you’re interested, and are able to come to this workshop, please let us know by emailing James, kjx@ecs.vuw.ac.nz so we have some idea who’s coming.

Object Independence Day

We hold these truths to be self-evident, that all objects are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are sole access to their internal representation

An object-oriented language should provide encapsulation: an object should be able to protect its representation from unwanted external access. Programming languages provide a wide range of different encapsulation mechanisms: statically and dynamically checked; encapsulating names or objects; encapsulating within objects, or within classes, or within modules…

Grace will have a module system to support separate development and compilation: to manage coupling between different development units. The design is yet to be finalised (Ok, yet to be started) – but we are thinking along similar lines to Newspeak, gBeta, J&t or Ceylon in that it will be based on classes nested within objects.

But this large-scale encapsulation, within compilation units, doesn’t really address the key independence of objects in object-orientation: that each object should be independent, having sole access to its own internal representation. Now many object-oriented languages don’t in fact support this either. C++, C#, and Java have private and protected modifiers: but these restrict access within classes not objects: an instance of one class may access private or protected fields of any other instance of the same class — and for protected, of any subclasses as well.

For this reason, like Smalltalk, Ruby, and other languages, Grace will provide object-level encapsulation. Encapsulated names – methods and fields – will only be accessible from within the same object — i.e. by method requests on self. Again like Smalltalk and Ruby, encapsulation in Grace can depend on types (or classes) but not on static types or classes: we don’t want programmers to e.g. remove static types from their code just to get around encapsulation!

But there are a number of different options even within this design:

  • private modifier – marks encapsulated attributes; no modifier means no encapsulation
  • public or shared modifier – marks unencapsulated attributes; no modifier means no access except through self
  • textual rules for encapsulation. In Go for example, names beginning with a Capital letter are public, names beginning with a lower-case letter are private. This convention is used throughout .Net programs – but so far we’ve been using a methods-as-lowercase convention, common in Java, Smalltalk, etc. This kind of implicit coding doesn’t work for code in non-Western alphabets that don’t distinguish between upper/lower case
  • “reverse” textual rules – lower case is public, Upper Case is Private. At least this would work better with the Java convention – but that seems to be all it has going for it.
  • sigils – use a non-alphabetic character to start all (encapsulated) identifiers. For example, any private const, var, or method must begin with an underscore (self._myStuff) — identifiers without underscores are public

There are only a few differences between these options: should the default be accessible (easier for novices to get started) or encapsulated (easier to learn good habits). Encoding encapsulation into the names (as in the last three options) makes their relationship with inheritance clearer, but changing visibility means changing names. On the other hand, modifiers on attributes decouples encapsulation status from the text of the name, but requires modifier-consistency rules across inheritance.

We’re in the process of working our way through these options (or at least thinking about them every so often). We’ll hope to have a decision by the time of the next Grace workshop (30 July, in Lancaster, after ECOOP).

If anyone has any random opinions (or even considered thoughts) on this, we’d love to hear them.

Talk on Grace at Microsoft Research

After the Grace workshop, James went up to Seattle and talked about Grace to the Research in Software Engineering group at Microsoft Research.

They’re working on a range of cool programming tools, from TouchStudio (simple programming on a Windows phone) to the big range of tools at http://rise4fun.com/.

Microsoft record most of their talks, and make them available on the web. The video and audio of James’s talk is here in various formats. The talk gives are reasonably high level overview of Grace. Be aware that the handwaving doesn’t really stop, but it certainly decreases in intensity after about the first twenty minutes! There are some good questions from people at the end.

Thanks to Manuel Fandrich & Rustan Leino for hosting James at Microsoft.

Saturday’s Grace Workshop

Saturday’s Grace Workshop made some good progress – closing some open issues, and making a good start for the next stage of the language design.

The main issues we resolved were:

  • Selecting a design for pattern matching based on blocks (aka “lambda-matching” )
  • No shadowing of names by lexically nested names
  • No nested methods, that is, no methods inside methods without an intervening object

For matching, we will need to finalise the details, both of the pattern syntax, and the underlying protocol. But with Scala, Newspeak, and F# as examples here we hope this will be mostly straightforward.

The next stage of the language design must tackle the really big issues:

  • Nested objects & classes? (like gBeta? Newspeak?)
  • Structural vs nominal type systems
  • Integration of statically and dynamically typed code (like C#? Typed Racket?)
  • Module system — (like LOOJ? or Newspeak?)
  • Relationship between language design and programming environment design

We’ve started discussions on all of these topics: but will have some way to go before we’re done.

Thanks again to all who came: Dave Ungar, Erik Ernst, Gilad Bracha, Jan-Willem Maessen. We really appreciate appreciate all the thoughts, feedback, suggestions, and that you’ve taken time to come and think about Grace.

Grace specification 0.1

The Grace language specification v0.1 is now available.

Most of the changes since 0.095 are minor/detail changes. Our goal for 0.1 was to focus on the sequential core and object model: we think we’ve done that, although especially the details of inheritance and pattern matching mechanisms remain to be worked out. Our plan now is to work towards 0.2 hopefully around the end of July, making progress on types/modules/encapsulation – we hope the workshop tomorrow will help us to plan the next phase of the project.

As ever, we’d very much appreciate comments on what is in the spec, what isn’t in the spec, and what we might do next.