TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Cog resurgence

74 pointsby lumpaover 3 years ago

7 comments

otover 3 years ago
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.
chriswarboover 3 years ago
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 未加载
teddyhover 3 years ago
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 未加载
bytK7over 3 years ago
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 未加载
vitiralover 3 years ago
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 未加载
neilparikhover 3 years ago
Similar: <a href="https:&#x2F;&#x2F;sustrik.github.io&#x2F;ribosome" rel="nofollow">https:&#x2F;&#x2F;sustrik.github.io&#x2F;ribosome</a>
评论 #29945657 未加载
petreover 3 years ago
This is possibly worse than the C preprocessor.
评论 #29947167 未加载