4 ms·
Some highlights: Q: "Do you hate static types" GB: "No" MF: "No" GB: "Types are useful for: 1. Doc for human 2. Doc for machine 3. Making things faster … 4
by mpweiher 9y ago
Some highlights:
Q: "Do you hate static types"
GB: "No"
MF: "No"
GB: "Types are useful for:
1. Doc for human
2. Doc for machine
3. Making things faster
…
4. Correctness"
This was experience from the Strongtalk project, which implemented a fast, typed Smalltalk. Strongtalk was purchased by Sun and the tech. was the basis for Java's Hotspot. They actually expected the correctness factor to be much higher, but in practice the static type system only helped to find one or two minor bugs in largely unused code-paths in the libraries. I also find it interesting that "making things faster" is on the list, because the mantra from that part of the discipline has always been that static types do not help for performance, because the JIT will fix it all.
MF: “Research on Types and Soundness smothers research on programming languages”
Clarifying, says something along the lines that you have to figure out more powerful/better language mechanisms first, then later start thinking about how to type them properly.
- Crazywater 9y agoThey're so right about that. As a frontend dev, I don't care about that extra 1-2% of bugs that, say, ownership types could catch if it kills my productivity by having to annotate everything. However, if I can figure out what a method actually returns and click through to it in the IDE, that's the real gain from types for me. Type analysis has to be fast to be able to do that. My impression of research in academia is that it's disproportionately focused on even stronger types that are even harder to compute. Not everyone builds spaceships.
- mpweiher 9y agoThe "documentation for humans" effect is also the only effect that has had at least some empirical validation[1]. Interestingly, it is not necessary to have the type names/annotations actually statically checked. [1] https://sites.google.com/site/stefanhanenberg/ https://sites.google.com/site/stefanhanenberg/ [EDIT] Clarified which effect
- rhaps0dy 9y ago> That's also the only effect that has had at least some validation scientifically Which effect, sorry? I can't identify the referent of "That".
- mpweiher 9y agoSorry, fixed. They also studied "time to completion" and "correctness" for a new task, and for those the dynamic languages did better.
- rhaps0dy 9y agoThanks. After commenting I read the first paper in the page you linked. The one about trying to give an advantage to dynamic languages (Groovy vs Java), and measuring time-to-completion, for 4 tasks. Turns out a static language has a time advantage when using an API, but a dynamic one has an advantage when writing code (that nobody will reuse).
- mafribe 9y agoresearch in academia is that it's disproportionately focused on even stronger types that are even harder to compute. Type inference for simple types in sequential computation is a solved problem, Milner and Damas showed how to do it in [1] in 1982. However, most extensions of Damas/Milner cross from decidable type inference to undecidability, so some annotation is often necessary, e.g. Scala, Rust, Haskell (kinding). Most work on expressive typing systems (e.g. dependent types) has a different aim, namely using types for the verification of arbitrary program properties. This is undecidable, but we want (and need) as much automation as possible to lower the cost of verification, whence a lot of research is about partially automated type inference for very expressive typing systems. For most standard front-end dev, verification is not an issue since - the field has fairly low correctness requirements that can easily achieved with testing - typically you don't have strong specifications to verify against. No formal spec, no verification. [1] L. Damas, R. Milner: Principal type-schemes for functional programs, http://web.cs.wpi.edu/~cs4536/c12/milner-damas_principal_types.pdf http://web.cs.wpi.edu/~cs4536/c12/milner-damas_principal_typ...
- hacker_9 9y agoJust going to point out here that you are conflating Javascript problems with dynamic language problems. Try Clojure, a well designed dynamic language, and you'll find you are a lot more productive with it than any statically typed language. Indeed over the weekend I was able to design and build a GUI DSL, layout system, model-view databinding, command event system, and serialisation/deserialisation logic for a side project of mine. This sort of stuff would have taken weeks of effort in a static language.
- wtetzner 9y agoClojure is a fine language, and I wrote it professionally for a few years. However, I don't see why this would be true: > This sort of stuff would have taken weeks of effort in a static language. I've also written plenty of things in typed languages, and in many ways they can be faster to develop in than dynamic languages. Of course, you do need to change the way you program a bit to really take advantage of types. I think the main advantage Clojure has over most typed languages is macros, but there is work being done to rectify even that.
- hacker_9 9y agoI used to think this, until I used Clojure. I'm surprised you used it professionally and have that mindset, I write far less code in Clojure and get far more done. The productivity gains are amazing, especially when I can just upload new code on the fly as the program is running.
- nickpsecurity 9y agoIt's because it's a LISP with good ecosystem. LISP is already strongly, but dynamically, typed from what I'm told. So, you get quite a bit of benefit. You could probably do the same in a statically- or gradually-typed LISP. Main difference is you'll catch a few more interface errors without tests. Also, if using specs or types, one can do automated generation of testing, enabled better static analysis, and/or improve optimization in compilers. Basically, the tools know a bit more about what you're trying to do.
- cronjobber 9y ago> Research on Types and Soundness smothers research on programming languages Perhaps, but you could turn it around, too. Statically typed languages had time to catch up because innovation into "more powerful/better language mechanisms" has stalled, for some other reasons.
- mafribe 9y agoinnovation into "more powerful/better language mechanisms" has stalled, for some other reasons. For sequential languages there is probably not much to improve -- except at the edges. ML nailed it. Almost all core PL research today is about - verification - concurrency/parallelism because both are beset with deep unsolved problems: for verification the problem is how to do it efficiently (we know we can do it in principle), and for concurrency/parallelism we have not yet discovered core abstractions including the right types that can express simple properties of concurrency/parallelism (at least that is my working hypothesis). This is intimately related to our current inability to auto-parallelise.
- mpweiher 9y ago> For sequential languages there is probably not much to improve -- except at the edges. ML nailed it. And that's the problem right there. There is sooo much that is out of whack with programming, even sequential. For starters look up 'architectural mismatch'.
- nickpsecurity 9y agoThat was solved with formal specifications in languages such as Z, CSP, ASM's, B, and recently TLA+. Even if you don't do proof, high-assurance projects would specify context of sequential components in such languages to find mismatches at interfaces, protocol errors, and so on. It got pretty easy to do, too. The tooling is really good for that now esp on TLA+ end. So, there's not so much a problem in programming languages with architecture so much as programmers ignoring proven ways of catching such problems. Usually what I just mentioned plus review and testing. People like hwayne are laying groundwork for reductions in this problem by making accessible tutorials showing practical value of such techniques. https://learntla.com/introduction/ https://learntla.com/introduction/
- mafribe 9y agobecause the JIT will fix it This has not been borne out in practise. Moreover JITs are much more complicated and hence expensive to develop to maturity than standard AOTs.
- mpweiher 9y ago> This has not been borne out in practise. Exactly. http://blog.metaobject.com/2015/10/jitterdammerung.html http://blog.metaobject.com/2015/10/jitterdammerung.html
- _pmf_ 9y ago> This was experience from the Strongtalk project, which implemented a fast, typed Smalltalk. That sounds like the global optimum of what I want in a language. > They actually expected the correctness factor to be much higher, but in practice the static type system only helped to find one or two minor bugs in largely unused code-paths in the libraries. Maybe these were already mature, well tested libraries?
- nickpsecurity 9y ago"That sounds like the global optimum of what I want in a language." I'd love to see them pitted against each other on many types of programming problems with same tooling and similarly-skilled developers. I want to know what differences there would be on large programs in terms of productivity, defect introduction, defect removal, and maintenance-level changes.
- qznc 9y agoTo make things faster, the memory layout matters these days. The type system is a convenient way to express memory layout. Java is a bad example, because it intentionally hides the memory layout. You could use other means than the type system, but I don't know any examples off the top of my head. Maybe some Python meta class magic?
- weberc2 9y agoOne under-appreciated aspect of static types is that they make certain classes of stupidity a little more difficult, for example, overloading the permissible types on an object's member variable such that every bit of code that uses it needs to do an `isinstance()` check to see if it has the type that particular bit of code wants. Doing this would be tedious in a statically typed language where the sane solution is often the easier solution. This doesn't mean it's hard to write bad code in a static language, just that it's harder to do by accident.
- panic 9y agoAlthough it'll always be tempting to provide isinstance() type checks in your dynamic language, there's no reason you have to have them!
- crdoconnor 9y agoOver the last few years I've started using them a lot simply because it means you get simpler, clearer and more actionable errors more quickly. They're especially useful when you are writing libraries for use by somebody else.
- weberc2 9y agoThis is basically the "correctness" argument for static typing. That you do this in a dynamic language is a liability.
- crdoconnor 9y agoPlacing a small number of sanity (hint: it's not always type that needs checking) checks on border code is not any kind of argument for static typing. I'd do the same thing in most languages - in fact, I'd end up doing way way way more of it in C because it's very weakly typed.
- weberc2 9y ago
- hota_mazi 9y agoDepressing that correctness comes in last, especially since it includes so many valuable sub properties, among which 1. Correctness of the code 2. Correctness of automatic refactorings, which dynamically typed languages can never achieve, which is why refactoring a dynamically typed language always requires the supervision of a human