Sunday, October 7, 2007

Microformats: One step towards semantic web (Part 2)

Microformats isn’t a new technology at all. It has been around for a while now. It is being adopted by many organizations. The future versions of the Firefox browser version 3 and version 8 of Internet Explorer are expected to include native support for microformats.

Why are microformats a good idea to represents semantics in web page?
  • It is a standard method to markup website content.
  • It is not a new language. It is just a combination of XHTML and CSS.
  • It is embedded in the web page. i.e. hidden from humans, readable by machines.
  • It facilitate the interoperability between different applications like integrating the Outlook calendar with the events of a certain website.
It is designed on the 3R principle (reduce, recycle and reuse). First, Reduce: It uses the KISS principle (Keep it simple and straight forward). Second, Recycle: It encourages the modularity. Third, Reuse: It favors best practices.

How can I create a microformats?
The Microformats community has developed a number of creators for hCard, hCalendar, and hReview. It helps people to create their first microformats. You enter the required data and it creates the equivalent XHTML code. These provide a simple way to start publishing microformatted content. Here is a list of some microformats creator:
People will think that it will take some time to be widely used on the web. Here is a tip for you the page you are reading right now uses microformats to markup contacts. Let us see some microformats in action, now you are asking me isn’t the semantics embedded in a webpage for machines to understand. So I think we need a special tools to extract this information. I will review 2 tools you can use to discover microformats in embedded web pages.

Operator
Operator lets you combine pieces of information on Web sites with applications in ways that are useful. For instance, Flickr + Google Maps, Upcoming + Google Calendar, Yahoo! Local + your address book, and many more possibilities and permutations. All of these scenarios are possible due to Microformats, an emerging standard for injecting semantics into HTML. The following screen shot shows Operator in action while opening http://11870.com/ which is a social network which implements hReview for user's reviews about places, services and business:
Tails Export
An extension for Showing and Exporting Microformats. Currently it supports the following formats ( hCard, hCalendar, hReview, xFolk and Rel-license). The following screen shot shows Tails export in action while opening http://11870.com/ :


Finally, Microformats is a good step towards semantic web. Now, your browser can understand some of the semantics in a web page like the contacts, addresses, reviews ... etc. For example, Microformats can help you integrate addresses with google maps and so on...
It is now clear that the dreams of Tim Burners Lee are going to be true "a single web of meaning about everything and for everyone".

Saturday, September 29, 2007

Microformats: One Step towards Semantic Web (Part 1)

So what is really Semantic Web? Well, Semantic Web is an extension of the World Wide Web in which content can be expressed in a format that can be read and used by software not only by humans, to facilitate the searching, sharing and integration of information. In simple words it is a way to standardize the data and information representation over the world wide web, so that software would be able to understand its semantics without the need of complicated intelligent software. There have been several technologies that drive the road to semantic web like Resource Description Framework (RDF) and Web Ontology Language (OWL).

Semantic Web is one of the theories that Tim Burners Lee the father of the World Wide Web has been dreaming about since he launched the first website in the history in 1991. He had a vision towards this giant network that it shouldn't be a human-human communication only, machines should have a role too. His exact words were "a single Web of meaning, about everything and for everyone.". He made his idea available freely with no patent, so they can be easily adopted by anyone.

During the keynote at Microsoft MIX06, Bill Gates said, “We need microformats and to get people to agree on them. It is going to bootstrap exchanging data on the Web . . . we need them for things like contact cards, events, directions.”



What are Microformats?

Microformats are, according to the definition of microformats.org,

“Designed for humans first and machines second, microformats are a set of simple, open data formats built upon existing and widely adopted standards. Instead of throwing away what works today, microformats intend to solve simpler problems first by adapting to current behaviors and usage patterns (e.g., XHTML, blogging).”

In another words, it is a web-based data formatting methodology that re-use existing content as metadata, using only XHTML and HTML classes and attributes. So that human still be able to understand it as they used to and software agents can process it easily to extract the information they want.

