[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: how to prevent bugs without static type checking?
- From: Enrico Tassi <gares@...>
- Date: Tue, 23 Oct 2012 14:28:57 +0200
On Tue, Oct 23, 2012 at 10:29:10AM +0200, spir wrote:
> 2. way of thinking
> I noticed the following: after programming for a long time only in
> dynamic languages, when I then switch to static typing, for a while
> I have about no type error (at compile-time, indeed); then they
> start to happen, and finally I have many. I think, maybe, after some
> time we start "programming-thinking" differently. Dynamic
> programmers may have a clearer awareness about types --that is,
> ultimately, the meaning of symbols-- and unconsciously pay more
> attention to their coherence in the model. Conversely, after some
> time, static programmers may start to rely on the machine to do this
> job; and it does it well, provided your typing is correct and clear.
> They become so-to-say lazy about that, not uselessly spending their
> "neuronic power" in what a machine can do (better).
> Both are good, in my opinion.
I fully agree, and I've the same experience switching back and forth
between OCaml and Lua (and C sometimes).
Hence, the only true advantage I see of static typing is when you do
true research, i.e. you have no clear idea about the right data
structure (or the right approach) to solve your problem. In this case
you continuously refine your data structure, and a static type checker
is invaluable in driving you trough the code, pointing out all the
places where you actually make assumptions on the underlying data
representation.
This never happens if you know how to tackle your problem in the first
place, and you start with the right data structure from the very
beginning.
Cheers
--
Enrico Tassi