FREE BURMA!

( ? , qUeStIoNMaRk )

Seeking for a sustainable amount of chaos. AKA an electronic stream of consciousness about software engineering, open source, life. By Marco Fabbri.

August 25, 2007

A one man band with no fans

Filed under: Uncategorized, music

Week-end… time for a relaxing post, time for listening to some good music.
The title of this post come from the (title of) website of the artists I am listening to right now, Brad Sucks; he’s a damn clever and skilled musician, a really enjoable listening!

His debut album is “I Don’t Know what I am Doing“, it has a (deliberately - the album doesn’t sound anything near scratchy, it’s well produced) lo-fi indie rock style that makes it really catchy, there are a couple of songs you’ll start remember just a few runs. The album has been making to the top ten best-selling albums on Magnatune for a long time (even if the album can be freely downloaded). My favourite songs (available from Brad Suck’s website):
Making Me Nervous
Sick As A Dog
I Think I Started A Trend

Brad Sucks - I Don't Know What I'M Doing

At Brad Sucks on Magnatune his own albums and derivative works are available for purchase, licensing and full listen preview.

For those “remixically oriented” derivate works (Mixter Two: CD1, CD2) contain remixes from some talented indipenendent internet remixers (the artwork is quite impressive too).

Brad Sucks: Mixter Two

Bottom line: take a listen, you won’t regret!

August 22, 2007

Erlang in the evening

Let’s unveil the (not so) misterious bug from yesterday Erlang post…
The auto-increment counter controller receives two kind of messages:

a start message which starts the timered auto-increment;
a stop message which stops the auto-increment.

An implicit assumption on the sequence of messages has been made; no two following messages are equal, i.e. assuming the auto_counter process starting as inactive every message history is produced by the following grammar:

S, scope
S -> start A
A -> stop, S | stop

What happens if the auto_counter process starts as inactive and the message history is of the kind start, stop, stop, start?
When the first start message is received the process starts incrementing (the message match the pattern in the receive expression in the inactive auto_counter function clause (auto_counter(inactive, CounterP, DeltaT)). The process stops incrementing when the first stop message (the message matches the stop pattern in the receive expression and the inactive auto_counter function is called) . Hence, when the second stop message arrives, the function clause being evaluated is auto_counter(inactive, CounterP, DeltaT) which holds indefinitely until a start message is received; bottom-line the second stop message is left in the process’ message box. When the second start message it matches the start pattern and the active auto_counter function gets called (remember: the second stop message is waiting in the message box for a “disaster” to happen :-) ). At this point as the active auto_counter function is being evaluated (which comprises a receive start expression) the process receives the second stop message which causes the auto-increment to stop. Is this behaviour supposed to be correct?
The last post didn’t go into a deep analysis of the problem and its requirements, but now has the problem is in the spotlight time has come to take a decision, the actual implemented behaviour is… WRONG! (an assumption holding true for fairly high percent of the programs being developed). I (the self-appointed project leader) expect the auto-increment process to filter out every stop message received when stopped and every start message when started. This requirements sounds a lot like having a filter on the messages sent to the auto_counter process, so let’s define a process with this capability:

Two “states”, active/inactive which translates in two functions clauses: increment_filter(active,...), increment_filter(inactive,...);
increment_filter(inactive,...) discards stop messages (which means after receiving one calls increment_filter(inactive,...)) and when a start message is received a start message is sent to the auto_counter process and increment_filter(active,...) gets called;
increment_filter(active,...) discards start messages (which means after receiving one calls increment_filter(active,...)) and when a stop message is received a stop message is sent to the auto_counter process and increment_filter(inactive,...) gets called;
knowledge of the auto_counter process identefier.

Here it follows the straightforward implementation:

autoinc_filter(active, Auto_counterP) ->
    receive start ->
            autoinc_filter(active, Auto_counterP);
            stop ->
            Auto_counterP ! stop,
            autoinc_filter(inactive, Auto_counterP)
    end;
