Cool! While I must admit I'm still on the fence regarding Lift's
polyglottism, I think you're doing excellent work here :).
> The first pattern I've got (and would really like feedback on this) is
> the "J" Java companion to Scala singletons.
>
> For example, to access LiftRules, you use LiftRulesJ.j() and you've
> got all the LiftRules methods available to you.
>
> Internally, for each singleton, I've got a Scala class named
> xxxJBridge (e.g., LiftRulesJBridge) with has a single method that will
> return the singleton.
>
> In Java-land, I've got the J companion with the static j() method on
> it. I chose a method over a final static because all Lift singletons
> will be mockable in 2.3 (LiftRules and DB are the prime candidates, S
> and SHtml contain no state so they don't need to be mockable.)
>
> What this means is:
>
> LiftRules.addToPackages(...)
>
> becomes:
>
> LiftRulesJ.j().addToPackages(...)
Another alternative would be to keep the same class names but have the
Java stuff live in a different package (e.g. net.liftweb.java). We could
have similar packages for support code for other languages, such as the
JRuby stuff.
I'm not sure how Scala objects (as in "object MyObj {}", not "val foo =
MyClass()") map to Java classes, but I think the ideal solution would be
a Java class with the same name, but in its own package, with the
object's methods exposed as java static methods (though I guess that
would interfere with the mockability you mention above).
> I'm also creating Java Func0-FuncXX interfaces with a Func.lift()
> method that lifts the Java representations to a Scala representation.
> I'm also considering sitting Lift on top of Functional Java and use
> all the stuff that the Functional Java guys have already built (with
> some helper methods in either util or common that will bridge the
> Functional Java stuff to Scala stuff.) Any opinions on writing our
> own vs. using Functional Java?
from a lazyness and code/knowledge-reuse perspective, I'd prefer using
Functional Java. I think there are too many Function interfaces in
JVM-land already (essentially every JVM language that supports
first-class functions has their own implementation).
Hope that makes sense :),
--Chris
Yeah, that sounds good. Having the J suffix on classnames makes the
API feel like a second-class citizen IMO.
> from a lazyness and code/knowledge-reuse perspective, I'd prefer using
> Functional Java. I think there are too many Function interfaces in JVM-land
> already (essentially every JVM language that supports first-class functions
> has their own implementation).
+1
Another alternative would be to keep the same class names but have the Java stuff live in a different package (e.g. net.liftweb.java). We could have similar packages for support code for other languages, such as the JRuby stuff.
The first pattern I've got (and would really like feedback on this) is the "J" Java companion to Scala singletons.
For example, to access LiftRules, you use LiftRulesJ.j() and you've got all the LiftRules methods available to you.