Skip to content

Comment on The Wake Programming Language

Comments

The Java code appears to be broken (`validate(records[i])` should be `validate(record)`). Further, Wake does

        return Record[].any({
            r -> return !validate(r);
        });
shouldn't this be
        return Record[].all({
            r -> return validate(r);
        });
?

And the inequality seems to be strict in Wake's case but weak in Java's. Finally, Java won't always return from `validate`.

The Java would really benefit from the newest version. I'm no Java expert, but I think it would look a bit like:

    public class RecordValidator {

        public RecordValidator(SessionHolder mySessionHolder) {
            sessionHolder = mySessionHolder;
        }

        protected SessionHolder sessionHolder;

        public boolean validate(List<Record> records) {
            return records.stream().allMatch(this::validate);
        }

        public boolean validate(Record record) {
            if(record.lastRevision != null && record.lastRevision.user != null) {
                List<Account> accounts = record.lastRevision.user.getAccounts();
                return accounts.stream().allMatch(sessionHolder::hasAccount);
            }

            record.revisions.stream().filter(this::usesLimits).count() < 3;
        }

        public boolean usesLimits(Revision revision) {
            return sessionHolder.hasUser(revision.user);
        }

    }
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.