Grace events at SPLASH

We’re now planning the next Grace workshop(s) in Portland Oregon in conjunction with the SPLASH conference. Based on the successful ECOOP workshops, at this stage we’re thinking of holding:

  • a BOF on Monday Oct 24 in the evening — after the Educators’ Symposium, the Dynamic Languages’ Symposium, PLOP, and the workshops (including Plateau & FOOL) which are on Sunday and Monday. All three of us will be there for a general report-back on the project to date.
  • a Design Workshop on Friday Oct 28th (the day after the conference) working over open questions in the design in detail (probably the module & type systems). This will be held at Portland State University, an easy tram ride from the conference venue & hotels. We expect some people would stay only for the morning, others till mid-afternoon.

We’d love to see as many of you as possible at the BOF and at design
workshop. If you’re able to come, please let us know by emailing
James, kjx@ecs.vuw.ac.nz, so we have some idea who’s coming.

Alternatively, if there is are reasons why the proposed dates don’t
work — but other dates might — again let us know!

Andrew & James will be around for all SPLASH, so we’ll also be able to catch up then. We’ll probably arrange to go out for dinner on the Thursday evening after the conference (before the Friday workshop), and we can probably organise another BOF during the conference if many people can attend neither Monday nor Friday.

We look forward to catching up with everyone at SPLASH/OOPSLA this year, and hope may of you will be able to come to the BOF and the workshop.

cheers

Andrew & Kim & James

From Lancaster to Portland

So this is a belated message about the Grace meetings in Lancaster. Early during the week (Tuesday evening) we held a BOF – mostly hosted by Kim – with a good group of people attending to hear about Grace. There were good discussions and questions, mostly about where we plan to go next. I wish I could have stayed for the whole thing!

Then on the Saturday, after the conference – while most people were heading home – Gary Leavens (University of Central Florida), Erik Ernst & Johan Winther (Aarhus Universitet), and Kim & James met for a “good, intense, and productive” time to talk over the next stages in the design – primarily the type system. Main choices so far include:

  • A primarily gradual, parametric, structural type system
  • Classes, Types, and Methods may all take generic parameters
  • Generic types written as Array[T], following Eiffel and Ada.
  • Constraints on type parameters expressed via where clauses, following CLU & C#
  • Explicit union types e.g. (ListNode[T] | None) designed to work well with Grace’s pattern matching. These are inspired more directly by ML-style languages (& Ceylon) as an alternative to Scala’s case classes; although (as in general in Grace) they will remain primarily structural types
  • No need for variance annotations — an ad-hoc structural interface can always be defined where necessary
  • MyType and exact types at the top language level

Over the next few weeks – now we’re over the jetlag! – we hope to post on more details of this design, and eventually a 0.2 version of the language spec.


And although we’re just back from Lancaster, we also need to look forwards to the next time we’ll meet about Grace, which we’re planning at the SPLASH conference in Portland (Oregon) at the end of October. Our current thoughts are a general BOF early in the week (perhaps Monday evening) with a day-long design working session perhaps the Friday after the main conference ends.

We still have a little time to confirm these plans – if you’re thinking about going to SPLASH, we’d love to hear from you, so let us know when you’d be able to come along.

Grace @ ECOOP today

We have arranged for a room for a Grace presentation/discussion at ECOOP tonight at 5:15 p.m. Please come to George Fox lecture theater 5/6 for the presentation. We will go out to dinner somewhere after the session (suggestions on where to go are welcome).

If you would like to learn more about Grace but cannot come to that session, please contact Kim or James at the meetings this week and we will make time to meet with you.

We are anxious for feedback on our language design, so please come if you can.

The Grace workshop to work through details of the language design — particularly regarding types vs classes remains on Saturday, for people staying longer.

Types vs Classes

Like many object-oriented languages, Grace will have classes. Like some object-oriented languages, Grace will have types. Like a few
object-oriented languages, Grace programmers have the option to ignore classes and use only objects, or to ignore static types and use only dynamic types.

The relationships between objects and classes, and static and dynamic types, are well known. So, then, what’s the relationship between
classes and types in Grace? Or rather, what should be the relationship between classes and (static types?

Here’s the problem. Let’s take a simple Grace class:

This class creates a factory object that supports the creation of new Cat instances in response to the method request “new(aColour,aName)” (cognoscenti will notice we’re trying “def x =” syntax to define constants rather than “const x :=”. Sorry Niklaus).

What type does the variable “fergus” have? As in C#, local type inference gives it whatever type the “Cat.new” method returns. What if we want to declare that type explicitly, say for a variable?

Here the name “Cat” is being used as a type, rather than a factory. The key question is: where did that type come from? There seem to be two options in the design here:

  1. The Cat class declaration implicitly creates a Cat type.
  2. The Cat type must be declared explicitly, separate from the class
    declaration:

The first option, a class implicitly creating a type, is what most typed object-oriented languaes do: a class declaration also creates a type (technically the cone type rooted at the class). Implicit class-types lead to more concise programs, and allow “static typing early” courses to have students write and use their own classes without requiring an explicit concept or separate declaration of a static type.

On the other hand, the second option, explicit type declarations, make static types much more explicit. Under this option, Grace programmers couldn’t declare an explicitly typed variable (or more likely, any method, as method arguments are not inferred) without an explicit declaration of the Cat type. But this clarity comes at a price: simple programs are longer, requiring apparently redundant type declarations, declarations that are close to class declarations, but duplicated some information with some mandatory tweaks.

Grace programmers can avoid the price of a separate declaration in a couple of ways. First they can use dynamic types or local type inference — omitting types from variable and constant definitions will find types via local inference (if the type-checker is run) while omitting types from method arguments and results are interpreted as type dynamic. So the costs of declarations (presumably) would only be required whenever a type is to be written explicitly. Still, this is another case where a ”better” program (with explicit types) is longer and more redundant than a ”worse” program (without them). Most Grace programmers may choose to omit the declarations, so the language would fall into being dynamically typed by default.

In fact, the real situation is worse than this: there are about five or six kinds of “class-like” or “type-like” objects in Grace: a good solution here should address all these roles:

  • ”’Factory”’ object that creates new instances of a class

  • ”’Type”’ with which variables, arguments, and methods are declared

  • ”’Reified Type Parameter”’ Since Grace will have “reified”
    generics, what value or object should the reified value be?

    Note that inside the Collection, the reified type argument will have to be bound to the formal type parameter.

  • ”’Pattern”’ object used to match objects of that type in
    match/case statements

  • ”’Mirrors”’ used to reflect on instances of the class

If these are played by different objects — how many different namespaces will Grace need to name them all? If they are accessible in a shared namespace, how are names resolved?

Finally, following C#, Grace will provide constructs to reify the declared static type of an expression (perhaps “decltype(e)”) and the exact dynamic type of an object (“o.dyntype”, or perhaps alternatively “reflect(o).dyntype” via a mirror). The aim here is to let programmers write programs that interrogate the static and dynamic types in their programs. And, whatever the relationship we end up with, do we need better names for static type and dynamic type?

Learning Edge Momentum

Like many computer science or software engineering departments, at VUW we seem cursed with a “bimodal” distribution of marks in first year programming courses. While some students do very well and collect A or A+ grades, about as many do very poorly, taking away only Ds and Es — and with relatively few students in the
middle. This profile is very different from most other courses at the university — and generally from our second and third year courses — which have much more normal distributions.

A number of hypotheses have been proposed for the bimodal distribution — most commonly, that a large proportion of the population are congenitally unable to learn programming, and that our advertising fails to dissuade them from enrollment.

Recently, Anthony Robins, a colleague from Otago University in NZ (the southern-most university in the world, and oldest university in the NZ) has developed a novel rationale to explain these distributions. His paper, “Learning Edge Momentum” , hypothesizes that introductory programming is unlike many other disciplines, in particular, that “success in acquiring one concept makes learning other closely linked concepts easier (whereas failure makes it harder).”

What’s this to do with Grace? Well, one of our main aims in the design of Grace is to reduce the accidental difficulties of learning to program. In Robins’ terms, I think this could be described as “uncoupling the concepts” within the language — partly removing concepts, but mostly trying to make concepts less
closely linked.

Here’s a simple example. In Java 1.0:

To me, this needs a whole collection of tightly-linked concepts:

  • For loop
  • Integers, and “int” type
  • Variables and assignment
  • Length of a collection and that “col.length()” gets the length
  • Less than, and that “< " is less-than
  • ++ increment operator…
  • “col.at(i)” to get i’th member of a collection.
  • System.out.println to print things.

But the “new for loop” in Java 5.0 needs far fewer concepts:

In particular:

  • For loop
  • Variable declaration
  • System.out.println to print things.

Hopefully Grace’s “for” loop:

will be closer to the Java 5.0 loop rather than Java 1.0!

I look forwards to seeing how Robin’s hypothesis is developed and tested over time. I also look forwards to see how much we can ensure a clear and loosely coupled conceptual model under Grace.