0% found this document useful (0 votes)
2 views

Programming Pardigm

C language

Uploaded by

chavvijain543
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Programming Pardigm

C language

Uploaded by

chavvijain543
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Programming Paradigm

A paradigm is the preferred approach to programming that a language supports.

A classification of programming languages based on their features (but most popular languages
support multiple paradigms).

● There are two main approaches:


o Imperative (statement-at-a-time paradigm): focuses on “how” to execute,
defines control flow as statements that change a program state. Ex Pascal, C , Java
o Declarative Programming: focuses on “what” to execute, defines program logic,
but not detailed control flow. Example SQL, ML, Lisp , pure Prolog
▪ Functional programming is subset of declarative + higher order

Imperative Declarative

Perform step by step task and manage Define what the problem is and what data
changes in state transformation are needed to achieve the
solution.

Tell the computer What to do Describe What to do as an end result

Ex Pascal, C , Java Example SQL, ML, Lisp , pure Prolog

o Structured: Structured programming is a programming paradigm aimed at


improving the clarity, quality, and development time of a computer program by
making extensive use of the structured control flow constructs of selection
(if/then/else) and repetition (while and for), block structures, and subroutines.
(Discourage usage of goto). Ex C, Pascal, java.
o Procedural: procedural programming is a programming paradigm, derived
from imperative programming based on the concept of the procedure call. Any given
procedure might be called at any point during a program's execution, including by
other procedures or itself. Ex C, Pascal, java.
o 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). Example Java, Python, C++
o Functional: In computer science, functional programming is a programming
paradigm where programs are constructed
by applying and composing functions. Example ML , LISP, Wolfarm Language
o Logic Programming Languages: Logic programming is a programming
paradigm which is largely based on formal logic. Any program written in a
logic programming language is a set of sentences in logical form, expressing facts
and rules about some problem domain. Ex Prolog , ASP (Answer set programming)

Other paradigms are event driven programming, Automata based programming, reactive
programming

Strongly, weakly, statically and dynamically typed programming languages


Programming languages are classified as strongly or weakly typed (loosely typed). There is no precise
technical definition for this but this relative ranking.

Type checking is the process of checking and verifying the type of a construct (constant, variable,
array, list, object) and its usage context. It helps in minimizing the possibility of type errors in the
program.

Type checking may occur either at compile-time (static checking) or at run-time(dynamic checking).

Statically Typed: A programming language is statically typed if the type of a variable is known at
compile time. So, every detail about the variables and all the data types must be known before we do
the compiling process.

Dynamically Typed: A language is dynamically typed if the type of a variable is checked


during run-time. In this type of language, there is no need to specify the data type of each variable
while writing code.

Strongly Typed: A strongly typed language is one where every statement that is executed must
follow the proper rules of the type system (That means the type of variable and expression is specified
before the use). In strongly typed languages, once a variable is told to be int type then it will remain
int type throughout. In general, a strongly typed language has stricter typing rules at compile time,
which implies that errors and exceptions are more likely to happen during compilation. They usually
do not permit implicit type conversions.

Weakly Typed: A weakly typed language has looser typing rules and may produce unpredictable or
even erroneous results or may perform implicit type conversion at runtime. In contrast to strongly
typed languages the type of variable may be changed.

Different languages are classified according to above as follows.

*Note: c is strongly or weakly typed is still controversial topic.


Classification of PL according to typing rules

You might also like