Now available: Golo 0-preview11
We are pleased to announce the release of Golo 0-preview11. This is the first release of 2014 following Golo 0-preview10 last December.
You can download a Golo 0-preview11 now with the following noteworthy changes:
- fallback methods for dynamic objects,
- lax imports,
- new JMH-based benchmarks,
- struct members encapsulation,
- Go-style objects.
- asynchronous future and promises API.
Fallbacks methods for dynamic objects
Daniel contributed the support of fallback methods for dynamic objects. Here is an example snippet:
As you can see, this can be used to provide a default behavior when a method is not defined in a dynamic object instance.
Lax imports widen the range of valid imports in Golo, as in:
Previously, one would have had to use either of the following constructs:
We rewrote our benchmarks using the OpenJDK JMH harness.
Benchmarking on the JVM/HotSpot is hard, especially as the virtual machine is doing lots of optimizations that can defeat the purpose of your benchmarks. JMH provides great support to mitigate these effects and get more meaningful results.
Struct members encapsulation
It is now possible to make some struct members private by prefixing them with
_, as in:
In this case,
_b is a private struct member. This means that
foo: _b() and
foo: _b(666) are
valid calls only if made from:
- a function from the declaring module, or
- an augmentation defined in the declaring module.
Any call to, say,
foo: _b() from another module will yield a
Private struct members also have the following impact:
- they do not appear in
- they are not iterated through
iterator()-provided iterators, and
- they are being used like other members in
- they do not appear in
Go-style “objects”, simpler same-module struct augmentations
Struct members encapsulation offers a simple object mechanism for Golo that is very much like what the Google Go programming language offers. More precisely:
- Golo structs offers containers for state where some members can be encapsulated, and
- Golo augmentations provide methods over instances of structs.
To make this more practical, we simplified same-module struct augmentations declarations. Previously, one had to to the following:
Now one can simply omit the full struct qualified name:
Asynchronous helpers with promises and futures
gololang.Async module provides helpers for composable futures and promises to support
asynchronous programming model.
The API that we designed is orthogonal to the underlying execution strategy, so you may opt to execute some stream operations on the same thread, in a new thread, in a new executor task and so on.
You should consult the golodoc to learn more about the API, but here is some sample code to give you a feeling of how this works:
Philippe spotted a bug in the
fileToText function implementation where files would not be
truncated on overwrites.
In the best spirit of opensource, he also provided a fix.
In the community
Good job Philippe!
Philippe goes to Devoxx France (and so does Jeff, too!)
Philippe will do a talk at Devoxx France on Golo called “Golo, de la sucrette syntaxique pour vos applications Java”.
He will also take part in another talk on web framework performance with JVM wizard Rémi Forax, Play! Framework specialist Nicolas Leroux and our Eclipse IDE guru Jeff Maury.
We wish you the best, mates!
Franck Verrot has been playing with a LLVM generation from Golo code:
Of course it’s an incomplete hack, but it highlights that Golo is hobbyist-friendly :-)
Jeff is keeping the Eclipse IDE support up-to-date, give it a try!