开发者

Interoperability between Java and Clojure and creation of GUIs

开发者 https://www.devze.com 2023-01-24 11:23 出处:网络
I\'ve been playing around for some time now with Clojure and I simply love the LISP-syntax, it\'s really beautiful, expressive, simple and yet extremely effective. I\'ve also been toying around with C

I've been playing around for some time now with Clojure and I simply love the LISP-syntax, it's really beautiful, expressive, simple and yet extremely effective. I've also been toying around with C# for some months and find it's syntax really verbose and quite ugly, but yet it works for me but I'd prefer the LISP-syntax.

However; the lack of a GUI-library/designer specifically for Clojure has been getting on my nerves somewhat. In C# making a test-application rapidly开发者_如何学C with WPF is really simple and easy, but I can't say the same about Clojure.

Anyways, I put some thought into it but couldn't really find a good resource for it. With for example C# and F# you can write the logic of the application in F# and then make the GUI with C#. Is there any way this is possible with Java and Clojure? That you make the logic of the application in Clojure and then code/design the GUI in Java?


You can use Swing pretty much directly from Clojure - and therefore get the benefit of the extensive range of Java Swing libraries and tools pretty quickly. Here's a nice blog post with examples:

http://stuartsierra.com/2010/01/03/doto-swing-with-clojure

I don't see any reason why you couldn't do the same with any other Java GUI library / GUI builder.

If you're more interested in 3D or visualizations, it's also worth taking a look at penumbra. I haven't used it much myself, but it seems like a very nice LISP-style approach to OpenGL programming.


If you're looking to paint UIs by hand then @mikera's pointers all make sense. I don't think it sounds like that was your question, though.

Given Clojure's excellent Java Interoperability, I would say there's no reason you couldn't paint your UI visually using Matisse, which is the only thing I hear anybody doing java desktop apps talk about these days. Tor Norbye of the Java Posse in particular speaks very highly of it, and his whole job for the past few years has been developing NetBeans which has quite a complicated GUI, albeit without too many whiz bang sorts of effects.

Once your UI is painted and generated in Matisse, have the bindings call your Clojure code where you implement your business logic.

0

精彩评论

暂无评论...
验证码 换一张
取 消