5 ms·
I think it would be interesting to have an init system and/or package manager configured using a logic programming language, such as a Prolog dialect. For inst
by jasonhansel 10y ago
I think it would be interesting to have an init system and/or package manager configured using a logic programming language, such as a Prolog dialect.
For instance, one could write "is_installed(X11) :- is_installed (KDE)" to specify that X11 must be installed if KDE is installed.
- iigs 10y agoI'm not sure how much of it is left today, but there is precedent for Prolog in OS startup: http://www.redditmirror.cc/cache/websites/web.archive.org_84624/web.archive.org/web/20040603192757/research.microsoft.com/research/dtg/davidhov/pap.htm http://www.redditmirror.cc/cache/websites/web.archive.org_84...
- kazimuth 10y agoAre there two layers of caching in that URL?
- jasonhansel 10y agoI wish that logic programming languages (and especially the one used in that article) had more friendly syntax. Even just replacing ":-" with "<-" would be nice...
- OskarS 10y agoActually, Prolog uses "-->" for to define grammars[1] for parsing. Not confusing at all! :) (actually, parsing is one of the things i really love about Prolog. Writing a simple grammars is much easier and much more pleasurable than using things like regular expressions. The fact that it's far more powerful and readable is just a bonus. ) [1] https://en.wikipedia.org/wiki/Definite_clause_grammar https://en.wikipedia.org/wiki/Definite_clause_grammar
- flukus 10y agoI'm sure the systemd people are working on one.
- jasonhansel 10y agoActually, it might be possible to translate (a subset of) prolog syntax into SystemD unit files. Hmm... (edit: incidentally, I've also had the same thought about CSS selectors.)
- nextos 10y agoNix (and Guix) uses a declarative approach to all things OS, including package building, managing, dependencies, deployment... It's functional and not logic though: https://nixos.org/ https://nixos.org/
- jasonhansel 10y agoI think logic programming is a better fit, because package configurations (and service unit files) are more like descriptions than functions. But Nix is certainly an improvement over traditional, imperative package management.
- nextos 10y agoGuix is implemented in Guile Scheme. Lots of the little DSLs used are in fact the descriptive abstractions you mention. If not, it's quite easy to implement Prolog or any other logic language like Kanren in Scheme. It's been done many times.
- jasonhansel 10y agoMoreover, the use of boolean operators (edit: and higher-order predicates) in such statements would provide a great level of flexibility.
- btschaegg 10y agoI actually had this thought w.r.t. makefiles after seing a talk on the Meson build system[1] on youtube. As a thought experiment: - Let distros, package maintainers, repository maintainers and the guy building define boolean flags (like "UNIX", "Linux", "ARM", "ARMv7h", "x86", "x86_64", "POSIX_Filesystem", "GCC", "Clang", "C++11", "C++14"... anything you could think of). The latter override earlier definitions (in the order above, i.e. build > repo > distro). Allow the deriving of flags for simplification: "ARMv7h -> ARM", "Windows && ARM -> Use_some_WinRT_Hack" etc. - Use a Prolog-Like system in which you can state rules for internal flags deciding if/which files should be included. Same goes for compiler flags. - Add an option to add definitions for external projects that can be included automatically from their sources/binaries (using the same system; like Meson does). - Just implement the "download/bootstrap" part and the logic solver. Generate ninja or tup files. That should make an interesting build system. Of course, the maintaining of source file dependencies (which can be dynamic due to header files) and the versioning of libraries would still be problems that are not easy to solve. But at least, one could get rid of the mess that is pretty much every CMake build there is. [1]: https://github.com/mesonbuild/meson https://github.com/mesonbuild/meson
- jasonhansel 10y agoNice idea; it's worth noting that Prolog can be used to specify the steps for building the program, not just the configuration.
- fulafel 10y agoWhat would be the advantage over the current system of having dependencies as data and running solvers on it? Turing-complete package metadata has some obvious disadvantages too.