[E-Lang] down with `define' (was: newbie syntax: picayune points from a prejudiced programmer)
Tyler Close
tclose@oilspace.com
Fri, 2 Mar 2001 11:34:11 -0000
MarcS wrote:
> We could also make "new" the secret shortcut method instead
> of "run":
>
> class Thing() :any {
> def thing{}
> }
> def thing := Thing new()
>
> This looks positively Java-esque. It kinda makes me smile :-)
I'm finding it strange that you are so wed to the word "new". For me,
the word "new" has unfavourable connotations. The first language that
I wrote serious applications in was C++. In C++, "new" is a keyword
for specifying memory use. "Thing()" constructs an object on the
stack, and "new Thing()" constructs an object on the heap. I was
taught that using the heap was expensive and error prone, and to be
careful that I was doing it right and for the right reasons.
For the last few years, I've been programming in Java. In Java, "new"
also constructs an object on the heap. In most of the performance
articles I've read, Java suffers on its use of the heap. This is
particularly true when the C++ implementation can use the stack
instead. Consequently, I'm always a little concerned when I scan a
page of code and see lots of "new" statements.
There's nothing in E's semantics for an object that require knowing
where the object actually is, stack or heap. It's quite possible that
a future E implementation could implement "selfless" objects on the
stack for performance reasons. As an E programmer, I can just use the
"construct an object" syntax, like "Thing()", and not have any
paranoia about performance. The E implementation will do what's best.
Zooko pointed out that Python also constructs new objects with
"Thing()". So both C++ and Python use this syntax. It seems Java is
the only place where you always use "new".
Tyler