Description and comparison of
- procedural
- declarative
- event-driven languages
Declarative languages or Logical languages model problem solutions very differently. Programmers specify what the problem is rather than how to solve it. In PROLOG, for example, a program represents propositional knowledge as facts and uses rules to test facts, building more complex propositions. Collectively facts and rules are called clauses. A proposition is the smallest unit of knowledge that can be judged true or false, such as “a collie is a sheepdog”, or “a beagle is a hound” or “George passed a ball to Steven”.
Contrast this with a procedural language where the programmer would need to set up a structure to hold the knowledge and predefine its type (string, number etc). Then they would need to describe the steps taken to search the structure in order to answer the query. A declarative/logical language is simplistically described as telling the computer what to do and not how to do it.
Event driven programming languages have evolved to handle events. Events can be initiated at two levels:
1. at system/hardware level: events can include timers, interrupts, loading of files etc;
2. at language/system level: events involve mouse clicks, keyboard presses and cursor movements.
In Visual Basic each object has a set of events. Here an event is an action that Visual Basic can detect and respond to by a user clicking on a command button, After each event is handled, nothing happens until the next event occurs. Note that event-driven programs do not have a predefined pathway in the execution of the code, as opposed to imperative programming style i.e. they have no beginning or end. Graphical user interface programs are typically programmed in an event-driven style using languages such as Visual Basic and Visual C
A Scripting language is a style of ’programming’ that produces ASCII text-based scripts which are usually designed for writing small programs like batch files. Scripting languages support high level language control features such as selection and iteration (syntax) but they are not considered programming languages as such. Examples of present day scripting languages are VBScript, JavaScript, Perl, Python, TCL (Tool Command Language) etc Applications that provide scripting capability allows the user to extend the functionality of the application by programming a sequence of actions. For example, in Filemaker Pro (a database package) it is possible to write scripts that open and close files, copy data from records or enter a certain database mode such as browse or find.