News for hackers. Stuff that matters.
Re:Pong (130 lines in Clojure) by llimllib on Saturday September 12, 2009 @11:49PM (#819789)
In python, 30 lines: http://billmill.org/pong.html

(edit: I just mean to offer for comparison to this program, not in some sort of macho programming-language pissing contest sense.)

Re:Pong (130 lines in Clojure) by swannodette on Sunday September 13, 2009 @02:19PM (#820346)
Of course this isn't much of a comparison at all :) You're using NodeBox to abstract away much of the pain of event handling and drawing to the screen. A more interesting and fair comparison would be something like using wxPython + pycairo.
Re:Pong (130 lines in Clojure) by cubicle67 on Sunday September 13, 2009 @12:14AM (#819819)
Interestingly, the original as written in zero lines of code (It was 'programmed' as a ttl logic circuit)
Re:Pong (130 lines in Clojure) by omouse on Saturday September 12, 2009 @10:11PM (#819726)
Ugh, the code is ugly :/
Re:Pong (130 lines in Clojure) by francoisdevlin on Saturday September 12, 2009 @10:46PM (#819753)
It could be cleaned up some, but due to all the awt interaction, it needs to be that way.
Re:Pong (130 lines in Clojure) by arb on Saturday September 12, 2009 @11:55PM (#819794)
It's unnecessarily ugly.

There's a lot of unnecessary state, where refs are initialized to nil, then only updated to a fixed value. There's side effects in transactions (mostly around the Timer). Not one function is defined with parameters, which ought to raise alarms. The flow resembles Java code rewritten in Clojure, rather than a functional Clojure program.

Besides that, much of the code is either non-idiomatic or primitive: the 'ns' macro should be used instead of 'import'; 'alter' can be better than 'ref-set'; 'when' is better than 'if' without an else form; the proxy identation is wrong.

The AWT/Swing interaction is excusable, as is the poor readability given the brevity constraint for this exercise, but there are still some elementary problems.

Re:Pong (130 lines in Clojure) by spuz on Sunday September 13, 2009 @02:53AM (#819903)
I'm trying to learn Clojure at the moment and pong seems like a decent real world example program to learn from. I'd love to see this code rewritten 'properly' with all these suggested improvements.
Re:Pong (130 lines in Clojure) by tsally on Sunday September 13, 2009 @08:21AM (#820053)
There were some suggestions posted on the Clojure mailing list: http://groups.google.com/group/clojure/msg/e091a732e9190afb?...
Re:Pong (130 lines in Clojure) by jcw on Saturday September 12, 2009 @09:15PM (#819682)
Just today I was tinkering with dreamscheme and its SDL hooks, thinking about writing a pong clone, wondering if it would gain any attention after Haskell pong has.