inicio mail me! sindicaci;ón

Archive for February, 2006

Freedom languages

What, pray tell, is a “freedom language”? Freedom languages are those languages that put the individual programmer at the center of their philosophical world. They work hard to remove any language constructs that reduce programmer freedom, and add the most powerful constructs available. Many are post-modern languages and most tend to be syntactically dense. The other kind of language is the “safety language.” Safety languages think first about the creation of contracts between modules, objects and functions. They focus on teams rather than individuals. They remove language features that are confusing or frequently misused so that there are fewer opportunities to make mistakes and so there can be clear separation of concerns and maximum verifiability. These languages are full of barriers and check-points and well-defined paths and they tend to be syntactically verbose.

via http://www.journalhome.com/codecraft/9003/

I made my decision long time ago, I chose freedom languages ™.

My 1000th delicious item

I just noticed that my 1000th delicious item is Python On Lisp project. Isn’t the destiny coming towards me :) ?

It’s coming

ipod black

E, episode nine (Distributed Computing)

There’s no much to write about E’s concurrency model after you read this enlightment (from E in a Walnut):

Multiple threads form the basis of conventional models of concurrent programming. Remarkably, human beings engage in concurrent distributed computing every day even though people are generally single threaded ([…]). How do we simple creatures pull off the feat of distributed computing without multiple threads? Why do we not see groups of people, deadlocked in frozen tableau around the coffepot, one person holding the sugar waiting for milk, the other holding milk waiting for sugar? The answer is, we use a sophisticated computational mechanism known as a nonblocking promise. Let us look at a conventional human distributed computation. Alice, the CEO of Evernet Computing, needs a new version of the budget including R&D numbers from the VP of Engineering, Bob. Alice calls Bob: “Could you get me those numbers?” Bob jots Alice’s request on his to-do list. “Sure thing, Alice, I promise I’ll get them for you after I solve this engineering problem.” Bob has handed Alice a promise for the answer. He has not handed her the answer. But neither Bob nor Alice sits on their hands, blocked, waiting for the resolution. Rather, Bob continues to work his current problem. And Alice goes to Carol, the CFO: “Carol, when Bob gets those numbers, plug ‘em into the spreadsheet and give me the new budget,okay?” Carol: “No problem.” Carol writes Alice’s request on her own to-do list, but does not put it either first or last in the list. Rather, she puts it in the conditional part of the list, to be done when the condition is met–in this case, when Bob fulfills his promise. Conceptually, Alice has handed to Carol a copy of Bob’s promise for numbers, and Carol has handed to Alice a promise for a new integrated spreadsheet. Once again, no one waits around, blocked. Carol ambles down the hall for a contract negotiation, Alice goes back to preparing for the IPO. When Bob finishes his calculations, he signals that his promise has been fulfilled; when Carol receives the signal, she uses Bob’s fulfilled promise to fulfill her own promise; when Carol fulfills her promise, Alice gets her spreadsheet. A sophisticated distributed computation has been completed so simply that no one realizes an advanced degree in computer science should have been required. In this simple example, we see why human beings never get trapped in the thread-based deadlock situations described endlessly in books on concurrent programming. People don’t deadlock because they live in a concurrent world managed with a promise-based architecture. And so it is withE.

Why we people stick with that evil and bad multithreading stuff?

Writing a Widget Using Cairo and PyGTK 2.8, Part 2

I wrote a Python version of this C-based article.

/writing-a-widget-using-cairo-and-pygtk-28-part-2

GuidaTV goes Atom1.0

Hello, fellows Italian readers. I finished the first working version of guidatv.py. I transformed the tv guide to an atom 1.0 feed. So your favourite news reader can eat it.

You can find the (hopefully) once-a-day updated feed here: http://www.oluyede.org/files/guidatv

If you want the full code, let me know :)

Italian tvguide (or why Python is wonderful)

I wrote a simple script (for the italian guys) to scrape the content of an Italian tvguide website, all in less than 40 lines.

40 lines to me means Python and its tools are wonderful! :|

The script is very simple:

  1. Builds the URI based on the today date with the datetime module.
  2. Retrieves the page with the page with the urllib module.
  3. Feeds the page to the BeautifulSoup HTML parser.
  4. Fetches the HTML of the channels programs with parser’s fetch() method.
  5. Fetches the names of the channels with fetch() and some one-line iteration combined with strings capabilities.
  6. Loops through the channels and:
    • fetches the channels content stripping away remaining HTML with htmlstripper.py.
    • Couples the on-air times with the names of the programs with zip() function.
    • Add the name of the program.
  7. Append the channel to the guide.

That’s it. Stunning :) Read the rest of this entry »

HTML Stripper

I’m writing a scraper for an ill-formed HTML page (it uses the beautiful BeautifulSoup tool). At the end of the process I need to strip all the HTML away from a string. So I remembered the gorgeous HTML Sanitizer written by Mark Pilgrim for his feedparser.

Two minutes of customization after and I have htmlstripper.py.

It strips away all the HTML (you can customize it to keep some tags or attribute if you want…)

Delicious api is (partially) broken

Try these simple steps:

  1. Open this page
  2. Confirm that posts/all actually returns all posts and the optional tag argument is used as a filter
  3. Open this link http://del.icio.us/api/posts/all. Fill in your delicious account info.

At this point the page has to be full of your posts data but it isn’t. So try to refresh it and et voilŕ some other random posts.

You can also pass the tag argument in the URI but it’s the same thing.

Is it my account to be broken or the delicious API is?

UPDATE: it seems that the bug has been fixed by the del.icio.us team. Great :)

UPDATE #2: no way, the delicious API is gone random :(

E, episode eight (Interfacing to Java)

Since E sits on top of the JVM is capable of using quite everything the Java world exposes.

Package access

We can import a class from the underlying Java virtual machine with the import statement, and speak to the Java object much as we would speak to an E object
  1. # create a single vector with a direct call to Java
  2. def vector := <unsafe:java.util.Vector>()
  3. vector.addElement(“abc”)
  4.  
  5. # create a makeVector function which can be called repeatedly to make more vectors
  6. def makeVector := <unsafe:java.util.Vector>
  7. def vector2 := makeVector()
  8.  
  9. # create a shorthand for the java.util package, that gives quick access to all the
  10. # classes in java.util
  11. def <util> := <unsafe:java.util.*>
  12. def vector3 := <util:Vector>()

unsafe: is of the many uri getters available in E. Others are file: (already seen), the programmer-defined util:, swing: (to access javax.swing) and awt: (to access java.awt), resource: (for read-only access to resource files such as images, sounds, and static texts) and import:.

The import: uriGetter is similar to unsafe:, except it only imports those parts of the Java API that have been audited for capability security and found to convey no authority. So import: is often useful in these security-aware situations. A complete list of safe versus unsafe classes, and the small percentage of Java API methods which are suppressed for security reasons, are listed in the documentation.

Public constants

As noted earlier, E does not have an expression to directly represent public static final variables. To use such static finals from a Java class, put parentheses at the end of the variable name, making it syntactically look like a function call, prefix it with “get”, uppercase the first letter, and E will get the value for you:
  1. <unsafe:java.util.Calendar>.getYEAR()

Access to overloaded methods

E.call() function can be used to access overloaded methods in this way:

  1. E.call(javaObject, “method(String, int)”, [“abc”, 23])

The first argument is the object to send the message to, the second is the full signature of the method and the third argument are the parameters to pass to the invoked method.

With E you have also the Java power in your pocket! :)

Next entries »