0% found this document useful (0 votes)
24 views14 pages

Extempo Essay

This document provides an overview of programming paradigms and how programming languages are executed. It discusses four main programming paradigms: procedural, declarative, functional, and object-oriented. It also explains the differences between compiled and interpreted languages. Compiled languages are translated to machine code once during compilation, while interpreted languages require an interpreter each time they are run. Compiled languages may execute faster but require recompiling when changed, while interpreted languages can be changed and rerun without recompiling. The document serves as an introduction to foundational concepts in programming languages.

Uploaded by

Didier Dzib
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)
24 views14 pages

Extempo Essay

This document provides an overview of programming paradigms and how programming languages are executed. It discusses four main programming paradigms: procedural, declarative, functional, and object-oriented. It also explains the differences between compiled and interpreted languages. Compiled languages are translated to machine code once during compilation, while interpreted languages require an interpreter each time they are run. Compiled languages may execute faster but require recompiling when changed, while interpreted languages can be changed and rerun without recompiling. The document serves as an introduction to foundational concepts in programming languages.

Uploaded by

Didier Dzib
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/ 14

Introduction to Programming Lenguages and

Paradigms

Extemporaneous – Unit 1

Essay about paradigms, variables and storage.

Professor: Jose Espinosa Atoche.

Student: Didier Dzib Briceño.

Data Engineering 2B
Programming paradigms.
Paradigms.
Research paradigms require that the concept of paradigms be reflected under the
assumption that it admits a plurality of meanings and different uses; therefore, it is
admitted as a generalist definition that it is a set of beliefs and attitudes, as a vision of
the world "shared" by a group of scientists that implies a determined methodology. The
paradigm is a theoretical scheme, or a way of perceiving and understanding the world,
adopted by a group of scientists.
1. Positivist or naturalistic paradigm.
The positivist paradigm, also called quantitative paradigm, empirical-analytical
rationalist, is the dominant paradigm; positivism is a philosophical school that defends
certain assumptions about the conception of the world and the way of knowing it, so the
characteristic of positivism is extended to the dimensions of the paradigm.
The positivist or naturalistic paradigm is characterized by the high interest in the
verification of knowledge through predictions. Some call it the "predictionist paradigm",
since the important thing is to pose a series of hypotheses such as predicting that
something is going to happen and then verifying or checking it. It has its greatest
application in the exact and natural sciences.
2. Realist paradigm
The realist paradigm focuses on the description and understanding of the phenomenon,
it questions the existence of an external and valuable reality to be analyzed; it focuses
on understanding reality from different angles, from a dynamic, multiple and holistic
perspective; The realist paradigm, in a way is a variant of the positivist paradigm, but
has its own status; here the prediction is not important, as is the explanation, what
matters is to advance in the knowledge of the causes, in reaching the ultimate
explanations, understanding that explanations are different from predictions.
3. Hermeneutic paradigm
The hermeneutic paradigm, also called qualitative paradigm, logical, humanistic or
ethnographic phenomenon, explains that "it is not interested in reaching an objective
knowledge" but in "reaching a consensual knowledge", what matters is to agree on the
interpretation of what is being studied. The limit of what would be good or bad
knowledge, obtained through interpretation, would be how close it is to reality. The
importance of having a certain fidelity in the interpretation is the possibility not only of
understanding, but also of modifying what is understood, and of being able to arrive at
deeper or broader knowledge from a first knowledge obtained that allows the researcher
to understand what is happening with his object of study, from giving an enlightened
interpretation, of course, or a more enlightened interpretation of what is being studied.
4. Interactionist paradigm
The interactionist paradigm arises as a response to the positive and interpretative
traditions and seeks to overcome the reductionism of the former and the conservatism
of the latter, admitting the possibility of a social science that is neither purely empirical
nor only interpretative. In the interactionist paradigm, as in the hermeneutic paradigm, it
is not important to arrive at an objective knowledge, the important thing is to see which
elements are interconnected with others and are interacting to produce something, the
important thing is to see the connections between them.
Programming paradigms.
For a computer to perform a task, it must be programmed to do so by placing in the
main memory an appropriate algorithm which is expressed in machine language. In the
early days of programming, this task was onerous because of the laboriousness and
difficulty of designing each algorithm (not to mention the errors that could be made).
The big step was taken when mnemonics began to be given to the various operation
codes and machine language operands. With this, programmers were able to
considerably increase the comprehensibility of the sequences of machine instructions.
The study of languages in terms of the approach to the programming process is called
programming paradigms, the term paradigm being understood as the way of seeing and
making programs. Under this approach there are four paradigms which are:
 Procedural paradigm or imperative paradigm:
