scratch-vm
scratch-vm copied to clipboard
Feature Request: Static Mode (Optimization)
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
Mutations
Parameters names should always ends with the desired type
Lists
List names should always ends with the desired type
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.
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)