0% found this document useful (0 votes)
5 views31 pages

CSC 432 - Comp Programming II

The document discusses the principles of programming languages, emphasizing their importance in expressing algorithms, choosing appropriate languages, and learning new languages. It covers various application domains, criteria for language evaluation, influences on language design, language paradigms, trade-offs in design, implementation methods, and a brief history of programming languages. Additionally, it provides specific information about languages like ALGOL, C++, and C#, highlighting their features and uses.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views31 pages

CSC 432 - Comp Programming II

The document discusses the principles of programming languages, emphasizing their importance in expressing algorithms, choosing appropriate languages, and learning new languages. It covers various application domains, criteria for language evaluation, influences on language design, language paradigms, trade-offs in design, implementation methods, and a brief history of programming languages. Additionally, it provides specific information about languages like ALGOL, C++, and C#, highlighting their features and uses.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

(As you have just found out, you cannot read all these so ask for AOC abeg 🥲)


(Did you know that APL means “A Programming language”)

Some random dude’s version CSC 432

lECTURE 1

Principles of Programming Languages II (CSC 432)


A programming language is a computer language used by programmers
(developers) to communicate with computers. It is a set of instructions written in any specific
language ( C, C++, Java, Python) to perform a specific task.

Reasons For Studying Concepts Of Programming Languages


1. Increased ability to express ideas/algorithms: In natural language, how you think is

😁
influenced by the power of the language you speak (tom scott made a video about this
), and for programming languages, the quality of the algorithm you implement is
influenced by the available constructs in the programming language.
2. Improved background for choosing appropriate Languages: Instead of using the most
appropriate language, many programmers use the language they are most familiar
with even though it is poorly suited for the project
3. Increased ability to learn new languages: Just like knowing the grammar will make
learning English easier, knowing the concepts of a language will make it easier to
learn. (like if you know OOP concepts you can very easily learn any OOP language)
4. Better Understanding of the Significance of implementation
5. Better use of languages that are already known
6. The overall advancement of computing

Application Domains (Of what 🤷🏽, he didn't specify I guess of


Programming sha)
1. Scientific Applications
2. Data processing Applications
3. Text processing Applications
4. Artificial intelligence Applications
5. Systems Programming Applications
6. Web software
Scientific Applications Involve manipulating numbers and arrays of numbers using
mathematical and statistical principles as a basis for the algorithms. Algorithms that solve
problems from statistical significance tests, linear programming, regression analysis and
numerical approximations for the solution of differential and integral equations.
Scientific programming languages are Fortran, Pascal, Meth lab…

Data Processing Applications Involve programming problems interested in the creation,


maintenance, extraction and summarization of data in records and files.
An example of a Dp language is COBOL.

Text Processing Applications Involve manipulating natural language text as data (not
numbers). SNOBOL and C have strong text-processing capabilities.

Artificial Intelligence Applications Involve programs designed to emulate intelligent


behaviours like playing games, chess natural language understanding programs, computer
vision, robotics and expert systems. LISP and PROLOG using the principle of ‘’Logic
programming’’. Lately, AI applications are written in Java, c++ and python.

Systems Programming Applications Involve developing programs that interface hardware


with the programmer and operator. These programs include compilers, assemblers,
interpreters, input-output routines, program management facilities and schedules for utilising
and serving the various resources that comprise the system. Examples are Ada, Modula – 2, C
etc.

Web Software Includes a collection of languages like


I. Markup lang (e.g XHMLM)
II. Scripting lang for client-side dynamic content embedded in XHTML (e.g Javascript,
PHP using the common Gateway interface, JSP, ASP, PHP)
III. General purpose executed on a web server through CGI (e.g Java, C++)

Criteria for language evaluation and comparison