The procedural paradigm is perhaps the best known and most widely used paradigm in
the programming process, where programs are developed through procedures. Pascal
C and BASIC are three of the most important imperative languages. The Latin word
imperare means "to give instructions". The paradigm began in the early 1950s when
designers recognized that variables and assignment commands or instructions were a
simple but useful abstraction of memory access and update of the machine instruction
set. Because of the close relationship with the machine architecture, imperative
programming languages can be implemented very efficiently, at least in principle.
 Declarative paradigm:
The declarative paradigm or logic programming paradigm is based on the fact that a
program implements a relation rather than a correspondence. Because relationships are
more general than mappings (identifier-memory address), logic programming is
potentially higher level than functional or imperative programming. The most popular
language within this paradigm is the PROLOG language. The rise of the declarative
paradigm is due to the fact that the formal logic area of mathematics offers a simple
problem-solving algorithm suitable for use in a general-purpose declarative
programming system.
 Functional paradigm:
If imperative programming is characterized by the use of variables, commands and
procedures, functional programming is characterized by the use of expressions and
functions. A program within the functional paradigm is a function or a group of functions
composed of simpler functions, establishing that a function can call another, or the
result of a function can be used as an argument of another function. The language par
excellence located within this paradigm is LISP. For example, if you want to obtain the
average grade of a student you could build an average function which would be
obtained from other simpler functions: one (add) which obtains the sum of the entries in
the list, another (count) which counts the number of entries in the list and the third
(divide) which obtains the quotient of the previous values, its syntax would be:
(divide (add notes) (count notes))
Note that the nested structure reflects the fact that the function divide acts on the results
of add and count.
 Object-oriented paradigm:
The object-oriented paradigm is based on the concepts of objects and object classes.
An object is a variable equipped with a set of operations that belong to it or are defined
for them. The object-oriented paradigm is currently the most popular paradigm and
everyday programmers, students and professionals try to take a course that has to do
with this paradigm, it could be said that object-oriented programming is fashionable.
The processors used in computers are capable of understanding and acting on
programs written in a fixed language for each architecture, called machine language.
Any program written in a high-level language can be executed in two ways:
 Compiled languages.
Before the program can be used, a translator called a "compiler" must be used, which is
responsible for translating ("compiling") the original program ("source code") into the
equivalent program written in machine or assembly language ("binary"). Binaries are the
executable programs and the only ones necessary for the program to function.
Examples of compiled languages include C, C++, Java, Go and Rust, among many
others.
Coding:
A compiled language has an additional step. If you have a C compiler you can create a
file called hello.c with the following content, or any valid C code:

#include <stdio.h>

