grose 2 years 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. 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

[1]: https://github.com/yarnpkg/berry/issues/4079#issuecomment-10...

  • sph 2 years ago

    Software 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 2 years ago

      The 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 2 years ago

        This 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 2 years ago

      I 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.

    • jodrellblank 2 years ago

      Maths is held back by having to get as much mindshare and reach the lowest denominator schoolchild, to have as many people able to add up as possible, so a niche branch which might have been very productive is ignored and then child reaches maturity and leaves. We should not teach anyone basic math, it should be reserved for those who can do advanced math from a young age, we should circle the wagons around an in-group and exclude all the others, the inferiors, who can't do what we can do, and spend time patting ourselves on the back about how clever we are instead of building things which improve the world.

      Rumour has it there's people using sums to keep track of their money, trade, measure their houses for furniture, weigh ingredients, count attendance levels, count votes - just adding and subtracting! crying laughing emoji Imagine being that dumb. crying laughing emoji. Millions of people who haven't even heard of {niche clever idea I love} making their lives better using {simpleton idea I scorn}. It's a disgrace, it should be stopped. They haven't heard of {niche clever idea I've tied my identity to} and it rankles that they aren't even aware how dumb they are. angry face emoji.

      > "we strive to dumb everything down."

      No you don't, you strive to keep everything elitist so you can feel clever; when it comes to making things easier and more accessible you don't talk of it as as positive thing, - simplifying, clarifying, explaining - you call it "dumbing down" - for dumb people who are beneath you. Instead of raising the floor with the idea that a rising tide lifts all boats, improving the situation for the lowest, you scorn the lowest; you want your genius for being able to use the dark arts to be known, not for the dark arts to be taken apart, explained clearly, widely known and considered blasé. The last thing you want is for all the web developers to use LISP, heaven forbid they might find the Holy Grail. You want them to stop programming entirely and worship you for using LISP. Maybe if they do that enough, you'll deign to make a CRUD app once in a decade to appease them, before going back to your true calling - writing a new LISP which fixing all the stupid decisions of the previous LISPs.

      Meanwhile, trillions of dollars of value and joy are added to the world, fraud is detected, trade is eased, family members stay connected, by people doing the lowly work of trucking bytes around with tools which are merely 'good enough' but not approved by the high priests.

      • sph 2 years ago

        That's a weird rant, that barely disguises its ad hominem nature. And you completely miss the point. I'm not scorning "those below me" (your words, not mine), I am simply saying the complete opposite, that we should in fact stop being so condescending of non-techies, creating fisher-price interfaces because they might get hurt or, by God, they might have to become proficient at it. The comparison is always with grandma, ask her how she likes being treated like that. She's quicker than most give her credit for.

        Dumbing down interfaces is treating users like idiots. Users are not idiot. Teach them instead. Let them make mistakes.

        In any case, you could disagree with a coherent response instead of being an obnoxious twit for absolutely no reason. The air of condescension is all on your side here, so I hope you feel real smart for putting me down right now. Good day.

        • jodrellblank 2 years ago

          > "I'm not scorning "those below me" (your words, not mine)"

          Your opening sentence: "Software engineering is held back by having to get as much mindshare and reach the lowest denominator" - the lowest denominator is not you, which means it's other people and they are low - beneath you. Instead of saying "the world is improved by experts making things accessible for everyone", you say "we (elites) are being held back by the lowest common denominator (plebs)". How is that not scorning those below you?

          > "I am simply saying the complete opposite, that we should in fact stop being so condescending of non-techies, creating fisher-price interfaces because they might get hurt"

          Fisher-Price?? What's that quote, "You think it’s degrading for a man to act like a woman, because you think being a woman is degrading"; you think using a plain, simple, accessible interface is not convenient and desirable, but like a baby's toy? That's you scorning those below you, right there. This is the "real man" view that things are better if they are hard and dangerous for no specific reason other than that filters out inferiors. It's the old, deaf, missing-fingered laborer mocking hearing protection and safety guards on workshop equipment, it's the person running everything as root. Hello? Getting hurt is bad, avoiding it is good, not laughable.

          > "or, by God, they might have to become proficient at it." "The comparison is always with grandma, ask her how she likes being treated like that. She's quicker than most give her credit for."

          My mom is approaching 70. She's used a smartphone for maybe 5 years and has never installed an app, never tried to swype on the keyboard despite seeing me do it, always saying she will have to learn about it another time, she has no interest in computers, but she uses it multiple times a day to WhatsApp with family and friends, share photos. The simple interface hides so much complexity, it is a wonder which enables her to do things without having to learn computer internals, not an embarrassment. The last thing she needs is punishing her by taking the guard rails off because some programmer thinks making a simple interface is holding the industry back, making her choose between png, webp, jpg2000, watch videos through ffmpg so she can set her own filter and processing chains, be able to sideload apps or use open source firmware. And if she did want those things, there's Android phones with third party builds and removable safety rails available.

          > "Dumbing down interfaces is treating users like idiots. Users are not idiot."

          If users are not idiots then making something easy for them ISN'T DUMBING DOWN. Hiding complexity and making things simpler is good, not bad. It's how we progress - abstractions let us wrap complexity up and pretend it's not there and use it as building blocks for higher level things. It's amazing that I can swipe an email to the left and it gets deleted, and I don't have to care if it's POP or IMAP or ActiveSync or if it's held in a text file or a SQLite DB, and the delete syncs across all my devices without me having to host the server or punch NAT holes in firewalls or anything. If I wanted to host my own mailserver and configure all that, that is an option, but it's in no way beneficial to force everyone to have to do that so they can become proficient at postfix or exim config files or Exchange administration or DKIM and SPF; what a complete waste of grandma's time!

      • kazinator 2 years ago

        Lisp is the source of almost everything that makes programming easy, welcoming, forgiving of mistakes and inclusive. (Except the ability to use infix syntax to calculate a formula, which goes back mostly to Fortran.)

        It should be taught to small children in schools. All kids should know how to correctly use macroexpand with an environment argument inside the body of a macrolet by the time they finish eighth grade. No elitist secrets!

        At least Excel has lambda now. That means every MBA who finds it in a reference manual and starts using it is ahead of most of his or her peers that went to CS.

  • jfengel 2 years ago

    It's a great query language, too. But since it's Turing complete you get lots of rope to hang yourself.

  • jodrellblank 2 years 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 2 years ago

      I 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/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.

opless 2 years ago

https://github.com/opless/small-prolog-walnut-creek-original

Is a copy of the PD prolog used in the PNP system in NT

More details (and probably where the original article was sourced from) http://www.drdobbs.com/cpp/extending-c-with-prolog/184409294

Finally a good write up by Microsoft themselves

https://web.archive.org/web/20040603192757/research.microsof...

  • abecedarius 2 years ago

    Thanks, Small Prolog looks neat.

    Since I couldn't find an author name in the github repo and had to grovel through the Dr. Dobbs article for it, I'll copy it here: "Henri de Feraudy during the late 1980s".

    • opless 2 years ago

      Added his name to the repo description, thanks for the suggestion!

kazinator 2 years ago

Interesting. That Small Prolog seems to be alive.

Note that the following HTTPS link times out; if you edit to HTTP it works:

https://snapageno.free.fr/Code/C/SProlog.htm

There is no copyright notice or license anywhere in sight; I think Microsoft wouldn't touch something like this with a ten foot pole today (without contacting the author directly to license it).

  • opless 2 years ago

    Nice find!

    I wonder when it was put up, it took me a while to track the original down

    License-wise on the site it says: > You can use it for anything you want

    Which implies “public domain”, and …

    https://github.com/opless/small-prolog-walnut-creek-original

    And on the copy on the Walnut Creek CD it explicitly says;

    These diskettes contain a public domain Prolog interpreter called Small Prolog version 2. In the USA the C User's Journal will have the latest releases.

    It has been compiled on an PC clone, on UNIX and on an Atari ST.

userbinator 2 years ago

The actual network configuration program is a Win32 dynamic-link library called NCPA.CPL. The extension CPL indicates that it is a Windows NT Control Panel extension (or applet). It is represented in the Control Panels main window by an icon representing a netcard cable.

That is still there in Windows 11, although MS had to put it back likely after a Very Important Customer started complaining loudly when MS redirected it to the horribly lobotomised new settings UI.

  • dboreham 2 years ago

    I'd heard (here, last time this came up) that the Prolog interpreter was removed c. Windows XP time.

    • monocasa 2 years ago

      Is expect it at least to have been removed when Microsoft rewrote the network stack in Vista.

      • p_l 2 years ago

        The important network configuration rewrite happened in NT5, IIRC, with the introduction of NETSH.EXE and its Cisco-ish command line interface. (It's still there in windows 11 and is probably the powerful way of interacting with network stack).

        The infamous rewrite didn't change the structure of networking in NT too much, there was also quite a lot of activity before and after (windows server 2016 delivered considerable changes, for example, though some of them were present already in 2012 mainly due to Hyper-V).

AshamedCaptain 2 years ago

Prolog was still being used for the same purposes (handling high-level network configuration and even device state) at least as late as in late 2000s smartphones.

gamache 2 years ago

Once I heard that ca. 1990s MS Word used an embedded Prolog to perform spell check. Anyone with knowledge of this, one way or another? I can't find any documentation of it online.

  • jodrellblank 2 years ago

    Word for Windows 1.1a was released in 1990 and the source code of it is available from the Computer History Museum: https://computerhistory.org/blog/microsoft-word-for-windows-...

    It has 1800 lines of "SPELL.C" for 17 languages already by that time, so if there's a Prolog interpreter involved that might be a place to look. There were Word 2, Word 6, Word 95, Word 98 and Word 2000 released in the 90s as well so it's quite possible they rewrote the spellchecking several times and absense in that code won't be conclusive evidence against the idea.

    • gamache 2 years ago

      Thank you for the link! Unfortunately the code in spell.c and spelcore.c seems to call out to an external DLL, whose source doesn't seem to be included here. Later versions of MS Word did the same thing, e.g., msspell3.dll.

jodrellblank 2 years ago

Prolog is excellent for bikeshedding, in fact that might be its strongest axis. It starts with everything you get in a normal language such as naming things, indentation, functional purity vs side effects, where to break code into different files and builds on that with having your names try to make sense in declarative, relational, logical and imperative contexts, having your predicates (functions) usable in all modes - and then performant in all modes - having your code be deterministic, and then deterministic in all modes. Being 50 years old there are five decades of learning "idiomatic Prolog" ideas to choose from, and five decades of footguns pointing at your two feet; it has tabling, label(l)ing, SLD and SLG resolution to choose from. Built in constraint solvers are excellent at tempting you into thinking your problem will be well solved by the constraint solvers (it won't be, you idiot, why did you think that was a constraint problem?), two different kinds of arithmetic - one which works but is bad and one which mostly works on integers but clashes with the Prolog solver - and enough metaprogramming that you can build castles in the sky which are very hard to debug instead of real castles. But wait, there's more! Declarative context grammars let you add the fun of left-recursive parsing problems to all your tasks, while attributed variables allow the Prolog engine to break your code behind the scenes in new and interesting ways, plenty of special syntax not to be sneezed at (-->; [_|[]] {}\[]>>() \X^+() =.. #<==> atchoo (bless you)), a delightful deep-rooted schism between text as linked lists of character codes or text as linked lists of character atoms, and always the ISO-Standard-Sword of Damocles hanging over your head as you look at the vast array of slightly-incompatible implementations with no widely accepted CPython-like-dominant-default.

Somewhere hiding in there is a language with enough flexibility and metaprogramming to let your meat brain stretch as far as you want, enough cyborg attachments to augment you beyond plain human, enough spells and rituals to conjour tentacled seamonsters with excellent logic ability from the cold Atlantic deeps to intimidate your problem into submission.

Which you, dear programmer, can learn to wield up to the advanced level of a toddler in a machine shop in a mere couple of handfuls of long years! Expertise may take a few lifetimes longer - in the meantime have you noticed your code isn't pure, doesn't work in all modes, isn't performant in several modes, isn't using the preferred idiom style, is non-deterministic, can't be used to generate as well as test, falls into a left-recursive endless search after the first result, isn't compatible with other Prolog Systems, and your predicates are poorly named and you use the builtin database which is temptingly convenient but absolutely verboten? Plenty for you to be getting on with, back to the drawing boar...bikeshed with you.

And, cut! No, don't cut; OK, green cuts but not red cuts and I hope you aren't colourblind. Next up, coroutines, freeze, PEngines, and the second 90%.

Visit https://www.metalevel.at/prolog and marvel as a master deftly disecting problems, in the same way you marvel at Peter Norvig's Pytudes https://github.com/norvig/pytudes , and sob as the wonders turn to clay in your ordinary hands. Luckily it has a squeaky little brute force searcher, dutifully headbutting every wall as it explores all the corners of your problem on its eventual way to an answer, which you can always rely on. And with that it's almost like any other high level mostly-interpreted dynamic programming / scripting language.