0

Erlang and concurrency

by klh 1. juni 2008 01:46

I just saw a great presentation on Erlang and concurrency by Joe Armstrong - the inventor of erlang. It is funny to see how someone is thinking completely different from the world you  live in (in my case it is OO).

It really strikes me how clearly he sees that Objects are not very good models of the world. What he says is that OO is made for sequential programming, and when he looks at the world it is not sequential, ít is concurrent.

So he brought out "Concurrency Oriented Programming". The main problem with OO is shared memory. What is the problem here is that every time threads or processes has to communicate with each other you use shared memorys. In order to not step on each others feet you use locks or mutexes. But that approach is not very fault tolerant.

So what he does instead is he copies messages between processes. That way you don't do locking or mutexes or ...

 

When I saw this presentation on erlang I started thing about using WCF for this purpose (yeah I know I got a new hammer and now everything is a nail):

Well WCF is all about sending messages.

OK so this was like only in a brainstorming way, don't take this idea to seroius ....

But what if we use WCF and named pipes to communicate and we send messages, we would get a lot of the erlang features.

Only we would have a problem with the cost of spawning a thread or process....

Tags: ,

0

About ruby

by klh 27. april 2008 03:23

Since there has been so much hype about ruby, I thought I'd better take a look at it.

I must say it looks really good. There's two things i like about Ruby:

1. Duck-typing

So many times I have been trying to make generic functionality for classes I didn't own. So in C# I have no chance of implementing a common interface.

With Duck-typing that is now possible, since I find that common functionality and do Duck-typing.

2. SOAP communication

WOAW, that was sure easy, I implemented a small serice in WCF and tried consuming it in Ruby - 20 secs. and it was done.

require 'soap/wsdlDriver'
require 'cgi'

WSDL_URL = http://localhost:8000/?wsdl
soap_client = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_driver

# Log SOAP request and response
soap_client.wiredump_file_base = "soap-log.txt"

# Call reset method.
result = soap_client.Test("klaus")
puts result.inspect

# Call stopGenerate method.
#result = soap_client.stopGenerate('1')
puts result.inspect

Powered by BlogEngine.NET 1.4.5.0
Original Design by Laptop Geek, Adapted by onesoft