[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Lightness vs. Largeness
On Thu, 6 Dec 2001, Dan Weinreb wrote:
> Me too, but my current opinion is that the next time I write a
> 100,000-line application, I'm going to use type declarations
> everywhere I can, if the langauge makes them available (whether
> mandatory or optional). I've really changed my mind on this over the
> years. Partly it's because type declarations sometimes catch
> programming mistakes statically, and partly it's because they make
> programs easier to read.
I's like 3 ways of dealing with types, and the ability to combine
them at will.
1. code without declarations should be allowed for short scripts/hacks,
initial prototyping or exploratory coding
2. inferred types, but an option to tell the compiler to shut up about
certain sections of code because I know what I'm doing or just don't
care right now
3. Explicit type declarations for module boundaries/interfaces
To me, this would make the language feel lighter as it gives me mechanisms
not policy. If I don't feel like using any type declarations or satisfying
the type inference engine..I don't have to. As long as I'm dreaming, the
language better allow me to introduce a type without much hassle; no new
file and excessive amounts of declarations if I don't want/need it. Often
this is something that I'll re-write or factor out once I have a better
understanding.
> How's that for a provocative statement? :-) Yes, easier to read.
> It's easier to understand a program if you can see, right on its face,
> important invariants. Assertions are helpful, and type declarations
> are an important special case of assertions.
I think this is true. But, while coding in a "typeful" language such as,
for example, Haskell gives me type inference, explicit type declarations
and lightweight ways to introduce types, its not what I'd call a
lightweight language (nor do implementations have the vital 'shut up and
compile it' option :-) On the other hand, something like Ocaml feels
a lot lighter weight to me and has many of the same advantages.
niall