Recent submissions

Comment · 5 months ago
I did something similar a few years back, with a slightly different approach to declaration, using interfaces to denote the layout of the struct. Mutation was opt-in by exposing setters using the (of the time) standard JavaBeans layout and an annotation processor took care of the codegen of an implementing class, which could be used where you wanted an on-heap box of an off-heap structure.

One benefit of this approach was that by using the interface as the type you could fairly easily support a flyweight pattern, reducing GC pressure when working with large off-heap collections. The parallels between stateless interfaces and offheap structs was also quite pleasing.

I'd love to see a similar effort using more modern techniques than Unsafe et al.

Comment · 11 years ago
They did have time-choice; they chose to allocate a substantial portion of it to having children.
Comment · 12 years ago
Click Here to Skip Intro
Comment · 12 years ago
Sure you can. Ctrl-Shift-A, type 'keymap', and you get a handy popup (same size as the 'recent files' switcher available with Ctrl-E) with the defined keymaps ready to use. Few seconds, maximum.
Comment · 12 years ago
Regarding the 'checked exception issue'; an alternative technique to the method-wrapping-lambda is to use a default interface method to implement the non-exceptional interface, which delegates to the possibly-exceptional method. It's a bit fussy, but it's a nice technique to know:

    interface IOConsumer<T> extends Consumer<T> {
        @Override
        default void accept(T t) {
            try { 
                maybeAccept(t); 
            } catch (IOException ie) { 
                throw new RuntimeException(ie); }
            }

        void maybeAccept(T t) throws IOException;
    }
As IOConsumer<T> is also a Consumer<T>, if you can assign the lambda to an IOConsumer<T> it will get this wrapping behaviour automatically. So your code might look something like:

        try (Writer writer = new StringWriter()) {
            final IOConsumer<String> ioPrinter = writer::write;

            // hand ioPrinter off to something that expects a Consumer<String>
        }
This is by no means beautiful; for 'writer::write' to be treated as an IOConsumer<T> requires that the target type be IOConsumer<T>, so typically would require an interim assignment. It does allow us to simplify the 'wrapping' method, though, so that lambdas can again be used as one-liners:

    static <T> Consumer<T> maybe(IOConsumer<T> consumer) {
        return consumer;
    }

    try (Writer writer = new StringWriter()) {
        final Consumer<String> printer = maybe(writer::write);
    }
It would be nice not to have these wrinkles, but I think Java 8 has done a fairly decent job of preserving backwards compatibility while introducing language features and APIs which feel like a vast improvement. I'd love to see reified generics in the future, particularly if the type parameter can be extended to support primitives.
Comment · 12 years ago
Comment · 12 years ago
Comment · 12 years ago
"I'm pretty sure in 10 years time I will read a post about how you need to switch your horrible old messy AngularJS app to XYZ which will fix all your problems."

More likely given the rapidity of churn in the JavaScript world, in about 10 weeks.

Comment · 12 years ago
There's a certain irony in the poster dismissing Java with one hand:

    "In effect, to the developer it 'feels like writing Java,' which as we all know, is a terrible feeling"
While professing the benefits of something which looks rather similar to Java tag libraries.

    <graph class="visitor-graph"> 
        <axis position="left"></axis> 
        <axis position="bottom"></axis> 
        <line name="typical-week" line-data="model.series.typicalWeek"></line> 
        <line name="this-week" line-data="model.series.thisWeek"></line> 
        <line name="last-week" line-data="model.series.lastWeek"></line> 
    </graph>
"If you’re thinking, “that’s not HTML anymore! What are these graph, line, and axis elements?”—well, that’s the point, Angular allows us to “extend HTML” to create those elements!"

    <cewolf:chart id="line" title="Page View Statistics" type="line" xaxislabel="Page" yaxislabel="Views"> 
        <cewolf:data> 
            <cewolf:producer id="pageViews"/> 
        </cewolf:data> 
    </cewolf:chart>
That's from a tag library released in June, 2002.

Lest angry Java-haters accuse me of trying to extol the virtues of JSPs, taglibs et al, this is not the point of my post. I'm indicating the commonalities between two modes of development separated by more than a decade, which in the churnful world of technology might as well be separate geologic eras.

It's interesting to compare these two things (particularly when a prior effort has fallen by the wayside) to determine if you are implementing the same concept in a new guise, or if you are removing the issues that people had with prior models which led to their lack of use.

Comment · 12 years ago

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton