Unified External Type for Static Checking of Dynamic Code

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Dynamically-typed programming languages like JavaScript lack type safety, leading to unpredictable behavior and difficulties in writing robust applications due to silent type errors, which static type checking cannot effectively address without manual annotations and complex verification processes.

Innovation Solution

A statically-typed programming language is developed to consume dynamically-typed code by unifying all types into a single 'unified external type' at compile time, enabling static type checking and providing explicit or implicit conversions, thus ensuring type safety and reducing manual effort in maintaining type annotations.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If static type checking is applied to dynamically-typed code, then type safety is improved, but manual type annotations and verification effort increase

Engineering Contradiction:
Improvetype safetyVSAvoidmanual annotation effort
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The system performs automatic type inference on dynamically-typed code, allowing the code to annotate and verify itself without manual intervention. The type inference engine automatically analyzes the dynamically-typed code and generates type information, making the system self-annotating and eliminating the need for manual type annotations while maintaining type safety

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

A type inference engine acts as an intermediary between dynamically-typed code and static type checking. This intermediary automatically generates type information from the dynamically-typed code and presents it to the static type checker, bridging the gap between dynamic execution and static verification without requiring manual annotations

Inventive Principle:
Principle #24Intermediary (Mediator)

2Adaptability or versatility

If manual type annotations are provided for JavaScript code, then interoperability with TypeScript is improved, but developer effort and complexity increase

Engineering Contradiction:
ImproveinteroperabilityVSAvoiddeveloper effort
Core Design Contradiction:
Adaptability or versatilityVSProductivity

Solution Approach 1:

The system automatically infers types for JavaScript code, allowing the code to provide its own type information without developer intervention. This self-annotating capability maintains interoperability with TypeScript while eliminating the manual effort required to add type annotations to existing JavaScript codebases

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The type inference engine performs preliminary type analysis on JavaScript code before integration with TypeScript, automatically generating type information in advance. This preliminary action prepares the JavaScript code for TypeScript interoperability without requiring developers to manually annotate types during the integration process

Inventive Principle:
Principle #10Preliminary action

3Adaptability or versatility

If dynamic type checking is used, then runtime flexibility is maintained, but type errors may occur at runtime

Engineering Contradiction:
Improveruntime flexibilityVSAvoidruntime type errors
Core Design Contradiction:
Adaptability or versatilityVSReliability

Solution Approach 1:

The system performs preliminary static type checking on dynamically-typed code by automatically inferring types and checking them before runtime execution. This preliminary verification catches type errors at compile time rather than runtime, maintaining runtime flexibility while preventing type-related crashes and errors during execution

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The type inference and static checking system provides beforehand cushioning by detecting and reporting type incompatibilities before the program runs. This prevents runtime type errors by identifying and correcting type issues in advance, while the dynamically-typed code retains its runtime flexibility for valid operations

Inventive Principle:
Principle #11Beforehand cushioning (Prior cushioning)

Data Source

PatentUS10296313B2Safely consuming dynamically-typed code from a statically-typed programming language
Publication Date: 2019.05.21 POON ROGER JAMES
  • US10296313B2 patent drawing
  • US10296313B2 patent drawing
  • US10296313B2 patent drawing

AI summary

A computerized method is provided to consume a dynamically-typed language in a compatible language, and to compile source code in the compatible language to a target language. The methods make it possible to add type safety and static type checking to a superset of dynamically-typed languages, irrespective of whether the dynamically-typed languages are dynamically type-checked or not. In preferred embodiments, the methods allow for all types in an external language to be represented as a single type. In various embodiments, more than one unified external type can be allowed, each unified external type being specific to a group or class of types. In the methods, conversions are used as a mechanism to convert types. Conversions can be either implicit or explicit, and explicit conversions can be either implementation-defined or user-defined.