building programming languages from components l.
Skip this Video
Loading SlideShow in 5 Seconds..
Building programming languages from components PowerPoint Presentation
Download Presentation
Building programming languages from components

Loading in 2 Seconds...

play fullscreen
1 / 17

Building programming languages from components - PowerPoint PPT Presentation

  • Uploaded on

Building programming languages from components. Simon Dobson Introduction. Changing contexts for computer science systems distributed at Internet scales - security, robustness, ... component-based software engineering

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Building programming languages from components' - alijah

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
building programming languages from components

Building programming languages from components


  • Changing contexts for computer science
    • systems distributed at Internet scales - security, robustness, ...
    • component-based software engineering
  • Challenges for programming languages
    • new constructs, new applications
    • changing programmer demographics
  • Can see languages themselves as component systems
    • rapid experimentation
    • domain-specific languages made easy
  • My aim: to tell you about some work we’ve been doing in this area

Programming languages from components - 2

language challenges
Language challenges
  • Need to experiment with languages quickly
    • language - programming in the huge, composition operators, how known features mutate in new circumstances
    • trust management - security, authentication, webs of trust
    • tools - component repositories, code selection
    • the balance between control and expressiveness
  • A compiler is a big piece of kit
    • typically much bigger than the average program written using it
    • hard to get source, hard to understand once you’ve got it
    • barrier to entry into language design too high for many

Programming languages from components - 3

a language as a component system
A language as a component system
  • Many (most?) language features are orthogonal
    • don’t need to know exactly what expressions are available to describe a sequential composition of them
    • substantial independent re-factoring of features

auto Int with [| 1, 2, 3 |]

(fun( Int n ) n + 1)(11)



The details of the sub-features aren’t really important in defining the feature itself

exp1 ; exp2

  • Features tend to be compositional: they often work by combining sub-expressions without inspecting them

Programming languages from components - 4

what does this mean
What does this mean?
  • A language is a composition of features
    • typing and behaviour - and syntax too, to an extent
  • Specify the features independently, and compose
    • there will be some dependencies…
    • …but a lot more independence
  • Effects
    • re-use - leverage feature independence
    • easy experimentation - just a composition exercise
    • extensibility - present features as syntax, or libraries, or hidden
    • targeting - exactly the features you want, how you want them
    • performance - generality brings overheads
    • complexity - dependencies, novel approach

Programming languages from components - 5

  • We’ve been developing an experimental language design system called Vanilla
    • build interpreters from language fragments (“pods”)
    • re-use existing fragments
    • incrementally construct language tools
  • Standard pods cover a large sub-set of the language design space
    • imperative, functional, “typeful”, object-oriented
    • 100% pure Java
  • The idea is to be able to experiment with (and deploy) new language variants quickly and easily

Programming languages from components - 6

vanilla architecture

A framework with core algorithms running over a set of components providing the actual functionality





Type checker

Record attributes derived from typing for use at run-time



Programming languages from components - 7

component phases




Component phases

Phase walks the AST

Components express an interest in the different node types

Try each interested component until one succeeds, one fails, or all decline to commit themselves

Having several interested components overloads the abstract syntax

Some interesting generalisations - e.g. functions taking types, the “dot” operator, ...


Programming languages from components - 8

component phase interactions
Component/phase interactions

interface TypeChecker { public Type typeCheck( ASTExpression x, TypeEnvironment tc, Context c ) throws TypeException; public Type parseType( ASTType x, TypeEnvironment tc, Context c ) throws TypeException;}

Recursive calls from components access the complete phase

Overall component-based phase walks the AST and calls components interested in each AST node type encountered

Programming languages from components - 9

what s in a pod
What’s in a pod


ALL(X <: T) X

Concrete syntax to abstract syntax

fun(X <: T) …


new UniversalType(…)

Abstract syntax to type


Behaviour may depend on attributes derived from type-checking

Abstract syntax to behaviour


new IClosure(…)

Programming languages from components - 10

some standard pods
Some standard pods
  • Core
    • ground types, simple constructed types, control structures, ...
  • Functions
    • higher-order closures with currying
  • Bounded universals
    • C++ templates
  • Automorphic values
    • dynamic typing
  • -recursive types
    • simple self-references
  • Objects and classes
    • based on Abadi and Cardelli object calculi with covariant self types

The basis for functional programming - no type inference as yet

Used for Java/CORBA object types, too

Programming languages from components - 11

the vanilla toolset
The Vanilla toolset
  • Framework
    • a component architecture for language tools
  • Pods
    • implement a single language feature - and only that feature
    • try to work uniformly across sub-expressions (e.g. don’t manipulate them operationally, just evaluate them appropriately)
  • Tools
    • batch and interactive interpreters
    • parser component generator - generates composable fragments of recursive-descent parsers from JavaCC-like grammar files
    • pod compilers - combine components together into a single class, eliminating run-time class loading
  • Samples - an implementation of the O-2 language

Programming languages from components - 12

  • A language, in Vanilla terms, is just a set of pods composed together within the framework
    • language definition files list the classes

Grammar fragment

Typing and sub-typing

// core pod







Default initial values

  • Tools instanciate classes into the framework
    • …and this is component-based too, of course…
  • Once loaded, behaves like a “normal” interpreter

Programming languages from components - 13

pod re use
Pod re-use
  • Pod usage
    • add/change a pod in a language without re-writing the whole thing
    • change a component of a pod, without changing the others
  • Same pods in several languages or variants
    • e.g. implement all Pascal and a lot of Java using the standard pods

FOR i := 1 TO 10 DO j := j + f(i)END;

for(i = 1; i < 11; i = i + 1) j = j + f(i);



Basically we just eliminate some of the possibilities syntactically




Programming languages from components - 14


Must have

  • Why do we name the super-class of a class?
    • just need to know the (minimal) type of possible super-classes
  • Ions
    • “class with a free super-class” (function over classes)
    • bind to a real super-class before instanciating
    • just change the pod implementing classes - nowhere else

Apply the same functionality to a family of legal super-classes

Reify ion with a particular super-class before instanciating the resulting class

Don’t over-commit to the super-class

Programming languages from components - 15

client side corba integration
Client-side CORBA integration

Import IDL definitions directly off the web - no stub compiler

import idl "";

Random r = bind(Random, ior "");

Int i;

Sequence(Int) rs = for(i = 0; i < 10; i = i + 1)


Binding builds a DII-based stub

Call the stub like any other method

IDL maps to Vanilla types through a component-based mapping

Programming languages from components - 16

  • As long as we program, we’ll need new language variants
    • composition, security, trust management
    • high-level, domain-specific
  • Vanilla provides an infrastructure for experimentation
    • define language features as fragments, and compose
    • lots of standard pods to re-use
    • experiment quickly across the spectrum of language design
  • Vanilla is open source, and on the web at

Programming languages from components - 17