Search code examples
javapythonprogramming-languagesimport

What is the history of the import statement?


I know of two languages that use import statement: Java and Python. And we all know the import antigravity joke.

Which language really introduced this statement? Was it one of the two, or another one altogether? When?


Solution

  • import is just one way to specify dependency on some other class/module. Some way of specifying that has been present in many, many languages.

    In fact import in Java and import in Python do two entirely different things:

    • In Java import only provides the ability to refer to a type (or field/method, if using import static) by its short name instead of its fully qualified name. No "module loading" of any kind happens based on an import.
    • In Python import actually loads a module and optionally provides a short name for some (or all) of its members.

    Other keywords that do somewhat similar things are include in C and use in Perl. Many, many languages have some kind of way to specify this kind of dependency, but the technical details vary a lot.

    One language with an IMPORT statement that predates both Java and Python is Modula-2 (1978) and its successor Modula-3.