Shijun He (2013-12-18T19:01:01.000Z)
On Thu, Dec 19, 2013 at 12:08 AM, Rick Waldron <waldron.rick at gmail.com>wrote:

>
> `Array.of` sounds a lot more expressive than `.fromElements` to me.
>
> Agreed.
>

1)
Array.of sounds expressive only for native speakers. Non native programmers
will have no idea about Array.of method, because they never seen such named
method with such usage in any codes of any programming languages before (at
least I never seen), if you search `array.of` in github, you will see many
`array of int` `array of byte`  `array of strings` `array of Book` or
`array of Point`... in code or comments.

2)
In fact such expressive is MEANINGLESS because we will never write `var a =
Array.of(1, 2, 3)` instead of `var a = [1, 2, 3]`

The only valid use case of Array.of is high-order function.

So what's the readability of `foo(bar, array.of)` ?


I just find that Dave Herman already pointed out this problem in the
original thread:

> That said, the "readability" story you and I tweeted about is not so
compelling given that, in the first-order usage pattern an array-literal is
strictly more readable. So a longer name like Array.fromElements or
something might be okay.


Interesting that Dave (native speaker) and 程劭非(a non native speaker which
suggest this name in this thread) both choose fromElements in the first
place.



>
>
> Additionally, `fromElements` will also be confusing when the new DOM
> `Elements` API arrives: http://dom.spec.whatwg.org/#elements
>
>
>
Well, even it's confusing it's still better than `of` for the use case, and
some other alternatives:
Array.fromItems // fromXXX has another benifit that alternative
constructors (String.fromCharCode, Array.from) all begin with `from`
Array.fromList
Array.fromArguments
Array.newArray
Array.makeArray
Array.theFixedConstructorWithoutGotchas

I like the last one ;) what about you?


>
>> Optimally I'd like the array constructor to just accept a collection and
>> convert it to an array but that's not going to happen. Would you mind
>> explaining the issue here for non native English speakers?
>>
>
> The specification reads:
>
>   Array.of(...items)
>
> Which, when said out loud is:
>
>   "Array of items"
>

Even `Array.ofItems` is better than `Array.of` for the only use case:
foo(bar, Array.ofItems)


>
> I don't know how much clearer that can get. Bikeshedding the name of an
> API at this stage in ES6's progress is not a valuable use of anyone's time.
>

Come on, there are only two things in Computer Science: cache invalidation
and naming things.

And if we don't fix bad names in this stage, we will lose the chance for
ever.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20131219/464c9018/attachment-0001.html>
domenic at domenicdenicola.com (2014-01-03T16:48:12.435Z)
On Thu, Dec 19, 2013 at 12:08 AM, Rick Waldron <waldron.rick at gmail.com>wrote:

>> `Array.of` sounds a lot more expressive than `.fromElements` to me.
>
> Agreed.

1. `Array.of` sounds expressive only for native speakers. Non native programmers
will have no idea about `Array.of` method, because they never seen such named
method with such usage in any codes of any programming languages before (at
least I never seen), if you search `array.of` in github, you will see many
`array of int` `array of byte`  `array of strings` `array of Book` or
`array of Point`... in code or comments.

2. In fact such expressive is MEANINGLESS because we will never write `var a = Array.of(1, 2, 3)` instead of `var a = [1, 2, 3]`

  The only valid use case of Array.of is high-order function.

  So what's the readability of `foo(bar, array.of)` ?


I just find that Dave Herman already pointed out this problem in the
original thread:

> That said, the "readability" story you and I tweeted about is not so compelling given that, in the first-order usage pattern an array-literal is strictly more readable. So a longer name like `Array.fromElements` or something might be okay.


Interesting that Dave (native speaker) and 程劭非(a non native speaker which
suggest this name in this thread) both choose `fromElements` in the first
place.



> Additionally, `fromElements` will also be confusing when the new DOM
> `Elements` API arrives: http://dom.spec.whatwg.org/#elements

Well, even it's confusing it's still better than `of` for the use case, and
some other alternatives:

```js
Array.fromItems // fromXXX has another benifit that alternative constructors (String.fromCharCode, Array.from) all begin with `from`
Array.fromList
Array.fromArguments
Array.newArray
Array.makeArray
Array.theFixedConstructorWithoutGotchas
```

I like the last one ;) what about you?

> The specification reads:
>
> ```js
> Array.of(...items)
> ```
>
> Which, when said out loud is:
>
>   "Array of items"

Even `Array.ofItems` is better than `Array.of` for the only use case: `foo(bar, Array.ofItems)`


> I don't know how much clearer that can get. Bikeshedding the name of an
> API at this stage in ES6's progress is not a valuable use of anyone's time.

Come on, there are only two things in Computer Science: cache invalidation
and naming things.

And if we don't fix bad names in this stage, we will lose the chance for
ever.