lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Oct 23, 2012 at 11:00:53AM -0200, Roberto Ierusalimschy wrote:
> In my opinion, a true advantage of static typing is when you do
> maintenance. If you have more than a few lines of code, and you have to
> change a little any data structure, "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."

Yes and no. I know your opinion is the most widespread one but I tend to
disagree.

According to my experience, once you get your data structures right, you
start piling up abstractions and define clear interfaces that hide the
data representation (I mean, an opaque datatype in ML terminology).
Hence, when you decide to make a minor change to your datatype, you
seldom alter the interface, and the type checker catches errors
within the module that defines the data structure only.
The errors that are eventually intruced by your change in other modules
are now part of another category, they are not syntactic any more in
some sense. Of course, if you alter the interface, types kick in again,
but you don't do that while do maintenance, or better, you avoid that as
much as possible.

My impression is that when people get their datatypes almost right, they
are so fed up of compile time errors that they hide their types behind an
abstract interface so that any other minor change does not require to
go trough the whole code base. In this sense type checking gets less
relevant, whilst being still useful.

Ciao
-- 
Enrico Tassi