views:

388

answers:

4

I'm learning Erlang. I've moved from Haskell so I don't want to and have to learn functional programming.

But Erlang is quite specific because of the microprocesses. So, can you give me some examples which will be simple to test and measure and use all the power of Erlang?

A: 

This is not Erlang specific but Project Euler has some wonderful problems that can easily be tackled with Erlang for practice.

Mimisbrunnr
oh my god. I'm cool with project euler problems. I'm just not cool with all these microprocesses
valya
+3  A: 

You can start wit Erlang documentation. At least Concurrent Programming from Getting Started chapter. So you can continue with Design principles. Book Programming Erlang as well as Erlang Programming contain a lot of examples (later little bit more). You can try Ring benchmark or Bing Bang benchmark.

But Erlang is not about "microprocesses", It is about reliability and all this concurrency, message passing, strong process isolation, immutability, error handling and so is only way to go with it. Read great Joe's Ph.D. thesis.

Hynek -Pichi- Vychodil
thank you very much!
valya
+1  A: 

I made a proxy for a random online game and learned a lot. Didn't really play it much but I always wanted to make some kind of bot. I made the game connect to a local port then erlang spawns the real connection and serves as a middleman between all incoming and outgoing packets. Basically one spawn is listening for local connections, if someone connects it spawns a node receiving all client data and a node connected to the actual server, receiving all server data. The server/client nodes have each other Pid's and talk to each other. I guess I could have one node as the controlling process for both sockets but making spawns in erlang is cheap and easier to organize at times. Parsing the data made me get really good at bit syntax and made me appreciate how powerful the language is. After erlang you won't want to have to mess with binary any other way. Depending on the packets different functions were called to parse different codes. Spawning the parse functions is necessary to not stall the receive loop, and if they want to send a customized packet they just send a message to the server node. Pretty soon I could make an army of bots that marched in unison chanting stuff came together to depict asteroid sprites.

Joe's book really helped most. I'd flip through at night. Programming erlang I bought as an ebook and I could never really tolerate reading it too long on the monitor. The manning OTP book sucks.

Jimmy Ruska
many thanks! bot for online game is really interesting project. i did kind of them in school :-)
valya
+1  A: 

I would love to recommend setting up a chat server of some type. One of the coolest things of Erlang is its power with concurrency in a client/server setup.

Learning how to write webserver in Erlang was also fun. :)

Rev316
Ok, I'll try! :)
valya