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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: Dynamic vs. Static Typed Languages

8 点作者 jlalfonso21超过 3 年前
What can do better static-typed languages that dynamic ones cant?

6 条评论

Comevius超过 3 年前
1. Find type-related bugs at compile time.<p>2. More readable code.<p>3. More maintainable code.<p>4. More efficient generated code.
UglyToad超过 3 年前
I&#x27;d say it&#x27;s about what static languages don&#x27;t let you do that dynamic ones do. For example I just found a bug in some scheduling code I wrote where a date value could be null but I was treating it as non null. I change the type to nullable and the compiler tells me everywhere I currently use it in an invalid way.<p>Types help make (some) invalid states unrepresentable, though the type systems could always be better and some data can only be checked at runtime.<p>But you can focus your test effort on checking those logic conditions. In addition it makes teamwork far easier.<p>I&#x27;d compare it to the benefits of rust over plain C. Yes you can write safe code in C with a lot of discipline and being 100% focused all the time, or you can leverage tools to let you catch your mistakes and free mental cycles for the actual problem at hand.
yhavr超过 3 年前
- Painless refactoring. I change field &quot;foo.bar&quot; into &quot;foo.quux&quot; and the same field changes everywhere else in the (huge) codebase. Or I change the field name in the type declaration and immediately see what&#x27;s broken.<p>- Integrated documentation. I see &quot;foo&quot;, I see it&#x27;s type, I see what can I do with it (if it&#x27;s OO-like).
runawaybottle超过 3 年前
I’ll take the downvotes.<p>It can fulfill certain compulsive needs of certain personality types that like to be comprehensive (think compulsive note takers, list makers).<p>No harm done, everyone has their quirks.
girishso超过 3 年前
Detect typos, can be a huge time saver at times.
preordained超过 3 年前
Accretion...