Fundamentals of programming II: Algorithms

in #developer5 years ago

cover of the day

Continuing with the basic foundations of programming today we are going to play one of the most used concepts that are algorithms and their representation as a programming language, if you have not read the first part I recommend you see it. See Part One

When we mentioned previously what a program means, we refer to a sequence of instructions or steps to complete a goal, because algorithms is the way to represent the set of steps. It sounds a little confusing at first to distinguish between the two, but the simplest way to differentiate between them is that the program is the result of algorithmically representing the objectives to be completed.

An algorithm represents the sequential instructions of the program in a code or natural language.

The computer, like all living beings, we have ways of interacting with the world around us, through language we can share ideas, in the case of the computer uses language as a mechanism to complete instructions, a program interacts with the computer through logic gates represented in binary.

Representing a set of logic gates in a natural language is the goal of an algorithm.

When we speak of logic gates, is the way in which the electronic circuits of a computer activate or interrupt the flow of current to carry out a process, this form of communication is represented mathematically as binary numbers (zeros and ones).

The zero represents a logic gate deactivated or without current flow and the one that is activated, in computer science it is known a binary as bits and represents the minimum unit of processing, the basic memory unit is one byte (8 bits), this It is an octet of binaries.

Representation

When we describe an algorithm as programmers we describe the steps in a natural language, for this the following techniques of representation of an algorithm are used.

  • Free diagramming (Flowcharts)
  • Diagrams Nassi-Shneiderman
  • Pseudocode
  • Natural language (Spanish, English, etc.)
    • Mathematical formulas

Programming language

A programming language is a language designed to describe the set of consecutive actions that a team must execute. Therefore, a programming language is a practical way for human beings to give instructions to a team.

Every language has a syntax and semantics that together build the language.

Syntax

Rules that determine how elements of the language can be constructed and sequenced, it is necessary to know these rules in order to create a set of instructions correctly, the most common elements of the programming syntax are:

  • Directives
  • Instructions
  • Reserved words
  • Declaration of types

Each programming language has rules for the elements mentioned above, but does not mean that they are all mandatory.

Semantics

It is the meaning of each element of language.

Machine language

It is a low-level language, dependent on the machine that represents, by means of hexadecimal code, instructions to the CPU, memory addresses or data, it must be borne in mind that a 1 byte equals 2 hexadecimal digits, so the language interacts between hexadecimal pairs.

The syntax of the machine language is represented as follows:

<statement> <argument>

The most common instructions:

  • ** A0 **: Access the memory cell
  • ** 3E **: Copy the register of the ALU (arithmetic-logical unit)
  • ** 1D **: Add
  • ** B3 **: Save results in the memory cell

All high and medium level programming languages ​​must translate their source code into machine language.

Assembly language

It is a medium level language, it represents the machine language through verbs that describe the instruction towards the processor.

The syntax is equal to the machine language except that the instruction is represented by an infinitive verb in the English language.

The most common instructions:

  • ** READ **: Access to the memory cell (A0 in machine language)
  • ** REG **: Copy the registration of the ALU (3E in machine language)
  • ** ADD **: Add (1D)

This type of programming language replaces the machine language and is used in the programming of microcontrollers and chips.

High level language

They are a way to represent low level language in a more natural and mathematical language, it is much more readable by adding more abstraction in its procedures.

High-level languages ​​require a translator that is capable of generating a low-level language for this use compilers and interpreters.

Among the high level programming languages ​​we have:

  • MATLAB
  • Pascal
  • COBOL
  • ADA
  • FORTRAN
  • COBOL
  • PROLOG
  • BASIC
  • C
  • C ++
  • Java
  • Ruby
    JavaScript
  • Haskell
  • PHP

I hope you liked this content, for the next tutorial we will talk about high level languages: compilers and interpreters. Do not forget to vote to make this project grow and subscribe if you want to keep getting new content.

Sort:  

Congratulations @matajm! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You received more than 100 upvotes. Your next target is to reach 250 upvotes.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Congratulations @matajm! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!