Professional Documents
Culture Documents
Programming concepts
Programming concepts
This “machine language” was very tedious to write by hand since even simple
tasks such as printing some output on the screen require 10 or 20 machine
language commands.
There are two different models of programming-
Structured programming–
• code is executed one after another.
• Control statements change which blocks of code are executed next.
• It is aimed at improving the clarity, quality, and development time of a computer program by making
extensive use of subroutines, block structures, for and while loops
Object oriented programming-
• It is based on the concept of “objects”, which may contain data, in the form of fields, often known as
attributes; and code, in the form of procedures, often known as methods.
• A feature of objects is that an object’s procedures can access and often modify the data fields of the object
with which they are associated.
• There is no single “flow” of the program as objects can freely interact with one another by passing
messages.
1. Program Structure
a well-structured program the division into components follows some recognized principle such as
information hiding, and the interfaces between components are explicit and simple.
By contrast, with a poorly structured program the division into components is largely arbitrary (or even
non-existent), and interfaces are implicit and complex.
Virtually all structured programs share a similar overall pattern:
Statements to establish the start of the program
Variable declaration
Program statements (blocks of code)
2. Variable Declaration
The variable name is the usual way to reference the stored value.
Variables are the backbone of any program, and thus the backbone of any programming language.
in simple terms, a variable is simply a way to store some sort of information for later use, and we can retrieve this
information by referring to a “word” that will describe this information.
Different types of variables include:
Integer – to store integer or “whole” numbers
Real – to store real or fractional numbers (also called float to indicate a floating point number)
Character – A single character such as a letter of the alphabet or punctuation.
String – A collection of characters
3. Looping structures
Loop structures allow you to run one or more lines of code repetitively.
repeat the statements in a loop structure until a condition is True, until a condition is False, a specified
number of times, or once for each element in a collection.
4. Control structures
the syntax of a programming language is the set of rules that define the combinations of
symbols that are considered to be correctly structured programs in that language.
Documents that are syntactically invalid are said to have a syntax error.
The concept of syntax in programming language is similar to the concepts of grammar
and spelling in spoken language.
When a sentence in English has very poor grammar and spelling, it becomes difficult or
even impossible to understand.
Similarly, when code has syntax errors, the program will not execute.
HIGH-LEVEL LANGUAGE CHARACTERISTICS
Easy to learn
The high Level Languages are close to human languages.
The instructions written in high level languages are similar to English like words and
Statements. This makes the high level languages easy to learn and use.
A high-level language is any programming language that enables development of a program in a much
more user-friendly programming context a
generally independent of the computer's hardware architecture.
A high-level language has a higher level of abstraction from the computer, and focuses more on the
programming logic rather than the underlying hardware
1. C++ 7. Objective C
2. C# 8. Pascal
3. Cobol 9. Perl
Undefined behavior
The idea that a language specification would explicitly specify certain constructs as having undefined
behavior is interesting.
Assemblies
This is a level of encapsulation above the typical namespaces or modules in most languages. Assemblies
are similar to the idea of static/dynamic libraries in C or JAR files in Java.
Cross-language compatibility is first-class (not just for C)
C# runs in the Common Language Runtime, which was designed from the beginning to support
interoperability between languages.
Properties are first-class No longer need to write explicit getter and (optional) setter methods.
Listeners are first-class Classes can declare an event Foo with addFooListener and removeFooListener
functionality built in. o Unfortunately the implementation has some annoyances.
Foreign Methods5 are first-class C# calls these extension methods.
Partial Classes Allows a class’s members to be defined in multiple files.
Useful to add functionality to a generated class
3.Python
Lazy evaluation
o Expressions are only evaluated when some primitive operation (like print or add) requires
the value of the expression.
o Allows you to glue programs together in new ways.
In particular, execution of multiple functions can be interleaved trivially and termination
conditions can be separated from looped computation.
Side effects banned by default o Mutation of data structures and I/O, both of which have
order-sensitive side effects, are not allowed except within the confines of monad.
null banned by default.
Unlike many languages, there is no special null value in Haskell that can be substituted anywhere.
6.Lisp (Common Lisp, Scheme, Clojure)
Homoiconic o When you write a Lisp program, the notation you use (the
grammar) is equivalent to what a compiler would see (an abstract syntax tree or
AST).
o Furthermore this Lisp code is represented as a nested structure of lists,
symbols, and literals, all of which can be directly generated and manipulated in
Lisp itself!
Macros o A function that transforms the AST of its operands at compile
time to new code.
Macros can be used to generate arbitrary new statements and
control structures.
Lisp Conditions and Restarts o Allows bidirectional communication between different parts of the
call stack.
More powerful than exceptions, since conditions can not only unwind the stack but also wind it back
again via a restart.
Call-with-current-continuation o Allows you to save the current execution state of the program in
a variable and jump back to it later. Multiple times, even. It’s like a friggin' time machine.
TRANSLATION SOFTWARE
It is the process by which computer software is used to translate a text from one natural language (such as English) to
another (such as Spanish).
To process any translation, human or automated, the meaning of a text in the original (source) language must be fully
restored in the target language, i.e. the translation.
I. No Compiler Interpreter
3 Requires more memory as linking is needed for the Memory usage is efficient as no intermediate object
generated intermediate object code. code is generated.
4 Debugging is hard as the error messages are generated It stops translation when the first error is met.
after scanning the entire program only. Hence, debugging is easy.
5 Programming languages like C, C++ uses compilers. Programming languages like Python, BASIC, and Ruby
uses interpreters.