Thursday, February 21, 2008

Multithread: the new era


Multi-threading is not new. This is, for instance, natively supported in Java since the beginning in 1996.

What is new started with this very popular article that appeared in Dr. Dobb's Journal, 30(3), March 2005. Basically the heat produced by the CPU doubles when the clock is 20% faster. Usual fans and radiators are saturated with CPU around 4GHz. It means the clock race is over. But processor manufacturers are smart. If they slow down the CPU by 20%, it produces half the heat, so let's put two of them in the same chip! The dual core is born. Same thermal envelope, 2 cores, 20% slower than mono core version. Moore's law still hold if we consider each core as a contributor of the total machine speed.

By the end of 2007, almost all new machines are equipped with multi-core processors.

From the software point of view, it has 2 major impacts:
  • Customers are now running your applications in true multi-threaded environment.
  • The multi-core hardware speeds up performance only if the application is multi-threaded.
We are still correcting bugs coming from first point. Even Java made mistakes, for example the famous single thread rule of Swing happens to fail on multi-core machines.

We are only starting to tackle the second point. And we have very few tools and theory background to help us so far.

After the Recursivity and the Object Oriented Languages, now comes the Multi-Threading.

Thursday, February 14, 2008

Function as parameter


All decent programming language allows function calls, with parameters.

Level 1 of parameter is a literal. It's safe, the literal is read-only and has no side effect outside the scope of the function.

Level 2 of parameter is a variable. More useful, but may have side effect if the variable is modified in the body of the function. Even when variables are copied before the function call, they can still points to data that may be modified.

Level 3 is a function. Even more power, but more risks. Some programming languages allow to pass functions as parameter, directly or indirectly (like a parameter of type Runnable in Java).


Why is it more dangerous than variables ?

Let's take a symbolic function, name it delta, with the following body:
void delta(x) { x(x); }
which reads "delta of x does: x applies to x". In lambda-calculus, it is written D = (\x.xx). I'll stick with this notation as it is more compact. Delta looks harmless. I mean, there is no obvious bug in the body of delta.

However problem occurs when you apply, for instance, delta to itself:

DD = (\x.xx)(\x.xx), and when you apply D to D, you substitute x in the first D by the second D, and you obtain (\x.xx)(\x.xx), i.e. DD.

So no way to escape, when the machine computes DD, the result is still DD and we enter in an infinite loop.

A slight variation, D' = (\x.xxx) is even worth because D'D' -> D'D'D' -> D'D'D'D' -> etc. D'D' is then a growing infinite loop.

So you see the hazard. The body of D (or D') looks safe. There is no explicit infinite loop inside. Actually D explodes only with suitable parameter that behaves as the second half of the bomb. That's something that couldn't occur with level1 or level2 parameter. Careful with that level3 parameter, Eugen.

World Wide Web: The Boostrap Age


Back in 1990, Tim Berners-Lee started the Web with the first web server. At this time internet wasn't mainstream and I was lucky enough to work in a research institute, probably the only one in France to be connected.

At this time internet was used to send email (no spam at all), download files through ftp and read news on newsgroups.

I met several times TBL. He's a pure geek. No surprise it's major invention, the URL, has such an ugly syntax. Ugly, but functional. At least the advantage is that today everybody recognizes an URL and knows what it means, and even basic text editors turn it into an hyperlink connected to a web browser.

This URL is for me what made the WWW possible. It contains all: the protocol, the server, the server port, the document path, anchor, and query. Mixing all this in one "word" is a masterpiece. For example, when the Web is made of one server (actually the one you see in the picture), you should have a good intuition to put the IP of the server as a mandatory item of the URL. And it happens that the URL scaled up to today structure, with billions of servers and web pages...

Next major breakthrough was "mosaic", in 1993. Mosaic is yet another proof that the UI is essential. The Web as we know it today started with mosaic (which became netscape, then firefox), because it attracted people to the Web technology and started the snow ball effect of always more servers, more documents, and then more reasons to join the Web community.

Next one was alta vista search engine (1995), because Web is anarchy and it became very hard to find out something without the URL. Other search engines existed already, but Alta Vista used Scooter, a web crawler to index all reachable web pages. 10 years ago, Google swept away alta vista with the added value of Page Rank that sorts the result of a search in popular order.

No doubt that these three software milestones marked the history of the Web.

Tuesday, February 12, 2008

User Interface

There are several domains in computer science. Database, algorithms, networks, etc. I'm rather specialized in User Interface.

Usually, UI shortcuts Graphical User Interface. However, UI in general means the relationship between users and computers, and as computers are connected together, interfaces between users.

This encompasses software tools to help users communicate and share data, through the computer.

Note that a particular case of user to user communication is when the user is communicating with him/herself, i.e. when using PIM (Personal Information Manager) and other productivity tools that power up the user experience on a computer.

Hello World



I don't know how many blogs start with such a post. I could have set the title to "Yet Another Hello World Initial Post", which is level 2, and same feed of computer joke...

So why I started this blog ? Well, I have things to tell, like everybody else. I'm modest enough to realize I may catch attention of 1 person over a million. That's few. But there are now several millions of people accessing the web now, so I can expect several readers from now on...

Next posts will be more informative. I promise. Just let me get confident with the interface.