Показаны сообщения с ярлыком scala. Показать все сообщения
Показаны сообщения с ярлыком scala. Показать все сообщения

воскресенье, 15 мая 2011 г.

Promoting dependency management to the web page with Lift framework

Just finished reading Simply Lift chapter about WiringUI. David Pollak is fucking genius!!! He promoted the idea of functional dependency management to web page scope.

Let's imagine you have some variable which introduces lot's of calculations based on it's value. In any full featured functional language one can define dependent values as a function applications that should be done to calculate final value based on dependent ones. This way you can pass around this applications and get actual values every time the function is executed.

With little functional voodoo you can now identify the changes to dependent variables when changing the dependency. And based on that generate a JavaScript doing this changes on the page(based on previously defined structure of variables placement in DOM tree).

Now for the real world example: you have a page with video player and a playlist. Also there is a currently playing item in the playlist. Also the playlist is manageable in a classic way(add, remove, play item).

So now you define that player depends on the current item and links to all playlist management functionality are doing atomic updates to it. Now you wire the stuff together in one place(source code of course) and BAM!!! Everything is working just as expected. It's really that simple(I tryed myself).

Plus you can combine all of that with Lift builtin Comet and create something like a webcast right on the webpage. Anyone just opens up a page an makes update to the playlist switching the currently playing item and everyone viewing it would receive the same live updates via Comet. It's long polling and cheap cause it's using continuations to keep you safe. Or you might want to create rooms of some sort. This also requires not too much code.

Everyone who's interested in Scala or/and functional programming even a little should definitely take a look on that. A little of abstract thinking would help to cut away the Lift specifics and get the main idea.

среда, 16 марта 2011 г.

Urxvt and JLine fix for Home, End keys

I’m getting mad when Java application(especially Scala) with readline functionality powered by JLine in urxvt. Looks like urxvt emits HOME,END keycodes different from ones emmited by Xterm. And JLine in turn is adopted for Xterm and have these values hardcoded in sources. To get the HOME,END keys working as expected in JLine application add following lines to your .Xdefaults:

urxvt*keysym.Home: \033[H
urxvt*keysym.End: \033[F

The idea is to remap the keys to it’s Xterm values. JLine then catches em as expected.

Also according to Scala mailing list JLine version compiled into Scala contains some regression and DEL is working like backspace. This is fixed in latest version of JLine, which will be adopted for Scala in it’s newer versions. 2.9 is coming soon. At least the snapshots are already there.

суббота, 12 марта 2011 г.

Scala Code Swarm

Here comes my first attempt to visualize the history of my favorite functional programming language Scala. When I first saw ‘Twitter Code Swarm’, I decided that I definitely should create one myself. But had no favorite project with really long repo history to experiment with. And even here Scala proved to be handy :) Finally I spent some time to encode the video from generated frames.

Enjoy the video itself

Unfortunately my ATI’s OpenGL is somewhat dark and unreliable. Better quality and longer length video coming soon… Oh and music gonna be heavy for that =)