q2K BHP
Black History Portal
THE BHP WIRE —
HIDDEN TRUTHS
What's New!
THE JOURNEY THROUGH TIME

Explore Black History

Explore the people, places, events, achievements, struggles and stories that shaped our journey.

✊🏾

Civil Rights

Movements, leaders, victories and the continuing fight for equality.

⚙️

Black Inventors

Innovation, patents, science, technology and world-changing contributions.

🏆

Sports

Pioneers, champions, Negro Leagues, records, activism and excellence.

♟️

People

Meet the people whose lives, choices and achievements shaped the journey.

📍

Places

Black towns, communities, institutions and places where history happened.

📜

Events

Moments that changed communities, movements, institutions and the nation.

Enter a person, place, event, or topic.
MY'STORY

The MOVE Fire

This is a personal recollection on the Move fire on May 13, 1985 Philadelphia police fired thousands of rounds at the MOVE house, city officials approved dropping an explosive device on the roof, the resulting fire was allowed to burn, 11 people—including five children—died, and 61 homes were destroyed. Philadelphia City Council later called it a “brutal attack carried out by the City of Philadelphia on its own citizens” and acknowledged that no individual faced criminal consequences for the bombing. One timeline correction worth preserving for the BHP record: the major previous MOVE-police confrontation was August 8, 1978, about seven years before the bombing, not a year or two earlier. Officer James Ramp was killed, other police and firefighters were wounded, nine MOVE members were later convicted, and television cameras recorded police beating Delbert Africa during his arrest. The 1985 MOVE Commission later specifically criticized city planners for failing to adequately use lessons from that 1978 confrontation. And that actually strengthens the point you’re making: 1985 did not happen without precedent or institutional memory. There had already been a deadly confrontation with MOVE, years of conflict, negotiations and police involvement before Osage Avenue.

MORE →
BLACK FACTS
The Truths They Never Taught You...

Ruler of the Mali Empire in the 14th century

Mansa Musa was the ruler of the Mali Empire in West Africa. Details recorded here should be sourced; unknown information is left blank.

MORE →
BHP gathered finds from its connected research sources. Showing the 4 strongest Black History matches.
← BACK TO RESULTS
Wikipedia

Gradual typing

Gradual typing is a type system that allows for both static typing and dynamic typing but enforces types at runtime. Gradual typing allows software developers to choose either type paradigm as appropriate, from within a single language.[1]

In many cases gradual typing is added to an existing dynamic language,[2] creating a derived language allowing for, but not requiring, static typing to be used. In some cases, a language uses gradual typing from the start. However, there are performance and implementation complexity tradeoffs compared to dynamic or optional typing.

History

[edit]

The term was coined by Jeremy Siek, who developed gradual typing in 2006 with Walid Taha.[3]

Implementation

[edit]

In gradual typing, a special type named dynamic is used to represent statically-unknown types. The notion of type equality is replaced by a new relation called consistency that relates the dynamic type to every other type. The consistency relation is reflexive and symmetric but not transitive.[4]

Prior attempts at integrating static and dynamic typing tried to make the dynamic type be both the top and bottom of the subtype hierarchy. However, because subtyping is transitive, that results in every type becoming related to every other type, and so subtyping would no longer rule out any static type errors. The addition of a second phase of plausibility checking to the type system did not completely solve this problem.[5][6]

Gradual typing can easily be integrated into the type system of an object-oriented language that already uses the subsumption rule to allow implicit upcasts with respect to subtyping. The main idea is that consistency and subtyping are orthogonal ideas that compose nicely. To add subtyping to a gradually-typed language, simply add the subsumption rule and add a subtyping rule that makes the dynamic type a subtype of itself, because subtyping is supposed to be reflexive. (But do not make the top of the subtyping order dynamic!)[7]

Comparison With Optional Types

[edit]

Gradual and optional typing are similar in that variables and expressions may be given types and the correctness of the typing is checked at compile time (which is static typing). However, in a gradual type system, runtime checks are inserted at the boundaries of typed and untyped code. In an optional type system, all types are erased at compile time and untyped values can propagate through code that had type annotations.[8]

