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

Re: "static" declaration

At Wed, 7 Aug 2002 09:13:27 -0400,
Sundar Narasimhan wrote:
> Kobayasi: I didn't mean my post to be about Perl-style.

Ok. I was too much "sensitive" for Perl's topic;-)

Because when you started your first message for this thread from
{...about 60-70% of our bugs in "newly deployed" Perl code...},
I recoginzed you want shooting Perl's weakness. But this kind of 
bug is now statically rejectable by Perl's mechanism.
So, as a fan of Perl, I just wanted to defend it from somekind of
rumors (ie. Perl has no way to check variable typos statically).

> I meant to say that w/ large bodies of existing code if you use "good"
> tools/IDE's that often rely on providing you with "all" errors,
> starting off with the strictest levels of error checking might not be
> a good idea.

I agreed. In general, it is possible.

> And yes, our experience with perl -- since we generate dynamic sql,
> and play gnarly games with cursors -- is likely not to match
> yours. Our codebases are also typically much larger (we do write one
> liners like others here, but we also use light-weight languages for
> other larger tasks) .. we are probably one of the few
> commercial ISV's that still maintain oh.. around a million lines of
> Lisp, for example. 

A million lines of lisp! Yes, it is very different from my situation.
My largest case (a network game contents, written in my DSL, generated
from XML) is merely 1/3 of yours.

> Please read the original thread.. Dan was asking about whether or not
> declaring variables implicitly and at any point causes more grief than
> it is worth. I tend to agree. Use strict and other similar bandaids do
> help. 

Ok. For other than "one-liners", mandatory explicit declaration is
best. But I cannot agree about totally prohibiting "declaration at any
point" though. IMHO, from refactoring perspective, for lexcal(scope
related) declarations, "declaration at any point" is worth enough for
reducing code complexity (and helps manageability).


BTW, for this topic, I should mention about another Perl episode for
declaration. Since perl5.004(may be), Perl5 has a way of declaring
*instance variables* via "use fields", which enables static/runtime
checking of instance variable typos. And with "use fields", you can
even obtain list of instance variables about specific class via
%FOO::FIELDS hash table.

...But, it was too late to become major. I personally switched to it,
but it is still minor in CPAN. From this lesson, we can learn

 * Declaration mechanism should be supplied at very beginning of the
   language history.
 * For reusable-codes, declaration should be mandatory by default.

Otherwise, no-declaration-codes will go abroad quickly, and most
codebases for the language (and printed books, habits of trained
developpers, communitie's preference...) will be filled with it.
Once it dominates, it needs many efforts to salvage them.

# Good night!
KOBAYASI Hiroaki -- hkoba@t3.rim.or.jp --
If you feel my english is strange, please correct me.