lua-users home
lua-l archive

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


On Tue, Oct 23, 2012 at 01:14:30PM -0200, Roberto Ierusalimschy wrote:
> > 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
> 
> Experiences vary :) You need *a lot* of discipline to define and
> keep clear interfaces that do not leak. (Moreover, because typical
> dynamically typed languages are interpreted, people sometimes avoid
> piling up abstractions for the sake of speed. Each intermediate function
> counts, so there is a big incentive not to abstract... And there is
> no type system to help keeping proper abstraction boundaries.)

Sure, I'm not saying you should use Lua as if it was OCaml.

I'm sort of claiming that adding static types to Lua would not make it
better suited to write large software, that is the contrary of what is
usually believed. The benefits would be minimal.

Writing good interfaces is hard, your are right!  But if you can't
define decent interface/boundaries between your modules you are unlikely
to build up a huge system, no matter if these boundaries are checked at
run time or at compile time or not checked at all.

Maybe a way to rephrase my opinion is that types help you to reach a
point where your understanding of the problem is such that you can write
down decent interfaces. After that point, types don't matter that much,
since you are not going to break these interfaces that often.

> > (I mean, an opaque datatype in ML terminology).
> 
> Could you say instead "in Python/Lua/Perl terminology"?  ;)

Hum, I guess the closest concept is an "object" accessed only trough the
method/members that are meant to be used.
In Lua you could use an empty proxy table for example, or follow the
"just don't do it" philosophy and give funny names to private data.

Cheers
-- 
Enrico Tassi