Programming Languages Basics

To communicate with a computer, we use computer languages or also known as programming languages. To write a program, we must use the computer languages. A computer language is a set of predefined words that are combined into a program according to predefined rules (syntax). Over the years, computer languages had evolved from machine language to high-level languages.

 

There are generally three types of computer languages. They are: 1. Machine Language, 2. Assembly Language and 3. High-level languages.

 

Machine Language

In the earliest days of computers, the only programming languages available were machine languages. Each computer has its own machine language which is made up of streams of 0’s and 1’s. The only language understood by a computer is the machine language. This language is tightly coupled with the computer hardware. It is difficult to write and maintain code in machine language.

1

Assembly Language

The next evolution in programming came with the idea of replacing binary code for instruction and addresses with symbols or mnemonics. Because they used symbols, these languages were first known as symbolic languages. The set of these mnemonic languages were later referred to as assembly languages. It is easy to write and maintain programs in assembly language than in machine languages.

2

 High-Level Language

Although assembly languages greatly improved programming efficiency, they still required programmers to concentrate on the hardware they were using. Working with symbolic languages was also very tedious, because each machine instruction had to be individually coded. The desire to improve programmer efficiency and to change the focus from the computer to the problem being solved led to the development of high-level languages.

Examples of high-level languages are:

  1. BASIC (Beginners All Purpose Symbolic Instruction Code).
  2. FORTRAN (Formula Translation).
  3. PL/I (Programming Language, Version 1).
  4. ALGOL (Algorithmic Language).
  5. APL (A Programming Language).
  6. COBOL (Common Business Oriented Language).
  7. RPG (Report Program Generator).
  8. LISP (List Processing).
  9. Prolog (Program in Logic).
  10. C++
  11. Java
  12. Visual Basic
  13. C

3

 

Translation

Programs today are normally written in one of the high-level languages. To run the program on a computer, the program needs to be translated into the machine language of the computer on which it will run. The program in a high-level language is called the source program. The translated program in machine language is called the object program. Two methods are used for translation: compilation and interpretation.

Translator

A translator is a program, which converts the code written in one language into another language. The widely used translators are compilers and interpreters.

Compiler

A compiler is a translator which converts the program written in high-level language into assembly code or into another form of intermediate code or directly into machine code. A compiler converts the whole source code at once into object code and then executes it. So, compiler is faster than a interpreter.

Interpreter

An interpreter is a translator which converts the source program into object or machine code. The interpreter converts the source code line-by-line and executes it immediately, which results in less performance. Thus, an interpreter is slower than a compiler.

 

Generations of Programming Languages

There are five generations of programming languages. There are classified based on how close the programming language is to human beings.

First Generations Languages (1GL): The first generation language is the machine language. It consists of only 0’s and 1’s. It is very difficult write programs in machine language.

Second Generation Languages (2GL): The second generation language is the assembly language. Assembly language consists of symbols known as mnemonics, English words rather than 0’s and 1’s. Programs written in assembly language are converted to machine language using a translator known as assembler.

Third Generation Languages (3GL): The third generation languages are high-level languages which are similar to English. It is easy to write programs using high-level languages. Programs written in high-level language are converted to machine language by using a translator like compiler or interpreter. Third generation languages are problem oriented languages. Examples: C, FORTRAN, COBOL, PASCAL etc.

Fourth Generation Languages (4GL): The fourth generation languages are non-procedural languages. Programmers have to specify only what to do but not how to do it. These languages are developed for users having minimum programming language. Examples: SQL, ABAP etc.

Fifth Generation Languages (5GL): The fifth generation languages are declarative languages which are used in artificial intelligence and expert systems. Example: Prolog etc.

 

Advertisements

Free e-books for developers

E-books written by experienced developers and is available free. Site has vast categories with many books on popular as well as new technologies. Check it out – DevFreeBooks.

 

Another similar website is – DZone. It has reference books as well as guides.

 

Comments and suggestions are always welcome. Pass the information on. Share this post and let your friends know too.  Thanks.

 

Who am I?   |   Contact me   |   Shop

Syntax reference for programming languages

Found another great website that allows reference as well as searching for syntax for different programming languages along with integration with DuckDuckGo, Slack and Visual Studio Code as well as API’s. Check it out –The programming syntax database: SyntaxDB.

 

Comments and suggestions are always welcome. Pass the information on. Share this post and let your friends know too.  Thanks.

 

 

Who am I?   |   Contact me   |   Shop

View popular Java projects online

Found a great website – GrepCode for searching and viewing source code for popular Java projects online. It also has plugins for Eclipse and InteliJ IDE. It also supports searching by stack trace. Check it out.

 

Comments and suggestions are welcome. Pass the information on. Share this post and let your friends know too.  Thanks.

 

Who am I?   |   Contact me   |   Shop

 

 

Introduction to Algorithms

I was recently searching for a good website for studying Algorithms. After going through various websites, I stumbled upon this educative.io course.

I was immediately hooked upon seeing the quality of the study material and that how easy it is for anyone to start learning. Course material are very visual with lots of explanations, pictures and demos.

It is divided into sub sections as follows –

 

 

 

 

 

 

 

 

 

 

 

Website – https://www.educative.io

 

And no, this post is not sponsored or anything. As I found it useful for myself and so I have shared. Pass it on and help others learn if you have too.

 

 

Java Programming Cheatsheet

Here is the quick reference for Java Programming I found on the web. It summarizes common features and usage in shortest and easiest way possible. 

This is just a blog post taking useful content from Princeton University’s site. For the good intend to share the knowledge with other users and programmers. No intention of modifying or removing credits. Just thought to share this awesome resource with everyone. For more in depth reference, above link to university’s website is advised. It is well documented with excellent documentation and programming examples. 

