art with code

2009-10-04

EU MozCamp 2009

Let's try writing something non-trollish for a change, hm? 

So, EU MozCamp 2009. I was there to participate in the HTML5 roundtable (and to show off my new canvas animation demo (~500kB), view source for headache.) It was great visiting Prague and meeting all the web people there, thanks everyone!

Cool stuff: DailyMotion SVG video filters demo, Stratified JavaScript - JavaScript with concurrency primitives, HTML5 location API demos, boat trip on the Vltava. Massive amount of expats present (also massive amount of French.) I think I met people from Bulgaria, Czech, Estonia, France, Germany, India, Ireland, Netherlands, Portugal, Romania, Spain, Sweden, UK and US...

I have also managed to plow through around fifteen pages of my newly-bought sketchbook, mostly at the airport and in the plane. Clouds be fabulous from above. 

Catching my flight home in a couple of hours, feeling pretty tired. I'll add some links to this post on reaching home. 

[edit] Added links.

2009-09-22

Mobile internet speed beats ADSL

Upstream-wise, that is. The Nokia CS-15 HSUPA wireless Internet USB stick has a maximum 10.2 Mbps downstream bandwidth and a 5.76 Mbps upstream bandwidth. You need fiber to beat that upstream, at least here in Finland.

And a Huawei stick doubles the downstream to 21 Mbps. If the latency is low enough and the network infra can take the load, that'd totally kill ADSL.

2009-09-21

Also on the INTERNETS

The final solution to piracy


Books


Ditched the sediment & river books from my reading queue, as the library wanted them back. Replaced them with two writing course -related book-like objects about simulated annealing, in addition to An Introduction to the World's Oceans (hey, 71% of the planetary area can't be wrong, right?) and Climatology - An Atmospheric Science (ooh, a pretty painting on the cover.) Both being introductory textbooks to their subjects.

The oceanography book gets extra points for the oceanography department probably having coated their whole library in tar, supposedly to protect it from the vagaries of the high seas. As a result, there's a smell to the book. There were also a few books from late 1800s and early-to-mid 1900s in the oceanography shelf, which I briefly looked at before putting them back to the shelf, carefully. If something survives a hundred years of students, it must be lucky!

I'm reading these non-CS related textbooks because CS gives me a headache and a neckache and a backache and they're actually interesting. Plus maybe I'll be able to use the knowledge gleaned as a way to slither my way into an outdoors IT job... Oh wait, the plan was to totally spruce up my drawing skills (a couple hours of daily practice actually works, whuda thot) and get an art/graphics job. Well, at least they have lots of pictures to draw.

Maybe a couple hours of daily practice would work for Swedish grammar as well. There's a thought.

Today's quote

"it isn't right for children to steal words"

2009-09-16

Back to programming

I've been hacking a bit on cakejs and canvas recently, making a paper doll animation system. The paper doll -part was actually pretty easy, but now I need tools for making the animations. Which might be less easy. Let's see :)

Also, cakejs is really lacking in the documentation & tutorials -department. I will try and fix that by pasting the code comments to wiki pages. Tutorials might be easy to write by taking the demo page scripts and adding narration.

Still sustaining a drawing routine of 1-2 A4 pages per day, which is awesome. Plein air drawing is a lot of fun and sunshine, and works great as practice. What I should also do is grab a book on machine illustration or some other really constructive ID method of drawing and work through the exercises.

Jogging has plateaued at three one-hour runs per week. I don't know if I should try to push it beyond that as I seem to get knee ache at around the 10 km mark. Maybe it's caused by bad technique? Fix by muscle training to sustain a better posture and lots of intervals to improve running technique?

Added shutdown -h now to root's crontab at one-hour intervals in the evening to boot me off the computer and go to sleep. And... it's working. Two weeks of <9am wakeups already. I had the tendency to latch onto a 25-26h daily rhythm before, which is really not conducive to getting to Swedish class at 9:15am.

2009-09-08

Reading list summer 2009

Started off with some scifi, three novels by Iain M. Banks from his Culture series: Consider Phlebas, Player of Games and Matter, and David Petersen's book of fighting mice; Mouse Guard: Fall 1152. Followed by borrowing the Banks novels to roommate in exchange for Alastair Reynold's Revelation Space, Redemption Ark and Chasm City. Stayed at the family cabin by the lake Saimaa for a month or so, and played the first two stories of Odin Sphere and some hours of Valkyrie Profile 2. On returning home, read Frank Herbert's Dune (courtesy of aforementioned roommate), then raided the university library for a change of pace with World Regions in Global Context. I'm currently reading Coastal Sedimentary Environments and The Practice & Science Of Drawing. After that I have queued up Rivers and Floodplains, and the next three books of Dune.

