4 ms·
I think Prolog really shines as an embedded query engine (I know this is old and it's been removed since). It's perfect for declarative configuration, very easy
by grose 3y ago
I think Prolog really shines as an embedded query engine (I know this is old and it's been removed since). It's perfect for declarative configuration, very easy to write powerful queries once you wrap your head around it.
The Yarn constraints plugin also used (Tau) Prolog, although it looks like it's in the process of being replaced with JS, which makes me a bit sad. The reasoning is here: https://github.com/yarnpkg/berry/issues/1276 https://github.com/yarnpkg/berry/issues/1276. Seems like the biggest issue is lack of a nice dev environment. I maintain the Trealla Prolog Wasm port (npm package 'trealla') and I hope some day to use it for a VSCode extension or LSP or something to provide a nice dev experience. Tau's performance has also been cited as an issue[1] but Trealla is quite fast and I expect it could easily handle a complex Yarn workspace with tons of facts. If this sounds like something you'd be interested in helping me with, feel free to contact me or make an issue/discussion here: https://github.com/guregu/trealla-js https://github.com/guregu/trealla-js
[1]: https://github.com/yarnpkg/berry/issues/4079#issuecomment-1033084124 https://github.com/yarnpkg/berry/issues/4079#issuecomment-10...
- sph 3y agoSoftware engineering is held back by having to get as much mindshare and reach the lowest denominator to have as many contributors or developers possible, so a niche language which might have been very productive to get the ball rolling, is cast aside once the project reaches maturity, and I would argue never for the best. Two examples off the top of my head are Reddit and SICP abandoning their Lisp roots because it's hard for new engineers (of average quality) to get into. Imagine if in mathematics there was a culture of avoiding abstraction and domain specific symbols because the average undergrad might have a hard time understanding them. Good luck exploring quantum mechanics with polynomials equations as your ceiling of complexity. In fact, it might a cultural problem at large: give people a chance to learn, and most are able to. But we are afraid of people needing to become familiar with it, that we strive to dumb everything down. Much of the UX focus of the 20 years has been on targeting the beginners, forgetting the fact that beginners eventually become power users and need force multipliers, not rounded-off scissors. (Sorry, Saturday morning philosophical rant after a week of thinking about the future of computing)
- AshamedCaptain 3y agoThe problem in your rant is comparing Reddit to "quantum mechanics". Reddit is a (huge) CRUD. You don't really need any fancy languages or abstractions because frankly the difference they are going to make is negligible. Go to places where they do software to solve problems which "undergrads might have a hard time understanding them" and then for sure you'll start to see extremely domain specific languages.
- PhilipRoman 3y agoThis is a good point, although be careful not to find yourself on the other side of the spectrum, surrounded by academics writing signal processing code in Visual Basic.
- grose 3y agoI agree. The longer I've been a programmer, the more Greenspun's tenth rule rings true. It's sad that in the modern day, ad-hoc YAML template programming is more widespread than e.g. embedded Lisps. Feels like the concept of "code as data" is severely underrepresented in the programming zeitgeist. I've been thinking a lot about how to make Prolog (and niche languages in general) more palatable. Killer app, like Ruby:Rails? Corporate backing, like Go:Google? Strong IDE integration, like Typescript:VSCode? Cute mascot? Meme power (HTMX:Grug)? Seems like all of these can help but none are a guarantee. So I figure that starting with IDE support is a decent approach. At the very least it's something I would use myself. The Reddit example you brought up is very interesting. I feel like niche languages can be a kind of advantage in attracting strong talent despite the small talent pool, but then you have companies that mistake headcount as growth and optimize their tech stack for hireability, picking the popular choices instead. One decent argument against niche languages is libraries. I have some vague hopes that Wasm Components will be a huge boon for niche languages once it stabilizes and libraries and cloud services start providing their APIs in component form. Of course, we already have near-universal FFI with the C ABI but that is messy enough that most people are unwilling to work with it. Enjoyed the rant! Here's my own :). I understand there are valid business reasons not to pick a niche language ("we need to hire 10 people NOW and use XYZ library! no time to write our own!") but it's a bit soul-crushing. Working on Prolog stuff is my way of coping.
- jfengel 3y agoIt's a great query language, too. But since it's Turing complete you get lots of rope to hang yourself.
- jodrellblank 3y ago> "I think Prolog really shines as an embedded query engine[...] It's perfect for declarative configuration, very easy to write powerful queries once you wrap your head around it." Can you explain more, or give any examples? VoidTools' Everything gives me a fast search over all files on my disk, it's some carefully optimised low level code, and I can search with wildcards or regex. Even if it supported it, I wouldn't want to change `cat*.jpg` to `findall(file(F), (file(F), name(F, FName), substring(FName, _, _, _, "cat"), append(_, ".jpg", FName)), Files)`. That's horrible so it's probably not at all what you're thinking of; on the other hand I'm endlessly pleased with `?- apropos(string).` in SWI Prolog. What kind of things are you thinking of where it could/does shine?
- grose 3y agoI think a compelling use case is flexibly defining rules. Biscuit’s Datalog tutorial does a good job of illustrating how you can go from simple auth to RBAC with just a few lines of code. https://www.clever-cloud.com/blog/engineering/2021/04/15/biscuit-tutorial/ https://www.clever-cloud.com/blog/engineering/2021/04/15/bis... For your particular example, using DCGs like: file(X), phrase(("cat", ..., ".jpg"), X). Is a bit clearer. You can use DCGs to do all kinds of parsing and generating (and in this case, testing). But they aren’t going to be as fast as a highly optimized regex engine.