inicio mail me! sindicaci;ón

Archive for September, 2006

PyObjC in OSX Leopard

It seems not only Twisted made his way into Leopard but also PyObjC will be part of Leopard. Yay!

Common Lisp’s quote

Directly from Practical Common Lisp:

DOLIST is similar to Perl’s foreach or Python’s for. Java added a similar kind of loop construct with the “enhanced” for loop in Java 1.5, as part of JSR-201. Notice what a difference macros make. A Lisp programmer who notices a common pattern in their code can write a macro to give themselves a source-level abstraction of that pattern. A Java programmer who notices the same pattern has to convince Sun that this particular abstraction is worth adding to the language. Then Sun has to publish a JSR and convene an industry-wide “expert group” to hash everything out. That process–according to Sun–takes an average of 18 months. After that, the compiler writers all have to go upgrade their compilers to support the new feature. And even once the Java programmer’s favorite compiler supports the new version of Java, they probably still can’t use the new feature until they’re allowed to break source compatibility with older versions of Java. So an annoyance that Common Lisp programmers can resolve for themselves within five minutes plagues Java programmers for years.

BzaarCamp in Milano

BzaarCamp Logo

Tomorrow I’ll try to attend the first BarCamp here in Milano. Antonio invited me there so see you there!

Backup delicious

Ever wondered how to backup your gazillion of website stored online with delicious?

Nothing can be more simple: delicious exposes a REST API enabling you to download your addresses in a simple XML file.

Here’s a bunch of lines to do that:

  1. import urllib2
  2. import time
  3.  
  4. API_URL = “https://api.del.icio.us/v1/posts/all”
  5.  
  6. USER = “XXX”
  7. PASSWD = “YYY”
  8.  
  9. manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
  10. manager.add_password(None, API_URL, USER, PASSWD)
  11.  
  12. handler = urllib2.HTTPBasicAuthHandler(manager)
  13. opener = urllib2.build_opener(handler)
  14.  
  15. res = None
  16. try:
  17.     res = opener.open(API_URL)
  18. except urllib2.URLError, e:
  19.     if hasattr(e, ‘reason’):
  20.         print ‘Reason: ‘, e.reason
  21.     elif hasattr(e, ‘code’):
  22.         print ‘Error code: ‘, e.code
  23.  
  24. if res:
  25.     filename = “%s.xml” % “_”.join(time.asctime().split()).replace(“:”, “-”)
  26.     f = open(filename, “w”)
  27.     f.write(res.read())
  28.     f.close()
  29.     print “%s written” % filename

You can easily “tune” it to be more scripty or put it under cron/launchd/whatever handling.

Update:

Fredrik Lundh posted a way to retrieve posts from delicious using JSON: grabbing delicious posts with python

Apple has donated an Xserve to Twisted

From Glyph’s words:

This new machine is serving its purpose admirably. The new build configuration, poll on osx, has already revealed some bugs that need fixing, less than 20 minutes after the machine was set up :).

Apple’s iCal Server takes advantage of Python and Twisted so that’s nice to hear from them!

Steve Ballmer in Marketing 101

This is _the_ man:

Erlang and the GUIs

Erlang is great about concurrency, fault-tolerance and performance but what about the old simple GUI support?

I made a quick research and I came up with this:

  • Gtk (my favorite toolkit) is available in two libraries: erlgtk is the first hit in Google but I didn’t manage to compile it in OSX so I dropped it down. The project is also discontinued so nothing to see here sadly :-( jungerl is a collection of very interesting stuff for Erlang and beneath it there’s gtkNode which wraps GTK 2.8, supports Glade and seems really promising although it’s not updated since months… Anyway it seems to work well but it requires X11 under OSX so a bit unhandy.

  • OSX Aqua: I haven’t found anything…

  • Qt: I haven’t found anything…

  • Tk: Erlang ships with GS which stands for Graphics System, a portable library indipendent from the underlying graphic system. Here uses Tcl/Tk and seems simple and cool.

For now that’s all. I’m going to use GS for my experiments but it’s nice too see that there’s some support for Gtk too!

I’ll update this post if I found out more.

Update (2006/09/20)

Liam Clarke mentioned wxErlang and I forgot to add EX11 in the list so here are two more:

  • X Window: EX11 is a X Window toolkit written in 100% Erlang that talks directly to the X Server, so its power is quite unlimited. The latest version is 2.5 released in 2004. My opinion is that screenshots look kinda ugly and it’s a bit low level (…since it talks with the X System directly). Anyway the simplest tutorial example didn’t work for me so I can’t say more. Joe Armstrong published a series of slides about EX11 if you want to know more: EX11 - An Erlang GUI.

  • wxWidgets: wx has the ability to use other toolkits for rendering so they (at least in theory) render equally your favorites native apps. wxErlang is a prototype implementation but it definitely looks nice on OSX. The project seems halted though (the latest CVS commit is from 10 months ago). Once more time: this library didn’t even compile on my machine so that’s all.

After digging into these two additional libraries I think I’ll stick with GS and gtkNode for my experiments.

Erlang is damn intuitive

Erlang is a multi-paradigm language since it has functional, declarative and imperative functionalities. Erlang exploits concurrency in a wonderful way through an asynchronous message-passing model. Erlang’s processes are lightweight (about 300 byte each) and the overall architecture is very fast.

I’m learning Erlang for fun and yesterday I tried to implement the simplest master/slave architecture: a master with N slaves linked to it; when the slave dies the master gets notified and regenerate it.

Sounds quite complicated in… Java but in Erlang takes 50 lines of code.

The key to the heaven lies in link/1 used to create a bond between two processes. When a processes dies Erlang automatically notifies the master with a failure message. The master has to trap those kind of messages with processflag/2 and handle them in the receive block.

Does the module sound simple? It is simple.

master slave

Toying with Erlang

There’s plenty of messages in the blogosphere about Erlang these days so I’m not gonna make praises for this wonderful tool some more. If you’re interested in concurrency and you had enough with the thread jiggling go check it out and learn message passing with Erlang.

After reading here and there I tried to write a simple pet program dealing with concurrency and I came with a very simple star topology example. You create a bunch of processes and send a message back and forth to them until the counter reaches 0. Nothing can be more simple in the message passing world! You share nothing, you create lightweight processes and you come up with something like this:

Read the rest of this entry »

“Ruby per applicazioni web” is out!

As I said earlier in June I cooperated (writing a chapter and reviewing the whole content) in the draft of the first book ever for Italian developers about Ruby and the Web.

The book is going to be available in the stores before the end of this month so check it out my fellows Italian readers :-)

book cover

Read the rest of this entry »

Next entries »