GPTScript / AiScript

A Minimal, Full-Stack, Tool-Assisted Language. Native to Browsers and Bun. Strictly & Strongly-Typed.
https://github.com/GPTScript/AiScript
Mozilla Public License 2.0
9 stars 1 forks source link

AjScript is Strictly & Strongly Typed (but not Statically) Typed #30

Open coolaj86 opened 2 years ago

coolaj86 commented 2 years ago

No type coercion and no type changes.

AjScript Types are like Go: Strong, Inferred.

Bad Examples

1 + ''

let foo = "1";
foo = parseInt(foo, 10);

Good Examples

(1).toString()
let fooInput = "1";
let foo = parseInt(fooInput, 10);

It would be nice if AjScript could support proper variable shadowing, like Rust, but it cannot.

Consideration

The use of String is a code smell. It signifies that you both don't know whether a type can be null or undefined, and don't know what other types it could be (otherwise you might use (x || '').toString() or x.toString()).