11. Noktalama
○ (.) when hariç herşeyi sonlandir
○ (;) koşulu sonlandır
○ (,) ifadeyi (expressions) sonlandır
12. List Comprehensions
{2n : n in L}
in Erlang:
○ brackets ({}) become square brackets ([]),
○ the colon (:) becomes two pipes (||)
○ and the word 'in' becomes the arrow (<-).
1> [2*N || N <- [1,2,3,4]].
[2,4,6,8]
22. Erlang Önemli Noktalar
● Declarative
● Concurrency
● Soft real-time
● Robustness
● Distribution
● Hot code loading
● External Interfaces
● Portability
○ Lightweight processes
○ Fast message passing
○ Response times in the order of
milliseconds efficient garbage
collection
Oynat Uğurcuğum
30. Error handling
● No global variables -- fewer side-effects
● No direct memory access -- no pointer errors
● No malloc/free bugs
● Solid concurrency model -- reduces synchronization
problems, reduces the state space (simpler programs)
● Fault isolation -- memory-protected lightweight
processes
● Built-in error recovery support -- more consistency
Concurrency & Fault Tolerance were designed into the
language from the start!
31. Debugging and Profiling Support
● Symbolic crash reports
○ Usually sufficient info to locate bugs within minutes
● Built-in trace support
○ Function calls (ability to filter on module name,
function and args)
○ Messages (+ sequence trace)
○ Process events (context switch, spawn, link, exit)
○ Garbage collections
○ Optionally with timestamps (can be used for profiling,
benchmarks)
○ Trace to process, file, or port (network socket)
○ Also available on live systems
32. Erlang Önemli Noktalar
● Declarative
● Concurrency
● Soft real-time
● Robustness
● Distribution
● Hot code loading
● External Interfaces
● Portability
○ Explicit or transparent
distribution
○ Network-aware runtime
system
Örnekler
33. Transparent Distribution
- başka bir bilgisayara prosesler arası mesaj gönderimi, aynı
bilgisayarda mesaj gönderimi kadar kolaydır.
35. Erlang Önemli Noktalar
● Declarative
● Concurrency
● Soft real-time
● Robustness
● Distribution
● Hot code loading
● External Interfaces
● Portability
○ Easily change code in a
running system
○ Enables non-stop operation
○ Simplifies testing
36. Erlang Önemli Noktalar
● Declarative
● Concurrency
● Soft real-time
● Robustness
● Distribution
● Hot code loading
● External Interfaces
● Portability
○ Ports to the outside world
○ behave as Erlang processes
- Erlang Port Drivers
37. Erlang Önemli Noktalar
● Declarative
● Concurrency
● Soft real-time
● Robustness
● Distribution
● Hot code loading
● External Interfaces
● Portability
○ Any UNIX
○ Windows
○ VxWorks etc.
39. Erlang/OTP (Open Telecom Platform)
● Middleware for Erlang development
● Designed for fault tolerance and portability
● Behaviors: A formalization of design patterns
● Components
○ Error handling, reporting and logging
○ Mnesia, distributed real-time database management
system CORBA, IDL Compiler, Java & C Interface Support
○ HTTP Server + Client, FTP Client
○ SNMP Agent + ASN.1 Compiler
○ H.248
○ XML
○ ...
40. OTP Behaviors
● "A formalization of design patterns"
○ A framework + generic code to solve a common problem
○ Built-in support for debugging and software upgrade
○ Makes it easier to reason about the behavior of a program
● Examples of OTP behaviors
application defines how an application is implemented
supervisor used to write fault-tolerant supervision trees
gen_server for writing client-server applications
gen_event for writing event handlers
gen_fsm for finite state machine programming
41. Büyük Projelerde Erlang
● Easy to build a first runnable application
● Easy to debug
● Easy to maintain
● Very strong support for fault tolerance
● Suitable for large systems/projects
● Great for prototyping
● Impressive performance/scalability in real applications
Outstanding tool for test automation
● High programmer satisfaction
43. Made with Erlang
○ Apache CouchDB – document-based DB with REST
○ Disco – Map/Reduce framework for Erlang
○ Fuzed – Generic clustering framework (Powerset)
○ Mochiweb – Fast lightweight web server framework
(like Java Servlets for Erlang)
○ DHT – Distributed Key/Value Stores – 90% of all
implementations in Erlang – Dynomite, Scalaris, etc.
○ Yaws web server
○ Cowboy
○ Nitrogen
○ RabbitMQ
○ Riak
44. Good fit for
● Irregular concurrency
○ Task-level parallelism
○ Fine-grained parallelism
● Network servers
● Distributed systems
● Middleware:
○ Parallel databases
○ Message Queue servers
● Soft Real-Time / Embedded applications
● Monitoring, control and testing tools