GUI programming

15 views
Skip to first unread message

Monsieur Pinocchio

unread,
Jul 6, 2008, 7:44:56 AM7/6/08
to Clojure
Hi,
    I was wondering what the community thought about GUI programming style in clojure. A few days ago I was looking at javaFX and I was delighted to see the language offering primitives for easily developing GUI applications. JavaFX supports creating objects by declaring them in an object-attribute notation and supports the use of "bindings" to tie different properties of different objects together.
    It seems to me that clojure data structures, esp. the map could be a good fit for the data structure to keep UI state in. However, I was a bit confused about how to fire and handle property change notifications from these maps. In this context, I would like to ask the following questions:
      - Previous Lisps would have had many ways of doing GUI programming. Does somebody remember a particularly elegant style of GUI programming? Does "functional" UI programming even make sense? How about "agent-based" UI programming (given the fact that agents do support sending/receiving notifications)?
      - Is it possible to capture "change" events from clojure data structures? Can clojure data structures be effectively used as the 'Model' in the Model-View/Controller architecture of Java Swing?

--
Pinocchio

Rastislav Kassak

unread,
Jul 6, 2008, 3:45:13 PM7/6/08
to clo...@googlegroups.com
As clojure data structures are immutable, I think it's not the best
idea to use them as model, which is inherently stateful.
I guess much better idea would be to use them together with functions
as state transformers. And to keep state in agents, ref, maybe some
GUI optimized framework.

However my biggest java GUI program was few tens of lines of
experimental JRuby code, so maybe I'm not the best person to guide you
here. :)

Monsieur Pinocchio

unread,
Jul 6, 2008, 9:21:33 PM7/6/08
to clo...@googlegroups.com
On Sun, Jul 6, 2008 at 3:45 PM, Rastislav Kassak <kasou.sk@gmail.com> wrote:

As clojure data structures are immutable, I think it's not the best
idea to use them as model, which is inherently stateful.
I guess much better idea would be to use them together with functions
as state transformers. And to keep state in agents, ref, maybe some
GUI optimized framework.

You're right. GUI programming would require a stateful model so we will have to use one of Vars, Refs or Agents to do the trick. I made a mistake by implying that I could use a map _directly_ as the model. The map would be just a way to convey to the rest of the application about what's happening in the GUI model and vice versa.

I am leaning on agents as a good abstraction for UIs in general its the only abstraction in closure which explicitly models event notification/reception. I am thinking of writing a wrapper on Swing so that I could use clojure's handy data structure for doing the GUI stuff. The other way is to (over?)use proxy for making event handlers and deal with threading issues.

I was hoping to get some pointers at attempts to do GUIs in the functional world. This is my first time with a Lisp so I was hoping a lisper would help me out here :)

--
Pinocchio

Raoul Duke

unread,
Jul 6, 2008, 10:42:35 PM7/6/08
to clo...@googlegroups.com
> I was hoping to get some pointers at attempts to do GUIs in the functional
> world. This is my first time with a Lisp so I was hoping a lisper would help
> me out here :)

if you are looking for the bleeding edge, i like Conal Elliott's
stuff, even if I can't understand most of what he says these days (I
gotta learn math).

http://conal.net/

Matt Revelle

unread,
Jul 6, 2008, 9:29:25 PM7/6/08
to clo...@googlegroups.com
There are some examples of functional GUI libraries here:

The only Lisp GUI library that gets mentioned is McCLIM for Common Lisp (http://common-lisp.net/project/mcclim/).

-Matt

Asbjørn Bjørnstad

unread,
Jul 8, 2008, 8:17:13 PM7/8/08
to Clojure


On Jul 7, 9:29 am, Matt Revelle <mreve...@gmail.com> wrote:
> There are some examples of functional GUI libraries here:http://www.haskell.org/haskellwiki/Applications_and_libraries/GUI_lib...
>
> The only Lisp GUI library that gets mentioned is McCLIM for Common  
> Lisp (http://common-lisp.net/project/mcclim/).

Actually, CAPI from LispWorks gets mentioned a lot by people who
doesn't insist on open-source.
--
-asbjxrn
Reply all
Reply to author
Forward
0 new messages