Samara University: College of Engineering &technology Department of Computer Science
Samara University: College of Engineering &technology Department of Computer Science
NAME ID SECTION
Year:3rd
Semester:2nd
1
1, Procedural vs Declarative Programming
procedural languages
In procedural languages, the program code is written as a sequence of instructions. User has to specify
“what to do” and also “how to do” (step by step procedure). These instructions are executed in the
sequential order. These instructions are written to solve specific problems.
Which executes code lines as directed, and a developer is fully in charge of the flow. Some repetitive
works might be automated within methods/tactics like OOP, AOP, etc., but at the end, it is a thing that
developer have to manage and configure regardless. This paradigm emphasizes on procedure in terms
of under lying machine model. There is no difference in between procedural and imperative approach. It
has the ability to reuse the code and it was boon at that time when it was in use because of its
reusability. Example:
#include <iostream>
int main()
fact = fact * i;
Cout << "Factorial of " << num << " is: " << fact << endl;
Return 0;
2
Declarative programming language
Decla tive programming is a style of building the structure and elements of computer programs that
expresses the logic of a computation without describing its control flow¹. It is unfortunate that this kind
definitions don’t explain how both approach impact developers to their daily routine. It is divided as
Logic, Functional, Database. In computer science the declarative programming is a style of building
programs that expresses logic of computation without talking about its control flow. It often considers
programs as theories of some logic.It may simplify writing parallel programs. The focus is on what needs
to be done rather how it should be done basically emphasize on what code code is actually doing. It just
declare the result we want rather how it has be produced. This is the only difference between imperative
(how to do) and declarative (what to do) programming paradigms. Getting into deeper we would see logic,
functional and database.
In logical programming the main emphasize is on knowledge base and the problem. The execution of the
program is very much like proof of mathematical statement, e.g., Prolog
r=r1+n
Its semantics are quite tough. Its semantics are very simple.
3
Procedural Language.
It is not suitable for time critical applications. It is suitable for time critical applications.
Iterative loops and Recursive calls both are used Recursive calls are used in declarative
in the Procedural languages. languages.
The main difference between two programming languages are, in procedural programming, we
tell the computer how to solve the problem and in declarative programming, we tell the
computer what problem we want solved.
In generally, both programming styles play significant roles while programming. In high-level
programming, especially, in data-driven applications, Declarative runtime may automate repetitive flow
along with simplifying code structure, and at the same time, imperative programming gives full control to
developer especially it is very important in low-level programming or mission-critical jobs. Clearly,
popularity of declarative and functional programming is arising, but as of today, imperative programming
including its libraries, tooling, etc. heavily dominates programming languages.
2, Expert Systems
An expert system is a computer system emulating the decision-making ability of a human expert. Expert
systems are designed to solve complex problems by reasoning through bodies of knowledge, represented
mainly as if–then rules rather than through conventional procedural code Expert systems are computer
applications which embody some non-algorithmic expertise for solving certain types of problems. For
example, expert systems are used in diagnostic applications servicing both people and machinery. They
also play chess, make financial planning decisions, configure computers, monitor real time systems,
4
underwrite insurance policies, and perform many other services which previously required human
expertise.
• Inference engine – the code at the core of the system, which derives recommendations from the
knowledge base and problem-specific data in working storage;
• User interface – the code that controls the dialog between the user and the system. To understand expert
system design, it is also necessary to understand the major roles of individuals who interact with the
system. These are:
• Domain expert – the individual or individuals who currently are experts solving the problems the system
is intended to solve;
• Knowledge engineer – the individual who encodes the expert's knowledge in a declarative form that can
be used by the expert system;
• User – the individual who will be consulting with the system to get advice that would have been
provided by the domain expert. Many expert systems are built with products called expert system shells.
The shell is a piece of software which contains the user interface, a format for declarative knowledge in
the knowledge base, and an inference engine. The knowledge engineer uses the shell to build a system for
a particular problem domain. Expert systems are also built with shells that are custom developed for
particular applications. In this case there is another key individual.
• System engineer – the individual who builds the user interface, designs the declarative