int main()
{

printf("Hola Mundo");

return 0;

Before running it you must compile it with the following command:

$ gcc hello.c -o hello

That creates a file called hello (without extension) with the machine code (called the
executable) that you can run in the console with the following command:

$ ./hello

You should get the string "Hello World" below it. If you need to change the source code
you must recompile it and run it again.
 Interpreted languages.
Each time the program is used, a translator called an "interpreter" must be used to
translate ("interpret") the instructions of the original program ("source code") into
machine code as they are used. The original code and the interpreter are always
necessary for the operation of the program.
Examples of interpreted languages include Ruby, Python and JavaScript, among many
others.
Coding:
Ruby is an interpreted language, so we can create a file called hello.rb with the
following code, or any valid Ruby code (this is known as the source code):

puts "Hola Mundo"

And run it directly by entering the following command in the console:

$ ruby hello.rb
You should get the string "Hello World" below it. If you want you can change the source
code and run it again.

Differences between compiled and interpreted languages.


 Compiled languages are compiled once and used as many times as you want
without having to re-use the compiler. Interpreted languages are interpreted,
redundantly, every time they are executed and always need the interpreter.
 Compilers analyze the entire program and do not generate results if all the code
is not correct. Interpreters analyze instructions as they need them and can start
the execution of a program with errors and even correctly terminate an execution
of a program with errors as long as it was not necessary to use the instructions
containing those errors.
 A compiler translates each instruction only once. An interpreter must translate an
instruction each time it encounters it.
 Binaries are compiled for a specific architecture and cannot be used on other
unsupported architectures (although different compilers may exist to generate
binaries for different architectures). An interpreted language can be used on any
architecture that has an interpreter without changes.
 Compiled languages are more efficient than interpreted languages and also allow
the program to be distributed confidentially via binaries.
 It is easier to package interpreted languages inside other languages, such as
JavaScript inside HTML.
Variables and Storage
The concept of Variable
A variable is an abstraction about a value stored in a memory location, using the
representation associated with a data type.
- A variable can have a name
- The stored value can change during the execution of a program.
- The location can change during program execution
Attributes
In a program, a variable is an entity that is composed of attributes, which are:
 Identity (a value of an implementation-dependent type).
 Name (a sequence of digits and letters)
 Memory location (a pointer type value)
 Value (a sequence of bits)
 Type (formal entity, determines the representation)
 Lifetime (time interval(s))
Variable scope
- It is the portion or portions of the source program in which the occurrence of the
variable name is correct and refers to the variable, its attributes or its value.
- Variables without a name have no scope.
Types of variables
Variables (which are not part of other variables) can be classified by their lifetime and
scope into several types:
 Named variables
 Global
 Local (variables in the stack)
 Static local
 Variables in the heap.
Named variables.
- These are variables that have a name or identifier associated with them.
- This identifier appears in program text
- These variables can be accessed directly using this name, or in some cases through
references (aliasing).
Global variables
- Their scope is the whole program
- Their lifetime coincides with the execution time of the program.
They are considered in C/C++, but not in Ada, Java or C#, since they are considered to
increase cohesion and may cause errors.
Global variables (C/C++)
Their scope can be:
- a single compilation unit (.c file)
- several units:
- in one it is declared without the keyword extern
- in the others, it is declared with the extern keyword.
Example of global vars. in C/C++
In this example, i is a global variable, whose scope is the whole source file where it
appears:

Local variables (on the stack, stack variables)


- Their scope is restricted to a statement or a subprogram.
- Their lifetime coincides with the time intervals in which the statement or subprogram is
being executed.
or subprogram
- They are created and destroyed automatically when entering or exiting the
subprogram or statement.
They are provided for in most languages.
Local variables in C/C++
- In C they go only at the beginning of a block
- In C++ they can go to any statement (the scope is to the end of the block).

Local variables in Java and C#


Similar syntax to C++, they can also be declared in place of any statement (scope is up
to
the end of the block)

Local variables in Ada


Can appear as local to a procedure or function
Local variables in Python
- All variables created (i.e., assigned for the first time) in a subprogram are local to that
subprogram.
subprogram
- In principle, any global variable with the same name that might exist is no longer
accessible from the subprogram.
from the subprogram.
- This mechanism is not available for blocks in if statements or loops.
Example of local vars. in Python
In this example, two different variables named c are involved, one global, the other local
to the subprogram subprog

Local static variables


- Their scope is restricted to a statement or a subprogram (in some languages, their
scope can be a class or a module, see below).
a class or a module, as will be seen later)
- Their lifetime coincides with the execution time of the program.
- They are considered in C/C++ (in Ada they can only appear in the hidden part of
packages, in Java and C# only in classes).
and C# only in classes)
Local static variables in C/C++
- They are declared by prefixing them with the static keyword
- They are created before the first time the control flow arrives at the declaration
(immediately before
at the latest)
- They are destroyed at the end of the program
Example of local static variables in C/C++

Variables in the heap (heap variables)


- They have no name, and therefore do not have a scope assigned to them.
- They are accessed exclusively using references.
- Access is made directly or indirectly from references stored in named variables.
named variables.
Example of heap variable in C

Example of array variable in the heap in C++


Example of a variable in the heap in Ada
Storage
Memory
The main memory is one of the most important components of a computer and is used
for information storage (data and programs). There are two types of memory and
storage: Main storage (main memory or central memory) and secondary storage or
mass storage (disks, tapes, etc.).
The central memory of a computer is a storage area organized into hundreds or
thousands of individual storage units or cells. The central memory consists of a set of
memory cells (these memory cells or locations are also called words, although they do
not "keep" analogy with the words of the language).
Magnetic disks
Disks are devices consisting of electromagnetic components that allow fast access to
physical blocks of data. The information is recorded on the surface of the disk and
accessed by read/write heads that move over the surface. Magnetic disks are classified
into floppy disks (floppy disk) and hard disks (hard disk).
Optical discs: CD-ROM and DVD
Optical disks differ from traditional hard disks or magnetic disks in that the former use a
laser beam to record information. They are storage devices that use the same
technology as compact audio devices to store digital information. For this reason they
usually have the same characteristics as music discs: very resistant to the passage of
time and with a large storage capacity. These discs are usually used to store historical
information (they will not be modified frequently), complex graphic files, digital images,
etc.
Conclusion.
A basic understanding of the concepts of programming languages and the different
paradigms are necessary for all software engineers, not so much for specialists in one
programming language. This is because programming languages are a fundamental
tool.
Programming languages greatly influence the way we think about the design and
construction of software and the algorithms and data structures we use to develop
software.
The programming paradigms are very useful for both work and daily life, since in order
to carry them out we must always take into account a base problem from which the
others are derived, and if we have the basic knowledge of each of them we will be able
to solve an infinite number of problems, not only educational but also personal. There
are a great number of paradigms with their different characteristics that make them
unique and incomparable, helping us to carry out one program better than another.
References.
https://guimi.net/descargas/Monograficos/G-Lenguajes_de_programacion.pdf
https://blog.makeitreal.camp/lenguajes-compilados-e-interpretados/
Introducción a la Programación, Teoría y Práctica, Jesús J. Rodríguez Salas, Ed. Club
Universitario

You might also like