Klangism

Things that were important enough at the time when they were written.

Viktor Klang is a legendary programmer, known from places like the Internet. Consider following him on Twitter.

Posts tagged scala

Nov 23

Serializable dynamic Proxies

So, I found myself in a situation where I was creating JDK Proxies, and I was in control of the invocation of newProxyInstance and needed to make the Proxies transparently Serializable.

The problem is that for it to work you need writeReplace, so that you’re in control of the rematerialization of the Proxy on the deserializing side using readResolve.

However, the problem is that you need to make sure that the Proxy gets a writeReplace method, and you don’t want to force the guy providing you with what interfaces to proxy to implement writeReplace himself, because at some point someone will forget it.

The solution might seem trivial, but the solution is the following:

Define a trait/interface with the writeReplace method (with correct signature)

Happy hAkking!

Cheers, √


Jul 1

DIY: Exhaustiveness checking on Scala Enums

Long time no blog,

I’m not much of a writer, so here’s the code!

Hardlink

Cheers,


Dec 28

All #Actors in #Scala - compared

As a late Christmas present I bring this to you dear readers:

I recently invited David Pollak (of Lift fame), Jason Zaugg (of Scalaz fame), Philipp Haller (of Scala Actors fame) and myself to collaborate on a feature matrix that would allow people to see the similarities and differences between the Actor libraries on the Scala platform.

So I’d like to start out by thanking David, Jason, Runar, Jonas, Philipp, Martin and all the people involved in these great projects for taking the time to fill out the matrix.

Here’s a link to a PDF-version of the document, enjoy!

PS. I attempted to embed the comparison to this blog post, but the formatting simply goes haywire. DS.


Oct 21

Akka 1.0-M1 is out!!

Hey!

We, the Akka committers, are very proud to announce the release of Akka 1.0-M1,
the first of 2 milestone releases leading up to the final 1.0 release.


It is all thanks to a fantastic team [http://doc.akkasource.org/team]
and user community. Thank you all for your time, hard work and great contributions.

The full release notes can be seen here: [http://doc.akkasource.org/release-notes].

91 tickets have been handled since the release of 0.10, and they can be seen here:
[https://www.assembla.com/spaces/akka/milestones/243291-1-0-milestone1]

Download it here: [http://github.com/jboner/akka/downloads].

Updated Maven repository here: [http://www.scalablesolutions.se/akka/repository/].

Here’s the documentation: [http://doc.akkasource.org]

Here’s the highlights on what’s happened since 0.10!

- Java API on par with the Scala API
- Say less, do more! Boilerplate reduction surgery performed.
- New persistence backends: Voldemort, HBase, Riak and CouchDB!
- Fewer deps for using actors only: akka-core is split into akka-actor, akka-remote and akka-typed-actor
- Lower memory footprint gives you 25% more actors on the same hardware
- ThreadBasedDispatcher can deallocate its thread when idling
- Lots of tweaks and bugfixes

Enjoy!


Oct 11

Cheaper ThreadBasedDispatchers in Akka 1.0

One of the small gems that will be available in Akka 1.0 is that ThreadBasedDispatcher is based upon ExecutorBasedEventDrivenDispatcher with a core thread pool of 1 and a max thread pool of 1 that allows core thread timeouts. This means that Actors with ThreadBasedDispatcher won’t hang on to any threads if they do not have anything to do.


May 3

Akka Message Routing: Part 1

This is the start of a miniseries of the components available to do interesting message dispatching.

Here’s a common scenario: Depending on the message, I want to forward it to different other Actors.

Enough talk, here’s some code!

Can’t see the code?

That was simple enough, right? Stay tuned for the next part!


May 2

To reply, or to reply_?

When you’re writing an Akka Actor and want to reply to a message, there are a number of options, two of them are reply(msg) and reply_?(msg), and today I’ll tell you when to use which.

Can’t see the code?

So the lesson of today: use reply(msg) then you require that there’s someone listening to the reply message, and reply_?(msg) if it’s ok to discard the reply message if no ones listening.


Apr 25

First

So here I am, all sweaty and tired from moving all the way from Blogger.

I got really sick and tired of that place, and I even decided to bury my old blog posts there. To start over with a clean slate.

This will be the place to look for news on good stuff like Scala, Akka and other promising new tech.