Fully dynamic d by opDotExp overloading
Yigal Chripun
yigal100 at gmail.com
Fri Apr 17 12:41:18 PDT 2009
On 17/04/2009 21:58, Steven Schveighoffer wrote:
> On Fri, 17 Apr 2009 14:49:37 -0400, Yigal Chripun <yigal100 at gmail.com>
> wrote:
>
>> On 17/04/2009 21:34, bearophile wrote:
>>> Nick Sabalausky:
>>>>> There are people who swear by the ability of adding methods at
>>>>> runtime and changing the inheritance hierarchy dynamically. It
>>>>> makes for a very fluid environment.
>>>> Personally, I've always seen that as extremely sloppy and
>>>> haphazard.
>>>
>>> Adding methods at runtime is named "monkey patching", and it is
>>> considered a bad practice even in Python. In Ruby it is more common.
>>> Usually in such languages such things are less dangerous because the
>>> code contains lot of tests anyway. Some people say that a way to
>>> remove most of the downsides of monkey patching is to make it scoped,
>>> that is the changes (like a method added or replaced) to a class
>>> aren't seen globally in the whole program (like from other modules),
>>> but only in the scope where such change is done (and its subscopes).
>>> I think I have not seen languages where this is doable yet.
>>>
>>> Bye, bearophile
>>
>> just like anything in life this can be overused. This is a very useful
>> tool in a programmer's toolbox for when you need, for example, to
>> quickly experiment with something or do an urgent fix.
>>
>> It's like when you build a house you have it properly designed and
>> have solid foundations but after the house is built you can still
>> redesign internally without rebuilding the entire house.
>
> It's more like adding another outside door. Try doing that ;) (BTW,
> removing one is easy, but that kind of doesn't apply here...)
>
> changing internals in code is easy, that's why we use OOP. Changing APIs
> is not.
>
> -Steve
I completely disagree. here's a use case from my work:
we have executables that take 20+ min to compile and link, written with
C, C++, and fortran, and we also have code in JavaScript.
when I work on the Javascript code it's very easy and quick to debug and
test changes while the program is still running while doing the same
with the C++ code is very annoying, every change I want to test requires
me to wait 20+ minutes for the re-link. a *HUGE* waste of time and also
it's easy to forget what you were doing while you wait. no APIs involved
in this case.
OOP has nothing to do with this since there are both dynamically typed
and statically typed OOP languages (Smalltalk vs. D/JAVA) as well as
non-OOP languages (ML vs. LISP).
btw, I'm not trying to convince you that dynamic typing is necessary
always a better solution. What I'm saying is that I agree with Andrei -
we need to be open minded and have as many useful tools as possible in
our programmer toolbox. The important thing is to choose the right tool
for the job.
Having only a hammer makes a person think that "when all you got is a
hammer everything looks like a nail" kind of way.
More information about the Digitalmars-d
mailing list