5 ms·
One of the reasons C is the way it is is that that way is the way the processor is. The abstraction isn't perfect, but it is decent enough for a first approxim
by roenxi 8y ago
One of the reasons C is the way it is is that that way is the way the processor is.
The abstraction isn't perfect, but it is decent enough for a first approximation. I'm guessing Fortran is similar. Imperitive languages of that era were used because they worked very closely with the actual actions of the CPU and gave a fine grained control over execution, allowing efficiencies. Since then, popular languages have all been improvements that take advantage of increased computing power to do interesting things.
Sometimes new paradigms rear up - eg, Clojure with its set-and-forget approach to values. That paradigm is sold on the basis that it is easier to reason about, debug and as a practical bonus faster in many cases than the alternative. This is a great reason to learn a new paradigm.
Prolog is an experiment, but has anyone found a domain for the paradigm of logic programming? I've used it, and I couldn't see any domain where it seemed to have an advantage. For AI in particular - the way the world is developing, it seems logic is a weak foundation for intelligence. At this point, given that we know humans do not use logic for their intelligence, it would be a little surprising if logic is the best way to approach that particular problem. In most domains, the error in your sensor overwhelms the existence of fact and the 'rules' are more what you'd call guidelines.
If I rule out AI, what field is Prolog especially suited for? It doesn't read like it has a natural advantage in debugability (quite the reverse imo), GUIs, stream processing, efficiency, etc. With a lack of a killer domain, why not implement it as an afterthought library in C or lisp, and keep the imperative languages we have so much research in?
Basically, the default state of Prolog is dead. It doesn't represent how humans want to think about programming, it doesn't represent how the computer implements programming and so if it doesn't have a domain where its paradigm is spot on perfect it isn't going to take hold. It is an interesting idea and might yet be useful, but someone will need to find a reason to justify it.
- adimitrov 8y agoProlog is useful everywhere proofs are useful. Now, a proof isn't what you may think of as a proof in the general sense. One example of a proof that Prolog is good at is solving games, such as solving a particular instance of tic tac toe, or 4-in-a-row. Beyond these toy examples, you can see a good fit in any application which needs to follow a procession of rules. These rules may be in a feeding/bleeding relationship — this is essentially constraint logic programming. The problem goes: given these constraints, does this statement fulfil the constraints? How can I make the statement fit the constraints? Which is the set of statements that fit these constraints? I know of an industry application in German luxury cars, where the customer can order a car with a lot (a lot a lot) of different features, but some are mutually exclusive. If you have this particular leather seat, you can't have that particular heating unit or whatever. Now tell me if the customer selected a valid configuration, and if not, tell me what the valid configurations "next to" the desired one are. Another application are DCGs (Definite Clause Grammar), which have the expressive power of regular expressions (EDIT: see below for a correction, it appears they're at least context-sensitive.) If you've done Monadic parsing, DCGs feel kinda similar. They're super-close to Phrase Structure Grammar rules, and used to be part of my linguistics curriculum (I hear it's all ML nowadays. Pity.) Yes, Prolog fits niche domains. But if you find a domain, such as regular languages or a problem that can be solved by CLP, the elegance of logic programming can hardly be beat. It's really a joy to work with in the right domain. It's absolutely awful as a general purpose programming language, though — mostly because the debugging is so complex, it almost feels nondeterministic (it isn't, but there were many moments at 2 in the morning where I could've sworn it is.) In principle, Prolog is great for searching for solutions of a formally posed problem. Think of it as a logic search engine. If your problem can be stated in logic, and the logic problem can be evaluated in a finite time, Prolog's your friend. If not, you'll blow the stack.
- tom_mellior 8y ago> DCGs (Definite Clause Grammar), which have the expressive power of regular expressions. DCGs have a lot more expressive power than regular expressions. They are at least context-sensitive (i.e., stronger than context-free grammars as well). But off the top of my head I don't see why they wouldn't be able to capture recursively enumerable languages (i.e., the languages of completely unrestricted grammars) as well. > Think of it as a logic search engine. Think of it as a logic search engine embedded in a general-purpose programming language, because that's what it is.
- adimitrov 8y agoYou're right, of course. I misremembered. The trouble is that your program can become non-terminating in all but the regular case IIRC. Man it's been 10 years since I've done Prolog, so take what I say with a grain of salt.
- danieldk 8y agoEven in the regular case it can be non-terminating by using left-recursive rules. E.g. consider parsing a*: as --> as, [a]. as --> []. Prolog will recurse infinitely on the first rule.
- jmmcd 8y ago> Think of it as a logic search engine embedded in a general-purpose programming language, because that's what it is. I think this is the whole problem. The Prolog language is not great as a general-purpose language, and the "logic search engine" doesn't need be so closely identified with a particular language. Prolog should be a library, not a language, and not the almost sole representative of a programming paradigm.
- fanf2 8y agoIsn’t that kind of what miniKanren is about, embedding logic programming in conventional languages?
- xelxebar 8y ago> ... is the way it is is that that way is ... Not at all on topic, but this is the first time I've seen double repetition like that in the wild. Makes me wonder about examples of non-contrived buffalo sentences.
- leg100 8y ago> For AI in particular - the way the world is developing, it seems logic is a weak foundation for intelligence. At this point, given that we know humans do not use logic for their intelligence, it would be a little surprising if logic is the best way to approach that particular problem. Whoa, "humans do not use logic for their intelligence"? Hold on there. How do we know that? I suspect the line of reasoning is something like: if machine learning is massively successfully without a great deal of logic or deductive rules, then the human mind works similarly. Which stems in turn from thinking the brain is just like a computer, and vice-versa, which is arguable (let alone lamentable).
- floatboth 8y ago> what field is Prolog especially suited for? Graphs? SWI-Prolog even comes with an RDF triple store: http://www.swi-prolog.org/pldoc/man?section=semweb-rdfapi http://www.swi-prolog.org/pldoc/man?section=semweb-rdfapi Why aren't people using Prologs instead of graph databases like neo4j?
- mark_l_watson 8y agoI got my start with semantic web/linked data using semweb library and SWI-Prolog. I think that RDF data stores (and more general graph databases like Neo4j) scale better, but semweb is great for experimenting.
- jcelerier 8y agobecause at some point you want to have business rules that use your graph and make a pretty UI and write a graph renderer and implement GraphQL and all of those would be horrible to do in prolog so prolog would have to be the backend of a graph API that you would use in $GENERAL_PURPOSE_LANGUAGE and at that point it may not be the fastest.
- TFortunato 8y agoIsn't this exactly what datomic / datalog are?
- astrobe_ 8y ago> it seems logic is a weak foundation for intelligence What an offensive statement. Over two thousand years of fighting intuition-based judgements, and now that DL can merely tell a gorilla from a mouse (with 712 hours of training on 91 GPUs), it is best form of "intelligence" but Logic - a fundamental part of mathematics that helped us u.n.d.e.r.s.t.a.n.d the universe better - is a "weak foundation for intelligence?
- jcelerier 8y ago> and now that DL can merely tell a gorilla from a mouse (with 712 hours of training on 91 GPUs) is a baby able to tell a gorilla from a mouse after ~2 months of being awake ?
- astrobe_ 8y agoI strongly believe that what you don't want for an AI is for it to make the same mistakes and have the same weaknesses as humans. For instance, people will never accept that the AI of a car kills by accident, even thought human drivers kill a lot more etc. A system that makes life-or-death decisions but has no liability nor ethics is difficult to accept. The article talks about expectations - unrealistic expectations even. People expect from AI that it makes clever decisions like humans and "no mistakes" like machines (scare quotes for bugs, failures etc.). Now, I don't suggest that DL is useless. It is good at what it does, but contrary to what OP suggests, I don't see it as the sole or even main component of an AI system.
- opless 8y agoLogic (needs to be specified by GP, but assuming predicate logic, as we're talking prolog here!) can't hold probabilities (very well) or contradictions.
- astrobe_ 8y agoAnd you have very faint hopes to have a DL system explain to you why it thinks it is a gorilla. Each system has its weakness. Still, logic systems are a lot closer to reasoning and understanding (if not for the machine itself, at least for its operators), in other words closer to intelligence than other systems.
- varjag 8y agoProlog has a great programming model, but atrocious efficiency. Programming anything beyond 8-queens quickly becomes an exponential combinatoric minefield.
- nerdponx 8y agoThis was always my concern about writing nontrivial programs in Prolog. It seems more like something I would want to embed as a DSL than something I would want to use for writing an entire program front to back.
- Jeff_Brown 8y agoMercury is like Prolog, but deterministic and strongly typed, hence faster to run and faster to write.
- rwmj 8y agoI almost finished implementing a Prolog-like system to determine what operating system is installed in a guest image (replacing a huge chunk of C code which had accreted lots of rules and special cases). Described in a bit of detail here: https://rwmj.wordpress.com/2015/12/06/inspection-now-with-added-prolog/ https://rwmj.wordpress.com/2015/12/06/inspection-now-with-ad... This never went upstream for a couple of practical reasons: (1) It wasn't much simpler than the C code. In fact once you've gone and explained to people how Prolog works they might as well have digested the C code. (2) There wasn't a good, embeddable, widely-available Prolog "engine" we could use. As a result I wrote my own engine which only did the simplest sort of forward inference and so wasn't at all efficient.
- nikofeyn 8y ago> Sometimes new paradigms rear up - eg, Clojure with its set-and-forget approach to values. why is that "new" paradigm associated with clojure?