4 ms·
Prolog is a deep language and can teach so you a lot. The main problem is that any prolog program bigger than, say, a thousand lines of code become difficult to
by sidkshatriya 4y ago
Prolog is a deep language and can teach so you a lot. The main problem is that any prolog program bigger than, say, a thousand lines of code become difficult to debug and understand. There are ways to make things better e.g. avoid impure prolog etc. but it is still problematic.
Engineers are always looking for technologies to hop onto. Prolog is niche for a reason: I don’t think Prolog scales. In some ways it is too flexible and powerful.
- agumonkey 4y agoI guess Erlang is the scalable Prolog in a way. Tiny blocks of logic, respawn.
- marcosdumay 4y agoOn the other hand, with dozens of lines of Prolog you can solve some problems that would take many thousands of lines in other languages (and a lot of calm study before you can map them into a real logic or imperative algorithm). I still avoid it, because yeah, once you solve that problem and avoid those thousands of lines, you are stuck. If you try make the rest of your system in Prolog, it will become a non-viable mess before you even finish it. That said, I think the main thing that Prolog is missing is easy integration with other languages. If I could define some environment in Haskell, pack it with some Prolog predicate and get a list back, I would use it all the time.
- infogulch 4y agoThere was a functional JVM language with built-in datalog that came through the other day. Datalog brings a lot of the value of pure prolog.
- robinsonrc 4y agohttps://flix.dev/ https://flix.dev/
- CodeSgt 4y agoI'm not familiar with Prolog and this statement sounds insane. I'm not doubting you exactly, it's just not something I can concieve. Can you provide an example of a problem that would only take a few dozen lines of Prolog which would take several thousand lines in another, "normal", language?
- prerok 4y agoIt's been more than a decade since I worked in Prolog, so I cannot give you a direct example but can try to answer :) Basically, Prolog is declarative programming. You can attach properties to your data and then define relations between the data based on whether they have that property (or not). Something along the lines of: X is grandfather of Y if X is man and X has child Z which has child Y. The above statement is very simple to write, a couple of lines. This will perform depth first search (or breadth first with some longer algirithm) using your data. As a result, Prolog can provide all such matches of all your data, or just the grandchildren of X, or both grandfathers of Y, etc. Anyway, what you are really getting is just a good implementation of the search through the relations based on constraints. The main reason Prolog is used is because other languages just don't provide a good library for constraint based search through your data.
- v-erne 4y agoSo You are saying that there is really not much difference between prolog and lets say constraint solver written in Java (DSL on top of another language)? Because if this really true than now I understand why this language never caught on.
- dymk 4y ago> now I understand why this language never caught on Can you illuminate why the language being a constraint solver tells you why it didn't catch on?
- v-erne 4y agoI believe in general purpose languages - from the business point of view its better to invest in one platform/language/ecosystem (if possible of course) than to spread too thin - each specialized language is potential liability (its trade-off but still the additional languages have to carry their own weight allowing for example to access more platforms)
- slaymaker1907 4y agoI think Minikanren does a pretty good job of being an embeddable version of Prolog. It's not that difficult to implement in whatever language you choose and uses the host language's data structures, you just have to implement unification over those days structures (i.e. figure out how to make it a tree). The main things it can't do is function like a database, though even that might be possible if you get creative.
- kitd 4y agoAre there any Prolog scripting engines or embeddable runtimes? It feels like the kind of thing where you might use it to solve a small part of your problem domain and leave the rest to a conventional language.
- QuinnWilton 4y agoTo an extent, you get this with Datalog, which is an easily embeddable subset of pure Prolog. I've been spending a ton of time with the language and its implementation through my day job, and I recently spoke about its use as a DSL for embedded knowledge bases: https://www.youtube.com/watch?v=lYLkaOq7WbU https://www.youtube.com/watch?v=lYLkaOq7WbU
- miltondts 4y agoNot exactly Prolog, but there is miniKanren. You can check a list of implementations here: http://minikanren.org/#implementations http://minikanren.org/#implementations
- Avshalom 4y agoOff the top of my head: Javascript: http://tau-prolog.org/ http://tau-prolog.org/ Java: https://apice.unibo.it/xwiki/bin/view/Tuprolog/ https://apice.unibo.it/xwiki/bin/view/Tuprolog/ (also SWI, Ciao and Sicstus have Java bridges) Go: https://github.com/ichiban/prolog https://github.com/ichiban/prolog Common Lisp: https://www.cliki.net/Prolog https://www.cliki.net/Prolog Racket: https://docs.racket-lang.org/racklog/ https://docs.racket-lang.org/racklog/ Guile: https://gitlab.com/gule-log/guile-log https://gitlab.com/gule-log/guile-log Erlang: https://github.com/rvirding/erlog https://github.com/rvirding/erlog Also SWI and Ciao have a pretty straight forward FFI for C.
- Avshalom 4y agoOh nice, looks like Tau just put out a new point release last week https://github.com/tau-prolog/tau-prolog/blob/master/RELEASE_NOTES.md https://github.com/tau-prolog/tau-prolog/blob/master/RELEASE... this looks handy https://github.com/tau-prolog/tau-prolog/issues/295 https://github.com/tau-prolog/tau-prolog/issues/295
- trenchgun 4y ago>The main problem is that any prolog program bigger than, say, a thousand lines of code become difficult to debug and understand. Sounds like there is a use case for abstraction? Category theory maybe?