13. Declarative Concentrate on “What” rather than “How”. The programs are concise. qsort([]) -> []; qsort([Pivot|T]) -> qsort([X || X <- T, X =< Pivot]) ++ [Pivot] ++ qsort([X || X <- T, X > Pivot]). Programs are readable and easy to maintain. It increases productivity.
14. Concurrency Each concurrent activity is called “process”. Processes don’t share data. Processes belong to language not operating system. Processes communicate through “message passing”not shared memory. Less process creation and message passing time.
15. Concurrency Create a process Pid = spawn(Module, fun, [Arguments]) Send and receive Pid ! message receive message1 -> actions1; message2 -> actions2; …… after Time -> time out actions; end.
17. 1,000 erlang java C# 100 Microseconds/process 10 1 10 100 1,000 10,000 100,000 Number of processes Process creation times (LOG/LOG scale) > 200,000processes Source: Joe Armstrong SICS
18. 100,000 erlang java 10,000 C# 1,000 Microseconds/message 100 10 1 1 10 100 1,000 10,000 100,000 Number of processes Message passing times (LOG/LOG scale) > 200,000processes Source: Joe Armstrong SICS
19.
20. Hot Code Swapping Embedded systems are reactive. How can I update my system without shutting down? In Erlang , we can change code on-the-fly. We can keep 2 version of same module running.
21. Multi-core Programming How to achieve? Use lots of processes. Avoid side effects. Avoid sequential bottleneck. Write “small message, big computation”. What is special about Erlang? Message passing system. No mutable data structure = No lock. No mutable data structure = Easy to parallelize.
22. Applications of Erlang Erlang is useful when applications are concurrent, distributed and soft-real time. It is used in telecommunication systems from Ericsson. Some other commercial applications are: Facebook uses Erlang to power the backend of its chat service, handling more than 100 million active users. Mobile arts (GSM and UMTS services) T-Mobile uses Erlang in its SMS and authentication systems.
24. Challenges & Solutions Challenges Erlang can’t directly interact with hardware. Erlang can’t be converted into it’s equivalent C code. Communication latency between PC and Firebird-V. Solutions Use C as middle-layer between Erlang and Micro-controller. Use PC as master and Firebird as slave mode. We can use small, low cost, fan-less processor and run Erlang on it.
25. Case Study Adaptive Cruise Control Robot will follow white line while maintaining safe distance from other robots. Robot using FireBird V (8051 micro-controller) Sensors using Whiteline sensors(Left, Middle, Right) Front sharp sensor
26. Communication Model Erlang PC Micro-controller read_sensor Sensing value C program Actuating Take corrective measure
27. Conclusion & Future Work Programs in functional languages are concise and readable. Concurrency model of Erlang helps in making concurrent programs without worrying about deadlocks. We have seen the possibility of implementing robotic system using Erlang. Since concurrency is crucial in building autonomous robotics applications, Erlang can be used in building such applications.
28. References Joe Armstrong “Programming Erlang”, May 2007 John Hughes "Why Functional programming Matters", 1984, revised in 1989 and 1990. Francesco Cesarini and Simon Thompson, "Erlang Programming, O'Reilly, June 2009 . Philip wadler "Functional Programming in the Real World“ http://homepages.inf.ed.ac.uk/wadler/realworld/ . Video lectures by Erlang- Training Consultancy