7 ms·
William Byrd on logic and relational programming, miniKanren (2014)
- zelphirkalt 5y agoI have not seen the complete series yet, but I found William Byrd's miniKanren uncourse to be fascinating material! This seems to be in the same area of knowledge.
- bob1029 5y agoThis whole area is so fascinating to me. I started my journey with Out of the Tar Pit [0]. We are now using SQL (SQLite in-memory) for virtually 100% of our business logic execution. We added a few UDFs and views throughout to make a really nice domain-specific language that the business can use to compose queries in terms they understand. Its really easy to map to/from SQL when you model your actual types in terms of tables/facts/relations as well. We do not nest complex types at all. We were very strict with how the schema was developed, building upon many prior failed iterations. I don't believe you could ever get this stuff right the first time through. You must be OK with iterating the whole schema a few times. Maybe start in Excel and surround yourself with business stakeholders. I think this might be cheaper & easier than starting with whatever new-fangled postgres clustering thing we have on the front page. Just piping simple things like .NET DateTime in as a UDF [1] turns SQLite from a fun idea into a scary weapon when compared to the competition from Oracle, SAP, IBM, et. al. Imagine where you could go with views on top of UDFs and recursive SQL evaluation. One tip I can provide to wary travelers struggling in complex problem domains: Embrace the notion of circular dependencies. These exist in the real world and if you can model them properly, you win at a huge part of what fucks up other developers. Relational programming/modeling is 100% the answer to this problem. If 2 types seem hopelessly interconnected, they are either the same type (unlikely if you tried during excel phase) or simply related by way of other combinations of types. For instance, if you have an Account.Customers and Customer.Accounts type of problem, you draw a third CustomerAccountRelationship type, and maintain 2 separate collections for the main domain types. This allows for very clean modeling of hyper-complex domains. You always want to shoot for something around 3NF/BCNF/DKNF [2] [0]: http://curtclifton.net/papers/MoseleyMarks06a.pdf [1]: https://docs.microsoft.com/en-us/dotnet/standard/data/sqlite/user-defined-functions [2]: https://en.wikipedia.org/wiki/Third_normal_form
- tluyben2 5y ago> We are now using SQL (SQLite in-memory) for virtually 100% of our business logic execution Any docs, open source etc?
- bob1029 5y agoI don't have any source I am able to share at this time, but I can share the core idea with a simple example. Assume you have a business app where you need to conditionally do a thing. The predicates (conditions) for this thing can be expressed in terms of constraints in a SQL query, the result of which is a scalar value representing true or false. All complex decision trees can ultimately be turned into combinations of these things. An example of this could be a decision point in a business app where you need to determine if the user should be allowed to proceed into a certain feature. Perhaps you call this knowledge IsUserAllowedIntoFeatureA. What we would do is expose a configurable SQL rule which allows for a business analyst to customize the behavior of this fact per-customer: SELECT 1 --1 == true, 0/null/empty == false FROM --My Domain WHERE --My Conditions The above SQL query would be run against a SQLite database that is mapped out of the current instance of that user's state. Once we determine the outcome, we throw away the database. This idea can also be extended to strings, arrays, etc.
- chrisjc 5y agoI'd love to understand more. Is there anything like this that already exists that perhaps you modeled this approach from? I'm having trouble envisioning the complete solution, but it really sounds intriguing and you've caught my attention.
- deleted 5y ago[deleted]
- rlguarino 5y agoI also am very curious to know more about the complete solution. It sounds like you've delegated if statements to configurable SQL queries, does that mean you need to take the context/variables/code and put it into a temporary SQL db whenever you evaluate them. Is the overhead of moving state into and out of SQLite a lot? It reminds me of SQL stream processing in Fluentbit https://docs.fluentbit.io/manual/stream-processing/getting-started/fluent-bit-sql https://docs.fluentbit.io/manual/stream-processing/getting-s...
- uptheroots 5y agoOne of my all time favorite YouTube videos is a lecture by William Byrd. I find myself still coming back to this video, it was so fascinating to me as an undergrad. https://youtu.be/OyfBQmvr2Hc https://youtu.be/OyfBQmvr2Hc
- kanzenryu2 5y agoYou might enjoy this amazing talk. I've linked to a part when the next 20 seconds of explanation turns the amazing up to 11. https://www.youtube.com/watch?v=er_lLvkklsk&t=1436s https://www.youtube.com/watch?v=er_lLvkklsk&t=1436s
- jmkr 5y agoI think this was the first Will Byrd video I saw, and what got me interested in Scheme, and PL. He has some great tutorials on Youtube too. I still haven't dived too much into miniKanren, but it's on the list with the Reasoned Schemer.
- will_byrd 5y agoFor anyone who finds this topic interesting, you might be interested in the following resources: http://minikanren.org/ http://minikanren.org/ The second edition of `The Reasoned Schemer` (MIT Press, 2018): https://mitpress.mit.edu/books/reasoned-schemer-second-edition https://mitpress.mit.edu/books/reasoned-schemer-second-editi... The Clojure/conj 2016 talk Greg Rosenblatt and I gave on Barliman: https://www.youtube.com/watch?v=er_lLvkklsk https://www.youtube.com/watch?v=er_lLvkklsk `A Unified Approach to Solving Seven Programming Problems (Functional Pearl)`, William E. Byrd, Michael Ballantyne, Gregory Rosenblatt, Matthew Might (ICFP 2017) (Open Access): https://dl.acm.org/doi/10.1145/3110252 https://dl.acm.org/doi/10.1145/3110252 and the related talk: https://www.youtube.com/watch?v=o3AHnyEf7IE https://www.youtube.com/watch?v=o3AHnyEf7IE and Nada Amin's interactive version of the paper: http://io.livecode.ch/learn/namin/icfp2017-artifact-auas7pp http://io.livecode.ch/learn/namin/icfp2017-artifact-auas7pp Cheers, --Will
- Y_Y 5y agoDid anything ever come out of Barliman or other attempts to make an interactive interface around this stuff? It's such a cool concept, I'm surprised I never saw a mainstream IDE where I can write rough constraints or examples and have it generate code, just like in those really nice examples of minikanren from a few years back.
- will_byrd 5y agoThis paper and prototype educational system was based on Barliman: `Towards Answering "Am I On the Right Track?" Automatically using Program Synthesis` Molly Q Feldman, Yiting Wang, William E. Byrd, François Guimbretière, & Erik Andersen. SPLASH-E 2019 https://mollyfeldman.github.io/splashe2019.html https://mollyfeldman.github.io/splashe2019.html This paper was at least partly inspired by the relational interpreter approach that is the foundation of Barliman: `From definitional interpreter to symbolic executor` Adrian D. Mensing, Hendrik van Antwerpen, Casper Bach Poulsen, and Eelco Visser. Proceedings of the 4th ACM SIGPLAN International Workshop on Meta-Programming Techniques and Reflection (META 2019) https://dl.acm.org/doi/10.1145/3358502.3361269 https://dl.acm.org/doi/10.1145/3358502.3361269 As for Barliman, we took a step back from imrpoving the interface, and started doing experiments with a bunch of colleagues on various ways to improve synthesis speed and expressiveness. Until COVID-19 got in the way, Kanae Tsushima and I were beginning to put some of the pieces back together in an improved Barliman, named `新-Barliman` (`Shin-Barliman`, `shin` meaning "new" in Japanese): https://github.com/k-tsushima/Shin-Barliman https://github.com/k-tsushima/Shin-Barliman I'm hoping we will make some real progress again soon!
- alvatar 5y agoFor a split second I thought a composer from the English Renaissance era wrote a book about logic.