Erlang is really nice. It was fairly easy to write the little twitter app, with a little help from a JSON lib I found. (mochijson2 also used in CouchDB, so I hear)
I'm going to miss pattern matching when I code in some other language. It makes things so much easier and clearer.
I haven't had this much fun programming since I made my last web-app in Lisp.
Next up: re-write that same web-app in Erlang.
The little app probably has lots of room for improvements, refactoring, cleaning up and is probably not the best Erlang style, but it works! :D
I'm very impressed with how easy this was to write.
I called it 'twitt' so the filename would be 'twitt.erl'..
-module(twitt).
-compile(export_all).
get_search(Search) ->
application:start(inets),
{ok,{_,_,Json}} =
http:request("http://search.twitter.com/search.json?q="++Search),
show_tweets(make_tweetlist(Json)).
get_entries_from_json({struct,[Results|_]}) ->
Results;
get_entries_from_json(_) ->
fail.
make_tweetlist(Json) ->
element(2,get_entries_from_json(mochijson2:decode(Json))).
print_tweet({struct,[{_,_Image},{_,_Created},
{_,From},{_,_ToUId},{_,Text},{_,_Id},{_,_FromUId},{_,_IsoLang},{_,_Source}]}) ->
io:format("From: ~p~n-- ~p~n",[binary_to_list(From),binary_to_list(Text)]);
print_tweet(_) -> fail.
show_tweets(TweetList) ->
[ print_tweet(X) || X <- TweetList ].