Settings

Theme

Less painful GUIs in Clojure - Talk

skillsmatter.com

45 points by scarredwaits 14 years ago · 13 comments

Reader

scarredwaitsOP 14 years ago

Project page: https://github.com/stathissideris/clarity

Jach 14 years ago

Looks worthwhile to try out. I've also used Seesaw ( https://github.com/daveray/seesaw ) which was pretty enjoyable.

roryokane 14 years ago

I think the project logotype, “cλarity”, is really bad. It looks like “charity”, and not like “clarity” – it will confuse Googlers who have only seen the logo.

teyc 14 years ago

I've always wanted to learn Clojure but found the curve a little too steep. The way you turn something as stuffy as Swing into JQuery-style code and stylesheets, that is so amazing. If only there were more time to learn stuff like this.

Are most of these implemented using macros?

  • scarredwaitsOP 14 years ago

    The components are constructed using the (make) macro, yes, and all the listener stuff that I explain is also done with macros. The selectors also use a very simple macro that makes the syntax a bit lighter (so instead of saying "and-matcher" you can just say "and"), but the mechanism is very composable, you can use your own custom functions in combination to the existing matchers.

    The rest is all functions!

    • moomin 14 years ago

      As a supplement to this for non-Clojure users. You can make an amazingly composable system using pure functions. The point at which you can't is when you want to do something flash that involves a construct (called form) that isn't a function itself. For instance, a variable declaration isn't a function, nor is a type declaration.

      To do the kind of magic Stathis has done here requires macros, but not many. I've been hacking Clojure for nearly two years without feeling the need to write one. (That changed two weeks ago.)

  • breckinloggins 14 years ago

    For some reason I found it was easier to learn a little Common Lisp first before moving to Clojure. There are a few reasons for this, I think:

    - CL has been around so long, there are TONS of good books and online documentation. Clojure literature is just starting out, really

    - Clojure places a strong emphasis on functional programming. I have no doubt that this was the right decision, but trying to wrap your head around Lisp AND FP at the same time is... well... I hope you have plenty of headache medication because your brain's gonna hurt. CL is at home in the imperative and OOP style, so you can get your Lisp on first, then get hip to the functional jive. A good thing about all Lisps though is that you naturally end up writing most things in a functional style anyway. It just kinda happens.

    - It's a bit unsettling to learn lisp by learning Clojure if you still have a bad taste in your mouth when it comes to Java. When you use CL, you know you're on a pure Lisp platform, so when it comes time to learn Clojure you'll just "know" when you're doing something in idiomatic Clojure/Lisp vs punting to Java.

    - Clojure has more native data structures than Common Lisp (by that I just mean more homoiconic data structures, I'm aware that CL actually has arrays and hashtables and such). This is much better, IMO, from a practical perspective, but might get in the way when you're trying to grok the philosophical purity of Lisp.

    So my advice is to start with Common Lisp and then move to Clojure. Specifically:

    1. Read "Land of Lisp" (http://landoflisp.com/). It's a gentle introduction to Lisp and it's fun.

    2. Read "Practical Common Lisp" (http://www.gigamonkeys.com/book/) and have fun with the "practicals". I really love this book because you build kind of "real stuff" and it helps tie all the concepts together.

    3. Read and try to understand pg's "On Lisp" (http://www.paulgraham.com/onlisp.html). It gives you a much better take on what makes Lisps so much more powerful than other programming languages.

    4. Watch Rich Hickey's talks on blip.tv (http://blip.tv/clojure). I would recommend watching the "Clojure for Java Programmers" talks first, then the "Clojure for Lisp Programmers". You'll need to budget about 5 - 6 hrs to watch all four videos. You probably don't want to watch the latter until you know things like what a Lisp-1 is vs a Lisp-2, what "homoiconic" means, and the difference between a macro and a reader macro. I'm not saying you need that knowledge specifically for the talk, just that if you know what those all mean then there's a good chance you'll get a lot of value out of the talk.

    5. Install Clojure and play around with it. I liked trying to port the stuff from Land of Lisp and Practical Common Lisp to Clojure as it got me on firm footing quickly. For the former, take a look at this StackOverflow post: (http://stackoverflow.com/questions/5363393/rewriting-wizard-...) to get started. Then, head over to PCL->Clojure (http://thinkrelevance.com/blog/2008/09/16/pcl-clojure.html) for help in converting the CL practicals over to Clojure.

    6. Get idiomatic by reading good Clojure code. I recommend the [Clojure source](https://github.com/clojure/clojure) itself as well as Compojure (https://github.com/weavejester/compojure) to get started.

    Finally, a note on development environments: just use whatever works for you. I prefer Emacs, but note that getting Clojure working well with Emacs is slightly more difficult than getting CL working well with Emacs. This is mainly because you can run into dependency issues and out of date packages fairly easily. However, if you get Emacs up and running with Common Lisp through SLIME (http://common-lisp.net/project/slime/) and enable paredit (http://www.emacswiki.org/emacs/ParEdit) and all that good stuff, you'll have almost zero learning curve developing Clojure in Emacs using swank-clojure (https://github.com/technomancy/swank-clojure).

    If you just want to play around with Clojure quickly and still have SOME semblance of an IDE that understands Lisp, try clooj (https://github.com/arthuredelstein/clooj). It's a bit bland on the looks side and low on features, but it gives you parenthesis matching and a nice REPL so it's a good way to play around with Clojure without feeling committed.

    • teyc 14 years ago

      Thanks for such a detailed reply.

      I had briefly met #1, #2, parts of #3, done #4. I think I've been spoilt by python.

      Maybe I just need to try to do some real work on Clojure and pair with someone who knows.

      • breckinloggins 14 years ago

        I've found that in order to really pick up a new language, paradigm, library, or platform, I HAVE to do some real work. I can't just sit there and start typing up something. Some people like Project Euler as their own rosetta stone for this kind of thing, but I don't.

        I always need tools or little one-off programs so I forced myself to write them in Common Lisp and then Clojure and it really helped me.

skatenerd 14 years ago

I don't know much about interoperation between clojure and java, but wouldn't it make more sense to build a java gui which makes calls to some sort of clojure backend?

cswetenham 14 years ago

Embedded Vimeo videos never seem to play for me, and the video is apparently private on Vimeo so I can't view it there either.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection