Re: Another ClojureScript app in the wild

2011-08-21 Thread Stuart Campbell
Ha! I was considering doing this exact same thing.

I'm working on a vanilla js version that I was considering porting to cljs.
It might be interesting to compare implementations:
https://github.com/harto/pacman

Thanks for sharing,
Stuart

On 18 August 2011 08:00, Matthew Gilliard matthew.gilli...@gmail.comwrote:

 I've been playing around writing a fun little ClojureScript project -
 it's a bit different, so I thought you might like to see it:

  http://mjg123.github.com/pacman/pacman.html

 As I was feeling my way quite blindly through ClojureScript and
 gClosure I have let the code get into a bit of a mess and I don't
 think I'll really work on it much more.  I have learned an awful lot
 though (which was the main objective) - my main lessons are:

  - ClojureScript is awesome.  The performance and stability of it are
 really astounding.  Really great work guys.
  - Debugging a ClojureScript app is hard.  I never figured out how to
 get js/console to work.  My best solution was to compile  run very
 often, so that errors were caught quickly.  Better yet would have been
 thorough testing ;)

  - it *is* possible to write a game with no mutable state (well, I use
 an atom to hold the most-recently-pressed key, but apart from that...
 The state-of-the-world datastructure is immutable)

  - Some functions missing from ClojureScript which surprised me: range, int
  - Some functions behave differently between Clojure and ClojureScript
 (due to underlying platform differences): mod

  - Testing is very important.  The gClosure jsunit stuff looks nice
 but I'd love a midje-like API for it.

 Browser-compatibility:  Chrome - OK, Firefox 6 - sometimes crashes
 with too much recursion, IE/Safari - Forget it.

 Happy to answer any questions, otherwise I'll be over here hacking
 some Clojure   :)

  Matthew

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Another ClojureScript app in the wild

2011-08-18 Thread Sam Aaron
Very cool! Now the logic of pacman is in a form I can easily read :-)

Out of interest, do you know why it only works in Chrome? Doesn't the closure 
library do any work to shield you from from the browser differences, or is it 
simply a performance issue with the Chrome js engine the only one operating 
fast enough to smoothly render the game?

Sam

---
http://sam.aaron.name

On 17 Aug 2011, at 23:00, Matthew Gilliard wrote:

 I've been playing around writing a fun little ClojureScript project -
 it's a bit different, so I thought you might like to see it:
 
 http://mjg123.github.com/pacman/pacman.html
 
 As I was feeling my way quite blindly through ClojureScript and
 gClosure I have let the code get into a bit of a mess and I don't
 think I'll really work on it much more.  I have learned an awful lot
 though (which was the main objective) - my main lessons are:
 
 - ClojureScript is awesome.  The performance and stability of it are
 really astounding.  Really great work guys.
 - Debugging a ClojureScript app is hard.  I never figured out how to
 get js/console to work.  My best solution was to compile  run very
 often, so that errors were caught quickly.  Better yet would have been
 thorough testing ;)
 
 - it *is* possible to write a game with no mutable state (well, I use
 an atom to hold the most-recently-pressed key, but apart from that...
 The state-of-the-world datastructure is immutable)
 
 - Some functions missing from ClojureScript which surprised me: range, int
 - Some functions behave differently between Clojure and ClojureScript
 (due to underlying platform differences): mod
 
 - Testing is very important.  The gClosure jsunit stuff looks nice
 but I'd love a midje-like API for it.
 
 Browser-compatibility:  Chrome - OK, Firefox 6 - sometimes crashes
 with too much recursion, IE/Safari - Forget it.
 
 Happy to answer any questions, otherwise I'll be over here hacking
 some Clojure   :)
 
 Matthew
 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Another ClojureScript app in the wild

2011-08-18 Thread Matthew Gilliard
 Very cool! Now the logic of pacman is in a form I can easily read :-)
  I assume you are referring to the gameinternals post not my code !

I do not know why it only works in Chrome.  The error too much
recursion is confusing.  It happens before the game is rendered so I
suspect it's in the code which parses the board.  The only explicit
recursion I do is my implementation of (range) here:
https://github.com/mjg123/pacman/blob/gh-pages/src/pacman/board.cljs
- but that uses (recur).  There's also the nested for loop in that
same file, I have no idea how (for) works internally.  The gameloop
uses a javascript timer-with-callback to call itself so that won't
consume stack space.  Another thing is that it seems to be machine
dependent - it works fine in ff6 on my work pc but not on my (much)
older home PC.

There are also rendering bugs in Firefox which seem to be caused by
SVG arc-segments with negative radius - I assume this is just an
implementation difference in a grey area of the spec.

If there's interest I can try to pare down the code to a minimal case
which throws the too much recursion error?

  mg



