Postingan

Session 13(Last) : Logic Programming Languages

Introduction Logic programs are declarative rather than procedural, which means that only the specifications of the desired results are stated rather than detailed procedures for producing them. Programs in logic programming languages are collections of facts and rules. Programming that uses a form of symbolic logic as a programming language is often called logic programming, and languages based on symbolic logic are called logic programming languages, or declarative languages. We have chosen to describe the logic programming language Prolog, because it is the only widely used logic language. A proposition can be thought of as a logical statement that may or may not be true. It consists of objects and the relationships among objects. Formal logic was developed to provide a method for describing propositions, with the goal of allowing those formally stated propositions to be checked for validity. The simplest propositions, which are called atomic propositions, consist of compoun...

Session 10 : Concurrency

Gambar
Concurrency in software execution can occur at four different levels: - Machine instruction level - High-level language statement level - Unit level - Program level Subprogram-Level Concurrency * A task or process or thread is a program unit that can be in concurrent execution with other program units * Tasks differ from ordinary subprograms in that:   - A task may be implicitly started   - When a program unit starts the execution of a task, it is not necessarily suspended   - When a task’s execution is completed, control may not return to the caller * Tasks usually work together Two General Categories of Tasks * Heavyweight tasks execute in their own address space * Lightweight tasks all run in the same address space – more efficient * A task is disjoint if it does not communicate with or affect the execution of any other task in the program in any way Task Synchronization * A mechanism that controls the order in which tasks execute * Two kinds of sync...

Session 12 : Function Programming Language

Mathematical Functions A mathematical function is a mapping of members of one set, called the domain set, to another set, called the range set. One of the fundamental characteristics of mathematical functions is that the evaluation order of their mapping expressions is controlled by recursion and conditional expressions, rather than by the sequencing and iterative repetition that are common to the imperative programming languages. Another important characteristic of mathematical functions is that because they have no side effects and cannot depend on any external values, they always map a particular element of the domain to the same element of the range. However, a subprogram in an imperative language may depend on the current values of several nonlocal or global variables. This makes it difficult to determine statically what values the subprogram will produce and what side effects it will have on a particular execution. A mathematical function maps its parameter(s) to a value (or v...

Session 11 : Exception Handling and Event Handling

Gambar
Introduction to Exception Handling * In a language without exception handling When an exception occurs, control goes to the operating system, where a message is displayed and the program is terminated * In a language with exception handling Programs are allowed to trap some exceptions, thereby providing the possibility of fixing the problem and continuing so we can conclude that programmers need exception handling. Exception handling lets programs to trap some exceptions, thereby providing the possibility of fixing the problem and continuing. Basic Concepts * Many languages allow programs to trap input/output errors (including EOF) * An exception is any unusual event, either erroneous or not, detectable by either hardware or software, that may require special processing * The special processing that may be required after detection of an exception is called exception handling * The exception handling code unit is called an exception handler Exception Handling Alternatives ...

Session 9 : Object-Oriented Programming

There are many object-oriented programming language... - Some are support procedural and data-oriented programming (e.g., Ada 95+ and C++) - Some are support functional program (e.g., CLOS) - Newer languages do not support other paradigms but use their imperative structures (e.g., Java and C#) - Some are pure OOP language (e.g., Smalltalk & Ruby) - Some are functional languages support OOP, but they are not discussed in this chapter there are three major language features : 1. abstract data types 2. inheritance 3. polymorphism - Inheritance allows new classes defined  in terms of existing ones, i.e., by allowing them to inherit common parts - Inheritance addresses both of the above concerns--reuse ADTs after minor changes and define classes in a hierarchy to make it easily, inheritance can be imagined as parent and child. The parent is the class while  the child is a derived class or a subclass. There are several ways a derived class can differ from its parent...

Session 8 : Abstract Data Types(GSLC)

here is some task from ms.Yanfi because of GSLC 1. What are the similarities of and the differences between Java Packages and C++ Namespace?  The similarity between Java Package and Namespaces In C++ are :  - Java Packages are namespaces system while C++ also has namespace  - Both are abstract containers for classes  - Java Packages and namespaces provide breakup for class names  - both make the code cleaner and less redundant, by enabling some  parts of the code  The differences between C++ namespace and Java packages :  - As a unit that guarantees access to non-private members to classes in the same block, there is no equivalent in C++ that the access level granted to a class is independent of the namespace where the class is defined.  - In C++ namespaces are just about partitioning the available names. Java packages are about modules.  - Packages are used to organize files or public types to avoid type conflic...