Null references redux

Yigal Chripun yigal100 at gmail.com
Wed Sep 30 18:12:53 PDT 2009


On 30/09/2009 16:53, Jeremie Pelletier wrote:
> Yigal Chripun wrote:
>> On 29/09/2009 16:41, Jeremie Pelletier wrote:
>>
>>> What I argued about was your view on today's software being too big and
>>> complex to bother optimize it.
>>>
>>
>> that is not what I said.
>> I was saying that hand optimized code needs to be kept at minimum and
>> only for visible bottlenecks, because the risk of introducing
>> low-level unsafe code is bigger in more complex and bigger software.
>
> What's wrong with taking a risk? If you know what you're doing where is
> the risk, and if now how will you learn? If you write your software
> correctly, you could add countless assembly optimizations and never
> compromise the security of the entire thing, because these optimizations
> are isolated, so if it crashes there you have only a narrow area to
> debug within.
>
> There are some parts where hand optimizing is almost useless, like
> network I/O since latency is already so high having a faster code won't
> make a difference.
>
> And sometimes the optimization doesn't even need assembly, it just
> requires using a different high level construct or a different
> algorithm. The first optimization is to get the most efficient data
> structures with the most efficient algorithms for a given task, and THEN
> if you can't optimize it more you dig into assembly.
>
> People seem to think assembly is something magical and incredibly hard,
> it's not.
>
> Jeremie

When I said optimizing, I meant lowering the implementation level by 
using lower level language constructs (pointers vs. references for 
example) and asm instead of D.
Assume that the choice of algorithm and data structures is optimal.

Like language_fan wrote, when you lower the level your increase your LOC 
and your loose all sorts of safety features.
statistically speaking there's about a bug per 2000LOC on average so you 
also increase the chance of a bug.
All that together mean a higher risk.

your ASM implementation of binary search could be slightly faster than a 
comparable Haskel implementation, but the latter would be much easier to 
formally prove that it's correct.

I don't know about you, but I prefer hospital equipment, airplanes, 
cars, etc, to be correct even if they'll be a couple percent slower.



More information about the Digitalmars-d mailing list