class Account { 
  credits:int //number of credits in account, statically typed
  new(credits:int) {
    this.credits = credits; 
  }
  
  compare(account:Account){
     //won't throw error in optionally typed as "1" > 1 is a valid comparison
    return this.credits > account.credits;
  }
  
  spendCredit(){
     this.credits = this.credits - 1; //optionally typed throws here
  }
  
}

//assume everything below executes at runtime/after Account has been compiled
let a = new Account(1); //valid in both systems
let b = new Account("2"); //gradually typed throws here, preventing invalid Account instances
b.compare(a); //optionally typed returns false
b.spendCredit(); //optionally typed throws here

In a gradually typed language, an exception would be raised anytime a non-integer value is supplied for credit and stack traces would stop at invalid calls (new Account("2")). In an optionally typed language, an exception would only be raised when the language is forced to perform operations that would be incompatible with its type: credit can be set to "1" (a string) but this would only throw an error when performing math on it (e.x. when spendCredit attempts to subtract the integer 1). compare functions as normal, illustrating how a program running in production could create and manipulate invalid Accounts without triggering an error. This could result in data corruption if the invalid instances are saved to a datastore.

Getting similar results in an optionally typed language requires a programmer to manually perform type checking by inserting guards:

class Account { 
  private credit:int //private prevents external code setting (invalid) value
  new(credit:int) {
    this.setCredit(credit); //must flow through guarded setter
  }
  
  //setter to ensure only values of the correct type are assigned
  setCredit(credit:int){ 
    if(isInt(credit)){ //manual type check to guard against data corruption
      this.credit = credit; 
    } else {
      throw TypeError;
    }
  }
  
  compare(account:Account){ //types are stripped at compile time
    if(instanceOf(account, Account)){ //manual type checks everywhere!
      return this.credit > account.credit;
    } else {
      throw TypeError;
    }
  }
  
  //since the private `credits` field can only be accessed within the class,
  //methods can rely on compile time type checking.
  spendCredit(){
     this.credits = this.credits - 1; //no need for `isInt(this.credits)`
  }
  
}

//assume everything below executes at runtime/after Account has been compiled
let a = new Account(1); //valid
let b = new Account("2"); //stacktrace wouldn't stop here, but inside `setCredit`

Note however, that stack traces won't trace to the offending call but the setter. If the programmer forgets to pass externally provided values through the setter, it's still possible that an invalid instance could be created and saved to disk but discovered during a later execution. This makes data corruption harder to prevent and impedes tracking down offending code paths.

Implementations

[edit]

Examples of gradually typed languages derived from existing dynamically typed languages include Closure Compiler, Hack (for PHP), PHP (since 7.0[9]), Typed Racket (for Racket[10][11]), Typed Clojure (for Clojure),[12] or cperl (a typed Perl 5). ActionScript was a gradually typed language[13] that interoperated with ECMAScript, though it originally arose separately as a sibling, both influenced by Apple's HyperTalk.

A system for the J programming language has been developed,[14] adding coercion, error propagation and filtering to the normal validation properties of the type system as well as applying type functions outside of function definitions, thereby the increasing flexibility of type definitions.

Conversely, C# started as a statically typed language, but as of version 4.0 is gradually typed, allowing variables to be explicitly marked as dynamic by using the dynamic type.[15]

Raku (formerly Perl6) has had gradual typing implemented from the start. Type checks occur at all locations where values are assigned or bound. An "untyped" variable or parameter is typed as Any, which will match (almost) all values. The compiler flags type-checking conflicts at compile time if it can determine at compile time that they will never succeed.

Objective-C has gradual typing for object pointers with respect to method calls. Static typing is used when a variable is typed as pointer to a certain class of object: when a method call is made to the variable, the compiler statically checks that the class is declared to support such a method, or it generates a warning or error. However, if a variable of the type id is used, the compiler will allow any method to be called on it.

The JS++ programming language, released in 2011, is a superset of JavaScript (dynamically typed) with a gradual type system that is sound for ECMAScript and DOM API corner cases.[16]

GDScript, the Godot game engine's primary scripting language, started out dynamically typed and introduced gradual typing with version 3.1 of the engine,[17] allowing users to type variables, function parameters, arrays and dictionaries through type hints. Additionally, when assigning a value to a variable using the := notation, Godot will attempt to infer the type of the variable at build time.[18]

References

[edit]
  1. ^ Siek, Jeremy (24 March 2014). "What is gradual typing?".
  2. ^ Bracha, Gilad (2004). "Pluggable Type Systems". OOPSLA'04 Workshop on Revival of Dynamic Languages.
  3. ^ David Herman (21 October 2011). "Space-efficient gradual typing" (PDF).
  4. ^ Siek, Jeremy; Taha, Walid (September 2006). Gradual Typing for Functional Languages (PDF). Scheme and Functional Programming 2006. University of Chicago. pp. 81–92.
  5. ^ Thatte, Satish (1990). "Quasi-static typing". Proceedings of the 17th ACM SIGPLAN-SIGACT symposium on Principles of programming languages - POPL '90. ACM. pp. 367–381. doi:10.1145/96709.96747. ISBN 978-0897913430. S2CID 8725290.
  6. ^ Oliart, Alberto (1994). An Algorithm for Inferring Quasi-Static Types (Technical report). Boston University. 1994-013.
  7. ^ Siek, Jeremy; Taha, Walid (August 2007). "Gradual Typing for Objects". ECOOP 2007 – Object-Oriented Programming. Lecture Notes in Computer Science. Vol. 4609. Springer. pp. 2–27. doi:10.1007/978-3-540-73589-2_2. ISBN 978-3-540-73588-5.
  8. ^ Siek, Jeremy G.; Vitousek, Michael M.; Cimini, Matteo; Boyland, John Tang (2015). Ball, Thomas; Bodik, Rastislav; Krishnamurthi, Shriram; Lerner, Benjamin S.; Morrisett, Greg (eds.). "Refined Criteria for Gradual Typing". LIPIcs, Volume 32, SNAPL 2015. 32: 274–293. doi:10.4230/LIPICS.SNAPL.2015.274. ISSN 1868-8969.
  9. ^ "PHP: Function arguments - Manual » Strict typing".
  10. ^ Tobin-Hochstadt, Sam; Felleisen, Matthias. "Interlanguage Migration: From Scripts to Programs". Proceedings of the Symposium on Object-Oriented Programming Systems, Companion Volume. Portland, OR. Tobin-Hochstadt06. Retrieved 2020-11-06.
  11. ^ Tobin-Hochstadt, Sam; Felleisen, Matthias. "The Design and Implementation of Typed Scheme". Proceedings of the Principles of Programming Languages. San Diego, CA. Tobin-Hochstadt08. Retrieved 2020-11-06.
  12. ^ Chas Emerick. "Typed Clojure User Guide". GitHub.
  13. ^ Aseem Rastogi; Avik Chaudhuri; Basil Hosmer (January 2012). "The Ins and Outs of Gradual Type Inference" (PDF). Association for Computing Machinery (ACM). Archived from the original (PDF) on 2017-08-12. Retrieved 2014-09-23.
  14. ^ "type-system-j". GitHub.
  15. ^ "dynamic (C# Reference)". MSDN Library. Microsoft. Retrieved 14 January 2014.
  16. ^ "The JS++ Type System, Appendix B: Problems (Why was this hard to solve?)". Retrieved 10 February 2020.
  17. ^ "Static typing in GDScript". Godot Engine documentation. Retrieved 2025-10-25.
  18. ^ "GDScript reference". Godot Engine documentation. Retrieved 2025-10-25.

Further reading

[edit]
  • Siek, Jeremy G.; Vitousek, Michael M.; Cimini, Matteo; Boyland, John Tang (2015). Ball, Thomas; Bodik, Rastislav; Krishnamurthi, Shriram; Lerner, Benjamin S.; Morrisett, Greg (eds.). Refined Criteria for Gradual Typing. Leibniz International Proceedings in Informatics. Vol. 32. Dagstuhl, Germany: Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik. pp. 274–293. doi:10.4230/lipics.snapl.2015.274. ISBN 9783939897804. S2CID 15383644.

