Sunday, August 12, 2012

Wednesday, August 01, 2012

Typing more to type less

My code is littered with bits like this:


public final class TimesIterable
        implements Iterable<Integer> {
    private final int n;

    public static Iterable<Integer> upTo(final int n) {
        return new TimesIterable(n);

    public TimesIterable(final int n) {
        this.n = n;

    public Iterator<Integer> iterator() {
        return new UnmodifiableIterator<Integer>() {
            private int i = 0;

            public boolean hasNext() {
                return i < n;

            public Integer next() {
                return ++i;

All so I can write:

import static TimesIterable.upto;
import static java.lang.System.out;

public static void main(final String... args) {
    for (int n : upTo(4))

To my surprise Google is not quite there yet. (I'd prefer to be wrong).

Zing zings

Azul's Zing remains amazing technology:

Where a typical JVM may spend time battling with garbage collection, McCandless says an in-memory test with the full Wikipedia English-language site loaded worked with no garbage collection pauses under Zing JVM, even with a 140GB heap.

Now free for open source.