Pendahuluan
Setelah membahas 2 artikel pada prolog, Sekarang baru terpikir kenapa kita belajar Prolog, Worth or Not Worth. Jujur saya pribadi pun belajar ini karena tuntutan dari mata kuliah. Nah, setelah mencoba searching. Akhirnya saya menemukan ruang diskusi bagus kenapa kita harus belajar Prolog.
Beberapa pendapat yang saya dapat kenapa kita harus belajar Prolog :
sumber : https://www.quora.com/Is-Prolog-worth-learning-Why-or-why-not
Setelah membahas 2 artikel pada prolog, Sekarang baru terpikir kenapa kita belajar Prolog, Worth or Not Worth. Jujur saya pribadi pun belajar ini karena tuntutan dari mata kuliah. Nah, setelah mencoba searching. Akhirnya saya menemukan ruang diskusi bagus kenapa kita harus belajar Prolog.
Beberapa pendapat yang saya dapat kenapa kita harus belajar Prolog :
Prolog is logic programming language which is one of the programming paradigm. So from theoretical point of view it is important.Since it is declarative you tell computer what you want, it figures out how to get it for you. The concept of back chaining are of great importance to aid in your logical thinking in general.It will give you idea how thinking can be automated to some extent.
It also has functional programming features, which is getting a lot of importance now a days.
One of the main reasons for its failure in commercial space is that it is not intuitive as procedural languages but very mathematical.You need recursion just to print all elements of list.
Please correct me if I am worng this is my first Quora answer. :). (Mayur R,2013)
Prolog adalah bahasa pemrograman logika dimana ini merupakan salah satu dari paradigma programming. jadi dalam sudut pandang teoritis ini sangat penting. Sejak ini mendeklarasikan apa yang kamu menginginkan komputer melakukan apa yang kamu mau, ini menggambarkan bagaimana itu bisa dimengerti oleh kamu. Konsep "back chaining" merupakan suatu hal yang sangat penting dalam membantu kamu untuk berfikir logis secara umum. Ini akan memberi Anda tahu bagaimana pemikiran dapat di otomatiskan sampai batas tertentu.Ia juga memiliki fitur pemrograman fungsional, yang semakin penting pada masa sekarang.
Prolog allows you to think about problems in a completely intuitive way without any reference to how to achieve a solution. (Yes, that is actually a lie, but we'll skip that for now). In this way it is similar to FP. (Yes, the initial statement is also a lie for FP).Mungkin itu sekian dari saya, sengaja saya tidak menerjemahkan banyak kalimat. Karena kemampuan saya dalam menerjamahkan yang kurang mumpuni. Mohon maaf atas kekurangannya Terimakasih.
If you come to Prolog with a background in procedural languages, it will seem foreign and hard. Our experience was that for people new to programming it was very easy and very logical (sic).
Why?
- What could be simpler than the idea that to solve a problem, you solve it for a basic case and then break it down into smaller sub-cases which will involve the same solution as for the entire case? This is recursion, which is far more natural than iteration? (Don't believe all you have been told about recursion being bad ... your system is quite capable of doing recursion as efficiently as loops in most cases).
- What could be simpler than solving your problem by looking at the structure of the data and describing the solution cases that apply to it? This is pattern matching and unification as well as multiple alternatives to handle the data variety (Scala has this as well).
append(nil,L,L).This is a variant of how a list of items can be appended to another list of items, except I chose to represent the list a,b,c as f(a,f(b,f(c,nil))) rather than the usual [a,b,c]. The second clause says: appending a list with first element X and other elements L1 to a list of elements L2 will a list with first element X and other elements L3 if appending L1 to L2 results in L3.
append(f(X,L1),L2,f(X,L3)) :- append(L1,L2,L3).
- What could be simpler than saying a relation holds if the following others hold, or if not then these do? Trying another alternative if one fails to pan out is called backtracking.
R1(f(X)) :- R2(X),R3(X).
R1(f(X)) :- R4(X),R5(X),R6(X).
R1(g(X)) :- R2(X),R1(f(X)).Notice that you don't have to know what recursion, pattern-matching, unification or backtracking are to program in Prolog ... those are how the language is implemented.
- What could be simpler than having unknowns rather than variables (though sadly Prolog stuck to using the name variable)? An unknown can have a value or not, but once it does it can never change in a given context.
I have done little to nothing with Prolog for the last 20 years or so, but it continues to influence my thinking in how I write code in procedural languages to this day.
But, back to the lie. Prolog normally tries alternatives in the sequence they are written and programmers often take advantage of it. Prolog has the infamous cut operator which allows programmers to commit to alternatives (part of the search tree is "cut" off) but leads to all sorts of problems. Prolog allows one to use the program as kind of DB of global variables which when used makes it as hard to reason about the correctness of the program as it is for procedural code. These and similar things were added in the name of efficiency.
Can you write large systems in Prolog? Yes. Is it necessarily a good idea? Probably not. But there are Prolog implementations available which can be invoked from other programs. You can then have the part of your solution which benefits form the kind of thinking described in Prolog, while leaving the parts that procedural languages are good at to those languages. (Peter Koves,2016).
Poin penting dalam Prolog menurut Peter Koves :
- Membantu anda berpikir dalam memecahkan masalah menjadi sub-sub masalah tersebut. Pemecahan tersebut biasanya digunakan dalam bentuk iterasi.
- Membantu anda dalam memahami pola dalam memecahkan sebuah masalah.
- Dan sisanya bisa dibaca pada 3 paragraf terakhir
sumber : https://www.quora.com/Is-Prolog-worth-learning-Why-or-why-not
Posting Komentar untuk "Prolog 2 : Untuk Apa Belajar Prolog ?"
Berilah komentar, saran, dan kritik dengan bijak