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.

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

15 pointsby maramonoover 8 years ago
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 comments

based2over 8 years ago
<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>
tomjen3over 8 years ago
Eiffel has design by contract build in, as does D.
评论 #12375962 未加载
piinbinaryover 8 years ago
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>
dougdescombazover 8 years ago
Assertions in Java exist. Not really tests per se, but the closest thing I could think of.
danblickover 8 years ago
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.)
alimwover 8 years ago
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>
reitanqildover 8 years ago
&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?
philippnagelover 8 years ago
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> ?
jsliover 8 years ago
Yeah, Pyret!
评论 #12377428 未加载