Thursday, September 27, 2007

Embedding Vimagi

Dear reader, I have good news. The internet is finished. The missing link was finally implemented.

You can now embed your Vimagi paintstream in any web page :)

All you have to do is add the following to your HTML, replacing [USERNAME] with your Vimagi username:

My Vimagi PaintStream


Tuesday, September 25, 2007

Great Concurrency -> Better Webapps

I've been asked a few times: Is concurrent programming really useful for web developers? Web servers already handle client requests in different threads/processes, so application code doesn't need to use concurrency explicitly, right?

My opinion is that althought it's possible to write many database-driven web apps without using concurrency, concurrency can still be useful.

Vimagi has some real-time features in that rely heavily on concurrency, but it also helps in a more common scenario: speeding up page loads.

In Vimagi, every time someone views a painting or a user profile, a SQL query is executed to increment the view counter for that page. This is more-or-less what the controller code does:

show(A, Id) ->
painting:increment([num_views], {id,'=',Id}),
Painting = find_id(Id),
{data, Painting}.

This caused a problem. When traffic increased, the 'increment' function, which executes an UPDATE statement in the database, started performing poorly, thereby noticeably slowing down page loads. Occasionally, it even timed out after 5 seconds, showing an error screen to the user.

I increased the timeout to 20 seconds. This helped avoid the error screen, but the response time was still too long.

Erlang made this almost too easy to fix. All I had to do was change

painting:increment([num_views], {id,'=',Id})


painting:increment([num_views], {id,'=',Id})

It's darn simple, and it works. Instead of executing the UPDATE statement in the process that's responsible for rendering the page, I spawn a new process and execute the transaction there. Spawning processes in Erlang is dirt-cheap, so I don't have to worry about performance or memory issues. The user gets a quick response, the view counter is incremented, and the problem goes away.

Sunday, September 23, 2007


I just launched Vimagi, my first ErlyWeb app:

Painting is fun. Sharing paintings with your friends is also fun. Painting together with your friends is a new kind of fun you can have on Vimagi.

Give it a try and let me know what you think -- I'll appreciate the feedback.

Note: Vimagi is in early beta. It probably has many bugs. Please email me if you find any.

Saturday, September 22, 2007

Fancy Language/Framework Poll Results

My Wufoo poll has reached 99 entries! Let's check out the results.

Most popular languages:
Ruby: 31%
Erlang: 23%
Python: 21%
Lisp: 4%

Most popular frameworks:
Ruby on Rails: 39%
All web frameworks suck: 16%
Django: 15%
ErlyWeb: 6%

You can see the report here, with pretty graphs:

(Btw, it would be great if Wufoo allowed embedding public reports on other pages.)

Ruby/Ruby on Rails is the most popular language/framework among my blog readers. This is interesting, given that I don't write about Ruby much. My take on it is that many Rubyists read my blog because a) they are numerous (I'm sure there are many more Ruby hackers than Erlang hackers) and b) they are curious about other languages, especially Erlang. The same goes for Pythonistas.

It's interesting how many people think that most web frameworks suck. Maybe they don't do web programming (but then, why would they think tools they never use suck?), they love the PHP/JSP model (somehow, I doubt it), or they have better solutions for their needs. It's a mystery.

A couple of responders hate all computer languages. I wonder why they are reading my blog, then. The self-help section is yet to be launched... :)

A curious response is by a Lisp hacker who likes ASP.NET.

Only a couple of responders like Java. It's strange, given that Java is one of the most widespread languages. Maybe I can make ErlyWeb more marketable by renaming it 'Erlang Enterprise ConcurrentBean Application Server' :)

This is too much fun.

Friday, September 07, 2007

A Fancy Language/Web Framework Poll

Making forms with wufoo is so darn easy I just had to create one. It is below, in all its glory: a language/web framework poll for my blog readers.

Powered by Wufoo

Thanks for participating. Your input is very valuable -- I think.