Microformats might catch up with the web development community faster than the RDF or OWL. As it is build on the existing skills of web developers. It doesn’t require developers to learn whole new technologies, throw away their existing code bases, or wait years for browser developers to catch up and actually implement support for the technology. Microformats simply use features of HTML that have been around for years and are familiar to most web developers,

Current microformats allow the encoding and extraction of events, contact information, social relationships, and so on. More are being developed.

Microformats uses XHTML and HTML standards allow for semantics to be embedded within the attributes of markup tags. Microformats indicates the presence of metadata using the following attributes class, rel and rev.

Let us see an example of microformats to understand how it works, the following example is how to use microformats to describe contact information:

<div class="vcard">
<div class="fn">Fady Younan</div>
<div class="org">ITWorx</div>
<div class="tel">000-555-1234</div>
<a class="url" href="http://www.fady-younan.com">http://www.fady-younan.com</a>

</div>


Another example of how describe geographic information:

<span class="geo">
<span class="latitude">28.47</span>,
<span class="longitude">19.89</span>

</span>


If you haven't notice it uses the same XHTML and CSS to embed semantics in the web page, it uses the class "geo" to describe that is a geographic information, latitude and longitude to describe the co-ordination and so on ...

Here is list of some of the available microformats and there are others under development:
  • hCard: describes the contact information for people or organizations
  • hCalendar: describes information about events such as conferences,meetings and parties
  • XFN: describes the relationships between people.
  • hReview: describes the reviews for movies, books .. etc.
To be continued ...

Saturday, September 1, 2007

Erlang: Web Development (Part 4)

Erlang was mainly developed targeting the telecom application. It had to satisfy some of requirements of the telecom applications which are being distributed, massively concurrent, real-time and high availability. These requirements are similar to those put upon Internet based applications, making Erlang a good candidate for development of web based services. So is Erlang ready to be an enterprise web development framework?

The first tries of Erlang to conquer the web development community was back at 1997, when Ericsson developed its first web server. This server was called INETS. It is still a part of the Open Telecom Platform (OTP). Back there it was written with 10,000 lines of code (Don’t forget it is a functional language) and achieved 80% of the Apache server functionality which at that time consisted of about 100,000 lines of code.


Yaws (Yet Another Web Server) is another HTTP high performance web server particularly well suited for dynamic-content web applications. It is entirely written in Erlang. It was released as an open source in 2002. It is a multithreaded web server where a light weight process is used to handle each client request. The performance of Yaws comes from the underlying Erlang system and its ability to handle concurrent processes in an efficient way. It was a revolutionary web server considering the performance.

Let us not forget the famous comparison between Yaws and Apache. In a denial of service attack, the number of parallel connections needed to crash the Erlang web server was about 20 times as many as an Apache web server running on the same hardware. Apache (blue and green) dies when subject to a load of concurrent 4,000 parallel requests. Yaws (red) works till 80,000 concurrent requests.


I will try to give you a simple example about how to create a simple dynamic web page with Yaws.

This a simple Hello world to Yaws.

