7 ms·
PHP: Prolog Home Page
- asalahli 4y agoIt's amazing that the FAQ in the repo readme actually contains the first two questions I had when I saw this. And yet, I'm even more confused.
- rizky05 4y ago[dead]
- nigamanth 4y agoAbsolutely love this! The accessibility of PHP within pages is easy af.
- tannhaeuser 4y agoIt's indeed easy to shit strings into HTML pages without consideration for context, escaping, and quoting, also known as injection attack vulnerability when sourced from user content, and plaguing PHP sites to this date. A better approach (and like processing instructions also from SGML's tool box) would be to use entities/text macros.
- radomir_cernoch 4y agoWhen I was teaching Prolog are the university, I always introduced it as a niche language. “Prolog makes you unbelievably fast at very specific tasks, but don't try to implement a web server in it.” I was so wrong! :-D
- linkdd 4y agoWell, a CGI script isn't really a web server.
- Avshalom 4y agoalthough there's certainly nothing stopping you from writing a server https://github.com/SWI-Prolog/packages-http https://github.com/SWI-Prolog/packages-http https://github.com/ciao-lang/ciao/tree/master/core/library/http https://github.com/ciao-lang/ciao/tree/master/core/library/h... https://github.com/mthom/scryer-prolog/tree/master/src/lib/http https://github.com/mthom/scryer-prolog/tree/master/src/lib/h...
- drbojingle 4y agoWhat tasks is it really good for?
- eyelidlessness 4y agoDefine a model of your program’s state, as if you’d define a model in a database. There, that’s your program! It is actually a database. You can’t create invariants in the program. It’s entirely defined by how you modeled it. Your program is correct.
- tannhaeuser 4y agoStraightforward searching through combinatoric spaces for planning and optimization, including robotic and eg. discrete investment planning for models where solutions can't be described by a finite number of variables (see [1] for in-browser container logistics planning). Composition of programs with complex rule-based semantics and large specs (the Prince CSS renderer is written in Mercury). Diagnostics, capturing legal, medical, and other taxonomic knowledge in executable form, possibly as implementation, extension, or replacement for semantic web stuff and description logic. All of the above with easy and powerful DSL capabilities ranging from built-in customizable operator precedence parsing, over natural recursive descent parsing with backtracking, to attribute grammars and arbitrary logic (Prolog started out as a 70's natural language understanding approach employing logic grammars). [1]: https://quantumprolog.sgml.io/ https://quantumprolog.sgml.io/
- mncharity 4y agoIIRC (it's been years), a highly-conformant Perl5/Perl6/python/javascript regex engine core in SWI Prolog was concise and performant. Like "wow, it just one short file" concise. And "KISS competitive-with-little-optimization" performant. Modulo memory halo. IIRC, far more effort went into bootstrapping grammars and creating testing infrastructure. It helped warped my perspective on how concise and pretty compiler guts could/should be.
- astrange 4y agoMercury, which is Prolog inspired, is actually a very interesting underrated language! I think languages need to lean harder in the direction of doing more with functions than just evaluating them. Unification is one example, but you can imagine more.
- jamesfisher 4y ago> you can imagine more My imagination is failing me! Can you give more examples?
- ragebol 4y agoDifferential computing comes to mind. Kinda like prolog in that you can run a function in reverse.
- eddsh1994 4y agohttps://github.com/guregu/php/blob/master/www/lib/php.pl https://github.com/guregu/php/blob/master/www/lib/php.pl Dear god
- deleted 4y ago[deleted]
- dylan604 4y agoholybejeebushchristopher that's disheartening to say the least
- dotancohen 4y agoFrom the site: > PHP is Prolog implemented in C, compiled to WASM, speaking CGI, executed > by a Rust runtime, interpreting PHP-style templates I'm so happy they left my beloved Python undefiled.
- Avshalom 4y agoAll web programming starts to sound silly if you explain what your stack actually looks like.
- breck 4y agoWhen I clicked the last commit message was too good. Preserving just in case they are doing rapid releases: https://github.com/guregu/php/commit/65b1e991f473d6ac0dd9de434a468eff5178ea0a https://github.com/guregu/php/commit/65b1e991f473d6ac0dd9de4...
- eyelidlessness 4y ago<!-- is this a quine? --> <section> <h2>Source Code</h2> <pre><?=Source current_file(File), read_file_to_string(File, Source, []) ?></pre> </section> No but it’s cute! Sorry if I butchered the indentation, I meant to preserve the tabs (tabs rule!), but I don’t know how to do that on my phone (spaces suffice).
- breck 4y agoThe link to https://php.energy/pricing.php https://php.energy/pricing.php does not work.
- hunter2_ 4y agoFelt like April 1 while going through this.
- phplovesong 4y agoOh God! Its alive! But honestly, it probably has less bugs than the "real" php implementation.
- rurban 4y agoHis taco solver produces 24 results, while only 6 wanted. That's why she quit, unsolvable with these goals. https://php.energy/tacos.html https://php.energy/tacos.html
- agumonkey 4y agoI'd so love to see relational dom tree programming.
- Avshalom 4y agoTau has a nice little DOM module http://tau-prolog.org/manual/manipulating-the-dom-with-prolog http://tau-prolog.org/manual/manipulating-the-dom-with-prolo... although it's not particularly relational, mostly just wrapped jaavascript function calls.
- agumonkey 4y agoBeside the usual dom api I was more thinking about non trivial interaction patterns, validation and structural suggestions.
- grose 4y agoI agree something like that would be really cool. If you have any ideas for the API, feel free to make an issue on the php or trealla-js repos to discuss.
- agumonkey 4y agoYou have an IRC channel too ? or maybe hang over #prolog on libera chat ?
- grose 4y agoI'm in the Prolog Discord (invite code: https://discord.gg/pUFm3Tjq https://discord.gg/pUFm3Tjq), if you're OK with that. I understand if you prefer IRC but I don't currently have a good setup for it unfortunately. I'll add that to my TODO list :)
- grose 4y agoHey, this is mine. Thanks for submitting it. I'll answer some questions. > Why? I ported Trealla Prolog to WASM (WASI) and I was looking for something useful to test it against. I found Spin, which can run WASM+CGI, and landed on this. Making this project exposed a number of bugs in my port that have now been fixed, so consumers of more useful projects[1][2] benefit as well. Also, PHP style templates are just fun! There's something valuable to just being able to shove a little bit of code inside some HTML and get it up on the internet. I started my webdev journey with PHP many many years ago, and it's nice to revisit it from a different perspective. I don't use the real (elephant) PHP anymore, but I've gained a newfound appreciation for how fun its quick & dirty development style is. I hope this project can serve as an example of how to use Prolog for fun things. It does showcase some of the cooler dynamic aspects of the language, and the PHP parsing code is like 10 lines of DCG. > Is it a joke? Yes and no. The name is certainly a joke. I was pondering what 'Prolog on Rails' might be and thought calling it PHP would be funny. This led to the PHP-style templates which were quick to implement and pretty powerful. Despite the humorous presentation, it does actually work. > Can you use Prolog for web services? Yes! For example, SWI has a mature HTTP package: https://www.swi-prolog.org/pldoc/doc_for?object=section(%27packages/http.html%27) https://www.swi-prolog.org/pldoc/doc_for?object=section(%27p.... It's used to power SWISH, an online Prolog code sharing thing: https://swish.swi-prolog.org/ https://swish.swi-prolog.org/ > Next steps? I would like to support persistence somehow. I think it'd be really cool if you could use Prolog's dynamic database[3] as a persistent store. Spin has components for Postgres and Redis so it shouldn't be too hard to implement, but I lose the WASI compatibility if I do that... which means I can't use the binary from WAPM, etc. I would also like to experiment with running Trealla on Cloudflare Workers. I have another project, worker-prolog[4], which uses Tau Prolog (a Prolog written in Javascript) on Workers. On a somewhat related note, I've also been playing around with Cosmopolitan libc[5]. I got Trealla to compile to an APE executable but there's some issues with the embedded Prolog libraries getting garbled, so I need to improve my GDB skills and figure out what's going on there. Finally, I'd like to say thanks to Andrew Davison (@infradig on GitHub), the author of Trealla Prolog, for letting me add WASM support to his project and helping me with lots of things. For example, PHP led to Andrew implementing improvements for using DCGs to parse Prolog terms, which is now super fast[6]! [1]: https://github.com/guregu/trealla-js https://github.com/guregu/trealla-js [2]: https://github.com/trealla-prolog/go https://github.com/trealla-prolog/go [3]: https://www.swi-prolog.org/pldoc/man?predicate=assertz/1 https://www.swi-prolog.org/pldoc/man?predicate=assertz/1 [4]: https://github.com/guregu/worker-prolog https://github.com/guregu/worker-prolog [5]: https://justine.lol/cosmopolitan/ https://justine.lol/cosmopolitan/ [6]: https://github.com/trealla-prolog/trealla/issues/53 https://github.com/trealla-prolog/trealla/issues/53
- deleted 4y ago[deleted]