scratch-vm icon indicating copy to clipboard operation
scratch-vm copied to clipboard

Feature Request: Static Mode (Optimization)

Open mguinhos opened this issue 2 years ago • 2 comments

Static Typed Mode

Static typing for variables, parameters and lists

TurboWarp could have a mode called "Static Mode" whose would force static typing for the compiler.

Benefits

  • Prevention of JavaScript Deoptimizations (reduce JIT workloads). code could run as fast as native
  • Won't change the behaviour in the Vanilla Runtime

OBS:. This proposal is just a sketch

Benefited Scratch projects

  • Emulators
  • Raytracers
  • 3D Games
  • (Projects that uses intesive type checking)

Avaliable Types

  • integer -> equivalent to integer
  • decimal -> equivalent to float
  • text -> equivalent to a string
  • byte -> a small integer (0-255) that can be converted to a character

Semantics

Variables

Name should always ends with the desired type image

Mutations

Parameters names should always ends with the desired type image

Lists

List names should always ends with the desired type image

mguinhos avatar Dec 08 '21 10:12 mguinhos

This is an interesting idea.

However, we still have significant performance gains that can be made without forcing projects to change. Those are higher priority.

GarboMuffin avatar Dec 08 '21 21:12 GarboMuffin

I feel like making the area where the type is shown look like part of the variable, list and operator names wouldn't look good. Instead, it could have a name, and then seperated by a line, and then after that line it would show the type (and you would maybe say value or int instead of integer just for the sake of not having long names for variables, lists and operators)

n-d-v avatar Aug 04 '23 13:08 n-d-v