Hello, World.

Hello, World in Java

Editing, compiling, and executing.

Compiling Hello, World in Java

Built-in data types.

Built-in types of data

Declaration and assignment statements.

Assignment statements

Integers.

int data type

Integer expressions

Floating-point numbers.

double data type

double expressions

Booleans.

boolean data type

Boolean operators

Comparison operators.

Comparison operators

Comparison examples

Printing.

System.out.print()

Parsing command-line arguments.

parsing Command-line arguments

Math library.

Math library API

Java library calls.

Expressions that use Java library methods

Type conversion.

Type conversion

Anatomy of an if statement.

anatomy of an if statement

If and if-else statements.

If-else statements

Nested if-else statement.

Nested if-else statements in Java

Anatomy of a while loop.

While loop

Anatomy of a for loop.

For loop

Loops.

While and for loops in Java

Break statement.

Break statement in Java

Do-while loop.

Do-while loop in Java

Switch statement.

Switch statement in Java

Arrays.

An array

Inline array initialization.

Inline initialization of arrays

Typical array-processing code

Two-dimensional arrays.

2D array

2D array inline initialization

standard output library.

Standard output API

Anatomy of printf

Formatting codes for printf

standard input library.

Standard input API

standard drawing library.

Standard drawing API

standard audio library.

Standard audio API

Command line.

command line

Redirection and piping.

Redirecting standard output                Redirecting standard input

Piping

Functions.

Anatomy of a function

Example functions

Libraries of functions.

Library abstraction

standard random library.

Standard random

standard statistics library.

Standard statistics

Using an object.

Using an object

Instance variables.

Anatomy of instance variables

Constructors.

Anatomy of a constructor

Instance methods.

Anatomy of an instance method

Classes.

Anatomy of a class

Object-oriented libraries.

Object-oriented library abstraction

Java’s String data type.

String library API

String operations

Java’s Color data type.

Color library API

input library.

Input API

output library.

Output API

picture library.

Picture API

stack data type.

Stack API

queue data type.

Queue API

Iterable.

Anatomy of an iterable

symbol table data type.

Symbol Table API

set data type.

Set API

graph data type.

Graph API

 

 

Pass it on and help others learn if you have too.

Python Programming Cheatsheet

Here is the quick reference for Python Programming I found on the web. It summarizes common features and usage in shortest and easiest way possible.

There are also some Princeton University developed modules which are very useful. I have also included them with direct links to it’s corresponding webpage on University’s website.

This is just a blog post taking useful content from Princeton University’s site. For the good intend to share the knowledge with other users and programmers. No intention of modifying or removing credits. Just thought to share this awesome resource with everyone. For more in depth reference, above link to university’s website is advised. It is well documented with excellent documentation and programming examples.

So, here it goes –

 

Hello, World.

import stdio

# Write 'Hello, World' to standard output.
stdio.writeln('Hello, World')

Editing, compiling, and interpreting.

Editing, compiling, and interpreting Hello, World in Python

Built-in data types.

Built-in types of data

Assignment statements and traces.

Assignment statements trace Assignment statements formal trace

Strings.

Str data type

Integers.

Int data type

Floating-point numbers.

Float data type

Booleans.

Bool data type Boolean operators operators

Comparison operators.

Comparison operators

Common functions.

Common Python functions

Type conversion.

Type conversion API

if and if-else statements.

If-else statements

if-elif-else statements.

if   income < 0:      rate = 0.00
elif income < 8925:   rate = 0.10
elif income < 36250:  rate = 0.15
elif income < 87850:  rate = 0.23
elif income < 183250: rate = 0.28
elif income < 398350: rate = 0.33
elif income < 400000: rate = 0.35
else:                 rate = 0.396

while and for statements.

While and for loops

break statements.

while True:
    x = 1.0 + 2.0*random.random()
    y = 1.0 + 2.0*random.random()
    if x*x + y*y <= 1.0:
        break

Arrays.

suits = ['Clubs', 'Diamonds', 'Hearts', 'Spades']

An array

a = stdarray.create1D(n)
...
for i in range(n):
    stdout.writeln(a[i])
... 
for element in a:
    stdout.writeln(element)

Array operations.

Array operations

Array aliasing and copying.

Array aliasing Array copying

Two-dimensional arrays.

2D array 2D array initialization
a = stdarray.create2D(rowCount, colCount)
...
for i in range(rowCount):
    for j in range(colCount)):
        stdio.writeln(a[i][j])
...     
for row in a:
    for element in row:
        stdio.writeln(element)

 

Redirection and piping.

Redirecting standard input Redirecting standard output

Piping

Functions.

Anatomy of a function

Example functions

Modules.

Module abstraction

Module control flow

The str data type.

The str module

Defining a class.

Charge API

Charge class

Creating an object.

Creating an object

Using an object.

p = c1.potentialAt(.20, .50)

Special methods.

Special methods: arithmetic

Special methods: comparison

Special methods: functions

 

stdio module: writing functions.

Standard output API

Anatomy of printf

Formatting codes for writef

 

stdio module: reading functions.

Standard input API

stddraw module.

Stddraw drawing functions

Stddraw control functions

Stddraw shape functions

Stddraw text and color functions

Stddraw animation functions

stdaudio module.

Standard audio API

stdrandom module.

Standard random module

stdarray module.

Standard array module

stdstats module.

Standard stats module

Color data type.

Color API

Picture data type.

Picture API

InStream data type.

InStream API

OutStream data type.

OutStream API

 

 

Pass it on and help others learn if you have too.