autoinc_filter(inactive, Auto_counterP) ->
    receive stop ->
            autoinc_filter(inactive, Auto_counterP);
            start ->
            Auto_counterP ! start,
            autoinc_filter(active, Auto_counterP)
    end.

The impact of the change on the previously developed system (even in the case that it was running) is minimal: only a new process is required to be spwaned; this definetely makes the case for true incremental development and it resembles a kind of living system (interesting reading: The Pinocchio Problem), capable of gracefully growing and evolving.

Another approach to the fixing of the spotted bug would have been discarding the “un-interesting” messages right into the auto_counter function:

auto_counter(active, CounterP, DeltaT) ->
        Activity = receive
                stop -> inactive;
                start -> active
        after DeltaT ->
                CounterP ! inc,
                active
        end,
        auto_counter(Activity, CounterP, DeltaT);
auto_counter(inactive, CounterP, DeltaT) ->
        receive
            start -> auto_counter(active, CounterP, DeltaT);
            stop  -> auto_counter(inactive, CounterP, DeltaT)
        end

This solution seems at first sight correct: althougth the change at the inactiveclause is rather simple, the change at the active clause is trickier enough you end up with a failing system. Every time a start message arrives the timeout gets reset, so the increment doesn’t happen every Delta and the timing is rather faulty; if the arrival rate of the “un-interesting” messages is high enough, let’s say greater than 1/(DeltaT-1) , the counter gets never incremented no matter how long the process keeps on evaluating the auto_counter(active,...) function. This ending osservation is purposed to point out that if you try to twist an inherently counterrent problem in a sequential way the odds you end up screwed are quite high. Erlang encourages to keep concurrent things concurrent, and this is, in my humble opinion, an important point (in software systems engineering) that Erlang gets it right. The world is parallel, better to keep it in mind ;-) .

GNOME - ten years of freedom

Filed under: open source, linux

GNOME Community Celebrates 10 Years of Software Freedom, Innovation and Industry Adoption.

I am a GNOME kind of guy (far from me starting any GNOME vs KDE flame-war, just a matter of personal taste) so the least I can do is to wish a:

Happy Birthday to the whole GNOME community!

Ubuntu Hug Day, Happy 10th Birthday GNOME!

Ubuntu is dedicating today an Hug Day to GNOME, focusing on the collaboration between the two projects, by improving the quality of bug reports and ensuring consistency between Launchpad and Bugzilla reports.

For those “internet-archeologically” inclined “The GNOME Desktop project announcement” by Miguel de Icaza (the young hacker who got this great project started and keeps on with the hard work for GNOME neverending improvement, thank you Miguel!).

August 21, 2007

Htmlize your * code buffer

Filed under: weblog, programming

I attempted to use the htmlize package for Emacs as described in Htmlize your Erlang code buffer, but I managed to get the code syntax hilighted only in the preview window, once the post gets published the syntax hilighting is no more effective. Any suggestions?

Erlang in the morning

