Live data from Hacker News

Static Typing Where Possible, Dynamic Typing When Needed (2004) [pdf]

ics.uci.edu

1–10 of 24 posts

Re: Static Typing Where Possible, Dynamic Typing When Needed (2004) [pdf]

#3
Yeah, it was pretty clear from the outset that the author(s) had a biased view against static typing when they describe static type "fanatics" versus dynamic type "advocates", and go on to discuss all the ways static types are unfeasible whereas dynamic types are "indispensable".

I enjoy programming in Python and JavaScript sometimes, but dynamic typing is never "needed". Furthermore, no static type aficionado that I know would go so far as to say "well-typed programs cannot go wrong", as this paper claims we say. However, a good compiler for a static-typed language can be a wonderful tool and ally for programmers who are serious about building robust programs. To take just one example, if I can get an OCaml program to compile, it's extraordinarily rare for there to be a runtime problem to occur that is not related to a conceptual or algorithmic error. Careless errors just aren't an issue when I use OCaml, Rust, etc.

Re: Static Typing Where Possible, Dynamic Typing When Needed (2004) [pdf]

#4
> Requiring explicit type declarations is usually unnecessary and always a nuisance.

Except at function declarations and similar - they help to make the code more readable. It's not feasible to dig in code where the only clue about the nature of the input and output in a function are variable names.

> Static typing provides a false sense of safety, since it can only prove the absence of certain errors statically.

This sentence contradicts itself: if it proves the absence of certain errors, doesn't it provide a certain level of safety? Also, it seems like the author never heard about substructural and dependent typing...

> Static typing fanatics try to make us believe that “well-typed programs cannot go wrong”. While this certainly sounds im-pressive, it is a rather vacuous statement. Static typechecking is a compile-time abstraction of the runtime behavior of your program, and hence it is necessarily only partially sound and incomplete.

And dynamic typing fanatics want us to believe that the only thing we need is unit tests...

Modern, statically and strongly typed programming languages are capable of making us forget many common errors like data races, incorrect resource management etc. The authors enumerate what "us" - the "fanatics" state about static types but what does dynamic typing gives us besides uncertainty? And how could they question the documentational value of static types?

The authors of this "research" paper should do more research about contemporary PLT because it seems like they've only programmed in 10-20 years old OOP languages. Also, what is the case for dynamic typing in this paper? I'm really curious because it feels like they're just biased towards dynamic typing.

Re: Static Typing Where Possible, Dynamic Typing When Needed (2004) [pdf]

#5
The argument over static and dynamic typing is so boring at this point. It's semi-intellectual "bike shedding". Practically speaking it doesn't make much difference one way or the other.

I wish the industry as a whole would get over it and focus on bigger issues.

Re: Static Typing Where Possible, Dynamic Typing When Needed (2004) [pdf]

#6
> Static typing provides a false sense of safety, since it can only prove the absence of certain errors statically.

That is as blatant a straw man as I have seen recently. I have never met someone who mistook static types for a guarantee of correctness, though I have met several people who did not understand why testing to 100% statement coverage does not do that.

The authors would be well-advised to remove this sort of thing if they want to be taken seriously, and in general, striving to "do our best to make it provocative" is not an effective way to influence people, no matter how smart it makes you feel.

Re: Static Typing Where Possible, Dynamic Typing When Needed (2004) [pdf]

#7
post #3

Yeah, it was pretty clear from the outset that the author(s) had a biased view against static typing when they describe static type "fanatics" versus dynamic type "advocates", and go on to discuss all the ways static types are unfeasible whereas dynamic types are "indispensable". I enjoy programming in Python and JavaScript sometimes, but dynamic typing is never "needed". Furthermore, no static type aficionado that I…

I'm a fan of static typing and I only have a cursory understanding of Godel's incompleteness theoroms, but

> but dynamic typing is never "needed".

my understanding is that it's not possible to construct a single static type system that simultaneously accepts all correctly typed programs and rejects all incorrectly typed programs.

In practice, most sound static type systems minimize the corner cases where they reject correctly typed programs, and provide an escape hatch for subverting the type checker if necessary. The presence of the escape hatch is basically an admission that dynamic typing is (rarely) necessary.

Re: Static Typing Where Possible, Dynamic Typing When Needed (2004) [pdf]

#8

> Static typing provides a false sense of safety, since it can only prove the absence of certain errors statically. That is as blatant a straw man as I have seen recently. I have never met someone who mistook static types for a guarantee of correctness, though I have met several people who did not understand why testing to 100% statement coverage does not do that. The authors would be well-advised to remove this sort…

I constantly see people discuss Haskell as if it prevented you from writing incorrect programs. But in fact static typing as it’s usually implemented does nothing for numeric programs/math errors. It won’t even catch dividing by 0.

Related: saying a program is correct because it’s been “security audited” (someone read the source once) or “formally verified” (someone wrote the program twice and didn’t make any typos).

Re: Static Typing Where Possible, Dynamic Typing When Needed (2004) [pdf]

#9
Quick question: is it enough to create guards/checks in languages like Ruby or Javascript to make sure that a parameter that is passed in is the type you expect? I try to set default values in the method/function declarations to at least return an empty set if I can live with it.

Only time I have had a dynamic language do weird things is with PHP, but that was due to my lack of understanding of how PHP handles empty strings.

Re: Static Typing Where Possible, Dynamic Typing When Needed (2004) [pdf]

#10
post #8

> Static typing provides a false sense of safety, since it can only prove the absence of certain errors statically. That is as blatant a straw man as I have seen recently. I have never met someone who mistook static types for a guarantee of correctness, though I have met several people who did not understand why testing to 100% statement coverage does not do that. The authors would be well-advised to remove this sort…

I constantly see people discuss Haskell as if it prevented you from writing incorrect programs. But in fact static typing as it’s usually implemented does nothing for numeric programs/math errors. It won’t even catch dividing by 0. Related: saying a program is correct because it’s been “security audited” (someone read the source once) or “formally verified” (someone wrote the program twice and didn’t make any typos).

Your dismissive characterizations of security auditing and formal verification are way off the mark.
Post reply on HN