Hi Jiahao,

Distributions is an awesome example of a package that explains what I was 
trying to say about using multi-dispatch instead of compound function names 
-- a work of art.  I hope to use it in the future.  Have you had an uproar 
from the community that the names don't follow the MATLAB "defacto 
standard"?

My point was meant to be taken more general -- I was using the examples 
brought up in this thread. I wish multi-dispatch was used everywhere 
instead of underscore (or not) compound names.  Like for:

open(FileType,....) vs opentable, openmatlab, openimage, opentext, 
openmytype, etc.
write(FileType,....) vs write, writetable, writetable, writedlm, writecsv, 
writepng, writemime, etc.
rand(Type,....) vs randi, randbool, randstring, randperm, randpoisson, 
randfoo, etc.
many other examples

When you don't use multi-dispatch it gets very confusing how to extend 
something, what the interface should be, and how to write generic code that 
can be specialized by the compiler.  Using compound function names leads to 
an API explosion and I can't see any technical benefits (unless it is to 
ensure type stability or something like that).

Glen

On Monday, April 27, 2015 at 11:13:42 PM UTC-4, Jiahao Chen wrote:
>
> You should look at Distributions.jl, which already overloads rand to 
> provide the functionality of the first two methods of "random" that you 
> want.
> On Apr 27, 2015 8:10 PM, "François Fayard" <[email protected] 
> <javascript:>> wrote:
>
>> Hi Stefan,
>>
>> I am just expressing my point of view here as a Mathematica user.
>>
>> [1] One can't compare Julia and C. C is one of the smallest language than 
>> can exist. Therefore, small names are not too much of a problem. Julia aims 
>> to be a langage with a huge standard library (kind of "batteries included") 
>> which makes it a totally different beast than C. If you look at C++ that 
>> has a bigger library, names are more consistent. The larger the library, 
>> the more consistency is needed.
>> [2] I think that Matlab gets a lot of things wrong, and its naming 
>> conventions (of lack thereof) is just  nightmare. For instance why not 
>> working on something as:
>>    - random(distribution) : gives a random number
>>    - random(dimension, distribution) : gives a random matrix
>>    - random(sparsity_pattern, distribution) : gives a random sparse matrix
>> I think it fits nicely the dispatch method of Julia which is very closed 
>> to what Mathematica does.
>>
>> On Tuesday, April 28, 2015 at 1:01:44 AM UTC+2, Stefan Karpinski wrote:
>>>
>>> I'm not sure what the problem with sprandn is. If you're working with 
>>> sparse matrices, you'll know what this is. If you're not, then you're 
>>> unlikely to accidentally use it. Sure, it's kind of an ugly name, but it's 
>>> the traditional, well-known name for this function. I don't see anyone 
>>> complaining about cryptic but standard names inherited from C.
>>>
>>

Reply via email to