1. Expressivity - The ability of a language to clearly reflect the meaning intended by the
programmer. Expressive languages encourage the use of statement forms associated
with structured programming (like“while “loops and “if – then – else” statements…)
2. Well–Definedness - Means that the language’s syntax is not ambiguous but internal,
consistent, and complete. The programmer should be able to predict exactly the
behavior of each expression before it is executed.
3. Data types and structures - Means the ability of a language to support a variety of data
values (integers, real, strings, pointers etc.). Elementary and non-elementary.
4. Modularity - (Sub programming, we mean the ability to define independent
procedures and functions (subprograms) Modularity is the ability of a language to
support sub programming and allow programmers define operators and datatypes then
invoke those functions using parameters and global variables.
5. Input-Output facilities - The ability of a program to support sequential, indexed, and
random access files, as well as support for database and information retrieval.
6. Portability - The ability of a language to run of a variety of computers. (The design is
relatively”machine – independent”)
7. Efficiency - Means a language permits fast compilation and execution on the
implemented machine. Traditionally, FORTRAN and COBOL are efficient.
8. Pedagogy - Is the ability of a language to be easy to learn and teach. They have
textbooks to help learn.
9. Generality - Means that a language is useful in a wide range of programming
applications. For instance, APL has been used in mathematical applications involving
matrix algebra and in business applications as well.
Influences On Language Design
1. Computer Architecture: Languages are developed around the Von Neumann
architecture (the most prevalent computer architecture). The speed of the computer is
determined by the connetion speen between the memory and CPU. Program
instructions usually execute faster than the connection speen, causing bottleneck (Von
Neumann bottleneck).
2. Programming Methodologies: New methodologies (e.g Object Oriented Software
Development) led to new paradigms in programming and by extension, to new
programming languages.

Language Paradigms (Developments in Programming Methodology)


1. Imperative - This is designed around the Von Neumann architecture. Central features
are variables, assignment statements and ileration, sequency of commands, explicit
state update via assignment. Examples of such languages are Fortran, Algol, Pascal,
e/c++, Java, Perl, Javascript, Visual BASIC.NET.
2. Funtional - Here, the main means of making computations is by applying functions
to parameters. Examples are LISP, Scheme, ML, Haskell. It may also include OOP

😁
concepts (So basically, instead of having functions inside classes, the functions are the
root directory…And Kotlin is also a functional language but who’s asking ).
3. Logic - Here computations are made with logical inference and rules (with no
particular order). Examples are PROLOG and CLIPS. It may also include OOP
concepts.

Trade-Offs In Language Design


1. Reliability Vs. Cost of Execution - For example, Java demands that all references to
array elements be checked for proper indexing, which leads to increased execution
costs.
2. Readability vs. Writability - Programming languages provide powerful operators
(and a large number of new symbols), allowing complex computations to be written in
a compact program but at the cost of poor readability.
3. Writability (Flexibility) vs. reliability - The pointers in c++ for instance are
powerful and very flexible but are unreliable.
Implementation Methods
1. Compilation – Programs are translated into machine Language & System calls
2. Interpretation – Programs are interpreted by another program (an interpreter)
3. Hybrid – Programs translated into an intermediate language for easy interpretation
4. Just–in-time – Hybrid implementation, then compile sub programs code the first time
they are called.
5. Pure Interptretation.

Compilation
1. Translated high level program (source language) into machine code (machine
language
2. Slow translation, fast execution
3. Compilation process has several phases
a. Lexical analysis converts characters in the source program into lexical units
(e.g. identifiers, operators, keywords).
b. Syntactic analysis: Transforms lexical units into parse trees which represent
the syntactic structure of the program.
c. Semantics analysis check for errors hard to detect during syntactic analysis
d. Generate intermediate code.
e. Code generation – Machine code is generated

Interpretation
1. Easier implementation of programs (run-time errors can easily and immediately be
displayed).
2. Slower execution (10 to 100 times slower than compiled programs)
3. Often requires more memory space and is now rare for traditional high level
languages.
4. Significant comeback with some Web scripting languages like PHP and JavaScript.
5. Interpreters usually implement as a read-eval-print loop:
a. Read expression in the input language (usually translating it in some internal
form)
b. Evaluates the internal forms of the expression
c. Print the result of the evaluation
d. Loops and reads the next input expression until exit
6. Interpreters act as a virtual machine for the source language:
a. Fetch execute cycle replaced by the read-eval-print loop
b. Usually has a core component, called the interpreter “run-time” that is a
compile program running on the native machine.

Hybrid
1. This involves a compromise between compilers and pure interpreters. A high level
program is translated to an intermediate language that allows easy interpretation
2. Hybrid implementation is faster than pure interpretation. Examples of the
implementation occur in Perl and Java.
a. Perl programs are partially compiled to detect errors before interpretation.
b. Initial implementations of Java were hybrid. Java’s intermediate form, byte
code, provides portability to any machine that has a bytecode interpreter and a
run time system (together, these are called Java Virtual Machine).

Just-In-Time Implementation
This implementation initially translates programs to an intermediate language and then
compiles the intermediate language of the subprograms into machine code when they are
called. The machine code version is kept for subsequent calls.
Just-in-time systems are widely used for Java and .NET languages.

A Brief History of Programming Languages


1. Assembly languages
2. IBM 704 and Fortran–FORmula TRANslation
3. LISP –LISt Processing
4. ALGOL 60 – International Algorithmic language
5. Simul 67 – First object-oriented language
6. Ada – history’s largest design effort
7. C++ - Combining Imperative and Object–Oriented Features
8. Java – An Imperative – Based Object – Oriented language
9. Prolog– Logic Programming

Algol
ALGOL 68 (ALGOrithmic Language 1968) is a computer programming language that was
designed as a successor to ALGOL 60, with a wider scope of application and more rigorously
defined syntax and semantics. It features expression-based syntax, user-declared types,
structures, and tagged unions; a reference model of variables, and support for string and array
slicing, as well as concurrency. ALGOL 68 was designed by IFIP Working Group 2.1 and
was formally adopted by them on December 20, 1968. It was defined using a two-level
grammar formalism created by Adriaan van Wijngaarden, which allows for a more expressive
and flexible way of defining the language's syntax.

Notable Algol Language Elements


● Bold symbol and reserved words: There are 61 reserved symbols (mode, op, prio,
proc, flex, heap, loc, long, ref, short, bits, bool, bytes, char, compl, int, real, sema,
string, void, channel, file, format, struct, union, of, at "@", is ":=:", isnt":/=:", ":≠:",
true, false, empty, nil "○", skip "~", co comment "¢", pr, pragmat, case in ousein
outesac"( ~ | ~ |: ~ | ~ | ~ )", for from to by while do od, if then elifthen else fi "( ~ | ~
|: ~ | ~ | ~ )", par begin end "( ~ )", go to, goto, exit ".". mode: Declarations)
● The basic data types (called modes in ALGOL 68 parlance) are real, int,
compl(complex number), bool, char, bits and bytes
For example: //Honestly I don’t really understand this part
intn = 2; //This is saying int n = 2. But its a constant cuz no : before the =
con is a fixed constant of 2.co //I don’t understand the “co” too. Sha put it
intm := 3; //I guess the : means it’s a variable i.e changable
com is a newly created local variable whose value is initially set to 3. //Shalaye
This is short for ref intm = locint:= 3; co //Me I don’t understand this rubbish
Real avogadro = 6.0221415􀀀23; co Avogadro's number co
longlong real pi = 3.14159 26535 89793 23846 26433 83279 50288 41971 69399
37510;
Compl square root of minus one = 0 ⊥1
However, the declaration real x; is just syntactic sugar for ref real x = loc real;. That
is, x is really the constant identifier for a reference to a newly generated local real
variable
● Special Characters: Most of Algol's "special" characters (×, ÷, ≤, ≥, ≠, ¬, ∨, ∧, 􀀀,
→, ↓, ↑, □, ⌊, ⌈, ⎩, ⎧, ○,⊥and ¢) can be found on the IBM 2741 keyboard with the
APL "golf-ball" print head inserted, these became available in the mid-1960s while
ALGOL 68 was being drafted. These characters are also part of the Unicode standard,
and most of them are available in several popular fonts.
● Transput: Input and output: Transput refers to ALGOL 68's input and output facilities.
There are pre-defined procedures for unformatted, formatted, and binary transput.
Files and other transput devices are handled in a consistent and machine-independent
manner. The following example prints out some unformatted output to the standard
output device:
print ((newpage, "Title", newline, "Value of i is ", i, "and x[i] is ", x[i], newline))
Note the predefined procedures newpage and newline passed as arguments.

C++
is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming
language. It is regarded as an intermediate-level language, cuz it has both high-level and
low-level language features. developed by Bjarne Stroustrup starting in 1979 at Bell Labs as
an enhancement to the C language. It was originally named "C with Classes" and then
renamed "C++” in 1983.
It is one of the most popular languages cuz it’s used in; systems software (like Windows),
application software, device drivers, embedded software, high-performance server and client
applications, and video games.
C++ is sometimes called a "hybrid language" cuz it can be object-oriented or procedural.
Some C++ programmers are still writing procedural code, but think it is object orientated.
Most time it’s both OO and procedural.

Language Features
C++ inherits most of C's syntax, but also includes additional features like OOP.
The above code is a simple C++ program that uses the C++ standard library's stream facility
to write "Hello, world!" to the standard output. In C++, if a function is defined with a
non-void return type and no value is returned before the end of the function, it results in
undefined behavior. The only exception to this rule is the main function, which will return a
value of zero if no other value is explicitly returned.

Operators and operator overloading


C++ provides various operators for basic arithmetic, bit manipulation, indirection,
comparisons, and logical operations. These operators can be overloaded for user-defined
types, but some operators such as member access operators (., .*) cannot be overloaded.
Overloading operators is an important feature of C++ as it allows the language to be used as a
domain-specific language. Additionally, it is an essential part of many advanced C++
programming techniques, such as smart pointers. However, overloading an operator does not
change its precedence or the number of operands it uses, and the overloaded "&&" and "||"
operators lose their short-circuit evaluation property.

C#
C# is a programming language developed by Microsoft as part of the .NET Framework. It
was originally developed under the name "Cool" (C-like Object Oriented Language) but was
later renamed to C#. C# is a modern, object-oriented language that is similar to C++ in terms
of syntax. Some of the notable features of C# include:
1. It does not have global variables or functions, all methods and members must be
declared within classes.
2. local variables cannot shadow variables of the enclosing block. //shadowing is when a
variable within a scope has the same name as a variable declared in the outer scope
3. It has a strict Boolean data type.
4. It has a try-finally construct to guarantee the execution of code in the finally block.
5. It has 77 reserved words
6. It does not support multiple inheritances but a class can implement any number of
interfaces.

Common Type System (CTS)


C# has a unified type system, known as the Common Type System (CTS). This means that all
types, including primitive types such as integers, are subclasses of the “System.Object” class.
As a result, all types inherit a ToString() method from this class. For performance reasons,
primitive types and value types in general are allocated on the stack, rather than on the heap,
which is typically used for storing objects.

Categories of data types


//I don’t understand this sha
C# Common Type System (CTS) categorises data types into two categories: value types and
reference types.

Value types are plain aggregations of data, instances of value types do not have a referential
identity or referential comparison semantics. Equality and inequality comparisons for value
types compare the actual data values within the instances unless the corresponding operators
are overloaded. They are derived from System.ValueType always has a default value and can
always be created and copied. Examples of value types are all primitive types, such as int,
float, char and System.DateTime. Value types cannot derive from each other and cannot have
an explicit default constructor.

Reference types have the notion of referential identity, each instance of a reference type is
inherently distinct from every other instance, even if the data within both instances is the
same. In general, it's not always possible to create an instance of a reference type, copy an
existing instance, or perform a value comparison on two existing instances. Examples of
reference types are object, System.String and System.Array.

Both type categories are extensible with user-defined types.

lECTURE 2
Programming languages are computer languages used by programmers to communicate with
computers. It is a set of instructions written in any specific language ( C, C++, Java, Python)
to perform a specific task. Like developing websites, desktop, and mobile app.

Types of Prog Languages

Low-Level Languages
This is a type of programming language that is machine-dependent and is directly
understood by the computer's processor without the need for a compiler or interpreter. It is
divided into two parts: Machine language and Assembly Language.

1. Machine language is a type of low-level programming language which is also called


machine code or object code. It is written in binary or hexadecimal form and does not
require a translator to convert the programs. The advantage of machine language is
that it helps the programmer (or frankly Mad person) execute programs faster than
high-level programming languages.
2. Assembly language (ASM) is also a type of low-level programming language that is
designed for specific processors. It uses symbolic notations and is human-readable. It
uses an assembler to convert assembly language to machine language. The advantage
of assembly language is that it requires less memory and less execution time to
execute a program.

High-Level Language
High-level programming language (HLL) is designed for developing user-friendly
software programs and websites. These languages require a compiler or interpreter to
translate the program into machine language before it can be executed. The main advantage
of high-level languages is that they are easy to read, write, and maintain. Examples of
high-level programming languages include Python, Java, JavaScript, PHP, C#, C++,
Objective C, Cobol, Perl, Pascal, LISP, FORTRAN, and Swift. HLL is divided into three
parts.
1. Procedural Oriented Programming (POP) language: Is derived from structured
programming and is based on the procedure call concept. It divides a program into
small procedures called routines or functions. The advantage of POP language is that
it helps programmers easily track the program flow and the code can be reused in
different parts of the program. Examples of POP languages include C, FORTRAN,
Basic, Pascal, etc.
2. Object-Oriented Programming (OOP) language: Is based on objects. Here programs
are divided into small parts called objects. It is used to implement real-world entities
like inheritance, polymorphism, abstraction, etc to make the program reusable,
efficient, and easy to use. The main advantage of object-oriented programming is that
it is faster and easier to execute, maintain, modify, as well as debug. Examples of
OOP languages include C++, Java, Python, C#, etc.
3. Natural language: Is a part of human languages such as English, Russian, German,
and Japanese. It is used by machines to understand, manipulate, and interpret human
language. It is used by developers to perform tasks such as translation, automatic
summarization, Named Entity Recognition (NER), relationship extraction, and topic
segmentation. The main advantage of natural language is that it helps users to ask
questions in any subject and directly respond within seconds.

Middle-level programming language


They are between high and low level languages. They are also known as intermediate
languages and pseudo-language. It supports HLL features, is user friendly, and closely related
to machine language and human language. E.g C, C++
Categories Of Programming Languages
Programming languages communicate instructions to a computer and there are many
categories.
1. Interpreted Programming Languages
2. Functional Programming Languages
3. Compiled Programming Languages
4. Procedural Programming Languages
5. Scripting Programming Languages
6. Markup Programming Languages
7. Logic-Based Programming Languages
8. Concurrent Programming Languages
9. Object-Oriented Programming Languages

Interpreted Programming Languages


A programming language where most of its implementations execute instructions
directly, without previously compiling into machine-language instructions.
1. Apl: Named after the book A Programming Language (Iverson, Kenneth E., 1962),
APL is an array programming language that works simultaneously on multiple arrays
of data.
2. Autolt: It is a freeware automation language for Windows for creating automation
scripts that can be used for the execution of repetitive tasks.
3. Basic: Beginner’s All-purpose Symbolic Instruction Code. It was designed to give
non-science people access to computers.
4. Eiffel: It is an OOP that is ISO standardised and used to develop extensible and
reusable software. Used in finance, aerospace and video gaming.
5. Forth: It is a structured imperative programming language, which bases its
implementation on stacks
6. Frink: It is based on the Java Virtual Machine and focuses on science and engineering
7. Game maker language: A programming language used with Game Maker, an
application for game creation.
8. ICI: A general-purpose interpreted computer programming language.
9. J
10. Lisp
11. Lua
12. M
13. Pascal: It is a procedural programming language that was intended to use data
structuring and structured programming
14. Pcastl
15. Postscript
16. Python: It is an HLL that has imperative, OOP, and functional programming features.
It also has automatic memory management
17. Rexx
18. Ruby: Similar to Perl, it has a dynamic type system and automatic memory
management. It is a dynamic object-oriented language
19. S language
20. Spin

Functional Programming Languages


They focus define every computation as a mathematical evaluation. on the application of
functions. Examples are:
1. Charity
2. Clean
3. Curry
4. Erlang
5. F#
6. Haskell
7. Joy
8. Kite
9. ML
10. Nemerle
11. OPAL
12. OPS5
13. Q

Compiled Programming Languages


Are languages whose implementations are typically compilers (translators that generate
machine code from source code), and not interpreters

1. Ada: It is a statically typed, structured, imperative programming language that is


based on Pascal
2. Algol: Is actually a family of imperative programming languages that was developed
in the middle 1950s
3. C(//Grandfather to many): It is a general-purpose, cross-platform, procedural,
imperative programming language. Used for implementing system software and
application software and is one of the most-used computer programming languages of
today(//Very false…It’s probably Javascript).
4. C++: Considered as a middle-level programming language, it has high and low-level
language features. Originally known as ‘C with Classes’, it came to be known as C++
from 1983. It is a multi-paradigm language that supports procedural programming,
generic programming, object-oriented programming, and data abstraction.
5. C#: C Sharp is a multi-paradigm programming language that supports imperative,
generic and object oriented programming. It is a part of the Microsoft .NET
Framework. It is similar to C++ in its object-oriented syntax and is also influenced by
Java and Delphi.
6. CLEO
7. COBOL: Stands for Common Business-Oriented Language that is designed for the
business and finance domain
8. Cobra
9. D
10. DASL
11. DIBOL
12. Fortran: It is a procedural, imperative, general purpose computer programming
language that works well for scientific computations and numeric
operations.Developed by IBM in 1950. Later revised to Fortran95. Fortran 2003
13. Java: It is a general-purpose computer programming language that is concurrent,
class-based, objectoriented, and specifically designed to have as few implementation
dependencies as possible. Compiled Java code can run on all platforms that support
Java without the need for recompilation
14. Jovial
15. Objective-C: It is a reflective object-oriented programming language that adds
messaging services to C.
16. SMALL
17. Smalltalk
18. Turing
19. Visual Basic: It is an event-driven programming language that is packaged with an
integrated development environment. It inherits many of its features from BASIC. Its
graphical development features make it easy for beginners.
20. Visual FoxPro
21. XL

Procedural Programming Languages


Procedural (imperative) programming implies specifying the steps that the programs should
take to reach to an intended state. Procedures help in the reuse of code. Procedural
programming makes the programs structured and easily traceable for program flow.

1. Bliss
2. ChucK
3. CLIST
4. HyperTalk
5. Modula-2
6. Oberon
7. Component Pascal
8. MATLAB
9. Occam
10. PL/C
11. PL/I
12. Rapia
13. RPG

Scripting Languages
Scripting languages are programming languages that control an application. Scripts can
execute independent of any other application. They are mostly embedded in the application
that they control. They are used for automation or communication with external programs.

1. Applescript (LOL)
2. AWK
3. BeanShell
4. ColdFusion
5. F-Script
6. JASS
7. Mondrian
8. PHP: Hypertext Preprocessor(How that makes sense? I don;t know too) is one of the
very popularly used general purpose scripting languages. It is developed for creating
dynamic web pages and supports a command line interface capability
9. Revolution
10. Tcl
11. VBScript
12. Windows Powershell

Markup Languages
A markup language is an artificial language that uses annotations to text that define how the
text is to be displayed.

1. Curl
2. SGML
3. HTML: Hypertext Markup Language is the most prominent markup language used for
web pages. It is written in the form of HTML tags that are surrounded by angular
brackets. HTML tags describe the appearance of the text in a document.
4. XML: Extensible Markup Language. It is extensible because it allows the users to
define their own XML elements. It supports the sharing of structured data over the
Internet and the encoding and serializing of data.
5. XHTML: It is a markup language that is similar to HTML and follows the XML
syntax. It is midway between HTML and XML.
Logic-Based Programming Languages
Logic programming is a type of programming paradigm which is largely based on formal
logic. It is used for expressing facts and rules about some problem domain.

1. ALF
2. Fril
3. Janus
4. Leda
5. Oz
6. Poplog
7. Prolog: It is a general-purpose programming language that supports logic
programming and is often linked with artificial intelligence and computational
linguistics. The language is declarative and the program logic is expressed in the form
of relations
8. ROOP

Concurrent Programming Languages


Is a computer programming technique that provides for the execution of operations
concurrently — either within a single computer or across a number of systems.

1. ABCL
2. Afnix
3. Clik
4. E
5. Joule
6. Limbo
7. Pick
8. Salsa
9. SR

Object Oriented Programming


is a programming paradigm based on the concept of “objects”, which may contain data, in the
form of fields known as "attributes", and code known as "functions/methods".

1. Agora
2. BETA
3. Cecil
4. Bava
5. Lisaac
6. MOO
7. Moto
8. Object-Z
9. Obliq
10. Oxygen
11. Pliant
12. Prograph
13. REBOL
14. Scala
15. Self
16. Slate
17. IO

Most commonly used Programming Language

Python
It is a user-friendly language. It was developed in the 1990s. It is mostly used in Machine
learning, Artificial intelligence, Big Data, GUI based desktop applications, and Robotics.

Advantage
1. Easy to read, write and understand
2. Integrates nicely with other languages
3. Executes line by line, so easy to find bugs
4. It is platform independent, so write once - run everywhere

Disadvantage
1. Not suitable for developing games and mobile apps
2. Slower than C and C++ because it uses interpreter

Java
It is simple, secure, platform-independent, reliable, architecture-neutral high-level
programming language developed by Sun Microsystems in 1995. Now, Java is owned by
Oracle.

Advantage
1. Write, compile, learn, and debug
2. It provides an ability to run the same program on different platforms.
3. It is highly secured because there are no explicit pointers
4. It can perform multiple tasks at the same time

Disadvantage
1. Consumes more memory and slower than languages like C or C++ (Then again, what
is ever faster than C of C++)
2. It does not provide a backup facility

C
It is a popular, simple, and flexible general-purpose language.Developes in 1972 at AT&T. It
is a combination of both low-level and high-level language.

Advantages
1. It is easy to learn.
2. It fast, efficient, portable, easy to extend, powerful, and flexible.
3. It is used to perform complex calculations and operations such as MATLAB
4. It provides dynamic memory allocation to allocate memory at the run time

Disadvantages
1. It is very difficult to find the errors.
2. It does not support OOP concepts (constructors, destructors, abstraction,
polymorphism, encapsulation, and namespace)

C++
It was developed by BjarneStroustrup in 1980. It is similar to the C, but also includes some
additional features such as exception handling, object-oriented programming, type checking,
etc.

Advantages
1. It is a simple and portable structured programming language.
2. It supports OOPs features such as Abstraction, Inheritance, Encapsulation.
3. It provides high-level abstraction and is more efficient for general-purpose
programming
4. It is more compatible with the C language.
Disadvantages
1. It is not secured as compared languages like Java or Python.
2. It doesn’t have a garbage collection.
3. It is difficult to debug large as well as complex web applications.

C#
C# (pronounced as C sharp) is a modern, general-purpose, and object-oriented programming
language used with XML based Web services on the .NET platform. It is easier to learn for
users with knowledge of languages like C, C++, or Java.
Advantages
1. It is a modern, type-safe, easy, fast, and open-source language that is easily integrated
with Windows.
2. The maintenance is lower than the C++.
3. It is a pure object-oriented programming language.
4. It includes a strong memory backup facility. That's why it avoids the problem of
memory leakage.

Disadvantages
1. It is less flexible because it is completely based on Microsoft .Net framework.
2. It is difficult to write, understand, debug, and maintain multithreaded applications.

Javascript
It is a scripting language used on both client-side and server-side. It is developed in the 1990s
for the Netscape Navigator web browser. It allows programmers implement complex features
to make web pages alive.

Advantage
1. It adds behavior and interactivity on the web page.
2. It can be used to decrease the loading time from the server.
3. It has the ability to create attractive, dynamic websites, and rich interfaces.
4. It is simple, versatile, and lightweight
5. Its syntax are easy to understand.

Disadvantage
1. It is completely based on the browser.
2. It does not support multiple inheritance.
3. It is less secure compared to other programming languages.

PHP

GO

Ruby
A Categorical List of Prog Languages
Too much note there jare. I don’t think it’s necessary

Lecture 3 -> 3_2

Expression Notations - Infix, Prefix and Postfix


Expressions
Prefix expression requires that all operators precede the two operands that they work on
Postfix, requires that its operators come after the corresponding operands.

To explain postfix use the below article


4.9. Infix, Prefix and Postfix Expressions — Problem Solving with Algorithms and Data
Structures (runestone.academy)

For prefix, pray it doesn’t come out… or you can just guess I dont know

Example 1
A + B * C in Infix
+ A * B C in Prefix.
A B C * + in postfix

Example 2
Infix Expression : (A + B) * C
Prefix Expression : * + A B C
Postfix Expression: A B + C *

Example 3
Infix Expression : A + B * C + D
Prefix Expression: + + A * B C D
Postfix Expression: A B C * + D +
Example 4
Infix Expression : (A + B) * (C + D)
Prefix Expression : * + A B + C D
Postfix Expression : A B + C D + *

Example 5
Infix Expression : A * B + C * D
Prefix Expression : + * A B * C D
Postfix Expression : A B * C D * +

Example 6
Infix Expression : A + B + C + D
Prefix Expression : + + + A B C D
Postfix Expression : A B + C + D +

Lecture 3_3

Language Semantics
Semantics is the study of the relationship between words and how we draw meaning from
those words.

Semantic Theories
ACC-FOLD

● Formal Semantic: Is the study of grammatical meaning in natural languages using


formal tools

● Lexical Semantics: It deconstruct words and phrases to understand the meaning in


terms of context.

● Conceptual Semantics: It deals with the most basic concept without adding context
with our thoughts and feelings.
● Denotation: Describes the meaning of a program as a mathematical function that maps
inputs to outputs.

● Connotation: It deals with the association or emotional connection of certain words


(e.g snakes are evil)

● Axiomatic semantics: Defines the meaning of a program through a set of axioms or


assertions about the program's behaviour.

● Operational Semantics: Defines the meaning of a program by specifying how it is


executed.

Expressions, Statements, and Blocks

Expressions
A series of variables, operators, and method calls that evaluates to (or return) a single value.
Like the ones in green below
● const y = 2 + 3.
● y = getAnswer().
● 12 + square ( 7 + 5 ) + square( square (2)).

Basically things that return or are equal to a value

Statements
A statement is code that forms a complete unit of execution and is usually terminated with a
semicolon (;).

Types of Statements
1. Expression statements: They sha perform an expression
E.g
● aValue = 8933.234; //assignment statement (In python, this can be a
declarative statement sha)
● aValue++; //increment
● System.out.println(aValue); //method call
● Int age = new Int(4); //object creation

2. Declarative statements: These are statements that declare a value


E.g
● double aValue = 8933.234; //declaration statement
3. Control flow statement: Statements that regulate the order of execution
E.g
● For loops
● If statements
● Case statements

Blocks
These are groups of zero or more statements usually grouped together with braces { }.
E.g
● If…Else blocks

The If…Else parts are statements, but the things it does after are blocks

● Function blocks

Chomsky Classification of Grammars


There are 4 Types: Type 0, Type 1, Type 2, and Type 3
Type - 3 Grammar
Type-3 grammars generate regular languages. Type-3 grammars must have a single
nonterminal on the left-hand side and a right-hand side consisting of a single terminal or
single terminal followed by a single non-terminal.
The productions must be in the form X → a or X → aY
where X, Y ∈ N (Non terminal)
and a ∈ T (Terminal)
The rule S → ε is allowed if S does not appear on the right side of any rule.

Example
X→ε
X → a | aY
Y→b

Type - 2 Grammar
Type-2 grammars generate context-free languages.
The productions must be in the form A → γ
where A ∈ N (Non terminal)
and γ ∈ (T ∪ N)* (String of terminals and non-terminals).
These languages generated by these grammars are be recognized by a non-deterministic
pushdown automaton.
Example
S→Xa
X→a
X → aX
X → abc
X→ε

Type - 1 Grammar
Type-1 grammars generate context-sensitive languages. The productions must be in the form
αAβ→αγβ
where A ∈ N (Non-terminal)
and α, β, γ ∈ (T ∪ N)* (Strings of terminals and non-terminals)
The strings α and β may be empty, but γ must be non-empty.
The rule S → ε is allowed if S does not appear on the right side of any rule. The languages
generated by these grammars are recognized by a linear bounded automaton.

Example
AB → AbBc
A → bcA
B→b

Type - 0 Grammar
Type-0 grammars generate recursively enumerable languages. The productions have no
restrictions. They are any phase structure grammar including all formal grammars.
They generate the languages that are recognized by a Turing machine.
The productions can be in the form of α → β where α is a string of terminals and
nonterminals with at least one non-terminal and α cannot be null. β is a string of terminals
and non-terminals.

Example
S → ACaB
Bc → acB
CB → DB
aD → Db

Regular Expressions
A Regular Expression can be recursively defined as follows −
● ε indicated empty string (L (ε) = {ε})
● Φ denoting an empty language. (L (φ) = { })
● x indicated L = {x}
● If X is a Regular Expression denoting the language L(X) and Y is a Regular
Expression denoting the language L(Y), then
○ X + Y is a Regular Expression corresponding to the language L(X) ∪ L(Y)
where L(X+Y) = L(X) ∪ L(Y).
○ X . Y is a Regular Expression corresponding to the language L(X) .
L(Y) where L(X.Y) = L(X) . L(Y)
○ R* is a Regular Expression corresponding to the language L(R*)where L(R*)
= (L(R))*

Some RE examples are:


Regular Sets
Any set that represents the value of the Regular Expression is called a Regular Set.
There are 5 properties of regular set.

Property 1. The union of two regular set is regular.


Property 2. The intersection of two regular set is regular.

Property 3. The complement of a regular set is regular.


Property 4. The difference of two regular set is regular.

Property 5. The reversal of a regular set is regular.

Property 6. The closure of a regular set is regular.


I don’t understand this one
Property 7. The concatenation of two regular sets is regular.

Declaration
A declaration is a statement describing an identifier, such as the name of a variable or a
function

Two types of declaration:


● implicit declaration : Declarations done by the compiler and user’s don’t specify data
type…like the rubbish in python

● explicit declaration: Declarations where the variable type is explicitely specified…


like the rubbish in Java

Lecture 3_4

Stacks
If it comes out, skip it, you have tried na…ahn ahn

Lecture 3_5

Language Semantics
Lecture 3_6
Programming Language Series

They are Compiled, Interpreted, and Bytecode Languages

Compiled

A compiled language is one where the program is first converted into machine code and then
executed directly on the target machine. E.g C, C++, Go, Rust…

Advantages:

1. Execution is faster
2. It is more efficient
3. It is converted to machine code, so it gives developers more control of memory and
hardware

Disadvantages:

1. It first needs to be manually compiled on the target system before execution


2. When debugging, you'll have to recompile every time
3. It is platform-dependent (compiled code on one machine will not work on a separate
machine)
4. It also takes more space because it stored a separate compiled version

Interpreted

An interpretive language is one in which the instructions are read and executed by some other
program called an interpreter (It is usually written in that language). E.g PHP, Python, Ruby,
Perl…

Advantages

1. It doesn't require manual compilation before execution


2. Debugging doesn't require recompilation
Disadvantages

The main disadvantage is that it is slower than compiled code, but newer technologies like
Just-In-Time compilation, where frequently executed sequences are compiled, have narrowed
the gap.

Bytecode Languages

These are both compiled and interpreted languages. Programs are first compiled from human
readable code to bytecode (bytecode is efficient to interpret and is in between machine
language and high-level language), and then a virtual machine interprets the code like an
interpreter would.

Common examples are Java and C#.

Advantages

1. There is a delay converting to bytecode, but the execution is faster than normal
interpreted
2. It is machine independent (as in the bytecode can be executed on any machine that
has the language's virtual machine without recompilation)

Type checking

Type checking is the process of verifying and enforcing the constraints of variable types,
either at compile time (statically) or at runtime (dynamically).

Like 1 + "2" will give an error in most languages (except rubbish languages like Javascript)

Types Of Type checking

1. Static type checking: This is checking the data types at compile time instead of
runtime. This is faster, uses less memory, and makes it harder to have errors … E.g
C++, C, C#, Java, Fortran…
2. Dynamic type checking: This is verifying the type safety at runtime. This happens
when you cannot verify if a safecast can happen (Like you cannot tell if you can
safely downcast an object of 2 classes at compile time). Examples of languages that
use this are Python, PHP, Javascript Objective C.

Common Misconception
A common misconception is that all statically-typed languages are also strongly-typed
languages, and that dynamically-typed languages are also weakly-typed languages. This isn’t
true. Python is a good example for this.

Python is strongly typed (because variables are bound to specific data types from start), but
also uses dynamic type checking (because it checks at runtime).

So not all strongly typed languages are statically typed.

Garbage Collection
Shalaye first:
When you allocate memory (like by creating a variable), that memory is allocated to
either the stack or the heap.
The stack is super fast at allocating and clearing memory all by itself, but the size and
state cannot change.
But memory alocated in heap will sit till the end of the prorgam except you manually
allocate and deallocate, but it’s state can change.

It is a process of automated memory management. The garbage collector is a tool that


removes the burden of manually managing the heap.

Why Do We Need GC
As you allocate more and more memory to the heap, memory size will begin to add up –
resulting in a heap overflow.

How and When does the Garbage Collector Run


It can either stall your program (i.e. stop-the-world GC) to sweep out all the garbage at once,
run incrementally to remove small batches, or run concurrently with your program.
Garbage Collection Algos

Reference Counting
In this algo, anytime you reference a memory location on the heap, a counter for that
particular memory location increments by 1. Every time a reference to that location is
deleted, the counter decrements by 1. When that counter gets to 0, then that particular
memory location is garbage collected.

Mark- Sweeping
Goan Read it if you want

Mark-Compact
Goan Read it if you want

Copying
Goan Read it if you want

Generational GC
Goan Read it if you want

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy