Programming Languages Flashcards
Assembly Language Characteristics
-One-to-one correspondence between machine instructions and assembly instructions
-Programmer must think like the machine
Inherently machine-dependent
-Converted to machine language by a program called an assembler
Third Generation Language
Uses high-level primitives
Similar to our pseudocode in Chapter 5
Machine independent (mostly)
Examples: FORTRAN, COBOL
Each primitive corresponds to a sequence of machine language instructions
Converted to machine language by a program called a compiler
Fourth Generation Language
There is no obvious difference between 3. and 4. generation PLs.
Programming process is short.
Spelled as “Fourth GL”. (“procedural language”).
Each step is defined and executed
Fourth GLs has own query languages.
SQL (structured query language)
SELECT address FROM staff WHERE name=“Ahmet”
Screen painter/designer,
Application generators
Report Generators
Local Global Variables Differences
Local Variable: is declared inside a specific function and can be accessed by the function in which its declared.
Global Variable: is one that declared outside of the functions in a program and can be accessed by any of the actions.
Formal, Actual Parameters
Actual Parameters: are the values that are passed to a function when its called.
Formal Parameters: are the variable declared in the function header that are used to recieve the values of the actual parameters passed during the function call.
Pass by Value and Ref
-Pass by Value
*Makes a copy of actual parameter
*Changes made inside the function are not reflected in original value
*Requires more memory
*Requires more time(copying)
-Pass by Ref
-Mechanism of passing the actual parameters to the function
-changes made inside the function are reflected in the original value
-requires less memory
-requires a less amount of time
Program Design Aims
Reliability
Maintainability
Portability
Readability
Performance
Storage Saving
Basic Coding Principles
Declarations: Long enough and meaningful descriptors should be used for program, subprogram, variables and constants.
Indentation: Indentations should be used in the program to reflect the structure of the program.
Structures: Appropriate program structures should be used.
Length: Subprograms in the program must be arranged in manageable lengths.
Descriptions: Descriptive information should be written into the program describing what has been done and what it is done for.
What are translators?
Assembler: A program that transfers assembly language into machine code.
Compiler: A program that translates a high-level language into a machine-oriented language, often the machine code.
Interpreter: A program which translates and executes each source statement in logical sequence as the program is executed.
The translation process
1-Source Program
2-Lexical analyzer
3-Parser
4-Code Generator
5-Object Program
Compiler and interpreter differences
1)Controls all program in one step.
Checks lexical and syntactical errors.
If no error is found, then the program is converted into object code.
The object code is converted to executable code
2)Checks all program statement by statement.
All statements in a loop are converted repeatedly.
Slow.
What is object and class
Object: Active program unit containing both data and procedures
Class: A template from which objects are constructed
An object is called an instance of the class.
Components of an Object
Instance Variable: Variable within an object
Method: Procedure within an object
Constructor: Special method used to initialize a new object when it is first constructed
Encapsulation
Encapsulation: A way of restricting access to the internal components of an object
Private
Public
İnheritance
Inheritance: Allows new classes to be defined in terms of previously defined classes