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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

When is it not preferable to specify your types first?

28 点作者 raphaelss超过 9 年前

2 条评论

molyss超过 9 年前
I can&#x27;t help it but disagree with the author.<p>His example shouldn&#x27;t make someone think &quot;god, I wish I didn&#x27;t have to specify the type here&quot;, but rather &quot;wait, there&#x27;s a problem here. There&#x27;s way too many concepts in a single line of code, I should probably refactor that to make it clearer&quot;. Having to specify the type is what should help the developer come to the realization that something needs to be more modular, so the people reading the code in the future (including him&#x2F;herself in a week from now) will have a easier time understanding what&#x27;s going on.<p>Overall, I feel like there&#x27;s a common thinking these days that most of software cost is in the time spent to write it and thus we should use any means necessary to reduce that time. type inference everywhere makes it so that just reading a source code prevents you from knowing the type of anything without learning first the whole API by heart. And it&#x27;s reaching the top when you define a function using &quot;fn&quot; in rust (there might be another explanation than saving keystrokes, but I can &#x27;t think of any), or &quot;go fmt&quot; instead of &quot;go format&quot;.<p>IMO, the truth is that while a code has been written exactly once in its current form, it&#x27;s being read hundreds or thousands of times. For learning, debugging, fixing, improving or adding performances. It doesn&#x27;t matter. And when you have to read the code to understand the concepts behind it, you&#x27;re just wasting brain cycles.<p>Yes, typing types everywhere is a complete pain in the neck. But reading and modifying code without anything has always felt 100 times worse to me
avmich超过 9 年前
The first example reminds me specifications of some types in typed Clojure. Part of the reason it gets complaints is those tricky types.<p>At least they look like that, comparing to Haskell.