MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Opinions about the "Oneliners"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40686] Re: [mg40649] Re: Opinions about the "Oneliners"
  • From: Dr Bob <majort at cox-internet.com>
  • Date: Sun, 13 Apr 2003 02:19:27 -0400 (EDT)
  • References: <200304120709.DAA21277@smc.vnet.net>
  • Reply-to: majort at cox-internet.com
  • Sender: owner-wri-mathgroup at wolfram.com

"Oneliners" are the result of applying design patterns to problems.  OO 
languages give lip-service to this idea, but -- in terms of algorithms -- 
they do nothing about it.  Fold, Outer, Inner, Tr, Nest, FixedPoint, Map 
and so forth are implemented design patterns for algorithms.  The right 
one-liner simply matches design patterns up against the problem's essential 
features.

The fly in this ointment is that in our "function wars" we often find that 
a less intuitive solution is faster because of the way code is optimized in 
the background.  The winning solution still depends on appropriate design 
patterns, but we depart from one-liners to get more speed.

Fortunately, processors are getting faster.  Everyday, ugly solutions that 
run faster are less necessary or tempting.

Bobby

On Sat, 12 Apr 2003 03:09:16 -0400 (EDT), Orestis Vantzos 
<atelesforos at hotmail.com> wrote:

> I'll second that...
> IMHO oneliners are a result of the Mathematica language, not some holy
> crusade that we have embarked upon. Once you realise that most
> problems can indeed be solved with oneliners it is natural to seek
> them out __plus__ they are almost always more efficient than any
> Fortran-like construct.
> In terms of comprehensibility, I think that the oneliners are not the
> problem. If you don't understand the kind of operations that we are
> routinely using in the oneliners (Fold, Outer, Tr, etc.) then
> expanding the oneliner in a many-liner will not help much. In my
> experience, when people complain about the oneliners, it is C or
> Fortran they expect to see.
>
> Orestis
>
>
> Dr Bob <majort at cox-internet.com> wrote in message 
> news:<b75o54$28p$1 at smc.vnet.net>...
>> Doing it in one line isn't the point.
>>
>> Do, While, and For are often the least efficient (slowest) way to do 
>> things in terms of execution time.  We see this time after time in our 
>> function wars.
>>
>> Bobby
>>
>> On Thu, 10 Apr 2003 03:42:06 -0400 (EDT), David Terr <dterr at wolfram.com> 
>> wrote:
>>
>> > nafod40 wrote:
>> >
>> >> Gerry Flanagan wrote:
>> >>
>> >>> Actually, this is a pretty serious problem. We've been trying to 
>> make >>> Mathematica a standard language for our engineering firm, but 
>> I've >>> struggled for years with developing good documentation 
>> standards. The >>> problem is that I have a couple of people that can 
>> program in >>> Mathematica style - very compact functional form, but the 
>> people that >>> don't use Mathematica everyday can never parse how the 
>> functions work.
>> >>>
>> >>
>> >> Ditto for us. The oneliners are clever tricks, but they are 
>> essentially >> opaque. A thick one liner can take even a decent (by our 
>> standards) >> Mathematica programmer far too long to understand.
>> >>
>> > I'll second that! During my 3 years at WRI, I've written essentially 
>> all > my Mathematica program in C style, i.e. using If, For, and While 
>> loops, > to make it look more like C. Very few of the functions I've 
>> written are > just one line, though I'm sure some clever Mathematica 
>> programmers could > make much of my code quite a bit shorter, perhaps 
>> turning many of my > functions into "Oneliners".
>> >
>> >>
>> >> I'm a big fan of using typography
>> >>
>> >>> (indenting and other visual aids) in programming, but Mathematica 
>> makes >>> even those methods difficult. I'm tempted to ban prefix and 
>> postfix >>> notation in packages because they can make for very opaque 
>> code.
>> >>>
>> >>
>> >> Another roadblock to those methods is that math typesetting and 
>> things >> like special fonts, font colors, and embedded comments play 
>> havoc with >> Mathematica's package autogeneration capability. It's been 
>> that way >> since version 3. I don't understand why they leave those 
>> bugs in.
>> >>
>> >>
>> >
>> >
>> >
>> >
>> >
>
>



-- 
majort at cox-internet.com
Bobby R. Treat



  • Prev by Date: Re: RE: Weirdness with symbol Degree vis Units
  • Next by Date: solving a PDE
  • Previous by thread: Re: Opinions about the "Oneliners"
  • Next by thread: Re: Opinions about the "Oneliners"