Record (computer science)

Notable applications include the programming language record type and for row-based storage, data organized as a sequence of records, such as a database table, spreadsheet or comma-separated values (CSV) file.

The definition includes specifying the data type of each field and an identifier (name or label) by which it can be accessed.

Since type-theoretical records may contain first-class function-typed fields in addition to data, they can express many features of object-oriented programming.

The concept of a record can be traced to various types of tables and ledgers used in accounting since remote times.

The modern notion of records in computer science, with fields of well-defined type and size, was already implicit in 19th century mechanical calculators, such as Babbage's Analytical Engine.

Generally, a record was the smallest unit that could be read from external storage (e.g., card reader, tape, or disk).

[9] When storage systems became more advanced with the use of hard drives and magnetic tape, variable-length records became the standard.

This was not possible to do before more advanced storage hardware was invented because all of the punchcards had to conform to pre-determined document lengths that the computer could read, since at the time the cards had to be physically fed into a machine.

The concept of records and fields was central in some early file sorting and tabulating utilities, such as IBM's Report Program Generator (RPG).

The language allows for the definition of nested records with alphanumeric, integer, and fractional fields of arbitrary size and precision, and fields that automatically format any value assigned to them (e.g., insertion of currency signs, decimal points, and digit group separators).

The original Lisp programming language too was lacking records (except for the built-in cons cell), but its S-expressions provided an adequate surrogate.

This influenced later languages such as C++, Python, JavaScript, and Objective-C which address the same modularity needs of programming.

These languages allow the programmer to store sets of data, which are essentially records, in tables.

This facility is needed to implement certain services such as debugging, garbage collection, and serialization.

Some languages may also require that corresponding types have the same size and encoding as well, so that the whole record can be assigned as an uninterpreted bit string.

Similarly to entering a different namespace in an object-oriented language like C#, it is no longer necessary to use the record name as a prefix to access the fields.

Often, fields are stored in consecutive memory locations, in the same order as they are declared in the record type.

Some languages may implement a record as an array of addresses pointing to the fields (and, possibly, to their names and/or types).

Journal sheet from 1880 United States census , showing tabular data with rows of data, each a record corresponding to a single person.
Hollerith punched card (1895)