Re: Flattening Nested Lists
Re: Flattening Nested Lists
- Subject: Re: Flattening Nested Lists
- From: "Mark J. Reed" <email@hidden>
- Date: Mon, 26 Jan 2009 13:03:34 -0500
On Mon, Jan 26, 2009 at 12:35 PM, <email@hidden> wrote:
> I believe very few of the reasons programmers are taught bad apply to most
> scripting.
Drawing a line between "programming" vs "scripting" is a false
dichotomy; it's all programming. Sure, you can do it at various
levels, from soldering circuits to programmable logic arrays to
microprogramming to machine language to assembly to a "high" level
language like C or Fortran to a "4th generation" language to a
"scripting" language. And there are different techniques at different
levels, and different things to worry about. Part of programming in
any environment is understanding the trade-offs of that environment.
But the guiding principles are the same. It's just not the case that
"Real Programmers(TM)" focus too much on the lower-level stuff or the
"Just-Another-Perl Hackers" on the higher-level stuff.
Global variables are bad because they make it harder to tell what's
going on. When you see this sequence of statements:
someHandler();
doSomethingWith(someGlobalVar);
there's no visible relationship between someHandler() and
someGlobalVar(). To know that the handler is setting the global, I
have to go read the handler code - which defeats the purpose of making
it a handler in the first place, which is that I should be able to
read the calling code and tell what it's doing without getting
distracted by the details of how it does it. Forest vs trees.
There are languages where you have no choice but to do things that
way; and there are extenuating circumstances in other cases where you
do it even though there's another option - for performance, or
integration, or whatever. But either way you should think about it
first.
It may be the case that when "scripting", you're more likely to write
a program short enough that you don't need to break things into
handlers in the first place, but other than that I don't see any
reason for "scripters" in general to ignore the time-honored wisdom
that global variables are a mechanism of last resort.
However, in the particular case of AppleScript, I have seen repeated
reference to the fact that list manipulations are faster on
globals/properties, and similar observations; I was just trying to see
if that's what was going on here.
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden