Mais conteúdo relacionado
Semelhante a Introduction to Erlang (18)
Introduction to Erlang
- 1. Erlang Essentials
Core Language Features of Interest
Excerpt From 12/4/08 Microsoft Presentation
Slides by Dave Fayram
dfayram@microsoft.com
© 2008 Powerset
- 2. Erlang Basics
• A Functional Language
• Based around pattern matching, a total
lack of shared state, and a flexible
message passing system.
• Lightweight Processes are just tail-
recursive functions executing in parallel.
© 2008 Powerset
- 4. Pattern Matching
• Erlang has no assignment.
• Every “=” statement forms a relationship.
• Type descriptions are also valid for pattern
matching.
© 2008 Powerset
- 6. Lightweight Processes
• Any function (named or anonymous) can
become a process.
• A process is simply a function executing in
parallel.
• Process semantics mirror function
semantics.
© 2008 Powerset
- 7. Lightweight Processes
• Extremely Efficient!
• Modern systems can accommodate
literally millions of Erlang processes.
• Erlang LWP can be run in parallel on
multiple CPUs.
• Programs heavily reliant on processes
tend to get free performance boosts.
© 2008 Powerset
- 10. Asynchronous Messages
• The “!” operator sends messages.
• Asynchronous, no guarantee of delivery.
• The “receive” statement matches messages.
• One call to receive, one message
removed from the process message
queue.
• Uses Pattern Matching to select messages
© 2008 Powerset
- 15. Asynchronous Messages
• Erlang does not distinguish between “local”
processes and “remote” processes.
• This is the core of Erlang’s distributed
programming.
• Semantics are identical (already, no strong
guarantees of message delivery).
© 2008 Powerset