Skip to content

Data to back up claims of usabilty favoring Hack #204

Closed
@runarberg

Description

@runarberg

The README includes a couple of section for why the Hack pipelines were chosen over the competing F# proposal. There are two sections in particular that interest me:

  1. Hack pipes favor more common expressions, and
  2. Hack pipes might be simpler to use.

Both of these claims are made without evidence to back them up, instead seemingly rely on speculations by the author. The former of these could easily be found out by searching for code samples in the real world and by asking a random sample of language users for typical code samples. This data would need to be considered in the context of where pipelines are likely to be used, so I would be interested in hearing some user stories about that. E.g. how common is it that a developer already has an n-ary function that they want to use in a pipeline? How much does it bother them that they need to wrap it in an arrow function? How often would you expect an arbitrary expression to show up in a pipeline? Are developers more likely to use libraries which will accommodate these pipelines by providing functions in place of operations. And if not, why?

The latter claim that “[h]ack pipes might be simpler to use” would probably need some in depth usability studies where participants are asked to use either pipelines and later ask participants if the following caused them any issues. E.g. how many participants experienced the issue of someFunction + 1 not being a unary function? I would also be interested in seeing some statistics of which third party tools likely users are using. E.g. the point that x |> someFunction + 1 is a runtime error is void if the majority of likely users are using static analysis tools that will point out that this code will result in a runtime type error.

To take a few of the real world examples provided in the explainer:

// Status quo
var minLoc = Object.keys( grunt.config( "uglify.all.files" ) )[ 0 ];

// With pipes
var minLoc = grunt.config('uglify.all.files') |> Object.keys(^)[0];
  • How many users favor the competing style of:
    var minLoc = grunt.config('uglify.all.files') |> Object.keys |> (key) => key[0];
  • Are users bothered by the syntax tax of (key) => key[0] over ^[0].
  • If they are, how likely are they to write a utility functions to accommodate this:
    const nth = (n, arr) => arr[n];
    const first = (arr) => nth(0, arr);
    
    var minLoc = grunt.config('uglify.all.files') |> Object.keys |> first;
// Status quo
const json = await npmFetch.json(npa(pkgs[0]).escapedName, opts);

// With pipes
const json = pkgs[0] |> npa(^).escapedName |> await npmFetch.json(^, opts);
  • How many users favor the following:
    const json = pkgs[0] |> (pkg) => npa(pkg).escapedName |> (name) => npmFetch.json(name, opts) |> await;
  • Are they bothered by the special case of |> await?
  • Do they value having the parameter named over the non-descriptive topic marker?
// Status quo
return _reduce(xf(typeof fn === 'function' ? _xwrap(fn) : fn), acc, list);

// With pipes
return fn
|> (typeof ^ === 'function' ? _xwrap(^) : ^)
|> xf(^)
|> _reduce(^, acc, list);
  • How many users peref the following:
     return fn
     |> (x) => (typeof x === 'function' ? _xwrap(x) : x)
     |> xf
     |> (x) => _reduce(x, acc, list);
  • Are they likely to use a library that will accommodate for unary function preference:
    import { ifNotTypeof, partial } from 'some-util';
    
    return fn
    |> ifNotTypeof('function', _xwrap)
    |> xf
    |> partial(_reduce, [, acc, list]);

I’m sure the committee has done some studies in order to reach the decision that they did. However, as somebody that would like the best decision to be made for the future of the language, I would love for these studies to be made publicly available so that they can be scrutinized by experts and that other members of the community—such as my self—can be reassured that the best decision was made. So far I remain unconvinced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions