0% found this document useful (0 votes)
11 views13 pages

Survey of Programming Languages

The document outlines a comprehensive course on programming languages, covering their history, various paradigms, and key concepts such as language description, declarations, types, and abstraction mechanisms. It discusses specific programming languages including FORTRAN, COBOL, C, C++, and Java, detailing their development, features, and applications. The course aims to provide a deep understanding of programming methodologies and the evolution of programming languages over time.

Uploaded by

lonkatbam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views13 pages

Survey of Programming Languages

The document outlines a comprehensive course on programming languages, covering their history, various paradigms, and key concepts such as language description, declarations, types, and abstraction mechanisms. It discusses specific programming languages including FORTRAN, COBOL, C, C++, and Java, detailing their development, features, and applications. The course aims to provide a deep understanding of programming methodologies and the evolution of programming languages over time.

Uploaded by

lonkatbam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Original Course Outline from Department

Overview of Programming Languages: History of programming languages, brief


survey of programming paradigms (procedural, OO, Functional, Declarative (non
algorithmic) and Scripting languages), the effects of scale on programming
methodology; language Description: Syntactic structure (Expression notations,
abstract syntax Tree, lexical Syntax, grammars for expressions, variants of
grammars), language Semantics (Informal Semantics, overview of formal
semantics, Denotation semantics, axiomatic semantics, Operational Semantics);
Declarations and types the concept of types, declaration models (binding, visibility,
scope, and lifetime), Overview of type-checking, Garbage collection; Abstraction
mechanisms: procedures, function, and iterations as abstraction mechanisms,
parameterization mechanisms (reference vs. value), activation records and storage
management, type parameters and parameterized types, modules in programming
languages; Object Oriented Language Paradigm; Functional and Logic Language
paradigms.
Overview of Programming Languages: History of programming languages, brief
survey of programming paradigms (procedural, OO, Functional, Declarative (non
algorithmic) and Scripting languages), the effects of scale on programming
methodology;

Language Description: Syntactic structure (Expression notations, abstract syntax


Tree, lexical Syntax, grammars for expressions, variants of grammars), language
Semantics (Informal Semantics, overview of formal semantics, Denotation
semantics, axiomatic semantics, Operational Semantics);

Declarations and types the concept of types, declaration models (binding, visibility,
scope, and lifetime), Overview of type-checking, Garbage collection;

Abstraction mechanisms: procedures, function, and iterations as abstraction


mechanisms, parameterization mechanisms (reference vs. value), activation
records and storage management, type parameters and parameterized types,
modules in programming languages;

Object Oriented Language Paradigm;

Functional and Logic Language paradigms.