Due to my interest in concurrent and parallel programming I recently started investigating the Erlang programming language, reading and practicing the book by Joe Armstrong "Programming Erlang, Software for a Concurrent World" (the book is awesome, easy and involving writing style, or in editor’s words: "Joe I want you to imagine you’re sitting at a terminal with your friend beside you, explaining how things work" - more on the book). Erlang is a concurrency oriented programming language (based on a mix between actors and functional paradigms) meaning you get first class (and really well engineered) abstractions for process and process comunication, pattern matching, higher order functions, and absolute lack of shared variables, processess communicate by (asynchronous) message passing. Coming from an object oriented (imperative) programming language (e.g. Java, C#) Erlang just feels kind of esoteric and alien, but having a sound Prolog background you can advance in the process of learning quite easily (time to express some deep appreciation for prof. Viroli’s Prolog lessons from "Computational Langauges and Models" graduate course). To have a quick grasp of the language and of some features I value most, let’s take a look at the code that realizes a counter in Erlang (who doesn’t love counters? :-) ). Personal note: I found the "Hello Counter" a really nice example to start exploring the computational landscape of a programming paradigm; it’s basic and quite universal (it resembles a Minsky Machine). This is a function modelling a cyclic counter:

counter(Value, EndVal) -> 
    NewValue = receive
        inc ->
                (Value + 1) rem EndVal;
        {get_value, PID} -> 
                PID ! {value, Value},
                Value
        end,
    counter(NewValue, EndVal).

The function has two arguments:

  • Value represents the state of the counter and it is passed through the (tail) recursive function call;
  • EndVal is the limit for the cyclic counter;
and receives two kind of messages, through the use of the communication primitive receive (which is blocking, i.e. it stops the execution flow until a message matching one of the specified patterns is received):
  • an inc atom which causes the increment of the counter value argument of the recursive function call. Here you have to keep in mind that receive evaluates to the value of the expression following the -> of the pattern matching the message. The expression following the inc pattern is the expression that represent the next value of a cyclic counter: value(n+1) = (value(n) + 1) % limit rem is the infix operator for the modulo operation. Hence, in the case an inc message is received, the variable NewValue is unified with the value of the previous expression, i.e. the counter increments;
  • a {get_value, PID} tuple where get_value is an atom and PID is a variable unifying with the second field of the tuple, the identifier of the process requesting the current counter value. Here the expression following the -> is made of two expressions: in the first one the current counter value is sent (through the ! operator) to the requesting process in a tuple of the kind {value, Value}, the second simply evaluates to the current counter value, which NewValue is unified to (otherwise NewValue would have been unified with {value, Value}, being that the last expression). A note on !: contrary to receive it is not blocking, hence if you want to create a rendezvous you have to send a request message and then wait for an answer message.
The last expression is a tail recursive function call, whith NewValue as value of the counter. Now, after saving the code in the counter module, a counter process can be spawned using the the counter function as the process body (the variable CounterP is unified to the process identifier of the spawned process):

CounterP = spawn(counter, counter, [0,42])

incremented by sending a message:

CounterP ! inc

and questioned on its current value (the self() function evaluates to the process identifier of the calling process):

CounterValue = CounterP ! {get_value, self()}

The cyclic counter here defined can be quite puzzling at first (for those who come from an OO background) but has some interesting properties about concurrency and distribution due to the Erlang programming model/platform, hereafter one to cath them all: this program is yet ready to be run as part of a concurrent/distributed system. As a proof of concept to this bold statement let’s implement an auto-increment controller (optionally remote) for the cyclic counter (auto-increment controller is a pompous definition for introducing a start/stop auto-increment cycle). The controller can be thought as another process incrementing the counter on a given time interval, switched on/off by sending it start/stop messages. Through the use of pattern matching in function definition different behaviour can be distinguished, id est the function auto_counter can have multiple clauses for different patterns of its arguments, as follows:

auto_counter(active,…) -> incrementig the counter every delta time until a stop message is received auto_counter(inactive,…) -> doing nothing until a start message is received
Here it follows the actual code for the (remote) auto-increment counter controller (the do X until a Y message is received is modelled through the use of a complete receive clause which comprises after T -> Expression):

auto_counter(active, CounterP, DeltaT) ->
        Activity = receive
                stop -> inactive
        after DeltaT ->
                CounterP ! inc,
                active
        end,
        auto_counter(Activity, CounterP, DeltaT);
auto_counter(inactive, CounterP, DeltaT) ->
        receive
                start -> auto_counter(active, CounterP, DeltaT)
        end.

The system just developed is "distribution ready": the counter process and the auto-increment process can be in the same Erlang runtime, in different runtimes on the same machine, in different machines, no change in their definition is needed to go through these different scenarios. This does not happen because the distribution/concurrency of the system is hide by some magic trickery trying to over-smart the programmer in believing remote entities could be considerated as near as local (the Fallacies of Distributed Computing), but it does happen because Erlang builds on the assumption that (from "Programming Erlang - Sofware for a Concurrent World":

The world is parallel If we want to write programs that behave as other objects behave in the real world, then these programs will have a concurrent structure.
This is just a small taste of Erlang and there is much more in the reliance/healing/scalability capabilities (granted by OTP), however it should be clear that: high-level abstractions are offered (and needed) to capture in a syntethic and powerful manner problems: communication primitives, pattern matching, first-order functions, list comprehensions; (very cheap and lightweight) Processes are first-class citizens, and systems are "naturally" modelled as concurrent; avoiding side effects (as long as it is possible… more on this in next posts) leads easens scalabilty and load capability. A last note on the presented program, the auto_counter function does some over-restrictive assumption on the sequence of messages it receives (exercise left to the reader :-) : try to figure out what the problem is) tomorrow a solution will be proposed. Ending a special thank to prof. Alessandro Ricci and Giulio Piancastelli for the tolerance shown towards my tendency to "express" (face-to-face/online) every random thougth about concurrency happening to strike my brain. (more…)

August 20, 2007

New Skype Ring (CTU like)

Filed under: television, fun, geek

Transcoding the mp3 file attached to Beggi’s post on his new IP phone (my inner geek is quite envious at the moment) to a wav file I managed to substitue the classical skype ring tone with the one of CTU phones from 24. Then I changed also my mobile ring tone, just to rember that “Jack Bauer could strangle you with a cordless phone” (source: Top One Hundred Facts about Jack Bauer).

The CTU IP Phone ring tone in wav format.

Cisco Unified IP Phone 7970G

Motivational Posters

Filed under: engineering, software, fun

I found on flickr three great “motivational” posters by Bill De Hora. This one should be in every introductory book/course on software engineering/programming:

I Pity the fool who does'nt write test cases!!

This should be in front of the entrance of the software lab/office:

I pity the fool who breaks the BUILD!

And the last one is definetely my favourite:

I love when a build comes together

Caffeine, Beavers and Squirrels

Filed under: fun

The comic strip from Dilbert “COFFEE SWILLING BEAVER” reminded me of an extraordinary funny character from the animation movie “Over the Hedge“: the hyper-nervous squirrel Hammy. The whole-world-time slowing down and stopping is just tremendously amusing, so I youtubbed for that video and surprise, surprise…


August 18, 2007

Current Zeitgeist: The Long Tail

Filed under: weblog, internet, web

Zeitgeist is a word mutuated from philosophy (Hegel - Phenomenology of Spirit) meaning “the spirit of the age”, i.e. the set of fundamental paridigms of society/humanity in a given time.
Chris Anderson’s book “The Long Tail” contains such a fundamental paradigm that is a compelling reading to understand current Zeitgeist.

“The Long Tail” shows how the statistical distribution of sales in online services (such as Amazon, Rhapsody, iTunes, Netflix and others) differs from “traditional” mass retailers (such as Wal-Mart), i.e. “the combined value of the millions of items that only sell in small quantities equals or even exceeds the value of a handful of best-sellers”.
At the root of the phenomenon is the end (or the slack) of constraints such as the shelf space and the emergence of tools (e.g. recommendation engine) to filter out the massive quantity of goods at end of the tail.

The author mixes an useful historical analysis, an overview of the economic context (with a nice recap of how mass distribution usally works), and a deep grasp of hard data (being everything digitally recorded nowadys data is rather abudant) to convey a detailed understanding of the phenomenon at stake. The analysis of the main forces behind the Long Tail (democratization of the production tools, democratization of distribution tools and supply-demand connection) is crystal clear as the 98 percent rule and the “death” of Pareto rule.
The final prescriptions on how to pursue a Long Tail enabled business are rather brief but that goes far beyond the book’s sake. Despite the briefness the Long Tail rules are a fair and concise set of pragmatic advices.

The book has a plethora of further online resources:
- the author’s blog about the book: The Long Tail Blog
- an introducing article about The Long Tail, where the term has been coined.
- a comprehensive Wikipedia entry about The Long Tail.

Bottom-line: a highly recommended reading ;-)

August 12, 2007

Second Life - YouTube Style

Filed under: web, fun

Quite funny… (via Tim Bray)


Get free blog up and running in minutes with Blogsome | Theme designs available here