How did Erlang's view of the world help with implementing an HTTP server?
In Erlang everything is a process and processes can only interact by exchanging messages. So to implement a HTTP server, the main loop of the server code create a new process for each connection, then listen for client’s requests and respond.
The author describes an interesting concept of handling errors, which is based on the hardware duplication approach of handling failures. In order to provide high reliability, many systems have redundant hardware so that if one fails the other can recover it and keep the system running. This idea is used and implemented in Erlang. The processes are linked in the event that one fails the other is notified of the failure with an explanation so that appropriate actions can be taken. The failing process sends a message to the other process before it terminate. If there is a hardware failure on the machine on which one process runs, the hardware failure is converted to look like a software failure. This allows a uniform error recovery mechanism to be used for both hardware and software failures.
Another interesting concept is the notion of completely separate error-handling code from the code solving the problem and have them run in different threads of executions. The main advantage on this approach is that the code can be developed in a single node system and ported to a distributed environment with only minor code changes.
How important is it to use intentional programming when it comes to maintenance? (The author gave the example of history of theDictionary API)
I think this is the central idea behind writing code that is easy to maintain. The function’s name and variable should be meaningful, descriptive and clearly express the function’s purpose.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment