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.
What’s new?
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
Lax imports widen the range of valid imports in Golo, as in:
or,
Previously, one would have had to use either of the following constructs:
or,
New benchmarks
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 NoSuchMethodError
exception.
Private struct members also have the following impact:
- they do not appear in
members()
andvalues()
calls, and - they are not iterated through
iterator()
-provided iterators, and - they are being used like other members in
equals()
andhashCode()
, and - they do not appear in
toString()
representations.
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
The new 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:
textToFile
fix
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
Atom editor
GitHub is working on a new text editor called Atom, and Philippe did an awesome job in providing a support package for Golo:
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!
LLVM hacking
Franck Verrot has been playing with a LLVM generation from Golo code:
One of today's achievement: compiling a @golo_lang function with goloc-llvm, then using it in a @RubyMotion app. Yeay for #LLVM !
— Franck Verrot (@franckverrot) February 22, 2014
Is @golo_lang going native? Probably not, but I know it could… :-) http://t.co/nOniVLW8ej
— Franck Verrot (@franckverrot) February 15, 2014
Of course it’s an incomplete hack, but it highlights that Golo is hobbyist-friendly :-)
Eclipse IDE
Jeff is keeping the Eclipse IDE support up-to-date, give it a try!
Little Christmas present: Golo libraries in #GLDT @golo_lang @typeunsafe pic.twitter.com/QYLSFKqbim
— Jeff MAURY (@jeffmaury) December 25, 2013