12.5.1.1 compare declarative and imperative programming languages Declarative and imperative programming languages Ex. 0. "Levels of programming languages" A programming paradigm is a fundamental style of computer programming.
We consider two paradigms: imperative vs declarative. Video "Programming Paradigms: Paradigms Overview" Declarative languages Declarative programming is when you say "what you want". Declarative languages are often used by intelligent systems. Declarative languages are very different from the other types of language because of the way that the language is structured. Programmers will create a knowledge base. A knowledge base contains a series of related facts and rules. Example of facts and rules, Fact: female (jane) A query could then be written: wife(david,mary)? Examples of declarative languages: Prolog, HTML, Haskell, CSS, SQL,... Imperative languages Imperative language is when you say "how to get what you want". Imperative programming: is a programming paradigm that describes computation in terms of statements that change a program state. In imperative programming, you use assignment statements to locate some information in memory to use later. The wide use of looping statements allows executing sequences of statements. If you want to check whether some condition is met before performing some actions, you can use conditional branching statements. Example of program, nums = ["камень", "ножницы", "бумага"] Examples of imperative languages: C++, PHP, C#, Pascal, Python, Java, ...
Difference between declarative and imperative programming
Sources: differencebetween.com Comparing the two approaches Traditionally, most developers have used the imperative approach to write web services. This meant using service and operation contracts to create the service, along with service implementation. However, much custom development is neither purely declarative nor imperative. It contains a mixture of both, although it generally shows a preference for one or the other. The development of services certainly adheres to this pattern. For example, if a developer uses an imperative approach to implement a service, the logic may include if statements or other conditional logic, but the program may still include a SQL query, which is considered declarative. The following table compares service development in terms of the imperative and declarative approaches.
Questions:
Exercises: Ex. 1 Ex. 2 Exam questions:
| ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
Просмотров: 10841 | | |
Всего комментариев: 0 | |