Type-Preserving Compilation of Class-Based Languages

Guillaume Martres

January 27th, 2023

What is a program?

  • A series of instructions that a computer can execute to produce some output given some input.
  • These instructions are written in a programming language.

Programs are like recipe

Ingredients

  • 2 cups of sugar
  • 1.5 cups of flour
  • 1 cup of 🧈
  • 4 πŸ₯š
  • 3 🍫

Instructions

  • Preheat oven to 350Β°
  • Crack the πŸ₯š
  • Mix sugar, flour, 🧈, πŸ₯š, 🍫
  • Bake for 30 minutes

There’s a lot of programming languages!

An intriguing announcement

So what is a compiler?

Compiling is like Translating

Ingredients

  • 2 cups of sugar
  • 1.5 cups of flour
  • 1 cup of 🧈
  • 4 πŸ₯š
  • 3 🍫

  • 400g de sucre
  • 200g de farine
  • 230g de 🧈
  • 4 πŸ₯š
  • 3 🍫

Instructions

  • Preheat oven to 350Β°F.
  • Crack the πŸ₯š.
  • Mix sugar, flour, 🧈, πŸ₯š, 🍫.
  • Bake 30 minutes.

  • PrΓ©chauffer le four Γ  180Β°C.
  • Casser les πŸ₯š.
  • MΓ©langer le sucre, la farine,le 🧈, les πŸ₯š, le 🍫.
  • Cuir 30 minutes.

Collaborative development

Doing a PhD

Doing a PhD

Doing a PhD

Doing a PhD

My PhD

  • Worked on many things to make Scala 3.0 a reality.
  • One area of focus: the type checker.

The type checker is like a Chef πŸ§‘β€πŸ³

Ingredients

  • 2 cups of sugar
  • 1.5 cups of flour
  • 1 cup of 🧈
  • 4 πŸ₯š
  • 3 🍫

Instructions

  • Preheat oven to 350Β°F.
  • Slice Slice Crack the πŸ₯š.
  • Mix sugar, flour, 🧈, πŸ₯š, 🍫.
  • Bake 30 minutes.

2021: Scala 3.0 is out!

… but now I have to write a thesis πŸ€”

  • How can I formalize the work we did?

A source of inspiration

My own paper!

The plan

  • Extend Pathless Scala to support more language features.
  • Prove Type Safety.

Type Safety

If a language is type safe then programs which are accepted by the type checker can be executed without getting stuck.


Ingredients

  • 2 cups of sugar
  • 1.5 cups of flour
  • 1 cup of 🧈
  • 4 πŸ₯š
  • 3 🍫

Instructions

  • Preheat oven to 350Β°F.
  • Slice Slice Crack the πŸ₯š.
  • Mix sugar, flour, 🧈, πŸ₯š, 🍫.
  • Bake 30 minutes.

… But proving type safety is hard!

An alternative approach:
Type-Preserving Compilation

  • If Language B is type-safe, then Language A will also be type-safe.
  • In our case, Language A will be Pathless Scala.
  • But what to pick as Language B?

Standing on the shoulders of giants

The DOT family tree πŸ‘ͺ

The plan

The plan

The plan

βœ…

🀯

When the recipe can’t be translated

Ingredients

  • 2 cups of sugar
  • 1.5 cups of flour
  • 1 cup of 🧈
  • 4 πŸ₯š
  • 3 🍫
  • 1 cup of cranberries

Instructions

  • Preheat oven to 350Β°F.
  • Crack the πŸ₯š.
  • Mix sugar, flour, 🧈, πŸ₯š, 🍫.
  • Stir in the cranberries
  • Bake 30 minutes.

Extending the DOT type safety proof

  • Unlike FJ, the DOT proof is mechanized: it’s a program we can improve!

Back to the plan

βœ…

βœ…

😱

A hint

Let’s change the type safety theorem!

The final result

Thank you!

Questions?