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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Dnjs: A pure subset of JavaScript that wants to replace configuration languages

54 点作者 tudorizer超过 4 年前

15 条评论

anderskaseorg超过 4 年前
Other pure languages with similar goals: <a href="https:&#x2F;&#x2F;cuelang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;cuelang.org&#x2F;</a>, <a href="https:&#x2F;&#x2F;dhall-lang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;dhall-lang.org&#x2F;</a>, <a href="https:&#x2F;&#x2F;gcl.readthedocs.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;gcl.readthedocs.io&#x2F;</a>, <a href="https:&#x2F;&#x2F;jsonnet.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jsonnet.org&#x2F;</a>.
评论 #24266862 未加载
评论 #24268742 未加载
评论 #24306126 未加载
评论 #24270209 未加载
4WIW超过 4 年前
Creating languages is fun but writing code in a half-assed language created by brilliant but not too experienced engineer with no real support for anything, is not! Then, when this engineer leaves your company, you are left with a mess to clean up...<p>IMO better strategy would be to reduce config files to absolute minimum and let the code that reads them handle all the complexity. Whatever is your main language, it is better supported than any of this.
评论 #24269381 未加载
评论 #24273159 未加载
flying_sheep超过 4 年前
I wouldn&#x27;t use any turing-complete language as configuration :-&#x2F;<p>Determinism is essential for a configuration language. I don&#x27;t want to load configurations that may or may not crash your computer.
评论 #24266340 未加载
评论 #24266360 未加载
评论 #24269142 未加载
Nihilartikel超过 4 年前
I feel like clojurescript but with all mutable functions removed would be a good option.<p>You get a cleaner literal syntax than Json, and easily composable functions.<p>The hiccup list syntax for html in clojure is a joy to work with.
评论 #24268548 未加载
leontrolski超过 4 年前
Author here, thanks for the feedback. This is v. much a work-in-progress, I&#x27;m in the process of trying to build something non-trivial with it. Just a couple of things to address in general from the comments so far:<p>- I&#x27;m aware of dhall, jsonnet and friends, I think they&#x27;re cool, but I think the most important for me is this is <i>just js</i> - that means nothing new to learn + you can use it from front end code + free linters etc.<p>- I think the to-html bit is important, this is something I tangentially talked about in more detail here - <a href="https:&#x2F;&#x2F;leontrolski.github.io&#x2F;dom-syntax.html" rel="nofollow">https:&#x2F;&#x2F;leontrolski.github.io&#x2F;dom-syntax.html</a>. There was some discussion on hacker news about that one too, again, I think the important &quot;feature&quot; is that it&#x27;s <i>just js</i>. Again, to me that&#x27;s really important, so hiccup, jsx, etc don&#x27;t cut it.
评论 #24270107 未加载
jmull超过 4 年前
By now I shouldn&#x27;t be, but I&#x27;m always a little surprised when people come to the conclusion that the best way to represent HTML is JSON or Javascript (or anything but HTML).
评论 #24267238 未加载
评论 #24266782 未加载
评论 #24271118 未加载
评论 #24270491 未加载
femto113超过 4 年前
I do think that something that&#x27;s enough more than JSON to make it more usable for config (comments, imports, reference env vars, etc) would be great to have, but I don&#x27;t see the two goals (config and templates) of dnjs as particularly compatible. HOCON[1] is the best attempt at a &quot;better JSON&quot; that I&#x27;ve seen but it&#x27;s cross support of Java properties syntax makes it a little weird to use in a JavaScript centric stack.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;lightbend&#x2F;config&#x2F;blob&#x2F;master&#x2F;HOCON.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lightbend&#x2F;config&#x2F;blob&#x2F;master&#x2F;HOCON.md</a>
lucasmullens超过 4 年前
I agree that there&#x27;s a ton of value in only using a subset of JavaScript, but wouldn&#x27;t this be better implemented as a set of lint rules?<p>Are there other advantages to a custom runtime that I&#x27;m missing? Even if it&#x27;s only a subset of the language, the Python runtime probably isn&#x27;t faster than Node.js.
verdverm超过 4 年前
<a href="https:&#x2F;&#x2F;cuelang.org" rel="nofollow">https:&#x2F;&#x2F;cuelang.org</a> is what I use. Wrap code in data, not data with code
throwaway894345超过 4 年前
This seems a lot like Starlark (go.starlark.net). Apart from the JS vs Python dialectal distinction, are there other differences?
bravura超过 4 年前
I just wanted to say that hydra is a mature, supported, well designed config library for python:<p><a href="https:&#x2F;&#x2F;hydra.cc&#x2F;docs&#x2F;intro" rel="nofollow">https:&#x2F;&#x2F;hydra.cc&#x2F;docs&#x2F;intro</a><p>Great for machine learning and generic config too
评论 #24269813 未加载
hans_castorp超过 4 年前
I was immediately reminded of <a href="https:&#x2F;&#x2F;xkcd.com&#x2F;927&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;927&#x2F;</a>
aronpye超过 4 年前
Can someone explain why you wouldn’t use python or lua, or even just plain JS?
评论 #24269769 未加载
评论 #24269734 未加载
darawk超过 4 年前
This seems neat. I feel like i&#x27;ve re-invented less complete versions of this dozens of times.
anentropic超过 4 年前
FYI some of the python imports in the README are like: `from djns`<p>I think that&#x27;s a typo?