Let Go, Standard Library From Community

Dan murpsoft at hotmail.com
Thu Apr 19 07:40:52 PDT 2007


janderson Wrote:
> The problem is that every code monkey ends up re-writing the same code. 
>      That means a lot of time wasted focusing on writing solutions to 
> problems that have already been solved.  It also means when reading 
> someone else's code there's more to learn, rather then there being a 
> standard way of writing something (more time wasted).  

To that end, I find it takes me more time to learn an entirely new set of types, methods parameters, interfaces and class hierarchy that follow a convention completely unlike the D language itself and the intricacies of the classes I'm working with when they're opague; than I do performing a mere cast on that void[], or merely using char[] rather than String.

Furthermore 
> things that have been in some public library (not necessarily standard) 
> generally receive a high level of free testing from the community, that 
> means I save more time.

Yes, I suppose it would save you a deal of time debugging if your code has obvious bugs like the two examples I provided for abs().  

It would also be prone to gradual improvement accross many applications and therefore be more maintainable compared to reimplementing the wheel each time.

> My approach to coding is to try to do as much re-use as is feasible.  It 
> means I can focus on the actual problem more, not how I get there.

design++;
code--;

Sounds like a good objective.

> Humm, although I respect your option:  You should know that this is one 
> common interview question.

Interview question or not... my abilities revolve around making code smaller, faster, cleaner, and more robust within the environment they are targetted.  Using library code may or may not have something to do with that, but my mentality when I code is KISS, and it's quite engrained.

When I see a bunch of code that works, such as raw D source with language features, and I compare it with a library made out of template and class hierarchies, I'm very hesitant.

When people start suggesting that we abandon the simple, working code in favor of the complex, I insist on it being justified - this being the stem of this topic.

So, I tried poking holes.  : )

As for abs():

The IEEE 754 standard is applied accross most if not all platforms, and proposes much the same for 32-bit, 64-bit, 43-bit, 79/80-bit, doubles, floats, and all.  The sign bit is the high bit.

Putting the high bit in the low bit of a register, and'ing it with the original value and performing a one's complement will give you the absolute value of all but one value - try int.min; then, try it with your other solutions...

Sincerely,
Dan



More information about the Digitalmars-d mailing list