[Novalug] Best programming language for "munging?" Not Perl? Ruby? Python?
gmaxwell at gmail.com
Thu Oct 29 01:06:00 EDT 2009
On Thu, Oct 29, 2009 at 12:30 AM, Bruce O. Benson <bbenson at gmail.com> wrote:
> "D" is...another great (incorrect) guess. D is nice because it supports
> programming to the metal, in asm, as well as a number of modern features,
> and has nice templates.
D has a lot of interesting things. I think the mixins are great.
Sadly, it doesn't disarm most of the features I've grown to hate in C++.
For example. This fragment of code could be C or C++:
route = existing_path+destination;
What does it do?
In C you could answer that question after a little thinking and
deduction, though with a little uncertainty regarding the types.
In C++, existing_path+new_destination might solve an enormous
travelling salesman problem while the == has been overloaded to cause
the software to go download a 600 megabyte map database to determine
if the midpoint on the route is a waterpark. ... you basically can't
tell what a code fragment does, and it may do awful awful things. You
basically have to know enormous swaths of the code to even understand
what a single line does.
This kind of insane job security enhancing crap... overloading
operator== with things that have side-effects is commonplace. Even in
other languages which give you these kinds of foot-guns they usually
also provide enough high level tools that no one seem to be too eager
to use the crazy stuff. But C++ is just the right mixture of
underequipped and over-expressive to really create danger and to make
matters worse the very *first* example of C++ that people learn uses
one of the more stupid abuses of overloading in the language.
Sadly, D is little better in this regard. Worse, because of some
philosophical notion about how the tokenizer and the rest of the
parser should be segregated you can't take other symbols to use as
your fancy operators. ... they didn't even bother simply reserving a
swath of symbols to use as application specific operators (heck, they
could have just reserved all the symbol planes in unicode: at least
if you saw "c = a ☭ b" you'd at least know you didn't know what it was
doing!). The official recommendation is to simply use function calls
rather than overloading, but I full expect to see D code continue the
C++ route of overloading all the basic operators in completely insane
The excuse the D folks give for allowing the comparison operator to be
overloaded with a non-pure function is that it allows you to implement
memoization. Yet… if the compare was required to be a pure function
the language could do memoization for you. (and, god forbid you be
forced to use a function for comparisons too complicated for the
More information about the Novalug