4 ms·
What sort of stuff do you use it for? I learned a bit of Prolog a long time ago (as part of a philosophy course at university!) and it sounds interesting but I
by graemep 2y ago
What sort of stuff do you use it for?
I learned a bit of Prolog a long time ago (as part of a philosophy course at university!) and it sounds interesting but I have no idea of how useful it is.
- xlii 2y agoFor more and more things. - Data queries (e.g. given data X show me as much as you can across multiple systems) - Cross API integration (e.g. show me a PRs that merged, but not marked as done in Jira) - Data transformation (JSON -> XML -> YAML), e.g. Excalidraw to Graphviz to draw.io - State transition checks (systems modeling) - Diagram generation - Code/Document generation One of the most crazy ideas I have is one to generate C++ code for Cardputter in order to have a little Uiua machine. Arduino tooling is so slow (or it might be the thing for this specific board, no idea), that I figured it's going to be easier to develop it in Prolog and then generate C code from it (i.e. key handlers, rendering etc.) Thing with Prolog is, that people think it's slow, but it's not. I agree that in 80's it might have not be usable, but today I'm having 2.1M Lips (Logical Iteration Per Seconds), so solution might not be inefficient but I save on the lines of code in the end.
- i_don_t_know 2y agoThat's super interesting. Do you use DCGs to read your data or do you call external libraries? How do you generate C code? Do you use a template system?
- xlii 2y agoI rarely use DCGs because they suffer from completeness syndrome, i.e. you either define full DCG or you crash on first error. For such tasks I prefer quasi-quotation [0] or a simple format with goal expansion [1]. As for readers I rarely need ones, because XML, YAML, JSON are already included. In order to do code analysis I first pulled pieces using Regex (mostly headers) and only then parsed them over with DCG. Which is also neat when creating own DSLs - one can ask people on meeting to decorate lightly notes and get - semantic linking almost for free. [0]: https://www.swi-prolog.org/pldoc/man?section=quasiquotations https://www.swi-prolog.org/pldoc/man?section=quasiquotations [1]: https://www.swi-prolog.org/pldoc/man?section=format-predicates https://www.swi-prolog.org/pldoc/man?section=format-predicat...
- i_don_t_know 2y agoThanks! I didn't know about quasiquotation.