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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Why Type Systems Matter

79 点作者 somecoder将近 8 年前

10 条评论

gumby将近 8 年前
Some languages mix static and dynamic typing. For example MACLISP used this to great effect to make MACSYMA super fast. All the numeric code was statically typed and the compiler built code that was as fast as hand crafted assembly. Yet you could write conventional Lisp code that called this static code just like any other code. MACLISP derivatives like lisp machine lisp also implemented this stuff and used it for system code. I used it heavily.<p>All that survived into Common Lisp but I am not up on the current state of lisp implementations and have no idea if people bother to take advantage of it any more.
评论 #15051898 未加载
评论 #15048784 未加载
评论 #15048965 未加载
AnimalMuppet将近 8 年前
A line from a novel by Georgette Heyer: &quot;I look for trouble. I don&#x27;t wait to have it brought to my attention.&quot;<p>That is, if there&#x27;s a type problem, I want to know at compile time, not at run time.<p>But I&#x27;m in embedded systems. My stuff looks like just a machine to the customer. They don&#x27;t want a type error at runtime messing them up. That may not be your world. If you&#x27;d rather things go happily along until the circumstances actually occur in execution, and <i>if</i> that ever happens, you then find out about the type problem, well, that&#x27;s what is reasonable to you in your environment and circumstances, and that&#x27;s fine. Use dynamic typing, and don&#x27;t feel guilty.
rdtsc将近 8 年前
Good post, but note all those things you don&#x27;t need a statically typed language. Erlang for example is a dynamically typed language but it has Dialyzer - a type checker. The more precisely you define the types the more discrepancies and issues it will find in the code, exactly the kind of stuff the author mentions.<p><a href="http:&#x2F;&#x2F;learnyousomeerlang.com&#x2F;dialyzer" rel="nofollow">http:&#x2F;&#x2F;learnyousomeerlang.com&#x2F;dialyzer</a><p>That&#x27;s technically called &quot;success typing&quot; <a href="http:&#x2F;&#x2F;www.it.uu.se&#x2F;research&#x2F;group&#x2F;hipe&#x2F;papers&#x2F;succ_types.pdf" rel="nofollow">http:&#x2F;&#x2F;www.it.uu.se&#x2F;research&#x2F;group&#x2F;hipe&#x2F;papers&#x2F;succ_types.pd...</a><p>Python has that too with MyPy. That came much later than Erlang and I haven&#x27;t used yet so not sure how well it works<p><a href="http:&#x2F;&#x2F;mypy-lang.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;mypy-lang.org&#x2F;</a><p>They seemed to have copied success typing but don&#x27;t actually mention it anywhere.
评论 #15048626 未加载
评论 #15048465 未加载
falcolas将近 8 年前
There is never a person more zealous (and vocal in their zealotry) than a new convert. You don&#x27;t see the bad points, just the good.<p>That&#x27;s how this post comes across: &quot;Types are so awesome, let me show you how awesome types are!&quot;<p>Come back in two years, show us how the types feel after the honeymoon is over.
评论 #15049042 未加载
评论 #15050046 未加载
评论 #15049379 未加载
blauditore将近 8 年前
I thought this was quite clear, and it&#x27;s what I&#x27;ve always been missing in languages like Python or JS. Yet I meet many devs, especially coming from such languages, making fun of Java for its verbosity and clumsiness.<p>On the other hand, it leads to some people abusing the static type system: They just randomly change types until it somehow compiles, without thinking about what their doing.
评论 #15048791 未加载
评论 #15048712 未加载
评论 #15049394 未加载
simplify将近 8 年前
If you haven&#x27;t thought much about type systems but want to understand what the big deal is, I wrote a post specifically for you [1]. It draws motivation for wanting a good static type system from first principles.<p>[1] <a href="http:&#x2F;&#x2F;gilbert.ghost.io&#x2F;type-systems-for-beginners-an-introduction&#x2F;" rel="nofollow">http:&#x2F;&#x2F;gilbert.ghost.io&#x2F;type-systems-for-beginners-an-introd...</a><p>(I posted this on a similar story and it was received very well, so I thought I might post it again for those who haven&#x27;t seen it.)
rocky1138将近 8 年前
Strong typing is great when I&#x27;ve already made sense of how the logic should flow and I&#x27;m ready to solidify my work into something stable and extensible over time. It&#x27;s not so great when I&#x27;m trying something new and am still trying to work out if what I want to do is even possible, since I find myself trying to identify the right type to use in a given situation rather than proving that I&#x27;m even able to do it. A lot of my daily work is prototyping.
评论 #15047886 未加载
评论 #15048006 未加载
评论 #15048125 未加载
评论 #15048020 未加载
评论 #15047890 未加载
评论 #15048412 未加载
评论 #15048794 未加载
mamcx将近 8 年前
My dream is a static-first (like with inmutable-first) language with a way to do dynamic.<p>The thing is not available (as far I know) is to build a dynamic object and &quot;close it&quot; for further modification so the compiler can optimize well. Other, that requiere good metaprograming, is to build a dynamic object AT COMPILE TIME (macro?) and close it, then the type-system work after that (F# type provider is almost this)<p>A use case is reflect a database&#x2F;data storage like JSON or relational table. I wish, like with python, to do:<p><pre><code> class Customer = @build(table(&quot;Customer&quot;)) </code></pre> and after this line :<p><pre><code> c = Customer() print c.name </code></pre> to &#x27;c&#x27; be a static type. If at compile time, it check the type, let say the field change to c.fullname, to mark as a type error.<p>If in runtime, like a interpreter, to &quot;close&quot; Customer and be certain that it never will mutate.<p>AKA: Inmutable types&#x2F;clases, but the posibility to mutate it in some discret places.<p>Make sense?
评论 #15051297 未加载
评论 #15051203 未加载
dmux将近 8 年前
I&#x27;d be interested in hearing what the community has to say regarding static types and whether or not they&#x27;re compatible with object-oriented programming. I&#x27;ve posted this link a couple times before, but it hasn&#x27;t been actively discussed: <a href="https:&#x2F;&#x2F;essencesharp.wordpress.com&#x2F;2014&#x2F;07&#x2F;17&#x2F;static-typing-and-interoperability&#x2F;" rel="nofollow">https:&#x2F;&#x2F;essencesharp.wordpress.com&#x2F;2014&#x2F;07&#x2F;17&#x2F;static-typing-...</a><p>From that article:<p>&quot;Static typing inhibits interoperability. It does so between class libraries and their clients, and also between programming languages.<p>The reason is simply because static typing violates encapsulation in general, and improperly propagates constraints that aren’t justifiable as architectural, design or implementation requirements in particular. It does so either by binding too early, or by binding (requiring) more than it should.&quot;
评论 #15051612 未加载
benhoyt将近 8 年前
Counterpoint I wrote a while back that focuses on compilation speed: <a href="http:&#x2F;&#x2F;benhoyt.com&#x2F;writings&#x2F;language-speed&#x2F;" rel="nofollow">http:&#x2F;&#x2F;benhoyt.com&#x2F;writings&#x2F;language-speed&#x2F;</a><p>I&#x27;ve used Scala a fair bit recently, and the compiler is so dog slow it&#x27;s painful. Maybe it&#x27;s just my relative fluency with Python, but I find I&#x27;m much more productive with Python&#x27;s almost instant edit-compile-run sequence.<p>Edit: I do like many of the benefits of static typing, though. I think mypy is coming into its own in the Python community, especially now with Guido behind it. Maybe this kind of optional typing is the best of both worlds...
评论 #15048565 未加载
评论 #15048461 未加载
评论 #15048526 未加载
评论 #15048446 未加载