4

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 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?

4
  • 1
    Every time I hear the words Expressive or Elegant these days I cringe--they generally equate to "Cryptic" and "Easy to write, hard to read and maintain". Commented Nov 12, 2010 at 0:39
  • Heh, I see your point. But this is code that will be used for personal use only so I don't really worry to much that I'll come back to it in ten years only to realize that I have no clue what I did back then. And for me the LISP-syntax is more expressive in the sense that it makes more sense to me when writing a function than it does in C# :) Commented Nov 12, 2010 at 0:43
  • 2
    @Bill K Lisp code is not cryptic and its not harder to maintain. In the end you will be much happier to maintain 100 loc in Clojure then 500 lines of java boilerblait that is split of in 30 diffrent files. Lisp code is great people are just not used to it. Commented Nov 12, 2010 at 1:19
  • @nickik I agree, but then I don't use java boilerplate (absolutely against it). If you use boilerplate in Java you should try harder. My java code ends up being less "Elegant" and more explicit which I personally prefer. Anything that's not explicit means it's going to confuse someone at some point. Everything you DO should be in your code and should be as readable as the written word, even if it takes twice as long to write, writing isn't the problem, it's reading, maintaining and updating that must be understandable. Commented Nov 12, 2010 at 20:44

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Infact the miglayout module makes it very easy to do Swing layouts in Clojure, even easier than Java. Check out a Swing UI I wrote in Clojure.
1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.