0

Swap strong/weak typing for static/dynamic typing.

This is as pedantic as nits get, but according to Wikipedia, strong/weak
typing doesn't have a precise definition, whereas static/dynamic typing
is clearly defined. We might as well refer to the clearly-defined
concepts here.

Anecdotally, I've heard "strong/weak" used to refer to a language's
willingness to do implicit coersions. E.g., `1 + "1"` is valid in
JavaScript, but invalid in Python; so Python is more strongly-typed than
JavaScript, even though both are dynamically-typed (ignoring the new
optional type annotations in Python, and Closure-flavored JavaScript).

Change-Id: I23ae6441fde7a29617b2cf00f588fdf1cfda0c2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3213286
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Auto-Submit: Chris Fredrickson <cfredric@chromium.org>
Cr-Commit-Position: refs/heads/main@{#929474}
This commit is contained in:
cfredric
2021-10-07 23:09:19 +00:00
committed by Chromium LUCI CQ
parent b42abc40b5
commit 477f29af20

@ -2,7 +2,7 @@
## What is type safety? ## What is type safety?
[Strongly-typed languages](https://en.wikipedia.org/wiki/Strong_and_weak_typing) [Statically-typed languages](https://en.wikipedia.org/wiki/Type_system#Static_type_checking)
like C++ and Java have the notion of variable types. like C++ and Java have the notion of variable types.
This is typically baked into how you declare variables: This is typically baked into how you declare variables:
@ -24,12 +24,12 @@ you if there's no sane default action to take.
Typing can also be manually annotated via mechanisms like `dynamic_cast` and Typing can also be manually annotated via mechanisms like `dynamic_cast` and
`static_cast` or older C-style casts (i.e. `(Type)`). `static_cast` or older C-style casts (i.e. `(Type)`).
Using stongly-typed languages provide _some_ level of protection against Using statically-typed languages provides _some_ level of protection against
accidentally using variables in the wrong context. accidentally using variables in the wrong context.
JavaScript is weakly-typed and doesn't offer this safety by default. This makes JavaScript is dynamically-typed and doesn't offer this safety by default. This
writing JavaScript more error prone, and various type errors have resulted in makes writing JavaScript more error prone, and various type errors have resulted
real bugs seen by many users. in real bugs seen by many users.
## Chrome's solution to typechecking JavaScript ## Chrome's solution to typechecking JavaScript