Type Oriented Programming Concept

From Mesham
Jump to navigationJump to search

Type Oriented Programming

Much work has been done investigating programming paradigms. Common paradigms include imperative, functional, object oriented and aspect oriented. However, we have developed the idea of type oriented programming. Taking the familiar concept of a type we have associated in depth runtime semantics with such, so that the behaviour of variable usage (i.e. access and assignment) can be determined by analysing the specific type. In many languages there is the requirement to combine a number of attributes with a variable, to this end we allow for the programmer to combine types together to form a supertype (type chain.)

Type Chains

A type chain is a collection of types, combined together by the programmer. It is this type chain that will determine the behaviour of a specific variable. Precidence in the type chain is from right to left (i.e. the last added type will override behaviour of previously added types.) This precidence allows for the programmer to add additonal information, either perminantly or for a specific expression, as the code progresses.

Type Variables

Type variables are an interesting concept. Similar to normal program variables they are declared to hold a type chain. Throughout program execution they can be dealt with like normal program variables and can be checked via conditionals, assigned and modified.

Advantages of the Approach

There are a number of advantages to type oriented programming

  • Efficiency - The rich amount of information allows the compiler to perform much static analysis and optimisation resulting in increased efficiency.
  • Simplicity - By providing a clean type library the programmer can use well documented types to control many aspects of their code.
  • Simpler language - By taking the majority of the language complexity away and placing it into a loosely coupled type library, the language is simplier from a design and implementation (compiler's) point of view. Adding numerous language keywords often results in a brittle design, using type oriented programming this is avoided
  • Maintainability - By changing the type one can have considerable effect on the semantics of code, by abstracting the programmer away this makes the code simpler, more flexible and easier to maintain.

Why use it in HPC

Current parallel languages all suffer from the simplicity vs efficiency compromise. By abstracting the programmer away from the low level details gives them a simple to use language, yet the high level of information provided to the compiler allows for much analysis to be performed during the compilation phase. From low level languages (such as C) it is difficult for the compiler to understand how the programmer is using parallelism, hence the optimisation of such code is limited.

We provide the programmer with the choice between explicit and implicit programming - they can rely on the inbuild, safe, language defaults or alternatively use additional types to elicit more control (and performance.) Therefore the language is acceptable to both the novice and expert parallel programmer.

Other uses

  • GUI Programming - GUI programming can be quite tiresome and repetative (hence the use of graphical design IDEs.) By using types this would abstract the programmer from many of the repetative issues.
  • Retrofit Existing Languages - The type approach could be applied to existing languages where a retrofit could be undertaken, keeping the programmer in their comfort zone but also giving them the power of type oriented programming.
  • Numerous Type Systems - The type system is completely separate from the actual language, it would be possible to provide a number of type systems for a single language, such as a parallel system, a sequential system etc...