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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: Is there a programming language with embedded testing support?

15 点作者 maramono超过 8 年前
There are many dimensions to programming languages that range from systems to scripting, weakly typed to strongly typed, dynamic to static typed, purely functional to statefull, imperative to declarative, etc...<p>There are also very few languages that focus on <i>correctness</i> and <i>contracts</i> to help create programs that have fewer bugs. Yet The mayority of languages simply focus on &quot;getting things done&quot;, so to speak, and leave testing and correctness out of the picture or add them later on.<p>Granted, testing support can be added later via libraries and frameworks, but I wonder: in the continuum of program correctness, is there a language that perhaps does not provide full proof&#x2F;correctness&#x2F;contract support but does come with testing right out of the box, either in its implementation or philosophy?<p>Also related question: do you know of any language that was specifically <i>designed</i> to encourage and&#x2F;or make testing easier for its programs?<p>Even though I didn&#x27;t get the &quot;joke&quot; for a recent post about Go[0], I still think it&#x27;s interesting to ask.<p>[0] https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12371029

9 条评论

based2超过 8 年前
<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Design_by_contract" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Design_by_contract</a><p><a href="https:&#x2F;&#x2F;coq.inria.fr&#x2F;about-coq" rel="nofollow">https:&#x2F;&#x2F;coq.inria.fr&#x2F;about-coq</a><p><a href="http:&#x2F;&#x2F;www.adacore.com&#x2F;adaanswers&#x2F;about&#x2F;ada-comparison-chart" rel="nofollow">http:&#x2F;&#x2F;www.adacore.com&#x2F;adaanswers&#x2F;about&#x2F;ada-comparison-chart</a><p><a href="http:&#x2F;&#x2F;www.adacore.com&#x2F;gnatpro&#x2F;toolsuite&#x2F;utilities&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.adacore.com&#x2F;gnatpro&#x2F;toolsuite&#x2F;utilities&#x2F;</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;lampepfl&#x2F;dotty" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lampepfl&#x2F;dotty</a><p><a href="http:&#x2F;&#x2F;www.scalatest.org&#x2F;getting_started_with_feature_spec" rel="nofollow">http:&#x2F;&#x2F;www.scalatest.org&#x2F;getting_started_with_feature_spec</a><p><a href="http:&#x2F;&#x2F;etorreborre.github.io&#x2F;specs2&#x2F;" rel="nofollow">http:&#x2F;&#x2F;etorreborre.github.io&#x2F;specs2&#x2F;</a><p><a href="http:&#x2F;&#x2F;www.gebish.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.gebish.org&#x2F;</a><p><a href="http:&#x2F;&#x2F;spockframework.github.io&#x2F;spock&#x2F;docs&#x2F;1.1-rc-2&#x2F;introduction.html" rel="nofollow">http:&#x2F;&#x2F;spockframework.github.io&#x2F;spock&#x2F;docs&#x2F;1.1-rc-2&#x2F;introduc...</a>
tomjen3超过 8 年前
Eiffel has design by contract build in, as does D.
评论 #12375962 未加载
piinbinary超过 8 年前
I&#x27;m not sure this is exactly what you are asking about, but Rust does support testing right in the language. You can add #[test] before a function to make it a test function (tests and regular functions can live together in the same file).<p><a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;testing.html" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;testing.html</a>
dougdescombaz超过 8 年前
Assertions in Java exist. Not really tests per se, but the closest thing I could think of.
danblick超过 8 年前
Look up &quot;model checking&quot; and see how that compares to what you&#x27;re thinking about. How would you <i>specify</i> tests (or rather, correct program behavior) in such a language?<p>The languages Alloy and TLA+ come to mind. (So does Coq, which is at the other extreme of actually proving your program correct.)
alimw超过 8 年前
Clojure&#x27;s most recent builds include &quot;spec&quot;. <a href="http:&#x2F;&#x2F;clojure.org&#x2F;guides&#x2F;spec" rel="nofollow">http:&#x2F;&#x2F;clojure.org&#x2F;guides&#x2F;spec</a>
reitanqild超过 8 年前
&gt; perhaps does not provide full proof&#x2F;correctness&#x2F;contract support but does come with testing right out of the box, either in its implementation or philosophy?<p>Python has doctests.<p>Not sure if thats what you mean?
philippnagel超过 8 年前
Like Rust: <a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;testing.html" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;testing.html</a> ?
jsli超过 8 年前
Yeah, Pyret!
评论 #12377428 未加载