Pong (130 lines in Clojure)
jng.imagine27.com
Pong (130 lines in Clojure)
1–10 of 10 posts
Re: Pong (130 lines in Clojure)
#2Re: Pong (130 lines in Clojure)
#3Re: Pong (130 lines in Clojure)
#4Ugh, the code is ugly :/
Re: Pong (130 lines in Clojure)
#5(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)
#6Ugh, the code is ugly :/
It could be cleaned up some, but due to all the awt interaction, it needs to be that way.
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)
#7Re: Pong (130 lines in Clojure)
#8Earlier quoted context omitted.
It could be cleaned up some, but due to all the awt interaction, it needs to be that way.
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…
Re: Pong (130 lines in Clojure)
#9Earlier quoted context omitted.
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…
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)
#10In 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.)