Page 1 of 1

Scala?

PostPosted: 21 Aug 2010, 17:52
by silly freak
nantuko84 wrote:I have some experience with Scala. why are you planning to use it in laterna?
btw, idea scala plugin is much better and more stable.
(I tried IDEA shortly, but I didn't feel comfortable with it. However irrational this may sound, it's just what it felt like. Besides either getting used to the different key bindings etc. or customizing them, I got a class path problem because the JDK wasn't put on the classpath by default.)

right now, two things come to mind where scala would really be great:

One, filtering using anonymous functions/match statements. if you look at net.slightlymagic.laterna.magica.util, the classes MagicaPredicates, MagicaFunctions, MagicaSuppliers mostly just handle this problem. They would still exist of course, but would be much shorter and clearer.

Two are the concurrency features, especially applied to the GuiActor class:
Code: Select all
private boolean    ready;
private PlayAction a;

public synchronized void putAction(PlayAction a) {
    ready = true;
    this.a = a;
    notifyAll();
}

public synchronized PlayAction getAction() {
    ready = false;
    while(!ready)
        try {
            wait();
        } catch(InterruptedException ex) {
            ex.printStackTrace();
        }
    return a;
}
this is just too much boilerplate code for every GUI input, and the Actors, as presented here, seem to fit very well, also because they very simply enable to differentiate between various inputs; there are going to be many, especially for combat

Re: Scala?

PostPosted: 23 Aug 2010, 09:12
by Snacko
You can use jetlang to write actors for java with little code, however Java always is verbose and sometimes it's a bit too much compared to Scala.

Re: Scala?

PostPosted: 23 Aug 2010, 16:09
by silly freak
thanks for the tip, works great so far