6th Chapter – Statement-Level Control Structures

This topic is going to explain about selection and iterative statements.

Before that, control structure is a control statement and the statements whose execution it controls.

Selection statements provide the means of choosing between two or more paths of execution. It have 2 general categories: two-way selectors and multiple-way selectors

Two-selectors is when “IF” function is used, the program will going to choose which is true or false. Whilst the multiple-way selectors can be in form of “switch case” in which the selectors will be listed depending on the case.

 

Iterative statements is a statement to do repetition of some task that may be done with iteration or recursion. This may called looping. Following are the categories of looping:

Counter-controlled Loops : Loop that use counter as the limit. When the counter has reached the end, it will stop. Like the use of “for”

Logically controlled loops : loop that use boolean expression to work. When the condition is true or false, it will end the looping.

User-Located Loop Control : Loop that will end the programmers decided to end it. It’s like when there is “break”, it is used to stop a loop.

Posted in Uncategorized | Leave a comment

5th Chapter – Expression and Asignment Statements

Expressions are the fundamental means of specifying computations in a programming language

 

Arithmetic evaluation was one of the motivations for the development of the first programming languages consisting of operators, operands, parentheses, and function calls.

Overloaded operators => Using an operators for more than one purpose which may leads to some problems like loss of error detection and readability.

Type Conversions => Converting the data types of variables. Narrowing conversion is to lessen the range of the data by removing some. Whilst widening conversion is to enlarge the range so the data can include more data.

 

Relational and Boolean Expressions

To relate a data between another with operators such as <= ; >= ; == ;etc.

The result will be in boolean which is true or false.

 

Short-Circuit Evaluation => An expression in which the result is determined without evaluating all of the operands and/or operators

 

Assignment Statements => Statement to assign targeted operators with some expression

Mixed-Mode Assignment => Combining or mixing the assignment statements.

Posted in Uncategorized | Leave a comment

4th Chapter – Data Types

This chapter is about data types, probably not all of them though.

 

Data type

Defining a collection of data objects .and a set of predefined operations on those objects.

A descriptor is the collection of the attributes of a variable

An object represents an instance of a user-defined (abstract data) type

 

Primitive data types => data types that is widely available in most languages. Such as:  integer, floating point, complex, decimal, boolean, and character.

Character String types =>sequences of character

User-Defined Ordinal Types => Range of the possible values

Enumeration Types => All possible values are provided in definition

Subrange Types => An ordered contiguous subsequence of an ordinal type

Array Types => Homogeneous aggregate of data elements in which an individual element is identified by its position in the aggregate

Record Types => Possibly heterogeneous aggregate of data elements in which the individual elements are identified by names

Tuple Types => Similar to a record, except that the elements are not named

List Types => Delimited by parentheses and use no commas

Union Types => Variables are allowed to store different type values at different times during execution

Pointer and Reference Types => Consisting of the memory addresses and special value

Type Checking => An action to evaluate the operands are able to be executed by operators.

Strong Typing => The variables which will be defined must be given a data types or it may turn out as error.

Posted in Uncategorized | Leave a comment

3rd Chapter – Names, Bindings, and Scopes

Basically this chapter is more about what is listed on the title.

 

Names

As the word describes, this is about the rules of naming a variables.

Length => there are minimum but there is the limit on how many characters you can put but it depends on the language which are being used. Example: FORTRAN 95 max is 31 while C99 have no limit but only the first 63 are significant.

Special character => some languages need the use of special character for naming a variable. Example: PHP variables must begin with dollar sign.

Case sensitivity => names in  C-based languages are case sensitive which means different case different variable whilst others language are not sensitive.

Special words => Some words are already defined, so you cannot use it as the name of variables.

 

Variables

A variable is an abstraction of a memory cell

Variables can be characterized as a sextuple of attributes which are name, address, value, type, lifetime, and scope. Meaning: you can insert or define those attributes in the variables.

 

Binding

