Skip to content

What if Boa was a Typescript engine?Β #4230

@aurium

Description

@aurium

I saw issue #4 by @JasonShin. I understand it may not be something to focus right now.

Typescript is no longer a niche language. Large projects and small solutions are written directly in Typescript.

Node, Deno and Bun support TS as something to be converted (lost) on the fly, not as something that can enable important optimizations at runtime. Boa can do more!

Just as an engine can be more performant manipulating numbers in a Float64Array than in a generic Array, some runtime benefit can be gained by arr: number = []

When a function is called with incompatible arguments, the engine will not allow the fate to decide application result... In this case the execution will stop and an exception should be thrown. With this approach other optimizations can be achieved, for example: (a:number, b:number)=> a + b, where the + operator will always be an arithmetic operator (no string concatenation will be possible) and no elaborate conversion should be expected.

Boa could follow one of this paths:

  • A TS first engine, and JS code will need to receive generic typing (any everywhere automatically) to run. I believe this is positive, so that any project will benefit when at least one module provides typing.
  • An Opt-in TS support, expecting a CLI --ts-strict flag, or a context.eval(..., ts_strict) arg, to enable type optimizations.

Extra: Mozilla, with asm.js, showed 10 year ago that types could improve JS performance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions