Investigation: downsides of being generic and correct

Dicebot m.strashun at gmail.com
Fri May 17 02:15:24 PDT 2013


On Thursday, 16 May 2013 at 19:15:57 UTC, Jonathan M Davis wrote:
> 1. In general, if you want to operate on ASCII, and you want 
> your code to be
> fast, use immutable(ubyte)[], not immutable(char)[]. Obviously, 
> that's not
> gonig to work in this case, because the function is in 
> std.string, but maybe
> that's a reason for some std.string functions to have ubyte 
> overloads which
> are ASCII-specific.

I was thinking exactly about that. Only thing I want to be 
advised on - is it better to add those overloads in std.string or 
separate module is better from the point of self-documentation?

> 2. We actually discussed removing all of the pattern stuff 
> completely and
> replacing it with regexes.

Is is kind of pre-approved? I am willing to add this to my TODO 
list together with needed benchmarks, but had some doubts that 
std.string depending on std.regex will be tolerated.

> 3. While some functions in Phobos are well-optimized, there are 
> plenty of them
> which aren't. They do the job, but no one has taken the time to 
> optimize their
> implementations. This should be fixed, but again, it requires 
> that someone
> spends the time to do the optimizations, and while that has 
> been done for some
> functions, it definitely hasn't been done for all. And if 
> python is faster than
> D at something, odds are that either the code in question is 
> poorly written or
> that whatever Phobos functions it's using haven't been properly 
> optimized yet.

I understand that. What I tried to bring attention to is how big 
difference it may be for someone who just picks random functions 
and writes some simple code. It is very tempting to just say 
"Phobos (D) sucks" and don't get into details. In other words I 
consider it more of informational/marketing issue than a 
technical one.

> - Jonathan M Davis

Thanks for your response, it was really helpful.


More information about the Digitalmars-d mailing list