Flashcards in Languages And Environments Deck (32):
What is the purpose and main characteristics of a declarative programming language. Give an example.
Code defines a set of logical statements - facts and rules - rather than carrying out instructions in a sequence.
Searches logical statements for conclusions as it is run.
Example - Prolog, used for artificial intelligence applications. It defines sets of unordered rules and facts known as a knowledge base.
What is the purpose and main characteristics of object-oriented programming? Give an example.
Classes are defined which include variables and methods (special procedures which define how the object behaves)
Each object created during the execution of an o-o program is called an instance of a class.
New objects will have a copy of the data required to define the object and may inherit data defined in other classes.
Example - Game programming and to model real-life situations (due to easy creation and deletion of objects)
Why do programs need to be translated into binary?
All processors have their own instruction set. Before execution on a specific processor, programs must be translated into binary which correspond to the processors instruction set.
Demonstrate the relationship between a computers instruction set and its program code.
-Low level languages like Assembly language have a 1:1 relationship between commands and binary machine code.
What is meant by 'High level language programs are described as platform independent, whereas binary programs are platform specific'?
HLL programs are compiled to run on different processors with different instruction sets.
Binary programs must be written according to the platform in which they are to be run on - on only one computer with a single instruction set.
Which programming language would be best for writing a touch screen phone application? Why?
Object oriented because different objects to be selected or dragged by touch are used.
Why does every programming language have a strict set of rules defining how lines of code should be formatted?
So it is possible for a compiler to be created to translate the code as users would be prevented from entering instructions in any way they like.
Why do most assembly languages instructions still need to be translated into binary?
The computers hardware is built to store and process only binary and so all data and instructions must be stored and processed as binary.
What is the purpose and main characteristics of a procedural language program? Give an example.
Written out in blocks of code called subroutines, procedures or functions.
Program carries out instructions one at a time
Examples include - Visualbasic, TrueBASIC,
Why are low-level languages used?
Allow for the optimisation of code because of a one to one relationship to machine code
Architecture/Platform dependent language
Low level language
Architecture/Platform independent language
High level language
Data value which can be passed to a subroutine at run time.
Declarative Languages contain
Facts and rules
Feature of a declarative language and what is it used for?
rules - join existing facts together using :- ( if ) and logic operators ( AND, OR )
The value of an attribute/instance variable at any given time within the context of object oriented programming
Inheritance and maintenance
Errors fixed in a super class/sub class get reflected automatically in sub classes/instances when using object oriented languages
This saves time
Required for the creation of executable code
Software held in RAM translates source code into executable code
Code which changes the state of an object's attribute in object oriented environment
The built in instructions processors are manufactured with
Before a program can be executed on a specific processor is must be translated into binary which corresponds to the processors instruction set
Why is it unlikely for a programmer to write LLL instructions in binary?
Code is difficult to read
Hard to find any mistakes when inputting long lists of 1s and 0s
Used to write LLL instructions
Consists of codes that represent each instruction from the instruction set
Must still be translated into binary equivalent before program can be run
High Level Language
Written in English, using a strict syntax
Completed HLL instructions translated into a separate binary program using a compiler
Simpler way to program
Not as efficient as LLL code
Types of high level language
Procedural, declarative, object-oriented
Written in blocks of code - Procedures, functions, subroutines
Instructions carried out one at a time
Not written as a sequence of instructions
Code defines a set of logical statements
These are searched for conclusions
Classes defined which include;
Variables - Store information on the object
Methods - Special Procedures which define how an object behaves
Object created during program execution is known as an instance of a class
What do new objects (Instances) in object-oriented programming have?
A copy of the data required to define the object
Data defined in other classes
Often used in programs which model real life situations
Objects can be created, destroyed and modified just as they would in reality
Ideal scenario for object-oriented code to be used
Game programming as objects in games are regularly created and destroyed during gameplay
Low Level Language Features
There is a one to one relationship between language commands and machine instructions
Declarative Language feature
Uses a knowledge base of facts and rules and matches these with a query to provide a solution to a problem