Bluish Coder

Programming Languages, Martials Arts and Computers. The Weblog of Chris Double.


2006-02-22

Free hosting for Seaside web applications

Looking for free hosting for your Seaside application? An announcement on the Seaside mailing list says that free hosting is available from Seaside-Hosting.

Seaside-Hosting is a free hosting service for non-commercial Seaside applications. This service provides a simple to use web interface with FTP access to set up and run your Seaside applications. It allows you to put your own application online within minutes. The service is a Seaside application and is itself running on Seaside-Hosting too.

Tags: seaside 

2006-02-21

Javascript and Generators

Could Javascript be getting generators, iterators and list comprehensions? This post from Brendan Eich is a status update about the future of Javascript that mentions the possibility (From Ajaxian).

js> function count(n) {
    for (var i = 0; i < n; i++)
        yield i;
}
js> g = count(10)
[object Generator]
js> g.next()
0
js> g.next()
1
js> two_to_nine = [i for i in g]
2,3,4,5,6,7,8,9
js> squares_to_20 = [i * i for i in count(20)]
0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289,324,361
Tags: javascript 

2006-02-21

Jaws Erlang Web Framework

Joe Armstrong posted on the Erlang mailing list about Jaws, a web framework he is developing in Erlang.

Jaws has a template language for the Yaws web server that allows mixing HTML and Erlang similar to PHP, JSP, etc. Multiple pages can be specified in a single file and it provides Ajax functionality.

It looks very interesting, hopefully a release will be available sometime soon.

Tags: erlang 

2006-02-15

Concurrency

Bill Clementson has been posting about concurrency in programming languages and linked to me about my use of Erlang.

I've been using Erlang for a personal project for the last few months and I've found it very easy to use. The ability to spawn processes without the need to worry about any practical limits is quite interesting. I've found that I've started thinking about concurrent solutions to problems rather than strictly OO or functional solutions.

Some people ask 'why would anyone need thousands of threads'. My answer is 'why not'? If it makes the program easier to write, maintain and understand, why should a programming language or implementation create an arbitary restriction?

It is especially useful for network applications. I'm using the Yaws webserver written in Erlang with a library I wrote to do server side push of events from the webserver to web browser clients. This results in a large number of server connections and Erlang models this easily with one process per connection with a low overhead compared to native threads.

The common objection related to not being able to use SMP machines will be addressed with an upcoming Erlang release that uses native thread pools to distribute the process load.

I also continue to maintain and extend the concurrency library I wrote for Factor. Currently I'm adding binary serialisation (based on the Pickler Combinators paper). The intent of this is to allow serializing Factor continuations and thus provide migrating processes and distributed concurrency. I use this as a means to explore concurrency methods at a lower level which gives me a greater understanding of how to use it in systems like Erlang. And ultimately I'd like it to become a productive and usable system in its own right.

Tags: erlang 

2006-01-24

Observers, Erlang and Server Push

As I've mentioned previously, I'm working on a framework for pushing events from an Erlang based web server to browser based clients using AJAX. My goal being to make it look like normal Erlang message sends to 'processes' running on the browser.

I have a server process that needs to broadcast events to interested parties whenever something of interest happens. My first thought was that this is the classic Observer pattern in OO style frameworks. I wanted other processes to be able to register with the server and they would then receive the notification. They can then later unregister when no longer interested in the data.

This turns out to be very easy in Erlang. A simple process to handle this looks something like:

notifier(Observers) ->
    receive
        {notify, Message} ->
            lists:foreach(fun(To) ->
                            To ! Message
                          end,
                          Observers),
            notifier(Observers);
        {register, Observer} ->
            notifier([Observer|Observers]);
        {unregister, Observer} ->
        notifier(lists:delete(Observer, Observers))
    end.

Given a notifier, observers can register their interest in events. A server then sends a 'notify' message to the notifier, passing it the required data. This is in turn sent to all currently registered observers. So something like:

test() ->
    receive
        X ->
            io:format("Received ~p~n", [X]),
            test()
    end.

Changes = spawn(module, notifier, [[]]).
Observer1 = spawn(module, test, []). 
Changes ! {register, Observer1}.
Changes ! {notify, "Hello Message!"}.
...observer1 will output 'Received Hello Message!'...
Changes! {unregister, Observer1}.

Using code similar to this I created a notifier for my data source, and the observers are my HTML web pages. This is easy since I'm modelling each active page as a process. When an event occurs, the HTML on all displayed web pages are updated immediately using the AJAX based server push.

Tags: ajax 


This site is accessable over tor as hidden service 6vp5u25g4izec5c37wv52skvecikld6kysvsivnl6sdg6q7wy25lixad.onion, or Freenet using key:
USK@1ORdIvjL2H1bZblJcP8hu2LjjKtVB-rVzp8mLty~5N4,8hL85otZBbq0geDsSKkBK4sKESL2SrNVecFZz9NxGVQ,AQACAAE/bluishcoder/-61/


Tags

Archives
Links