TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

PHP: Prolog Home Page

126 点作者 zichy超过 2 年前

11 条评论

radomir_cernoch超过 2 年前
When 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&#x27;t try to implement a web server in it.”<p>I was so wrong! :-D
评论 #34296945 未加载
评论 #34296371 未加载
评论 #34296199 未加载
rurban超过 2 年前
His taco solver produces 24 results, while only 6 wanted. That&#x27;s why she quit, unsolvable with these goals.<p><a href="https:&#x2F;&#x2F;php.energy&#x2F;tacos.html" rel="nofollow">https:&#x2F;&#x2F;php.energy&#x2F;tacos.html</a>
agumonkey超过 2 年前
I&#x27;d so love to see relational dom tree programming.
评论 #34297652 未加载
eyelidlessness超过 2 年前
<p><pre><code> &lt;!-- is this a quine? --&gt; &lt;section&gt; &lt;h2&gt;Source Code&lt;&#x2F;h2&gt; &lt;pre&gt;&lt;?=Source current_file(File), read_file_to_string(File, Source, []) ?&gt;&lt;&#x2F;pre&gt; &lt;&#x2F;section&gt; </code></pre> 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).
grose超过 2 年前
Hey, this is mine. Thanks for submitting it. I&#x27;ll answer some questions.<p>&gt; Why?<p>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 <i>fun</i>! There&#x27;s something valuable to just being able to shove a little bit of code inside some HTML and get it up on the internet.<p>I started my webdev journey with PHP many many years ago, and it&#x27;s nice to revisit it from a different perspective. I don&#x27;t use the real (elephant) PHP anymore, but I&#x27;ve gained a newfound appreciation for how fun its quick &amp; dirty development style is.<p>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.<p>&gt; Is it a joke?<p>Yes and no. The name is certainly a joke. I was pondering what &#x27;Prolog on Rails&#x27; 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.<p>&gt; Can you use Prolog for web services?<p>Yes! For example, SWI has a mature HTTP package: <a href="https:&#x2F;&#x2F;www.swi-prolog.org&#x2F;pldoc&#x2F;doc_for?object=section(%27packages&#x2F;http.html%27)" rel="nofollow">https:&#x2F;&#x2F;www.swi-prolog.org&#x2F;pldoc&#x2F;doc_for?object=section(%27p...</a>. It&#x27;s used to power SWISH, an online Prolog code sharing thing: <a href="https:&#x2F;&#x2F;swish.swi-prolog.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;swish.swi-prolog.org&#x2F;</a><p>&gt; Next steps?<p>I would like to support persistence somehow. I think it&#x27;d be really cool if you could use Prolog&#x27;s dynamic database[3] as a persistent store. Spin has components for Postgres and Redis so it shouldn&#x27;t be too hard to implement, but I lose the WASI compatibility if I do that... which means I can&#x27;t use the binary from WAPM, etc.<p>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.<p>On a somewhat related note, I&#x27;ve also been playing around with Cosmopolitan libc[5]. I got Trealla to compile to an APE executable but there&#x27;s some issues with the embedded Prolog libraries getting garbled, so I need to improve my GDB skills and figure out what&#x27;s going on there.<p>Finally, I&#x27;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]!<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;guregu&#x2F;trealla-js">https:&#x2F;&#x2F;github.com&#x2F;guregu&#x2F;trealla-js</a><p>[2]: <a href="https:&#x2F;&#x2F;github.com&#x2F;trealla-prolog&#x2F;go">https:&#x2F;&#x2F;github.com&#x2F;trealla-prolog&#x2F;go</a><p>[3]: <a href="https:&#x2F;&#x2F;www.swi-prolog.org&#x2F;pldoc&#x2F;man?predicate=assertz&#x2F;1" rel="nofollow">https:&#x2F;&#x2F;www.swi-prolog.org&#x2F;pldoc&#x2F;man?predicate=assertz&#x2F;1</a><p>[4]: <a href="https:&#x2F;&#x2F;github.com&#x2F;guregu&#x2F;worker-prolog">https:&#x2F;&#x2F;github.com&#x2F;guregu&#x2F;worker-prolog</a><p>[5]: <a href="https:&#x2F;&#x2F;justine.lol&#x2F;cosmopolitan&#x2F;" rel="nofollow">https:&#x2F;&#x2F;justine.lol&#x2F;cosmopolitan&#x2F;</a><p>[6]: <a href="https:&#x2F;&#x2F;github.com&#x2F;trealla-prolog&#x2F;trealla&#x2F;issues&#x2F;53">https:&#x2F;&#x2F;github.com&#x2F;trealla-prolog&#x2F;trealla&#x2F;issues&#x2F;53</a>
评论 #34298144 未加载
asalahli超过 2 年前
It&#x27;s amazing that the FAQ in the repo readme actually contains the first two questions I had when I saw this. And yet, I&#x27;m even more confused.
评论 #34295638 未加载
nigamanth超过 2 年前
Absolutely love this! The accessibility of PHP within pages is easy af.
评论 #34297733 未加载
breck超过 2 年前
The link to <a href="https:&#x2F;&#x2F;php.energy&#x2F;pricing.php" rel="nofollow">https:&#x2F;&#x2F;php.energy&#x2F;pricing.php</a> does not work.
hunter2_超过 2 年前
Felt like April 1 while going through this.
eddsh1994超过 2 年前
<a href="https:&#x2F;&#x2F;github.com&#x2F;guregu&#x2F;php&#x2F;blob&#x2F;master&#x2F;www&#x2F;lib&#x2F;php.pl">https:&#x2F;&#x2F;github.com&#x2F;guregu&#x2F;php&#x2F;blob&#x2F;master&#x2F;www&#x2F;lib&#x2F;php.pl</a><p>Dear god
评论 #34296698 未加载
评论 #34296694 未加载
评论 #34295790 未加载
phplovesong超过 2 年前
Oh God! Its alive!<p>But honestly, it probably has less bugs than the &quot;real&quot; php implementation.