PROGRAMMING
Hi Everyone !
What is Programming ?
Programming is the process of taking an algorithm and encoding it into a notation, a programming language, so that it can be executed by a computer.What is Programming ?
Define Programming Language
A programming language is a special language programmers use to develop software programs, scripts, or other sets of instructions for computers to execute.
Different languages have different purposes, so it makes sense to talk about different kinds, or types, of languages. Some types are:
- Machine languages, that are interpreted directly in hardware
- Assembly languages, that are thin wrappers over a corresponding machine language
- High-level languages, that are anything machine-independent
- System languages, that are designed for writing low-level tasks, like memory and process management
- Scripting languages, that are generally extremely high-level and powerful
- Domain-specific languages, that are used in highly special-purpose areas only
- Visual languages, that are non-text based
- Esoteric languages, that are not really intended to be used, but are very interesting, funny, or educational in some way.
Machine Code
Most computers work by executing stored programs in a fetch-execute cycle. Machine code generally features:
- Registers to store values and intermediate results
- Very low-level machine instructions (
add
, sub
, div
, sqrt
)
- Labels and conditional jumps to express control flow
- A lack of memory management support β programmers do that themselves
Machine code is usually written in hex. Hereβs an example for the Intel 64 architecture:
89 F8 A9 01 00 00 00 75 06 6B C0 03 FF C0 C3 C1 E0 02 83 E8 03 C3
Assembly Language
Most computers work by executing stored programs in a fetch-execute cycle. Machine code generally features:
- Registers to store values and intermediate results
- Very low-level machine instructions (
add
,sub
,div
,sqrt
) - Labels and conditional jumps to express control flow
- A lack of memory management support β programmers do that themselves
Machine code is usually written in hex. Hereβs an example for the Intel 64 architecture:
89 F8 A9 01 00 00 00 75 06 6B C0 03 FF C0 C3 C1 E0 02 83 E8 03 C3
An assembly language is an encoding of machine code into something more readable. It assigns human-readable labels (or names) to storage locations, jump targets, and subroutine starting addresses, but doesnβt really go too far beyond that.
.globl f
.text
f:
mov %edi, %eax # Put first parameter into eax register
test $1, %eax # Examine least significant bit
jnz odd # If it's not a zero, jump to odd
imul $3, %eax # It's even, so multiply it by 3
inc %eax # and add 1
ret # and return it
odd:
shl $2, %eax # It's odd, so multiply by 4
sub $3, %eax # and subtract 3
ret # and return it
And hereβs the same function, written for the SPARC:
.global f
f:
andcc %o0, 1, %g0
bne .L1
sll %o0, 2, %g2
sll %o0, 1, %g2
add %g2, %o0, %g2
b .L2
add %g2, 1, %o0
.L1:
add %g2, -3, %o0
.L2:
retl
nop
An assembly language is an encoding of machine code into something more readable. It assigns human-readable labels (or names) to storage locations, jump targets, and subroutine starting addresses, but doesnβt really go too far beyond that.
.globl f .text f: mov %edi, %eax # Put first parameter into eax register test $1, %eax # Examine least significant bit jnz odd # If it's not a zero, jump to odd imul $3, %eax # It's even, so multiply it by 3 inc %eax # and add 1 ret # and return it odd: shl $2, %eax # It's odd, so multiply by 4 sub $3, %eax # and subtract 3 ret # and return it
And hereβs the same function, written for the SPARC:
.global f f: andcc %o0, 1, %g0 bne .L1 sll %o0, 2, %g2 sll %o0, 1, %g2 add %g2, %o0, %g2 b .L2 add %g2, 1, %o0 .L1: add %g2, -3, %o0 .L2: retl nop
High-Level Languages
A high-level language gets away from all the constraints of a particular machine. HLLs have features such as:
- Names for almost everything: variables, types, subroutines, constants, modules
- Complex expressions (e.g.
2 * (y^5) >= 88 && sqrt(4.8) / 2 % 3 == 9
)
- Control structures (conditionals, switches, loops)
- Composite types (arrays, structs)
- Type declarations
- Type checking
- Easy, often implicit, ways to manage global, local and heap storage
- Subroutines with their own private scope
- Abstract data types, modules, packages, classes
- Exceptions
e.g ;
- C++
- C#
- Cobol
- Fortran
- Java
- JavaScript
- Objective C
- Pascal
- Perl
- PHP
- Python
- Swift
A high-level language gets away from all the constraints of a particular machine. HLLs have features such as:
- Names for almost everything: variables, types, subroutines, constants, modules
- Complex expressions (e.g.
2 * (y^5) >= 88 && sqrt(4.8) / 2 % 3 == 9
) - Control structures (conditionals, switches, loops)
- Composite types (arrays, structs)
- Type declarations
- Type checking
- Easy, often implicit, ways to manage global, local and heap storage
- Subroutines with their own private scope
- Abstract data types, modules, packages, classes
- Exceptions
e.g ;
|
|
System Languages
System programming languages differ from application programming languages in that they are more concerned with managing a computer system rather than solving general problems in health care, game playing, or finance. In a system langauge, the programmer, not the runtime system, is generally responsible for:
- Memory management
- Process management
- Data transfer
- Caches
- Device drivers
- Directly interfacing with the operating system
System programming languages differ from application programming languages in that they are more concerned with managing a computer system rather than solving general problems in health care, game playing, or finance. In a system langauge, the programmer, not the runtime system, is generally responsible for:
- Memory management
- Process management
- Data transfer
- Caches
- Device drivers
- Directly interfacing with the operating system
Scripting Languages
Scripting languages are used for wiring together systems and applications at a very high level. They are almost always extremely expressive (they do a lot with very little code) and usually dynamic (meaning the compiler does very little, while the run-time system does almost everything).
Esoteric Languages
An esoteric language is one not intended to be taken seriously. They can be jokes, near-minimalistic, or despotic (purposely obfuscated or non-deterministic).
Java Programming Language
- enables programmers to write computer instructions using English-based commands instead of having to write in numeric codes.
- Itβs known as a high-level language because it can be read and written easily by humans.
Java was designed with a few key principles in mind:
Ease to use
- The fundamentals of Java came from a programming language called C++. Although C++ is a powerful language, it is complex in its syntax and inadequate for some of Java's requirements. Java built on and improved the ideas of C++ to provide a programming language that was powerful and simple to use.
- Java needed to reduce the likelihood of fatal errors from programmer mistakes. With this in mind, object-oriented programming was introduced. When data and its manipulation were packaged together in one place, Java was robust.
- Because Java was originally targeting mobile devices that would be exchanging data over networks, it was built to include a high level of security. Java is probably the most secure programming language to date.
- Programs need to work regardless of the machines they're being executed on. Java was written to be a portable and cross-platform language that doesn't care about the operating system, hardware, or devices that it's running on.
e.g ;
Language Paradigm
Definition
is a way in which computer language looks at the problem to be solved.
Types of Language Paradigm
(a) Procedural
- Simple and straight forward
- Routines and subroutines
- Top down , step by step instruction
(b) Object-oriented Program (OOP)
- Approach to problem using where all computations are carried out using objects.
- Object knows how to perform certain actions and how to interact with other elements of the program.
- Example : Object is Ben ( People ) , Ben can Walk ( method ).
(c) Logic
- The program is the description of the desired results in the form of symbolic logic.
- Example : Statements and symbolic logic
- Language : Prolog
Language Translator
Definition : is a program that translates from one programming language into another.
Types of Translator :
(a) Interpreter
- Translates one high-level program instructions at atime (line by line) into machine code and immediately execute the code
(b) Compiler
- Translate entire source program into an executable object program and saves it in a file which is ready for execution
(c) Assembler
- Converts programs written in assembly language to machine code so that it can be executed
References :
Comments
Post a Comment