Now if I could find a monitor that works with the PS2, I could go back to wasting my evenings with games instead of boring myself to death on the computer writing blog posts like this...

2009-07-03

Tomtegebra - a small Haskell puzzle game


Tomtegebra, my project for our summer Haskell lab course, is a small puzzle game that masks abstract algebra with cutesy animals. Your goal is to apply transformations to an equation tree to either make both sides equal or, in some levels, to find a binding for the wanted variable.

The levels are Abelian group axioms (no closure though, I don't know how to do that.) The animals are binary operators, the fruits are variables and the rock is a constant.

Implementation follows: the rendering is done with OpenGL, event handling with GLUT, image loading done with Gdk.Pixbuf, textures created with Cairo and text with Pango. There's a shared AppState record IORef that the GLUT callbacks edit and draw. Draw calls, event handling, image loading and all other icky side-effecty stuff happens in the IO monad, while the actual gameplay core is functional.

I'm using vertex buffer objects for drawing and a wholly Haskell-side transform matrix system, mostly for the heck of it. My matrix math lib is probably somewhere between pretty slow and really slow, as it uses lists of lists to represent the matrices (oh the humanity.)

The whole thing weighs in at around 1200 lines of source code, which sounds about OK for a small project like this. The algebra module is the largest individual part, followed by game rendering and the game logic. The drawing helper libraries are scattered in smaller files, in total they'd be about the same size as the algebra bit.

Haskell-land


Overall, Haskell is nice. I like ghc --make and typeclasses. I don't like fromIntegral. GHC doesn't error on partial pattern matches at compile time, which makes it error-prone (at least if you don't use -Wall.) I had some mysterious run-time crash bugs, and they didn't show where the error happened, which was flummoxing. Debugging by randomly changing things did conquer in the end, though.

And Haskell has the usual statically typed functional language good bits.

I used Haddock and Cabal for documentation and compiling, respectively. In the beginning (read: until yesterday) I was using a build script which was more or less ghc --make *.hs, but now it's all Cabalized and everything. Yay!

Tales of woe


There are odd pauses in the game every couple of seconds (old-generation GC run?) Gtk2Hs doesn't have -prof on Debian, so I haven't been able to profile the thing. The game uses 5-10% CPU to draw at 60fps on my Core 2. Which sounds like pretty much for such a trivial drawing load.

The Haskell OpenGL library is not really OpenGL. It's more a new graphics library that calls OpenGL internally, so you get to relearn the names and syntax of everything. And yet it uses Ptrs as its preferred data structure and the GL numeric types, so you can't just pass it lists of Doubles or other easy Haskell data structures. It's a bit worst of both worlds in terms of user friendliness.

GLUT's callback procedures are exactly the wrong way to go for a functional language. They basically necessitate having shared mutable state. A recursive event loop, Xlib/SDL-style, is probably a better way. At least there you wouldn't have to fool around with IORefs.

eventLoop state = do
ev <- nextEvent
state' <- handleEvent state ev
if quit state'
then return ()
else eventLoop state'


I used only lists and tuples, because all the other Haskell data structures are weird (more like, I don't know them, so better not use them, otherwise I might be forced to learn something *shock, horror*) And that means that I sometimes get to O(n) the O(1) and O(nm) the O(m). Oh well, maybe I go back and try to optimize things with Data.Map and UArray and friends if I ever get the profiler working.

I didn't like Haddock's parser. Writing code examples was a pain because it complained about them not parsing. And it's using ', ", and ` as special characters, so using the less whiny @code example@ requires backslashing like a demented backswordsman. Haddock only shows the type signature for a function, which means that you get documentation like frustumMatrix :: GLfloat -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> GLfloat -> Matrix4x4, which is not very helpful.

Cabal was a bit of a pain to get going, but not all that bad. The documentation didn't really answer my questions and the examples were kinda useless as they focused on a one-file codebase. You get to poke around blind a good bit. Took me around an hour from mkcabal to a working build with data files found at runtime. The problems I had were: 1) Module name and file name must be the same. 2) If you have user-installed libs, you need to do Setup.hs configure --user to add them to the search path. 3) To get the paths for installed data files, you need to import getDataFilename :: FilePath -> IO FilePath from Paths_mypackage.

Blog Archive