On Thu, Aug 18, 2011 at 8:04 AM, Sam Aaron samaa...@gmail.com wrote:
 Very cool! Now the logic of pacman is in a form I can easily read :-)

 Out of interest, do you know why it only works in Chrome? Doesn't the closure 
 library do any work to shield you from from the browser differences, or is it 
 simply a performance issue with the Chrome js engine the only one operating 
 fast enough to smoothly render the game?

 Sam

 ---
 http://sam.aaron.name

 On 17 Aug 2011, at 23:00, Matthew Gilliard wrote:

 I've been playing around writing a fun little ClojureScript project -
 it's a bit different, so I thought you might like to see it:

 http://mjg123.github.com/pacman/pacman.html

 As I was feeling my way quite blindly through ClojureScript and
 gClosure I have let the code get into a bit of a mess and I don't
 think I'll really work on it much more.  I have learned an awful lot
 though (which was the main objective) - my main lessons are:

 - ClojureScript is awesome.  The performance and stability of it are
 really astounding.  Really great work guys.
 - Debugging a ClojureScript app is hard.  I never figured out how to
 get js/console to work.  My best solution was to compile  run very
 often, so that errors were caught quickly.  Better yet would have been
 thorough testing ;)

 - it *is* possible to write a game with no mutable state (well, I use
 an atom to hold the most-recently-pressed key, but apart from that...
 The state-of-the-world datastructure is immutable)

 - Some functions missing from ClojureScript which surprised me: range, int
 - Some functions behave differently between Clojure and ClojureScript
 (due to underlying platform differences): mod

 - Testing is very important.  The gClosure jsunit stuff looks nice
 but I'd love a midje-like API for it.

 Browser-compatibility:  Chrome - OK, Firefox 6 - sometimes crashes
 with too much recursion, IE/Safari - Forget it.

 Happy to answer any questions, otherwise I'll be over here hacking
 some Clojure   :)

 Matthew

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Another ClojureScript app in the wild

2011-08-17 Thread Matthew Gilliard
I've been playing around writing a fun little ClojureScript project -
it's a bit different, so I thought you might like to see it:

  http://mjg123.github.com/pacman/pacman.html

As I was feeling my way quite blindly through ClojureScript and
gClosure I have let the code get into a bit of a mess and I don't
think I'll really work on it much more.  I have learned an awful lot
though (which was the main objective) - my main lessons are:

 - ClojureScript is awesome.  The performance and stability of it are
really astounding.  Really great work guys.
 - Debugging a ClojureScript app is hard.  I never figured out how to
get js/console to work.  My best solution was to compile  run very
often, so that errors were caught quickly.  Better yet would have been
thorough testing ;)

 - it *is* possible to write a game with no mutable state (well, I use
an atom to hold the most-recently-pressed key, but apart from that...
The state-of-the-world datastructure is immutable)

 - Some functions missing from ClojureScript which surprised me: range, int
 - Some functions behave differently between Clojure and ClojureScript
(due to underlying platform differences): mod

 - Testing is very important.  The gClosure jsunit stuff looks nice
but I'd love a midje-like API for it.

Browser-compatibility:  Chrome - OK, Firefox 6 - sometimes crashes
with too much recursion, IE/Safari - Forget it.

Happy to answer any questions, otherwise I'll be over here hacking
some Clojure   :)

  Matthew

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Another ClojureScript app in the wild

2011-08-17 Thread Kevin Lynagh
Hi Matthew,

Have you tried console.log() as

(.log js/console is anybody out there?)

That works for me currently.
When I first started in ClojureScript I had trouble calling
console.log() because it was a native code function and it couldn't be
called with JavaScript's .call(this, args) form, so I defined a
wrapper in JavaScript manually:

window.p = function(x){console.log(x); return x;}


On Aug 17, 3:00 pm, Matthew Gilliard matthew.gilli...@gmail.com
wrote:
 I've been playing around writing a fun little ClojureScript project -
 it's a bit different, so I thought you might like to see it:

  http://mjg123.github.com/pacman/pacman.html

 As I was feeling my way quite blindly through ClojureScript and
 gClosure I have let the code get into a bit of a mess and I don't
 think I'll really work on it much more.  I have learned an awful lot
 though (which was the main objective) - my main lessons are:

  - ClojureScript is awesome.  The performance and stability of it are
 really astounding.  Really great work guys.
  - Debugging a ClojureScript app is hard.  I never figured out how to
 get js/console to work.  My best solution was to compile  run very
 often, so that errors were caught quickly.  Better yet would have been
 thorough testing ;)

  - it *is* possible to write a game with no mutable state (well, I use
 an atom to hold the most-recently-pressed key, but apart from that...
 The state-of-the-world datastructure is immutable)

  - Some functions missing from ClojureScript which surprised me: range, int
  - Some functions behave differently between Clojure and ClojureScript
 (due to underlying platform differences): mod

  - Testing is very important.  The gClosure jsunit stuff looks nice
 but I'd love a midje-like API for it.

 Browser-compatibility:  Chrome - OK, Firefox 6 - sometimes crashes
 with too much recursion, IE/Safari - Forget it.

 Happy to answer any questions, otherwise I'll be over here hacking
 some Clojure   :)

   Matthew

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en