270 likes | 290 Views
Understand different programming paradigms such as imperative, declarative, structured, object-oriented, functional, and logical programming. Learn about programming languages, their usage, examples, and applications in this introductory overview by Dr. Robert Kowalczyk.
E N D
ProgrammingParadigms and Languages Introduction dr Robert Kowalczyk WMiIUŁ
Whatis a programmingparadigm? A programming paradigm is a fundamental style of computer programming, a way of building the structure and elements of computer programs. There are two main programmingparadigms: imperativeprogramming and declarativeprogramming. source: www.wikipedia.com dr Robert Kowalczyk WMiI UŁ
Definitions Imperative programming: telling the "machine” (computer) how to do something, and as a result what you want to happenwill happen. Declarative programming: telling the "machine” (computer) what you would like to happen, and let the computer figure out how to do it. dr Robert Kowalczyk WMiI UŁ
Declarativevs. imperativeprogramming dr Robert Kowalczyk WMiI UŁ
Imperativevs. declarativeprogramming - example We wish to double all the numbers in an array. Imperative style of programming: varnumbers = [1,2,3,4,5] vardoubled = [] for(var i = 0; i < numbers.length; i++) { varnewNumber = numbers[i] * 2 doubled.push(newNumber) } console.write(doubled) //=> [2,4,6,8,10] Declarative style of programming: var numbers = [1,2,3,4,5] var doubled = numbers.map(function(n) { return n * 2 }) console.log(doubled) //=> [2,4,6,8,10] dr Robert Kowalczyk WMiI UŁ
Programminglanguages Imperative Declarative Structured Logical Functional SQL, XML Generic Object-oriented Concurrent Distribution of programmingparadygms Procedural dr Robert Kowalczyk WMiIUŁ
Fourmainprogrammingparadyms Procedural/Structuredprogramming Object-orientedprogramming Functionalprogramming Logicalprogramming dr Robert Kowalczyk WMiIUŁ
Procedural/structuredprogramming Proceduralprogrammingis a computer programming language thatorganises ourcodeinto small „programs" that use and change our datas. Structuredprogrammingis a programming paradigm recommending hierarchical division into blocks of code with one entry point and one or more exit points. In structured programming we use three main structures : - sequences (instruction _1; instruction _2;…; instruction _n), - choices (if, if...else, switch, case), - iterations (while, repeat, for). Keywords: variables, types, procedures and abstractdatas. Using: network systems, operating systems, etc. Procedural/structuredlanguages: • Fortran • Cobol • Pascal • C • C++ • others. dr Robert Kowalczyk WMiIUŁ
Procedural/structuralprogramming - example dr Robert Kowalczyk, Katedra Analizy Nieliniowej, WMiI UŁ
Object-orientedprogramming Object-orientedprogrammingis a programming paradigm in which programs are defined using objects - the state of the connecting elements (orfields) and behavior (or method). Object-oriented computer program is expressed as a set of such objects, which communicate with each other in order to perform tasks. Keywords: classes and objects, inheritance, encapsulation, polymorphism. Using: www and stand-aloneapplications. Object-orientedlanguages Simula, Smalltalk, C++, C#, Java, others. dr Robert Kowalczyk WMiI UŁ
Obcject-orientedprogramming - example dr Robert Kowalczyk WMiI UŁ
Functionalprogramming Functional programming is a programming paradigm in which the functions are the core values and the emphasis is on valuation (often recursive) function, and not to execute commands. Theoretical basis for functional programming was developed in the 19330s of theTwentieth century by Alonzo Church's lambda calculus, called lambda calculus with types. Keywords: functions, lambda calculus, parametricpolymorphism. Using: theoretical, in telecommunications, infinancial calculations. Functionallanguages: Lisp, ML, Haskell, H#, Erlang others. dr Robert Kowalczyk WMiI UŁ
Functionalprogramming - example dr Robert Kowalczyk WMiI UŁ
Functionalprogramming - example dr Robert Kowalczyk, Katedra Analizy Nieliniowej, WMiI UŁ
Logicalprogramming The paradigm of logic programming is a programming method in which the program is given as a set of relations, and the relationship between these dependencies. Keywords: facts, reports, queries. Using: theoretical, artificialintelligence. Logicallanguages: Gödel, Fril, Prolog, others. dr Robert Kowalczyk WMiI UŁ
Logicalprogramming - example dr Robert Kowalczyk, Katedra Analizy Nieliniowej, WMiI UŁ
Logicalprogramming - example dr Robert Kowalczyk, Katedra Analizy Nieliniowej, WMiI UŁ
TIOBE – indexpopularity of programminglanguages źródło: www.tiobe.com dr Robert Kowalczyk, Katedra Analizy Nieliniowej, WMiI UŁ
ProgrammingParadigms • Introductionthecourse (26-02-2019) dr Robert Kowalczyk WMiI UŁ
Haskell (schedule) • Introducing to Haskell(me) • Types and Typeclasses + Syntax in Functions(Adam - Andrii) • Recursion(Manuel - Nageshwar) • Higher order functions and modules(Sofiane - Joanna) • Input/Output(Ayaz-Smith) • RevisionHaskelllanguage(student) • We refer thesechaptersfromthe bookLearn You a Haskell for Great Good! By Miron Lipovaca dr Robert Kowalczyk WMiI UŁ
Prolog (schedule) • Introducing to Prolog (me) • Tutorial Introduction and A Closer Look(Nageshwarsingh ) • Using Data Structures(JovanKanevche) • Backtracking and the ”Cut”(ManojJayakumar) • Input and Output and Built-in Predicates (Ines San Luis ) • Revision Prolog language(RubenMourino, GurcanKaynak) • We refer thechapters of the bookProgramming in Prolog by William Clocksin, Christopher S. Mellish dr Robert Kowalczyk WMiI UŁ
Exam • Exam – term 0 dr Robert Kowalczyk WMiI UŁ
How to get course credit • To pass theclass: 2 tests (Haskell+Prolog) • To pass thelecture: Exam = 15 closequestions and 4 openquestions + lecture dr Robert Kowalczyk WMiI UŁ
Literature • Learn You a Haskell for Great Good!by Miron Lipovaca • Programming in Prologby William Clocksin, Christopher S. Mellish • Any wwwsites and booksdedicated to Haskell and Prolog languages dr Robert Kowalczyk WMiI UŁ
Any Questions? dr Robert Kowalczyk WMiI UŁ