On Thu, Oct 01 2015, Sheehan Olver <[email protected]> wrote:

>       I think an argument for linspace returning an Array is that it makes 
> teaching new programmers Julia a lot easier.
>
>  If it returns an Array, its sufficient to teach students the Array type.  
> But if it returns a Range, one has to teach an extra data type before the 
> students can use it.  Teaching [1:5;] is not as bad as one can just teach 
> that as the syntax for creating an array of [1,2,3,4,5].  (Teaching the 
> syntax [linspace(1,5,1);]  is too over the top I think.)

Certainly it is a new concept to learn if one wants to understand the
implementation, but it also demonstrates the elegance of Julia: you can
have a type that behaves like an array in many respects, but at the same
time does not store all that information explicitly. This also has
pedagogical value.

Trying to transform Julia in such a way that it has "no surprises
compared to X", where X is Matlab, R, C, Python, etc, has two possible
pitfalls:

1. there will never be an agreement about what the right X is (see the
infamous string concatenation operator issue),

2. many great features would be lost, making Julia nothing but an
incremental improvement over X.

As a new Julia user, I found linspace and how it integrates into the
whole Julia iteration framework very elegant. Sure, it was different
than what I was used to in other languages, but I value elegance over
familiarity -- after all, I am learning a new language.

Best,

Tamas

Reply via email to