Chapter 2 : Programming Language



⚠IF YOU'RE LOOKING FOR  NOTES OF CIS THEN YOU HAVE COME TO THE RIGHT PLAC








Machine Level Language

  • They are just Sequence of Numerals
  • Programs written in Binary Form
  • It is machine dependent
  • Easier for machines to understand and not illegible/ readable for humans
  • There are two parts:
  • a) opcode - command words for operations such as ADD, COMPARE, etc
  • b) operands- specifies the data, or the address of data.
  • Advantages are Fast Execution and No Translation needed.
  • Disadvantages are Error-Prone, Machine Dependent and hard to remember due to only containing 0's and 1's

Assembly Language
  • Mnemonics are used to write program in Assembly language
  • Memory locations are replaced by Hexa-decimals.
  • Assembler is used to translate Assembly Language into Machine Level Language
  • Advantages are easy to memorize, faster than high-level language and easy to understand.
  • Disadvantages are they are machine-dependent, knowledge of hardware si required and coding takes a long time.

High-Level Language
  • A high-level language is a programming language such as Java, C ++, Python, C#, C, Ruby, FORTRAN, etc.
  • They are all machine dependent language.
  • It is a high level because it is closer to human languages & far from the machine language.
  • Advantages are easy to read and write, easy to learn, programmer-friendly and easy to debug.
  • Disadvantages are it takes time to run and more memory is required for the library.

Low-Level Language
  • The programmer of low- level languages should have detailed knowledge of the computer's internal architecture and instruction set.
  • Eg: Machine language, Assembly Language


Assemblers
  • It is a program that translates Assembly Language to machine language.
  • It converts the source code ( Mnemonic code / Symbols ) into Object Code
  • Two types of assembler are One pass Assembler which performs single scan only and Two-Pass Assembler which performs two sequential scans.

     SOURCE CODE =====> ASSEMBLER ====> OBJECT CODE


Compilers
  • It is a program that translates High-Level Language to Machine Level Language.
  • Compiler takes the entire program as input, hence the errors are shown after all the program is checked.
  • Eg: Java, C, C++, etc
  • It generates an error message if found.

Interpreters
  • It takes one instruction at a time, checks it and executes one at a time.
  • If errors are found it shows it right away.
  • Eg: Python, Perl, Matlab, etc
  • Object Code is not generated


Algorithms
  • It is a step by step instruction to solve a problem.
  • Eg; Google search engine
  • In algorithms assignment of values can be done by A <== 3 which means A is equals to 3.
Properties of Algorithms:
  1. Finiteness
  2. Definiteness
  3. Input
  4. Output
  5. Effectiveness

Flow Charts
  • It is known as a diagrammatical representation of an Algorithm.
  • Advantages of Flow Chart are:
  1. Communication
  2. Effective Analysis
  3. Coding becomes easy
  4. Efficient Program Maintenance
  5. Documentation of Program/ System
  • Some Examples Questions of Flow Chart are shown below:

Three Basic Operations: Sequence, Selection, and Iteration

a) Sequence
  •  This means that the computer will run your code in order, one line at a time from the top to the bottom of your program. 
  • It will start at line 1, then execute line 2 then line 3 and so on till it reaches the last line of your program.
b) Selection ( Branching )
  • Sometimes you only want some lines of code to be run only if a condition is met, otherwise you want the computer to ignore these lines and jump over them. 
  • This is achieved using IF statements. e.g. If a condition is met then lines 4, 5, 6 are executed otherwise the computer jumps to line 7 without even looking at lines 4,5 and 6.
c) Iteration ( Repetition )
  • Sometimes you want the computer to execute the same lines of code several times. This is done using a loop. 
  • There are three types of loops: For loops, while loops and repeat until loops. 
  • That’s handy as it enables you not to have to copy the same lines of code many times.

Structured Programming


  • Structured Programming is defined as a programming paradigm that aims at improving the clarity, quality and development time of a computer program.
  • Makes use of structured control flow of selection like ( IF, ELSE, THEN ) and repetition ( WHILE or FOR ), block structures & subroutines ( functions )
  • Each module has a single entrance & exit & performs a single task.
  • Three phrases of Modular Programming are;
  • i) Top-down analysis
  • ii) Modular Programming &
  • iii) Structured Code

Features of structured programming are:
  1. Division of complex problems into small functions and procedures.
  2. No GOTO statement
  3. The main statements include - IF - THEN - ELSE, case & call statements
  4. Each module performs a specific operation.
  5. Each module has a single entry & exit point.
  6. Eg: C, C+, C++, C#, Java, PERL, Ruby, PHP.

Advantages:
  • Reuseable codes
  • Easy to represent in flowcharts and algorithms
  • Easier to read and understand
  • Easier to maintain sometimes you want the computer to execute the same lines of code several times. This is done using a loop. There are three types of loops: For loops, while loops and repeat until loops. That’s handy as it enables you not to have to copy the same lines of code many times.po
  • Require Less effort and time
  • Modularity ables many programmers to work on the same project at the same time.

Disadvantages:
  • Data is exposed to the whole program, so less data security
  • Importance given to operation rather than data.
  • Difficult to relate with real-life objects.
  • Difficult to create new data types.
  • Same code repetition. 

Object-Oriented Programming

  • OOP is defined as a programming language that is based on objects.
  • Objects collaborate by sending each other messages.
  • An object is an entity that possesses both attributes and behaviors ( methods )
  • Eg:- If a Car is an object the attributes of the car will be its color, size, weight, fuel capacity, etc and methods would be start engine, stop, turn left, etc
  • Class is the collection of objects of similar types.
  • Eg:- Grape, Bananas, Apples, Oranges are all the members of the fruits.

Features of OOP are:
  1. Object
  2. Class
  3. Abstraction
  4. Encapsulation ( Data binding )
  5. Inheritance
  6. Polymorphism
Difference between Structured Programming and OOP:

Difference between Server and Client-Side Scripting are:


Scripting Language

  • A scripting language is a programming language designed for integrating and communicating with other programming languages.
  • Widely used scripting languages are JavaScript, PHP, Perl, Python, VB Script, etc
  • Used to combine different tasks together.

Client-Side Scripting
  • Scripts that are executed on the client-side.
  • In context to website it is the scripts that execute in the browser of the user.
  • Tasks to be performed are animation, validating input and manipulating UI elements.
Server Side Scripting
  • Scripts that execute in the server
  • In the context of websites, it is a script that executes on application servers.
  • Eg: PHP, Python, etc.
  • Tasks to be performed are generating dynamic context, inserting and updating database and encoding the data into HTML.

Note: If there are any questions or incorrect things please let me know in the comments.

Comments

Popular posts from this blog

Chapter 1: Introduction to Computer

Chapter 4: Multimedia