<html>
<h1> Title</h1>
<erl>
out(Arg) -> {html, “Hello World"}.
</erl>
<h1> Something</h1>
</html>

Thanks to Yariv Sadan’s effort to involve Erlang in the web development community using ErlyWeb which is a web framework that helps you easily build database-driven applications using the MVC architecture. It's similar to Ruby on Rails, except that it's written in Erlang. There is also ErlyDB a database abstraction layer generator. ErlyDB taps into Erlang’s runtime metaprogramming powers to generate an abstraction layer for your database on the fly.


I am going to propose an architecture for web development using Erlang. It will consists of five layers:

  • Hardware/ Operating System: This layer represents the physical layer of the system. It can be a Linux system running on a network file system(NFS) to make use of the concurrency and distribution features in Erlang.
  • DBMS: This layer represents the persistence layer of the system. It can be either Mnesia or MySQL.
  • Data Base Abstraction Layer.
  • Erlang/Open Telecom Platform: It is the standard libraries of the Erlang language.
  • Presentation Layer: This layer consists of two components. Yaws as a web server and ErlyWeb as rapid development framework.

Now, I can see that Erlang is starting to involve itself in the web development community. The problem is that the Erlang community isn't big enough to support this involvement. Is this going to change?



Erlang: Open Telecom Platform (Part 3)

Is Erlang really a new language? Do we have to write our old libraries and applications again from scratch? Actually Erlang is an old language may be older than Java and dot NET. It was developed in the late 80's. I will talk today about one the strengths of Erlang which is the Open Telecom Platform (OTP). The OTP is a development platform for building telecommunications applications based on Erlang. It was released as open source in 1998.

The OTP is a development system platform for building, and a control system platform for running, telecommunications applications. It is not a monolithic platform, but is made up of sets of tools and building blocks. Most of it is written in Erlang, there are some components that are written in C++. The OTP architecture consists of three layers as shown in the figure.


The Bottom layer: The system hardware in this layer. This is merely an architectural view; in real systems, the bottom layer contains many computers which may be of different types.

The Middle layer: Support for telecommunications requirements is provided by a robust real-time components. Its main modules are:
  • Erlang run-time system: The basic system that supports the execution of Erlang programs.
  • Web server: A Web server that serves HTTP requests via executing server side applications written in Erlang.
  • Mnesia: A real-time fault-tolerant distributed DBMS that supports fast transactions for the telecommunications application, and a query language, called Mnemosyne, for handling complex queries.
  • SASL: The systems architecture support libraries (SASL) contain basic software that supports system start/restart, live system software updates, and process management.
  • SNMP support: SNMP provides run-time support through an extensible agent.
The Top layer: All applications have access to Mnesia and SASL. The SNMP agent and the Web server may also invoke functions that are provided by the applications in this layer.

Using this platform, libraries and utilities you will be able to write robust, real-time systems. You won't be able to realize how powerful is Erlang. I will talk next time about existing systems that uses Erlang.

To be continued ...

Friday, August 24, 2007

Erlang: Concurrency and Distribution (Part 2)

One of the main strengths for Erlang is support for concurrency and distribution. It has a small set of primitives to create processes and communicate between them. Erlang processes are not operating system processes or threads, but they are lightweight threads similar to Java's "green threads".

Erlang is designed to be run in a distributed multi-node environment. Every computation in Erlang is performed within a process. Processes have no shared memory and communicate by asynchronous message passing. This is the philosophy of Erlang, the Concurrency Oriented Programming (COP). You have to think of your design from this prospective. Your application consists of a set of processes may be distributed on different machines.

Here is a simple application to illustrate the feautres I was talking about. A process sends a message to another process using the send construct: Pid ! Message. Even if the Pid doesn’t exist, the send will succeed. A process can block to receive a message by using the receive construct. The receive construct may also take an optional timeout value in millseconds, after which the “after” clause of the receive construct is executed.


-module(IPCExample).

-export([main/0, thread/0]).

main() ->

Pid = spawn(receive1, thread, []),

io:fwrite("Spawned new process _w_n", [Pid]),

Pid ! hello.

thread() ->

io:fwrite("This is a thread._n", []),

process_messages().

process_messages() ->

receive

hello ->

io:fwrite("Received hello_n"),

process_messages()

after 2000 ->

io:fwrite("Timeout._n")

end.


Process IDs do not have to refer processes running on the same machine as the processes can be distributed an remote machines. So you can spawn a process using the node name and use the returned process ID to send messages just as if it were a process on the local machine.


Pid = spawn(remote_node,process1, thread, []) Pid ! a_message
Pid ! a_message


Erlang handles the creation of the processes very efficiently. Here is a simple graph comparing Java, C#, Erlang comparing the time taken to create processes and asynchronous message passing.


This figure compares the time of creation of processes in Erlang versus Java and C#. We observe that the time taken to create an Erlang process is a constant 1 micro second up to 2,500 processes; and then it increases to about 3 micro second for up to 30,000 processes. As for Java and C# a small number of processes takes about 300 micro second to create a process. Creating more than two thousand processes is impossible.
This figure compares the time of message passing between different processes in Erlang versus Java and C#. The time to send a simple message between two concurrent processes running on the same machine as a function of the total number of processes. We see that for up to 30,000 processes the time to send a message between two Erlang processes is about 0.8 micro second. For C# it takes about 50 micro second. per message, up to the maximum number of processes (which was about 1800 processes). Java was even worse, for up to 100 process it took about 50 micro second per message thereafter it increased rapidly to 10ms per message when there were about 1000 Java processes.

It is quite clear that Java and C# can't compete with Erlang in this features. We have to realize that the world is going towards parallel processing even we don't accept Erlang as a language I think it will take place in the next decade.

To be continued ...

Ruby vs Java, PHP, dot NET ... Hilarious :D

I have never imagined that comparing web development frameworks would be that funny ... Ruby Rulez :D.
Ruby vs Java
Comparing Jars of Java to Ruby.



Ruby vs dot NET
Or we can say dot NOT :D.




Ruby vs PHP
I didn't know that php is this sticky.
Round 1

Round 2

Round 3


Round 4




Sunday, August 19, 2007

Erlang: The Introduction (Part 1)

Is Erlang really going to be the next Java according to Ralph's Blog? Erlang is really a powerful programming language, but thinking of it as a replacement for Java is not realistic. Developers are using Java over a decade now, they already have their applications, frameworks, libraries, ... etc. all written in Java. I don't see a clear reason to leave all this and start again from a scratch using another programming language. I am not completely against Erlang, although I am not completely with Java but I will try to predict the answer for the question I asked at the beginning. I will talk a bit about Erlang before I start comparing it to Java.

Introduction

Erlang is a general-purpose concurrent programming language and runtime system. It was designed by Ericsson to support distributed, real time, fault tolerant and non-stop application.

It was developed in the late 1980's by Ericsson to program the next generation of telecom applications. First it was used to program ATM Switches. It was released as open source in 1998 with the Open Telecom Platform (Erlang language, libraries and a real-time distributed database (Mnesia)) which I am going talk about it in details later.

Erlang is named after A. K. Erlang (Agner Krarup Erlang was a Danish mathematician, statistician and engineer, who invented the fields of traffic engineering and queuing theory). It is sometimes thought that its name is an abbreviation of Ericsson Language.

Erlang as a framework has a lot features:

Concurrent: has a process-based model of concurrency with asynchronous message passing

Real-time: intended for programming real-time systems where response times in the order of milliseconds are required

Continuous operation: has primitives which allow code to be replaced in a running system and allow old and new versions of code to execute at the same time

Robust: Safety is a crucial requirement in systems such as the above. There are three constructs in the language for detecting run-time errors.

Memory management: a symbolic programming language with a real-time garbage collector

Distribution: has no shared memory. All interaction between processes is by asynchronous message passing

Erlang is a functional programming language. It is different from C++, C#, and Java, which are Procedural Programming Languages.

Procedural languages: stress on the organization of data, and sequences of instructions which operate on some global state

Functional languages: treat programs as evaluations of functions without a global state

To have a good idea about the language I added simple examples to check:
  • Example 1: Hello World

This is the usual hello world program that displays "Hello World!" to the screen.

-module(hello).

-export([hello/0]).

hello() ->io:fwrite("Hello, World!~n", []).

  • Example 2: Factorial

This a simple factorial example.

-module(fact).

-export([fac/1]).

fac(0) -> 1;

fac(N) when N > 0 -> N * fac(N-1).


To be continued ...