Blimey, are we top-posting or bottom-posting in this discussion?  Anyway...

The original question was about whether there were studies on
the effect of 'magic' features, but we seem to have devolved into
a show-and-tell of them instead.

I wonder whether one person's 'magic' is another person's failure
to RTFM, and if the question should really be about accepting that
it is inevitable that helpful defaults and syntactic short-cuts
will also be seen as unexpected traps and incomprehensible flakiness
by those who don't have time, or inclination, to read before they write.

Particularly now, when programmers often have to dip into a language
that they're not deeply experienced in to do something quickly,
it's hardly surprising when they get confused by Javascript's
apparently non-commutative comparison operators, perl's veritable
buffet of syntactic exceptions, or CSS's hyperdimensional boxes.

Perhaps it's possible to discover when the benefit of magic
is outweighed by the curse of the confusion it also brings.
But the real trick would then be to get language designers to
pay attention to the results of such work, and to make their
languages more usable by being less magical.


Lindsay Marshall wrote:
PDP-8 had auto-increment locations down in low memory in similar style.

I suppose the device addressing through memory on lots of machines counts as 
magic too,

L.

Sent from my iPad

On 22 May 2011, at 06:39, "Thomas Green" <green...@ntlworld.com> wrote:

Kevlin Henney wrote:
To really demonstrate autoboxing you need to allow the compiler to convert from int to Integer:
  Integer x = 1000;
  Integer y = 1000;
However, if you are after interesting counterintuitive corner cases, change the constant to 100:
  Integer x = 100;
  Integer y = 100;
A direct equality comparison will now compare true because, by default, the JVM caches the Integer objects for values from -128 to +127 (the range can be extended as an optimisation).
In other words, your corner case has a corner case. Magic.

Back in the sixties, the autocode for the Atlas machine at Harwell had a fine piece of magic. As an outsider, I could book for an occasional week there, and while I was there I could run programs twice a day iirc. I once spent two of those 7 days trying to find out why my program wouldn't work, panicking desperately about meeting my target, before discovering that of its 128 registers (called B-lines), the one I had chosen to use was fitted with a hardware conversion to return log-2 of any quantity stored in it.

All the higher-numbered B-lines silently did special things, apparently. Great if you knew about them. Tough otherwise.

(For those of you who came late to the party and missed the early days, an 'autocode' was a slightly-Englished version of machine code. Bit like a penny-farthing - if you stayed on, people admired you, but when you fell off it really showed.)

Thomas


--
The Open University is incorporated by Royal Charter (RC 000391), an exempt charity 
in England & Wales and a charity registered in Scotland (SC 038302).


--
Frank Wales [fr...@limov.com]

Reply via email to