Historically, compilation involves creating a symbol table that associates variable names with their attributes defined from source code. This is a little simplified to illustrate, but the principles have not changed since FORTRAN was useful. Custom types in languages ββsuch as C ++ and Java form part of the compilation unit metadata that is collected at compile time and tied together when the runtime executable is created or loaded into memory.
Note that all types must be defined before they can be used to define type objects. This is the goal of "import" in Java and "#include" in C / C ++. Metadata includes definitions of the methods and data elements of an object (or class) and is used to determine the size of objects to create in static memory, on the stack (block input / output), or heap (dynamic allocation).
Type checking at compile time or at runtime is one of the most significant events of the last forty years and is the main reason that we can use autonomous robots on Mars, on California highways or on the Internet. On this core, the central problem of compiling or translating a programming language traces everything that is known about objects and puts them in memory, where it can be used properly at runtime.
Ancient languages, such as FORTRAN and COBOL, had one type of variable (static), which would have only fundamental attributes of the data type. They had almost trivial symbol tables. The most difficult problem was to combine compilation units to execute. We have come a long way!
source share