Hacker News new | past | comments | ask | show | jobs | submit login

I can't even make a guess as to how such a program could be written.

anyone has an idea?




it sounds a little bogus to me, but i can outline some ways to approach it

if you have a set of features, generating its powerset is fairly simple

    >>> powerset = lambda xs: [x0 + others for others in powerset(xs[1:]) for x0 in [[], [xs[0]]]] if xs else [[]]
    >>> powerset(['int', 'float', 'set', 'array'])
    [[], ['int'], ['float'], ['int', 'float'], ['set'], ['int', 'set'], ['float', 'set'], ['int', 'float', 'set'], ['array'], ['int', 'array'], ['float', 'array'], ['int', 'float', 'array'], ['set', 'array'], ['int', 'set', 'array'], ['float', 'set', 'array'], ['int', 'float', 'set', 'array']]
then you just need some way to calculate various merits of the different designs. one merit is simplicity, which you could maybe try to operationalize as something like this:

    >>> [(d, {'simplicity': 10 - len(d)}) for d in powerset(['int', 'set', 'array'])]
    [([], {'simplicity': 10}), (['int'], {'simplicity': 9}), (['set'], {'simplicity': 9}), (['int', 'set'], {'simplicity': 8}), (['array'], {'simplicity': 9}), (['int', 'array'], {'simplicity': 8}), (['set', 'array'], {'simplicity': 8}), (['int', 'set', 'array'], {'simplicity': 7})]
comparing two merit-maps such as {'simplicity': 8} and {'simplicity': 6} for pareto optimality is simple enough with some thought, especially if we assume the keys are the same:

    >>> some_way_better = lambda a, b: any(a[k] > b[k] for k in a)
    >>> defeats = lambda a, b: some_way_better(a, b) and not some_way_better(b, a)
    >>> defeats({'simplicity': 9}, {'simplicity': 8})
    True
    >>> defeats({'simplicity': 8}, {'simplicity': 9})
    False
    >>> defeats({'simplicity': 9, 'turing-complete': 0}, {'simplicity': 8, 'turing-complete': 1})
    False
    >>> defeats({'simplicity': 9, 'turing-complete': 1}, {'simplicity': 8, 'turing-complete': 1})
    True
then it's easy enough to calculate which of a set of candidate designs can be eliminated because some other design defeats them

the bogus part is how you automatically calculate the various merits of a hypothetical collection of language features


Yeah, what was the representation of these "data type systems" and what were the metrics I wonder.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: