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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ideology – do unit tests make type systems unnecessary? (2015)

3 点作者 Fannon大约 4 年前

4 条评论

linkdd大约 4 年前
&gt; simple unit tests aren&#x27;t the important ones<p>And yet, they prevented me from committing dumb mistakes to the main branch so many times.<p>&gt; types are just simple unit tests written for you<p>Even better if I don&#x27;t have to write them. Is this really a counter argument?<p>&gt; dynamic languages only need unit tests because they don&#x27;t have type systems<p>But every language has a type system! How would they differentiate an integer from a string if they don&#x27;t?<p>Even assembly has a type system (byte vs word vs double-word).<p>Am I just nitpicking or is that argument fundamentally flawed and ignorant?<p>&gt; What&#x27;s going on here? These can&#x27;t both be right.<p>They can both be wrong though, and they seem to be IMHO.<p>This does not incite me to watch the 20min video. This seems too click-baity.
评论 #27089439 未加载
proc0大约 4 年前
This sounds a bit like a &#x27;no true Scotsman&#x27; (i.e. the bar would be moved with any example of a bad unit test that needs types), but I would need think more on it.<p>In my opinion, unit tests need to cover multiple levels, at least two, the units, and also the business logic, and proper types would cover the gaps in between. If anything I would invert the title of this, and say a strong enough type system makes unit tests unnecessary, but I don&#x27;t think that&#x27;s anything new and you can see it at work in pure FP languages like Haskell.
Fannon大约 4 年前
Some people claim that unit tests make type systems unnecessary: &quot;types are just simple unit tests written for you, and simple unit tests aren&#x27;t the important ones&quot;. Other people claim that type systems make unit tests unnecessary: &quot;dynamic languages only need unit tests because they don&#x27;t have type systems.&quot; What&#x27;s going on here? These can&#x27;t both be right. We&#x27;ll use this example and a couple others to explore the unknown beliefs that structure our understanding of the world.
galaxyLogic大约 4 年前
I think &quot;types&quot; are just compile-time unit-tests.<p>But unlike conventional &quot;unit-tests&quot; they also apply inside the code, not just on its externally observable call-boundary.<p>So perhaps more appropriately then types are &quot;reusable assertions&quot;.