Hacker News new | past | comments | ask | show | jobs | submit login
Chaos Theory vs Clojure (bestinclass.wordpress.com)
63 points by fogus on Sept 25, 2009 | hide | past | favorite | 8 comments



Awesome quote:

"If you’re on Windows it’s basically the same approach, you just have to start by installing Linux, but afterwards you’ll also get this result in all its animated splendor:"

(Emphasis mine)


It would be funnier if it were true. Instead this would run in the command line.


   (-> #(animate panel) Thread. .start))
>I doubt you’ll ever see such impressive Java Interop mixed with Closures in other languages!

Rhino is pretty impressive too:

  new Thread(function () { print("\nrun"); }).start()


Your Rhino example isn't creating a closure, is it?


Most interesting thing was two links away and unrelated:

http://www.assembla.com/wiki/show/clojure/New_new


I'm not sure if this demonstrates great ability for Clojure.

One of the first programs I ever wrote, when I was still in High School, was a simple simulation of planetary motion using BASIC. For this, I used a naive approximation of Newton's laws. I was disappointed to discover that because of approximation error, my planets all fell into the sun! But the program did put the death-spirals on the screen in black and whie!

My impression is that while mathematical formulas generally aren't that hard to interpolate into any programming language, the art of such interpolation is making sure that arithmetic error and such don't pile up to spoil things.

Given this, Chaos Theory graphics would be great fodder for seeming like you've done something amazing since you don't have to simulate anything correctly, you only have to create a swirl which looks intriguing. Oddly enough, planets orbiting a sun are better since you've got to create a useful simulation with the properties of the original system.


I've always wanted to write a planetary simulator. I think clojure might be a decent language for it, as long as you avoid floating point as much as possible and use clojure's Ratios class instead.

  user=> (type (/ 1 3))
  clojure.lang.Ratio
  
  user=> (* (/ 1 3) 3)       
  1
I'd really like to see an arithmetic macro for clojure to allow infix notation, constants, and lazy evaluation. Something like (arith 2m/s^2) would be crazy awesome.


check out "the structure and interpretation of classical mechanics" by sussmann et al for a whole raft of things like this done in scheme.

I don't see why would you want to stay away from floats, using rationals isn't going to magically fix the numerical errors from approximating derivatives and such.

I believe they develop an automatic differentiation routine in SICM that will actually allow you to make a pretty good planetary motion simulator, i.e one that won't just go horribly wrong if you run it for a few thousand years.

Of course if you're really interested/mathematically inclined one of the best ways to simulate Hamiltonian systems is via iterated maps, not unlike what was in the article. A good (but quite hard) ref to this is "simulating hamiltonian dynamics" by Leimkuhler and Reich.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: