Title: Matthias Ladkau
1A Type Transformation System for Legacy
Applications
Matthias Ladkau
STRL Seminar
2Overview
- Introduction to type systems
- Why introduce types to Legacy Applications ?
- Disadvantages of types
- Properties of type systems
- The approach
- Discussion
3Introduction to type systems
- Assigning datatypes ("typing") gives meaning to
collections of bits - A type system stipulates the ways typed programs
may behave and makes behavior outside these rules
illegal
In computer science, a type system defines how a
programming language classifies values and
variables into types, how it can manipulate those
types and how they interact. From Wikipedia, the
free encyclopedia
4Why introduce types to Legacy Applications ?
- Types assist in the comprehension of legacy
systems - The introduction of a type system will bring a
program to a more defined level - A type system helps to exclude some errors during
runtime
5Why introduce types to Legacy Applications ?
- A type system increases the efficiency of a
program - Type systems help to improve the security of a
system - Programs written in different languages can
interact much more easily if they have well
defined data types and interfaces.
6Disadvantages of types ?
- Loss of Flexibility
- Difficult when working with reflection or code
generation during runtime - Increases lines of code
7Properties of type systems
8Static type checking
- Favoured in compiled languages
- All type checks are done during compiling time
- Can only check if the data processing is right
but not the data itself - Results in compiled code that executes more
quickly.
9Dynamic type checking
- Appears more often in interpreted languages
- Allows more kinds of code constructs (e.g. eval
functions which executes arbitrary data as
code). - Shortens the edit-compile-test-debug cycle
- Makes metaprogramming more powerful and easier to
use
10Strong / Weak typing
- A strongly typed language doesnt allow an
operation to succeed on arguments which have the
wrong type.
y 29 Result in C
int x 5, y float c 24.6 y x c Example
java.lang.Error Unresolved compilation
problems Type mismatch cannot convert from
float to int Result in Java
11Safe / Unsafe typing
- A language is type-safe if it does not allow
operations or conversions which lead to erronous
conditions
var x 5 var y "hi" var z x y Example
in Visual Basic
int x 5 char y "hi" char z x
y Example in C
z 5hi Result in Visual Basic
z Result in C
12Equational theories
- A type system has always an own definition of
equality - Two extreme cases are
- Nominative type systemsTypes must have the same
name in order to be equal.(e.g. Java, C,
Fortran) - Structural type systemsTypes must have the same
structure in order to be equal.(e.g. Haskell,
Lisp) - A special form of dynamic typing is duck typing
where the language guesses which type is meant
(e.g. Perl, Python, Ruby, Smalltalk)
13The approach
Transformation
Translation
WSL
P1
P2
Type System 3
Type System 1
Type System 3
Type System 2
Source Code
Type System 1
14The approach
WSL type safety
Transformation
Translation
WSL
Strong/Safe
Fortran
Weak/Safe
Perl
Weak/Unsafe
C
C
15The approach
- The different type systems within WSL will help
to reduce the assumed parts of a correct code
translation - The approach will introduce differential levels
of type safety to WSL - The approach will prefer static type checking
16Design decisions
- How to identify different types ?
- How many levels of different strong type systems
should be defined ? - How typeful should the new type systems be (e.g.
should it be possible to define Types of types
like in Haskell) ? - How much should the maintainer be involved in the
transformation process ?
17Problems to solve
- How to transform expressions doing pointer
arithmetic ? - How can a type be safely converted into another
? - How to deal with reflection and runtime generated
code (found in reflexive languages) ?
18To Research
- Which mathematical model can be used as
foundation for this idea ? - What are the limitations of the approach ?
- How to measure the type safety of a system ?
- Maybe the term semantic equivalent can be
defined in some other way than justwp(f1,q)
wp(f2,q) ?q?Q
19Thanks for your Questions!