Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What Even Is An Erlang?

What Even Is An Erlang?

Wicked Good Ruby 2013; Lightning Talks

Christopher Meiklejohn

October 11, 2013
Tweet

More Decks by Christopher Meiklejohn

Other Decks in Programming

Transcript

  1. -module(fact). -export([fac/1]). fac(0) -> 1; fac(N) when N > 0,

    is_integer(N) -> N * fac(N-1). Friday, October 11, 13
  2. % Create a process and invoke the function web:start_server(Port, MaxConnections)

    ServerProcess = spawn(web, start_server, [Port, MaxConnections]), Friday, October 11, 13
  3. % Create a process and invoke the function web:start_server(Port, MaxConnections)

    ServerProcess = spawn(web, start_server, [Port, MaxConnections]), % Create a remote process and invoke the function % web:start_server(Port, MaxConnections) on machine RemoteNode RemoteProcess = spawn(RemoteNode, web, start_server, [Port, MaxConnections]), Friday, October 11, 13
  4. % Create a process and invoke the function web:start_server(Port, MaxConnections)

    ServerProcess = spawn(web, start_server, [Port, MaxConnections]), % Create a remote process and invoke the function % web:start_server(Port, MaxConnections) on machine RemoteNode RemoteProcess = spawn(RemoteNode, web, start_server, [Port, MaxConnections]), % Send a message to ServerProcess (asynchronously). The message consists of a tuple % with the atom "pause" and the number "10". ServerProcess ! {pause, 10}, Friday, October 11, 13
  5. % Create a process and invoke the function web:start_server(Port, MaxConnections)

    ServerProcess = spawn(web, start_server, [Port, MaxConnections]), % Create a remote process and invoke the function % web:start_server(Port, MaxConnections) on machine RemoteNode RemoteProcess = spawn(RemoteNode, web, start_server, [Port, MaxConnections]), % Send a message to ServerProcess (asynchronously). The message consists of a tuple % with the atom "pause" and the number "10". ServerProcess ! {pause, 10}, % Receive messages sent to this process receive a_message -> do_something; {data, DataContent} -> handle(DataContent); {hello, Text} -> io:format("Got hello message: ~s", [Text]); {goodbye, Text} -> io:format("Got goodbye message: ~s", [Text]) end. Friday, October 11, 13