An association between an entity and an attribute, such as between a variable and its type or value, or between an operation and a symbol.

Binding time is the time at which a binding takes place.

Dynamic type binding is used for its flexibility on the cost of high cost and harder error detection.

 

Scope

the range of statements over which it is visible it can used to making local/non-local/global variables.

Static scope is based on program text and need declaration in order to connect variables.

Dynamic scope is based on calling sequences of program units, not their textual layout (temporal versus spatial) and connected by searching back.

Global scope is on the program itself.

Posted in Uncategorized | Leave a comment

2nd Chapter – Describing Syntax and Semantics

In this chapter we’ll go further on Syntax and Semantics.

But before that what is Syntax and Semantics ?

Syntax:  the structure of the code in a programming language. Much like grammar.

Semantics: the meaning of the code which are written. Like the reason it is written.

 

The formal method of describing syntax is going with the terminology which is the defined words of what is written, such as sentence, language, lexeme, token, etc. Thus

 

Based on Backus-Naur Form and Context-Free Grammar, you can derivate what is written in the code. Like as the following:

<program> => <stmts> => <stmt>

=> <var> = <expr>

=> a = <expr>

=> a = <term> + <term>

=> a = <var> + <term>

=> a = b + <term>

=> a = b + const

 

Attribute Grammars

A context-free grammar G = (S, N, T, P) with the following additions:

–For each grammar symbol x there is a set A(x) of attribute values

–Each rule has a set of functions that define certain attributes of the nonterminals in the rule

–Each rule has a (possibly empty) set of predicates to check for attribute consistency

and the example:

Syntax

<assign> -> <var> = <expr>

<expr> -> <var> + <var> | <var>

<var> A | B | C

  • actual_type: synthesized for <var> and <expr>
  • expected_type: inherited for <expr>

 

Semantics

So far there are no widely acceptable notation of describing this. So go with what I’ve defined on the top ^^^.

Several needs for a methodology and notation for semantics:

–Programmers need to know what statements mean

–Compiler writers must know exactly what language constructs do

–Correctness proofs would be possible

–Compiler generators would be possible

–Designers could detect ambiguities and inconsistencies

List of semantics and what they are:

Operational Semantics: Describing the meaning of a program by executing it.

Denotational Semantics: Based on recursive function theory and the most abstract semantics.

Axiomatic Semantics: Semantics which is based on formal logic (predicate calculus)

Posted in Uncategorized | Leave a comment

1st Chapter – Introduction

Hi everyone, author here. Thanks for opening and reading what’s on this website. To make it brief, I’ll just get into the point. Let’s go, shall we?

So basically this is about intro of Programming Languages Concepts.

Before that, the main reasons of why people who want to take IT as their major should learn about this is because of PLC is crucial in increasing the ability of to express ideas and learn new languages, choosing the right language for them, etc. TL;DR: Getting better in computing.

Programming domain: a specific use of a programming languages, examples: scientific applications, business applications, etc.

In order a language can be accepted universally, it needs evaluation criteria which are:

Readability: the ability of a language to be understood and read.

Writability: the ability of creating a program by a language.

Reliabilty: the ability of how a language can be used and maintained.

Cost: The effectivity of the language.

 

Influences on Languages Design:

Von Neumann architecture is the base of most computer architecture.

Source : https://en.wikipedia.org/wiki/Von_Neumann_architecture#/media/File:Von_Neumann_Architecture.svg

Program Design Methodologies -> New software development means new programming paradigms and languages.

 

Implementation Methods

1.Compilation

Programs are translated into machine language; includes JIT systems

Use: Large commercial applications

2.Pure Interpretation

–Programs are interpreted by another program known as an interpreter

–Use: Small programs or when efficiency is not an issue

3.Hybrid Implementation Systems

–A compromise between compilers and pure interpreters

–Use: Small and medium systems when efficiency is not the first concern

 

Posted in Uncategorized | Leave a comment