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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Cog resurgence

74 点作者 lumpa超过 3 年前

7 条评论

ot超过 3 年前
I wish I had known about cog some 14 years ago when I implemented exactly the same thing (<a href="https:&#x2F;&#x2F;github.com&#x2F;ot&#x2F;inpytex" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ot&#x2F;inpytex</a>).<p>It was made for LaTeX files but could have worked with anything. It even uses the same checksum protection!<p>I wonder how many people independently came up with the same idea.
chriswarbo超过 3 年前
I think the closest &quot;standard&quot; tool for this is m4, which doesn&#x27;t seem powerful enough for most applications.<p>Lips seems similar, but for Lisp&#x2F;Scheme (e.g. <a href="https:&#x2F;&#x2F;github.com&#x2F;zc1036&#x2F;lips" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;zc1036&#x2F;lips</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;rbryan&#x2F;guile-lips" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rbryan&#x2F;guile-lips</a> )
评论 #29946269 未加载
teddyh超过 3 年前
My immediate thoughts:<p>• PHP, the poster example for template-based languages, seems to have spent all its recent years in development trying to get <i>away</i> from its HTML templating roots. I basically never see a PHP file in the wild which is using the old style with mostly HTML with sprinkles of PHP; it’s almost <i>all</i> pure PHP.<p>• Python has a perfectly good templating system in Jinja2, used by Flask and many others. Last I looked, even <i>Django</i> seemed to imply that they’d themselves would rather be using Jinja2 than Django’s own templating language. IIRC, Django even natively supports replacing its templating engine with Jinja2.<p>• For small-ish templates embedded inline in code, Python now has f-strings.<p>Therefore, I wonder: In what situation, exactly, would Cog, a PHP-style inline code templating system, be better than Jinja2 and&#x2F;or f-strings? And would this benefit be worth the added cost of having yet another model of abstractions which few people would be familiar with?
评论 #29943288 未加载
评论 #29944654 未加载
评论 #29944129 未加载
评论 #29946863 未加载
bytK7超过 3 年前
Looking at this reminds me strongly of texthon, but with a less attractive syntax. A quick skim through the source appears to show a similar use of eval.<p>Too bad texthon is essentially unknown and unmaintained, as far as I know. I worked on a project with it for several years and it always worked really well and was much more pleasant to use than something like jinja. Maybe I need to make a modern fork…<p>Anyway, anyone interested in cog should check it out as well.
评论 #29944666 未加载
vitiral超过 3 年前
I both like and dislike the &quot;immediate inline&quot; nature. I guess it depends on what you&#x27;re using it for. It&#x27;s great when the output is small, but I just imagine folks using it to generate enourmous classes or such inline, forcing programers to scroll through all of that, as well as giving false signals when searching code.<p>Like any tool, you need to use it well or it will be a foot gun.
评论 #29946769 未加载
neilparikh超过 3 年前
Similar: <a href="https:&#x2F;&#x2F;sustrik.github.io&#x2F;ribosome" rel="nofollow">https:&#x2F;&#x2F;sustrik.github.io&#x2F;ribosome</a>
评论 #29945657 未加载
petre超过 3 年前
This is possibly worse than the C preprocessor.
评论 #29947167 未加载