Overview of Programming Languages:
History of programming languages
Ref: Wikipedia
(https://en.wikipedia.org/wiki/History_of_programming_languages#First_programming_languages)

Machine Language
In computer programming, machine code, consisting of machine language instructions, is a low-level
programming language used to directly control a computer's central processing unit (CPU). Each
instruction causes the CPU to perform a very specific task, such as a load, a store, a jump, or
an arithmetic logic unit (ALU) operation on one or more units of data in the CPU's registers or memory.

Machine code is a strictly numerical language which is intended to run as fast as possible, and it may be
regarded as the lowest-level representation of a compiled or assembled computer program or as a
primitive and hardware-dependent programming language. While it is possible to write programs
directly in machine code, managing individual bits and calculating numerical addresses and constants
manually is tedious and error-prone. For this reason, programs are very rarely written directly in
machine code in modern contexts, but may be done for low level debugging,
program patching (especially when assembler source is not available) and assembly
language disassembly.

The majority of practical programs today are written in higher-level languages or assembly language.
The source code is then translated to executable machine code by utilities such
as compilers, assemblers, and linkers, with the important exception of interpreted programs,[1] which
are not translated into machine code. However, the interpreter itself, which may be seen as an executor
or processor performing the instructions of the source code, typically consists of directly executable
machine code (generated from assembly or high-level language source code).

Machine code is by definition the lowest level of programming detail visible to the programmer, but
internally many processors use microcode or optimise and transform machine code instructions into
sequences of micro-ops. This is not generally considered to be a machine code.

Assembly Language
In computer programming, assembly language (or assembler language),[1] often abbreviated asm, is
any low-level programming language in which there is a very strong correspondence between the
instructions in the language and the architecture's machine code instructions.[2] Because assembly
depends on the machine code instructions, every assembly language is designed for exactly one specific
computer architecture. Assembly language may also be called symbolic machine code.[3][4]

Assembly code is converted into executable machine code by a utility program referred to as
an assembler. The conversion process is referred to as assembly, as in assembling the source code.
Assembly language usually has one statement per machine instruction (1:1), but comments and
statements that are assembler directives,[5] macros,[6][1] and symbolic labels of program and memory
locations are often also supported.

The term "assembler" is generally attributed to Wilkes, Wheeler and Gill in their 1951 book The
Preparation of Programs for an Electronic Digital Computer,[7] who, however, used the term to mean "a
program that assembles another program consisting of several sections into a single program". [8]

Each assembly language is specific to a particular computer architecture and sometimes to an operating
system.[9] However, some assembly languages do not provide specific syntax for operating system calls,
and most assembly languages can be used universally with any operating system, as the language
provides access to all the real capabilities of the processor, upon which all system call mechanisms
ultimately rest. In contrast to assembly languages, most high-level programming languages are
generally portable across multiple architectures but require interpreting or compiling, a much more
complicated task than assembling.

The computational step when an assembler is processing a program is called assembly time.

FORTRAN
The first commercially available language was FORTRAN (FORmula TRANslation), developed in 1956 (first
manual appeared in 1956, but first developed in 1954).

In 1954, FORTRAN was invented at IBM by a team led by John Backus; it was the first widely used high-
level general purpose programming language to have a functional implementation, as opposed to just a
design on paper.[6][7] When FORTRAN was first introduced, it was viewed with skepticism due to bugs,
delays in development, and the comparative efficiency of "hand-coded" programs written in assembly.
[8]
However, in a hardware market that was rapidly evolving; the language eventually became known for
its efficiency. It is still a popular language for high-performance computing[9] and is used for programs
that benchmark and rank the world's fastest supercomputers.[10]

COBOL
COBOL (/ˈkoʊbɒl, -bɔːl/; an acronym for "common business-oriented language") is a compiled English-
like computer programming language designed for business use. It is an imperative, procedural and,
since 2002, object-oriented language. COBOL is primarily used in business, finance, and administrative
systems for companies and governments. COBOL is still widely used in applications deployed
on mainframe computers, such as large-scale batch and transaction processing jobs. However, due to its
declining popularity and the retirement of experienced COBOL programmers, programs are being
migrated to new platforms, rewritten in modern languages or replaced with software packages. [8] Most
programming in COBOL is now purely to maintain existing applications; however, many large financial
institutions were still developing new systems in COBOL as late as 2006 due to the mainframe
processing speed.[9]

COBOL was designed in 1959 by CODASYL and was partly based on the programming language FLOW-
MATIC designed by Grace Hopper. It was created as part of a US Department of Defense effort to create
a portable programming language for data processing. It was originally seen as a stopgap, but the
Department of Defense promptly forced computer manufacturers to provide it, resulting in its
widespread adoption.[10] It was standardized in 1968 and has since been revised four times. Expansions
include support for structured and object-oriented programming. The current standard
is ISO/IEC 1989:2014.[11]

COBOL statements have an English-like syntax, which was designed to be self-documenting and highly
readable. However, it is verbose and uses over 300 reserved words. In contrast with modern, succinct
syntax like y = x;, COBOL has a more English-like syntax (in this case, MOVE x TO y). COBOL code is split
into four divisions (identification, environment, data, and procedure) containing a rigid hierarchy of
sections, paragraphs and sentences. Lacking a large standard library, the standard specifies 43
statements, 87 functions and just one class.

Academic computer scientists were generally uninterested in business applications when COBOL was
created and were not involved in its design; it was (effectively) designed from the ground up as a
computer language for business, with an emphasis on inputs and outputs, whose only data types were
numbers and strings of text.[12] COBOL has been criticized throughout its life for its verbosity, design
process, and poor support for structured programming. These weaknesses result in monolithic and,
though intended to be English-like, not easily comprehensible and verbose programs.

C
C (/siː/, as in the letter c) is a general-purpose, procedural computer programming
language supporting structured programming, lexical variable scope, and recursion, with a static type
system. By design, C provides constructs that map efficiently to typical machine instructions. It has
found lasting use in applications previously coded in assembly language. Such applications
include operating systems and various application software for computer architectures that range
from supercomputers to PLCs and embedded systems.

A successor to the programming language B, C was originally developed at Bell Labs by Dennis
Ritchie between 1972 and 1973 to construct utilities running on Unix. It was applied to re-implementing
the kernel of the Unix operating system.[6] During the 1980s, C gradually gained popularity. It has
become one of the most widely used programming languages,[7][8] with C compilers from various vendors
available for the majority of existing computer architectures and operating systems. C has been
standardized by the ANSI since 1989 (ANSI C) and by the International Organization for
Standardization (ISO).

C is an imperative procedural language. It was designed to be compiled to provide low-level access


to memory and language constructs that map efficiently to machine instructions, all with
minimal runtime support. Despite its low-level capabilities, the language was designed to
encourage cross-platform programming. A standards-compliant C program written with portability in
mind can be compiled for a wide variety of computer platforms and operating systems with few changes
to its source code.[citation needed]

As of January 2021, C was ranked first in the TIOBE index, a measure of the popularity of programming
languages, moving up from the no. 2 spot the previous year.[9]
C++
C++ (/ˌsiːˌplʌsˈplʌs/) is a general-purpose programming language created by Bjarne Stroustrup as an
extension of the C programming language, or "C with Classes". The language has expanded significantly
over time, and modern C++ now has object-oriented, generic, and functional features in addition to
facilities for low-level memory manipulation. It is almost always implemented as a compiled language,
and many vendors provide C++ compilers, including the Free Software
Foundation, LLVM, Microsoft, Intel, Oracle, and IBM, so it is available on many platforms.[9]

In 1979, Bjarne Stroustrup, a Danish computer scientist, began work on "C with Classes", the
predecessor to C++.[16] The motivation for creating a new language originated from Stroustrup's
experience in programming for his PhD thesis. Stroustrup found that Simula had features that were very
helpful for large software development, but the language was too slow for practical use, while BCPL was
fast but too low-level to be suitable for large software development. When Stroustrup started working
in AT&T Bell Labs, he had the problem of analyzing the UNIX kernel with respect to distributed
computing. Remembering his PhD experience, Stroustrup set out to enhance the C language
with Simula-like features.[17] C was chosen because it was general-purpose, fast, portable and widely
used. As well as C and Simula's influences, other languages also influenced this new language,
including ALGOL 68, Ada, CLU and ML.

Initially, Stroustrup's "C with Classes" added features to the C compiler, Cpre, including classes, derived
classes, strong typing, inlining and default arguments.[18]

In 1982, Stroustrup started to develop a successor to C with Classes, which he named "C++" (++ being
the increment operator in C) after going through several other names. New features were added,
including virtual functions, function name and operator overloading, references, constants, type-safe
free-store memory allocation (new/delete), improved type checking, and BCPL style single-line
comments with two forward slashes (//). Furthermore, Stroustrup developed a new, standalone
compiler for C++, Cfront.

In 1984, Stroustrup implemented the first stream input/output library. The idea of providing an output
operator rather than a named output function was suggested by Doug McIlroy[1] (who had previously
suggested Unix pipes).

In 1985, the first edition of The C++ Programming Language was released, which became the definitive
reference for the language, as there was not yet an official standard.[19] The first commercial
implementation of C++ was released in October of the same year.[16]

In 1989, C++ 2.0 was released, followed by the updated second edition of The C++ Programming
Language in 1991.[20] New features in 2.0 included multiple inheritance, abstract classes, static member
functions, const member functions, and protected members. In 1990, The Annotated C++ Reference
Manual was published. This work became the basis for the future standard. Later feature additions
included templates, exceptions, namespaces, new casts, and a Boolean type.
In 1998, C++98 was released, standardizing the language, and a minor update (C++03) was released in
2003.

After C++98, C++ evolved relatively slowly until, in 2011, the C++11 standard was released, adding
numerous new features, enlarging the standard library further, and providing more facilities to C++
programmers. After a minor C++14 update released in December 2014, various new additions were
introduced in C++17.[21] After becoming finalized in February 2020,[22] a draft of the C++20 standard was
approved on 4 September 2020 and officially published on 15 December 2020. [23][24]

On January 3, 2018, Stroustrup was announced as the 2018 winner of the Charles Stark Draper Prize for
Engineering, "for conceptualizing and developing the C++ programming language". [25]

As of 2021 C++ ranked fourth on the TIOBE index, a measure of the popularity of programming
languages, after C, Java, and Python.[26]

Etymology
According to Stroustrup, "the name signifies the evolutionary nature of the changes from C". [27] This
name is credited to Rick Mascitti (mid-1983)[18] and was first used in December 1983. When Mascitti was
questioned informally in 1992 about the naming, he indicated that it was given in a tongue-in-
cheek spirit. The name comes from C's ++ operator (which increments the value of a variable) and a
common naming convention of using "+" to indicate an enhanced computer program.

During C++'s development period, the language had been referred to as "new C" and "C with Classes" [18]
[28]
before acquiring its final name.

Philosophy
Throughout C++'s life, its development and evolution has been guided by a set of principles: [17]
 It must be driven by actual problems and its features should be immediately useful in real world
programs.
 Every feature should be implementable (with a reasonably obvious way to do so).
 Programmers should be free to pick their own programming style, and that style should be fully
supported by C++.
 Allowing a useful feature is more important than preventing every possible misuse of C++.
 It should provide facilities for organising programs into separate, well-defined parts, and provide
facilities for combining separately developed parts.
 No implicit violations of the type system (but allow explicit violations; that is, those explicitly
requested by the programmer).
 User-created types need to have the same support and performance as built-in types.
 Unused features should not negatively impact created executables (e.g. in lower performance).
 There should be no language beneath C++ (except assembly language).
 C++ should work alongside other existing programming languages, rather than fostering its own
separate and incompatible programming environment.
 If the programmer's intent is unknown, allow the programmer to specify it by providing manual
control.
Java
Java is a class-based, object-oriented programming language that is designed to have as few
implementation dependencies as possible. It is a general-purpose programming language intended to
let application developers write once, run anywhere (WORA),[16] meaning that compiled Java code can
run on all platforms that support Java without the need for recompilation. [17] Java applications are
typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the
underlying computer architecture. The syntax of Java is similar to C and C++, but has fewer low-
level facilities than either of them. The Java runtime provides dynamic capabilities (such as reflection
and runtime code modification) that are typically not available in traditional compiled languages. As of
2019, Java was one of the most popular programming languages in use according to GitHub,[18]
[19]
particularly for client-server web applications, with a reported 9 million developers.[20]

Java was originally developed by James Gosling at Sun Microsystems (which has since been acquired by
Oracle) and released in 1995 as a core component of Sun Microsystems' Java platform. The original
and reference implementation Java compilers, virtual machines, and class libraries were originally
released by Sun under proprietary licenses. As of May 2007, in compliance with the specifications of
the Java Community Process, Sun had relicensed most of its Java technologies under the GNU General
Public License. Oracle offers its own HotSpot Java Virtual Machine, however the official reference
implementation is the OpenJDK JVM which is free open source software and used by most developers
and is the default JVM for almost all Linux distributions.

As of March 2021, the latest version is Java 16, with Java 11, a currently supported long-term
support (LTS) version, released on September 25, 2018. Oracle released the last zero-cost public update
for the legacy version Java 8 LTS in January 2019 for commercial use, although it will otherwise still
support Java 8 with public updates for personal use indefinitely. Other vendors have begun to
offer zero-cost builds of OpenJDK 8 and 11 that are still receiving security and other upgrades.

Principles
There were five primary goals in the creation of the Java language:[17]
1. It must be simple, object-oriented, and familiar.
2. It must be robust and secure.
3. It must be architecture-neutral and portable.
4. It must execute with high performance.
5. It must be interpreted, threaded, and dynamic.
Python
Python is an interpreted high-level general-purpose programming language. Python's design philosophy
emphasizes code readability with its notable use of significant indentation. Its language constructs as
well as its object-oriented approach aim to help programmers write clear, logical code for small and
large-scale projects.[29]

Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms,


including structured (particularly, procedural), object-oriented and functional programming. Python is
often described as a "batteries included" language due to its comprehensive standard library.[30]

Guido van Rossum began working on Python in the late 1980s, as a successor to the ABC programming
language, and first released it in 1991 as Python 0.9.0.[31] Python 2.0 was released in 2000 and
introduced new features, such as list comprehensions and a garbage collection system using reference
counting and was discontinued with version 2.7.18 in 2020.[32] Python 3.0 was released in 2008 and was
a major revision of the language that is not completely backward-compatible and much Python 2 code
does not run unmodified on Python 3.

Python consistently ranks as one of the most popular programming languages.[33][34][35][36][37]

PHP
PHP is a general-purpose scripting language especially suited to web development.[5] It was originally
created by Danish-Canadian programmer Rasmus Lerdorf in 1994.[6] The PHP reference
implementation is now produced by The PHP Group.[7] PHP originally stood for Personal Home Page,
[6]
but it now stands for the recursive initialism PHP: Hypertext Preprocessor.[8]

PHP code is usually processed on a web server by a PHP interpreter implemented as a module,
a daemon or as a Common Gateway Interface (CGI) executable. On a web server, the result of
the interpreted and executed PHP code – which may be any type of data, such as
generated HTML or binary image data – would form the whole or part of an HTTP response. Various web
template systems, web content management systems, and web frameworks exist which can be
employed to orchestrate or facilitate the generation of that response. Additionally, PHP can be used for
many programming tasks outside of the web context, such as standalone graphical
applications[9] and robotic drone control.[10] PHP code can also be directly executed from the command
line.

The standard PHP interpreter, powered by the Zend Engine, is free software released under the PHP
License. PHP has been widely ported and can be deployed on most web servers on almost
every operating system and platform, free of charge.[11]

The PHP language evolved without a written formal specification or standard until 2014, with the
original implementation acting as the de facto standard which other implementations aimed to follow.
Since 2014, work has gone on to create a formal PHP specification.[12]
W3Techs reports that, as of April 2021, "PHP is used by 79.2% of all the websites whose server-side
programming language we know."[13]

BASIC
BASIC (Beginners' All-purpose Symbolic Instruction Code)[1] is a family of general-purpose, high-level
programming languages whose design philosophy emphasizes ease of use. The original version was
designed by John G. Kemeny and Thomas E. Kurtz and released at Dartmouth College in 1964. They
wanted to enable students in fields other than science and mathematics to use computers. At the time,
nearly all use of computers required writing custom software, which was something
only scientists and mathematicians tended to learn.

In addition to the language itself, Kemeny and Kurtz developed the Dartmouth Time Sharing
System (DTSS), which allowed multiple users to edit and run BASIC programs at the same time. This
general model became very popular on minicomputer systems like the PDP-11 and Data General Nova in
the late 1960s and early 1970s. Hewlett-Packard produced an entire computer line for this method of
operation, introducing the HP2000 series in the late 1960s and continuing sales into the 1980s. Many
early video games trace their history to one of these versions of BASIC.

The emergence of early microcomputers in the mid-1970s led to the development of a number of BASIC
dialects, including Microsoft BASIC in 1975. Due to the tiny main memory available on these machines,
often 4 kB, a variety of Tiny BASIC dialects was also created. BASIC was available for almost any system
of the era, and naturally became the de facto programming language for the home computer systems
that emerged in the late 1970s. These machines almost always had a BASIC interpreter installed by
default, often in the machine's firmware or sometimes on a ROM cartridge.

BASIC fell from use in the early 1990s, as newer machines with far greater capabilities came to market
and other programming languages (such as Pascal and C) became tenable. In
1991, Microsoft released Visual Basic, combining a greatly updated version of BASIC with a visual forms
builder. This reignited use of the language and "VB" remains a major programming language in the form
of VB.NET.

Brief survey of programming paradigms


Procedural
Procedural programming is a programming paradigm, derived from imperative programming,[1] based
on the concept of the procedure call. Procedures (a type of routine or subroutine) simply contain a
series of computational steps to be carried out. Any given procedure might be called at any point during
a program's execution, including by other procedures or itself. The first major procedural programming
languages appeared circa 1957–1964, including Fortran, ALGOL, COBOL, PL/I and BASIC.
[2]
Pascal and C were published circa 1970–1972.

Computer processors provide hardware support for procedural programming through a stack
register and instructions for calling procedures and returning from them. Hardware support for other
types of programming is possible, but no attempt was commercially successful (for example Lisp
machines or Java processors).

Procedures and modularity


Modularity is generally desirable, especially in large, complicated programs. Inputs are usually specified
syntactically in the form of arguments and the outputs delivered as return values.

Scoping is another technique that helps keep procedures modular. It prevents the procedure from
accessing the variables of other procedures (and vice versa), including previous instances of itself,
without explicit authorization.

Less modular procedures, often used in small or quickly written programs, tend to interact with a large
number of variables in the execution environment, which other procedures might also modify.

Because of the ability to specify a simple interface, to be self-contained, and to be reused, procedures
are a convenient vehicle for making pieces of code written by different people or different groups,
including through programming libraries.

Object Oriented
Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects",
which can contain data and code: data in the form of fields (often known as attributes or properties),
and code, in the form of procedures (often known as methods).

A feature of objects is that an object's own procedures can access and often modify the data fields of
itself (objects have a notion of this or self). In OOP, computer programs are designed by making them
out of objects that interact with one another.[1][2] OOP languages are diverse, but the most popular ones
are class-based, meaning that objects are instances of classes, which also determine their types.

Many of the most widely used programming languages (such as C++, Java, Python, etc.) are multi-
paradigm and they support object-oriented programming to a greater or lesser degree, typically in
combination with imperative, procedural programming. Some significant object-oriented languages
include: (list order based on TIOBE index) Java, C++, C#, Python, R, PHP and Visual Basic.NET.

Features
Object-oriented programming uses objects, but not all of the associated techniques and structures are
supported directly in languages that claim to support OOP. The features listed below are common
among languages considered to be strongly class- and object-oriented (or multi-paradigm with OOP
support), with notable exceptions mentioned.[3][4][5][6]

See also: Comparison of programming languages (object-oriented programming) and List of object-
oriented programming terms
Shared with non-OOP languages
 Variables that can store information formatted in a small number of built-in data
types like integers and alphanumeric characters. This may include data
structures like strings, lists, and hash tables that are either built-in or result from combining
variables using memory pointers.

 Procedures – also known as functions, methods, routines, or subroutines – that take input,
generate output, and manipulate data. Modern languages include structured
programming constructs like loops and conditionals.

Modular programming support provides the ability to group procedures into files and modules for
organizational purposes. Modules are namespaced so identifiers in one module will not conflict with a
procedure or variable sharing the same name in another file or module.

Objects and classes


Languages that support object-oriented programming (OOP) typically use inheritance for code reuse and
extensibility in the form of either classes or prototypes. Those that use classes support two main
concepts:

 Classes – the definitions for the data format and available procedures for a given type or class of
object; may also contain data and procedures (known as class methods) themselves, i.e. classes
contain the data members and member functions

 Objects – instances of classes

Objects sometimes correspond to things found in the real world. For example, a graphics program may
have objects such as "circle", "square", "menu". An online shopping system might have objects such as
"shopping cart", "customer", and "product".[7] Sometimes objects represent more abstract entities, like
an object that represents an open file, or an object that provides the service of translating
measurements from U.S. customary to metric.

Object-oriented programming is more than just classes and objects; it's a whole programming paradigm
based around [sic] objects (data structures) that contain data fields and methods. It is essential to
understand this; using classes to organize a bunch of unrelated methods together is not object
orientation.

Each object is said to be an instance of a particular class (for example, an object with its name field set
to "Mary" might be an instance of class Employee). Procedures in object-oriented programming are
known as methods; variables are also known as fields, members, attributes, or properties. This leads to
the following terms:

 Class variables – belong to the class as a whole; there is only one copy of each one

 Instance variables or attributes – data that belongs to individual objects; every object has its
own copy of each one
 Member variables – refers to both the class and instance variables that are defined by a
particular class

 Class methods – belong to the class as a whole and have access only to class variables and
inputs from the procedure call

 Instance methods – belong to individual objects, and have access to instance variables for the
specific object they are called on, inputs, and class variables

Encapsulation
Encapsulation is an object-oriented programming concept that binds together the data and functions
that manipulate the data, and that keeps both safe from outside interference and misuse. Data
encapsulation led to the important OOP concept of data hiding.
If a class does not allow calling code to access internal object data and permits access through methods
only, this is a strong form of abstraction or information hiding known as encapsulation. Some languages
(Java, for example) let classes enforce access restrictions explicitly, for example denoting internal data
with the private keyword and designating methods intended for use by code outside the class with
the public keyword. Methods may also be designed public, private, or intermediate levels such
as protected (which allows access from the same class and its subclasses, but not objects of a different
class). In other languages (like Python) this is enforced only by convention (for
example, private methods may have names that start with an underscore). Encapsulation prevents
external code from being concerned with the internal workings of an object. This facilitates code
refactoring, for example allowing the author of the class to change how objects of that class represent
their data internally without changing any external code (as long as "public" method calls work the same
way). It also encourages programmers to put all the code that is concerned with a certain set of data in
the same class, which organizes it for easy comprehension by other programmers. Encapsulation is a
technique that encourages decoupling.
Composition, inheritance, and delegation
Objects can contain other objects in their instance variables; this is known as object composition. For
example, an object in the Employee class might contain (either directly or through a pointer) an object in
the Address class, in addition to its own instance variables like "first_name" and "position". Object
composition is used to represent "has-a" relationships: every employee has an address, so every
Employee object has access to a place to store an Address object (either directly embedded within itself,
or at a separate location addressed via a pointer).
Languages that support classes almost always support inheritance. This allows classes to be arranged in
a hierarchy that represents "is-a-type-of" relationships. For example, class Employee might inherit from
class Person. All the data and methods available to the parent class also appear in the child class with
the same names. For example, class Person might define variables "first_name" and "last_name" with
method "make_full_name()". These will also be available in class Employee, which might add the
variables "position" and "salary". This technique allows easy re-use of the same procedures and data
definitions, in addition to potentially mirroring real-world relationships in an intuitive way. Rather than
utilizing database tables and programming subroutines, the developer utilizes objects the user may be
more familiar with: objects from their application domain.[9]

You might also like