Source: Wikipedia. Article content is retrieved live through the MediaWiki API.

No preview image
Wikipedia

Gradual typing

Gradual typing is a type system that allows for both static typing and dynamic typing but enforces types at runtime. Gradual typing allows software developers to choose either type paradigm as appropriate, from within a single language. In many cases gradual typing is added to an existing dynamic language, creating a derived language allowing for, but not requiring, static typing to be used. In some cases, a language uses gradual typing from the start. However, there are performance and implementation complexity tradeoffs compared to dynamic or optional typing.

MORE →
Wikipedia

Luau (programming language)

Luau (, LOO-ow) is an open-source scripting language derived from Lua 5.1. Developed by Roblox Corporation, it serves as the primary scripting language for the Roblox platform. Luau adds gradual typing, performance improvements, and sandboxing features to the base Lua language while maintaining backward compatibility with Lua 5.1. The language was released to Roblox developers in August 2019 and became free and open-source software under an MIT License in November 2021. Since its open-source release, Luau has been adopted by several video game developers outside of Roblox, including Remedy Entertainment for Alan Wake 2, Digital Extremes for Warframe, and Giants Software for Farming Simulator 2025.

MORE →
No preview image
Wikipedia

Principal type

In type theory, a type system is said to have the principal type property if, given a term and an environment, there exists a principal type for this term in this environment, i.e. a type such that all other types for this term in this environment are an instance of the principal type. The principal type property is a desirable one for a type system, as it provides a way to type expressions in a given environment with a type which encompasses all of the expressions' possible types, instead of having several incomparable possible types. Type inference for systems with the principal type property will usually attempt to infer the principal type. For instance, the ML system has the principal type property and principal types for an expression can be computed by Robinson's unification algorithm, which is used by the Hindley–Milner type inference algorithm. However, many extensions to the type system of ML, such as polymorphic recursion, can make the inference of the principal type undecidable. Other extensions, such as Haskell's generalized algebraic data types, destroy the principal type property of the language, requiring the use of type annotations or the compiler to "guess" the intended type from among several options. The notion was introduced by Curry and Feys around 1958, under the name of "principal functional character". The "principal type" name (as well as "type scheme") is due to Hindley (1969). The principal typing property requires that, given a term, there exist a typing (i.e. a pair with a context and a type) which is an instance of all possible typings of the term. The principal typing property can be confused with the principal type property but is distinct. The principal type property relies on the context as an input to determine the type, but the principal typing property outputs the context as a result. The principal typing property allows "compositional" type reasoning, meaning the analysis can be performed on the parts in any order. The Hindley–Milner type system is not compositional in this sense due to how let val x = e1 in e2 end is typed first by evaluating the type of e1 and using the result to type e2. Thus, it is said that ML has principal types but not principal typings. The simply typed lambda-calculus, on the other hand, has both of these properties. Generally speaking, type systems based on intersection types also have the principal typings property. This may not be computable, although if one limits intersections to rank-2 or with the introduction of some additional variables to any finite rank, then principal typings are computable for intersection types. These type systems been proposed for various applications, typically focused on incremental compilation or gradual typing.

MORE →
No preview image
Wikipedia

Hack (programming language)

Hack is a programming language for the HipHop Virtual Machine (HHVM), created by Meta (formerly Facebook) as a dialect of PHP. The language implementation is free and open-source software, licensed under an MIT License. Hack allows use of both dynamic typing and static typing. This kind of a type system is called gradual typing, which is also implemented in other programming languages such as ActionScript. Hack's type system allows types to be specified for function arguments, function return values, and class properties; however, types of local variables are always inferred and cannot be specified.

MORE →
TOPIC OF THE DAY

Greenwood / Black Wall Street

Before the 1921 destruction of Tulsa’s Greenwood District, Black residents had created a remarkable center of business and community life. The district included stores, professional offices, entertainment venues and homes owned by Black citizens. Understanding Greenwood means learning what was built—not only what was burned.

MORE →
TRIVIA QUESTION OF THE DAY

What prosperous Tulsa district became widely known as “Black Wall Street”?

The Greenwood District.