SlideShare a Scribd company logo
Learning Erlang
(from a Prolog dropout's perspective)


               Kenji Rikitake, JJ1BDX
                   26-APR-2008
          For 1000speakers:4 conference

26-APR-2008      1000speakers:4 by JJ1BDX: Creative   1
                    Commons CC-BY 3.0 licensed
Disclaimers
*Strictly NO WARRANTY
    (Ab)use this presentation at your own risk
*JJ1BDX is the author and the only
responsible person for this presentation
    My (former) employers or anyone else have
    nothing to do with this work and the contents
*This is a work-in-progress
    You may find a bunch of errors and glitches

26-APR-2008     1000speakers:4 by JJ1BDX: Creative   2
                   Commons CC-BY 3.0 licensed
Who am I?
*... I've been the JJ1BDX since 1976
    JJ1BDX is my amateur radio callsign in Japan
*I’ve been an Internet activist since 1986
*In 1986, I was partying around with
fellow radio and computer hackers, like
what you guys are doing now in the
1000speakers conference and other
events. So I come here to enjoy. :-)
26-APR-2008     1000speakers:4 by JJ1BDX: Creative   3
                   Commons CC-BY 3.0 licensed
Why I didn't like prolog
               (in 1980s)
*programming only by matching?
*programming without assignment?
*you can't really compute numbers?
*parallelism on the desktop?
*runtime (slow) virtual machines?
               ...NO WAY!
 (and I spent too much time on NetNews)
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   4
                 Commons CC-BY 3.0 licensed
...then why Erlang NOW??
*...works fast enough on modern PCs
    it works OK even on Windoze! (UNIX rules)
*...has a bunch of practical applications
    yaws, ejabberd, ATM packet exchanges
*...can get the most out of parallelism
    threads and shared memory are headaches
*...is new to me and I’m sure I can learn
something new. That’s for sure.

26-APR-2008    1000speakers:4 by JJ1BDX: Creative   5
                  Commons CC-BY 3.0 licensed
Why Erlang is hard to learn?
*extraordinary syntax
    embedded Prolog-ism
        Horn clauses and pattern-matching branches
        message-driven parallelism
*I’m preoccupied by C and FORTRAN
    leaning tail recursion is not a trivial task
    local variable declaration is not explicit
*lots of new things
    modules, data structures, Mnesia, OTP...
26-APR-2008        1000speakers:4 by JJ1BDX: Creative   6
                      Commons CC-BY 3.0 licensed
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   7
                 Commons CC-BY 3.0 licensed
What I'm going to show you
*IPv6-related string manipulation
    generation of 10,000 random IPv6 addresses
    parsing IPv6 colon-notation addresses into
    Erlang-native tuple forms
    generating reverse-lookup names from the
    Erlang tuples
        colon-form addresses -> ip6.arpa name
*some crude profiling results
    with parallelism: using SMP Erlang VM

26-APR-2008        1000speakers:4 by JJ1BDX: Creative   8
                      Commons CC-BY 3.0 licensed
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   9
                 Commons CC-BY 3.0 licensed
Erlang IP address tuples
*IPv4
    {127,0,0,1} -> localhost
    (4 x 8-bit elements)
*IPv6
    {0,0,0,0,0,0,0,1} -> ::1 (... well, localhost)
    (8 16-bit big-endian elements)
*Address conversion function ready
    inet_parse:address() for both IPv4 and IPv6
26-APR-2008      1000speakers:4 by JJ1BDX: Creative   10
                    Commons CC-BY 3.0 licensed
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   11
                 Commons CC-BY 3.0 licensed
Reverse lookup is getting
       harder in IPv6 than IPv4
*IPv4:
    just reversing the tuple elements is enough
        127.0.0.1 -> 1.0.0.127.in-addr.arpa
        lists:reverse() for the tuple elements
*IPv6:
    parsing and string manipulation needed
        2001:1:3fff:dbde::1 ->
        1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.e.d.b.d.f.f.f.3.1.0.0.
        0.1.0.0.2.ip6.arpa
        ... binary bit pack/unpack operation is effective

26-APR-2008         1000speakers:4 by JJ1BDX: Creative      12
                       Commons CC-BY 3.0 licensed
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   13
                 Commons CC-BY 3.0 licensed
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   14
                 Commons CC-BY 3.0 licensed
Concurrency and map()ping
*simple list iteration: map()ping
    Applying a function to all the list members
    lists:map(fun(X) -> function(X) end, Arglist)
*parallelism: parallel map()
    Joe Armstrong’s pmap()
        (in Programming Erlang: Software for a Concurrent World)
        spawn()ing light-weight process per element
        preserving result list sequence
    caution: execution sequence implementation
    dependent – no side effect allowed in the function

26-APR-2008          1000speakers:4 by JJ1BDX: Creative            15
                        Commons CC-BY 3.0 licensed
map() .vs. pmap() results
 * 10,000 addresses / Core2Duo 2.33GHz
     (mean values of 5-time measurements)

completion time lists:map()                           Armstrong’s
for test functions                                    pmap()
non-SMP            1.309 seconds                      2.029 seconds
(single scheduler)                                    (+55.0%)
SMP (2 cores)        1.343 seconds 1.202 seconds
(2 schedulers)                     (-10.5%)

 26-APR-2008     1000speakers:4 by JJ1BDX: Creative               16
                    Commons CC-BY 3.0 licensed
Spawning overhead of
              lightweight processes
*cost of creating lightweight processes
    3 to 12 microseconds/process
*messaging overhead between processes
*more efficient utilization of CPUs needed
    granularity: per-function computation
    number of simultaneous processes
    efficient process spawning
        e.g., result list sequence need not be preserved

26-APR-2008        1000speakers:4 by JJ1BDX: Creative      17
                      Commons CC-BY 3.0 licensed
Conclusions and lessons
*Erlang is weird, but worth learning
    getting out of the modules is essential
*parallelism works (even for 2 CPUs!)
    write parallelism-aware functions:
        Erlang’s idioms help parallel programming
*programmers need to learn parallelism
    Erlang’s idea applicable to other languages
    effective serialization is also critical; some
    algorithms have to run fast (e.g., crypto)
26-APR-2008        1000speakers:4 by JJ1BDX: Creative   18
                      Commons CC-BY 3.0 licensed
Appendix: lighter function
    means less parallelism gain
* 10,000 addresses / Core2Duo 2.33GHz
    (mean values of 5-time measurements)
*Faster implementation
    io_lib:format() -> primitive hex conversion
completion time lists:map()                          Armstrong’s
for test functions                                   pmap()
SMP (2 cores)      0.129 seconds                     0.198 seconds
(2 schedulers)                                       (+53%)
26-APR-2008     1000speakers:4 by JJ1BDX: Creative              19
                   Commons CC-BY 3.0 licensed
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   20
                 Commons CC-BY 3.0 licensed
26-APR-2008   1000speakers:4 by JJ1BDX: Creative   21
                 Commons CC-BY 3.0 licensed

More Related Content

What's hot

Code gpu with cuda - CUDA introduction
Code gpu with cuda - CUDA introductionCode gpu with cuda - CUDA introduction
Code gpu with cuda - CUDA introduction
Marina Kolpakova
 
BPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable DatapathBPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable Datapath
Thomas Graf
 
Pragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
Pragmatic Optimization in Modern Programming - Mastering Compiler OptimizationsPragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
Pragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
Marina Kolpakova
 
[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation
[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation
[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation
Zhen Wei
 
Code GPU with CUDA - Memory Subsystem
Code GPU with CUDA - Memory SubsystemCode GPU with CUDA - Memory Subsystem
Code GPU with CUDA - Memory Subsystem
Marina Kolpakova
 
The Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF PrimerThe Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF Primer
Sasha Goldshtein
 
GEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkGEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkAlexey Smirnov
 
Qemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System EmulationQemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System Emulation
National Cheng Kung University
 
TinyML - 4 speech recognition
TinyML - 4 speech recognition TinyML - 4 speech recognition
TinyML - 4 speech recognition
艾鍗科技
 
Machine Trace Metrics
Machine Trace MetricsMachine Trace Metrics
Machine Trace Metrics
Wang Hsiangkai
 
Compilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMCompilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVM
Linaro
 
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
Linaro
 
5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron) 5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron)
艾鍗科技
 
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
Yuuki Takano
 
Programming Trends in High Performance Computing
Programming Trends in High Performance ComputingProgramming Trends in High Performance Computing
Programming Trends in High Performance Computing
Juris Vencels
 
Polyraptor
PolyraptorPolyraptor
Polyraptor
MohammedAlasmar2
 
Code GPU with CUDA - SIMT
Code GPU with CUDA - SIMTCode GPU with CUDA - SIMT
Code GPU with CUDA - SIMT
Marina Kolpakova
 
A Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB SimulinkA Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB Simulink
Jaewook. Kang
 

What's hot (20)

Code gpu with cuda - CUDA introduction
Code gpu with cuda - CUDA introductionCode gpu with cuda - CUDA introduction
Code gpu with cuda - CUDA introduction
 
BPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable DatapathBPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable Datapath
 
Pragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
Pragmatic Optimization in Modern Programming - Mastering Compiler OptimizationsPragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
Pragmatic Optimization in Modern Programming - Mastering Compiler Optimizations
 
[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation
[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation
[Sitcon2018] Analysis and Improvement of IOTA PoW Implementation
 
Code GPU with CUDA - Memory Subsystem
Code GPU with CUDA - Memory SubsystemCode GPU with CUDA - Memory Subsystem
Code GPU with CUDA - Memory Subsystem
 
The Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF PrimerThe Next Linux Superpower: eBPF Primer
The Next Linux Superpower: eBPF Primer
 
GEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkGEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions Framework
 
Qemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System EmulationQemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System Emulation
 
TinyML - 4 speech recognition
TinyML - 4 speech recognition TinyML - 4 speech recognition
TinyML - 4 speech recognition
 
Machine Trace Metrics
Machine Trace MetricsMachine Trace Metrics
Machine Trace Metrics
 
Compilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVMCompilation of COSMO for GPU using LLVM
Compilation of COSMO for GPU using LLVM
 
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
 
ocelot
ocelotocelot
ocelot
 
5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron) 5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron)
 
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
SF-TAP: Scalable and Flexible Traffic Analysis Platform (USENIX LISA 2015)
 
Programming Trends in High Performance Computing
Programming Trends in High Performance ComputingProgramming Trends in High Performance Computing
Programming Trends in High Performance Computing
 
Polyraptor
PolyraptorPolyraptor
Polyraptor
 
Code GPU with CUDA - SIMT
Code GPU with CUDA - SIMTCode GPU with CUDA - SIMT
Code GPU with CUDA - SIMT
 
Ns2pre
Ns2preNs2pre
Ns2pre
 
A Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB SimulinkA Simple Communication System Design Lab #4 with MATLAB Simulink
A Simple Communication System Design Lab #4 with MATLAB Simulink
 

Similar to Learning Erlang (from a Prolog dropout's perspective)

Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)
Andriy Berestovskyy
 
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Akihiro Hayashi
 
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPF
Alex Maestretti
 
Playing BBR with a userspace network stack
Playing BBR with a userspace network stackPlaying BBR with a userspace network stack
Playing BBR with a userspace network stack
Hajime Tazaki
 
Kernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are moneyKernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are money
Anne Nicolas
 
Berkeley Packet Filters
Berkeley Packet FiltersBerkeley Packet Filters
Berkeley Packet Filters
Kernel TLV
 
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Hajime Tazaki
 
Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...
Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...
Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...
Takahiro Katagiri
 
Lustre Generational Performance Improvements & New Features
Lustre Generational Performance Improvements & New FeaturesLustre Generational Performance Improvements & New Features
Lustre Generational Performance Improvements & New Features
inside-BigData.com
 
Breaking New Frontiers in Robotics and Edge Computing with AI
Breaking New Frontiers in Robotics and Edge Computing with AIBreaking New Frontiers in Robotics and Edge Computing with AI
Breaking New Frontiers in Robotics and Edge Computing with AI
Dustin Franklin
 
ADCSS 2022
ADCSS 2022ADCSS 2022
Java on arm theory, applications, and workloads [dev5048]
Java on arm  theory, applications, and workloads [dev5048]Java on arm  theory, applications, and workloads [dev5048]
Java on arm theory, applications, and workloads [dev5048]
Aleksei Voitylov
 
General Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareGeneral Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareDaniel Blezek
 
Directive-based approach to Heterogeneous Computing
Directive-based approach to Heterogeneous ComputingDirective-based approach to Heterogeneous Computing
Directive-based approach to Heterogeneous ComputingRuymán Reyes
 
Analise NetFlow in Real Time
Analise NetFlow in Real TimeAnalise NetFlow in Real Time
Analise NetFlow in Real Time
Piotr Perzyna
 
Introduction to DPDK
Introduction to DPDKIntroduction to DPDK
Introduction to DPDK
Kernel TLV
 
Hardware assited x86 emulation on godson 3
Hardware assited x86 emulation on godson 3Hardware assited x86 emulation on godson 3
Hardware assited x86 emulation on godson 3Takuya ASADA
 
Porting and optimizing UniFrac for GPUs
Porting and optimizing UniFrac for GPUsPorting and optimizing UniFrac for GPUs
Porting and optimizing UniFrac for GPUs
Igor Sfiligoi
 
Nilesh ranpura systemmodelling
Nilesh ranpura systemmodellingNilesh ranpura systemmodelling
Nilesh ranpura systemmodellingObsidian Software
 
GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra
GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra
GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra
Umbra Software
 

Similar to Learning Erlang (from a Prolog dropout's perspective) (20)

Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)
 
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
 
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPF
 
Playing BBR with a userspace network stack
Playing BBR with a userspace network stackPlaying BBR with a userspace network stack
Playing BBR with a userspace network stack
 
Kernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are moneyKernel Recipes 2019 - Metrics are money
Kernel Recipes 2019 - Metrics are money
 
Berkeley Packet Filters
Berkeley Packet FiltersBerkeley Packet Filters
Berkeley Packet Filters
 
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
Linux rumpkernel - ABC2018 (AsiaBSDCon 2018)
 
Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...
Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...
Towards Auto-tuning Facilities into Supercomputers in Operation - The FIBER a...
 
Lustre Generational Performance Improvements & New Features
Lustre Generational Performance Improvements & New FeaturesLustre Generational Performance Improvements & New Features
Lustre Generational Performance Improvements & New Features
 
Breaking New Frontiers in Robotics and Edge Computing with AI
Breaking New Frontiers in Robotics and Edge Computing with AIBreaking New Frontiers in Robotics and Edge Computing with AI
Breaking New Frontiers in Robotics and Edge Computing with AI
 
ADCSS 2022
ADCSS 2022ADCSS 2022
ADCSS 2022
 
Java on arm theory, applications, and workloads [dev5048]
Java on arm  theory, applications, and workloads [dev5048]Java on arm  theory, applications, and workloads [dev5048]
Java on arm theory, applications, and workloads [dev5048]
 
General Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics HardwareGeneral Purpose Computing using Graphics Hardware
General Purpose Computing using Graphics Hardware
 
Directive-based approach to Heterogeneous Computing
Directive-based approach to Heterogeneous ComputingDirective-based approach to Heterogeneous Computing
Directive-based approach to Heterogeneous Computing
 
Analise NetFlow in Real Time
Analise NetFlow in Real TimeAnalise NetFlow in Real Time
Analise NetFlow in Real Time
 
Introduction to DPDK
Introduction to DPDKIntroduction to DPDK
Introduction to DPDK
 
Hardware assited x86 emulation on godson 3
Hardware assited x86 emulation on godson 3Hardware assited x86 emulation on godson 3
Hardware assited x86 emulation on godson 3
 
Porting and optimizing UniFrac for GPUs
Porting and optimizing UniFrac for GPUsPorting and optimizing UniFrac for GPUs
Porting and optimizing UniFrac for GPUs
 
Nilesh ranpura systemmodelling
Nilesh ranpura systemmodellingNilesh ranpura systemmodelling
Nilesh ranpura systemmodelling
 
GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra
GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra
GDC2014: Boosting your ARM mobile 3D rendering performance with Umbra
 

More from elliando dias

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
elliando dias
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScriptelliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
elliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de containerelliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Librarieselliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Webelliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduinoelliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorceryelliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Designelliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
elliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebookelliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Studyelliando dias
 

More from elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 

Learning Erlang (from a Prolog dropout's perspective)

  • 1. Learning Erlang (from a Prolog dropout's perspective) Kenji Rikitake, JJ1BDX 26-APR-2008 For 1000speakers:4 conference 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 1 Commons CC-BY 3.0 licensed
  • 2. Disclaimers *Strictly NO WARRANTY (Ab)use this presentation at your own risk *JJ1BDX is the author and the only responsible person for this presentation My (former) employers or anyone else have nothing to do with this work and the contents *This is a work-in-progress You may find a bunch of errors and glitches 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 2 Commons CC-BY 3.0 licensed
  • 3. Who am I? *... I've been the JJ1BDX since 1976 JJ1BDX is my amateur radio callsign in Japan *I’ve been an Internet activist since 1986 *In 1986, I was partying around with fellow radio and computer hackers, like what you guys are doing now in the 1000speakers conference and other events. So I come here to enjoy. :-) 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 3 Commons CC-BY 3.0 licensed
  • 4. Why I didn't like prolog (in 1980s) *programming only by matching? *programming without assignment? *you can't really compute numbers? *parallelism on the desktop? *runtime (slow) virtual machines? ...NO WAY! (and I spent too much time on NetNews) 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 4 Commons CC-BY 3.0 licensed
  • 5. ...then why Erlang NOW?? *...works fast enough on modern PCs it works OK even on Windoze! (UNIX rules) *...has a bunch of practical applications yaws, ejabberd, ATM packet exchanges *...can get the most out of parallelism threads and shared memory are headaches *...is new to me and I’m sure I can learn something new. That’s for sure. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 5 Commons CC-BY 3.0 licensed
  • 6. Why Erlang is hard to learn? *extraordinary syntax embedded Prolog-ism Horn clauses and pattern-matching branches message-driven parallelism *I’m preoccupied by C and FORTRAN leaning tail recursion is not a trivial task local variable declaration is not explicit *lots of new things modules, data structures, Mnesia, OTP... 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 6 Commons CC-BY 3.0 licensed
  • 7. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 7 Commons CC-BY 3.0 licensed
  • 8. What I'm going to show you *IPv6-related string manipulation generation of 10,000 random IPv6 addresses parsing IPv6 colon-notation addresses into Erlang-native tuple forms generating reverse-lookup names from the Erlang tuples colon-form addresses -> ip6.arpa name *some crude profiling results with parallelism: using SMP Erlang VM 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 8 Commons CC-BY 3.0 licensed
  • 9. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 9 Commons CC-BY 3.0 licensed
  • 10. Erlang IP address tuples *IPv4 {127,0,0,1} -> localhost (4 x 8-bit elements) *IPv6 {0,0,0,0,0,0,0,1} -> ::1 (... well, localhost) (8 16-bit big-endian elements) *Address conversion function ready inet_parse:address() for both IPv4 and IPv6 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 10 Commons CC-BY 3.0 licensed
  • 11. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 11 Commons CC-BY 3.0 licensed
  • 12. Reverse lookup is getting harder in IPv6 than IPv4 *IPv4: just reversing the tuple elements is enough 127.0.0.1 -> 1.0.0.127.in-addr.arpa lists:reverse() for the tuple elements *IPv6: parsing and string manipulation needed 2001:1:3fff:dbde::1 -> 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.e.d.b.d.f.f.f.3.1.0.0. 0.1.0.0.2.ip6.arpa ... binary bit pack/unpack operation is effective 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 12 Commons CC-BY 3.0 licensed
  • 13. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 13 Commons CC-BY 3.0 licensed
  • 14. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 14 Commons CC-BY 3.0 licensed
  • 15. Concurrency and map()ping *simple list iteration: map()ping Applying a function to all the list members lists:map(fun(X) -> function(X) end, Arglist) *parallelism: parallel map() Joe Armstrong’s pmap() (in Programming Erlang: Software for a Concurrent World) spawn()ing light-weight process per element preserving result list sequence caution: execution sequence implementation dependent – no side effect allowed in the function 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 15 Commons CC-BY 3.0 licensed
  • 16. map() .vs. pmap() results * 10,000 addresses / Core2Duo 2.33GHz (mean values of 5-time measurements) completion time lists:map() Armstrong’s for test functions pmap() non-SMP 1.309 seconds 2.029 seconds (single scheduler) (+55.0%) SMP (2 cores) 1.343 seconds 1.202 seconds (2 schedulers) (-10.5%) 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 16 Commons CC-BY 3.0 licensed
  • 17. Spawning overhead of lightweight processes *cost of creating lightweight processes 3 to 12 microseconds/process *messaging overhead between processes *more efficient utilization of CPUs needed granularity: per-function computation number of simultaneous processes efficient process spawning e.g., result list sequence need not be preserved 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 17 Commons CC-BY 3.0 licensed
  • 18. Conclusions and lessons *Erlang is weird, but worth learning getting out of the modules is essential *parallelism works (even for 2 CPUs!) write parallelism-aware functions: Erlang’s idioms help parallel programming *programmers need to learn parallelism Erlang’s idea applicable to other languages effective serialization is also critical; some algorithms have to run fast (e.g., crypto) 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 18 Commons CC-BY 3.0 licensed
  • 19. Appendix: lighter function means less parallelism gain * 10,000 addresses / Core2Duo 2.33GHz (mean values of 5-time measurements) *Faster implementation io_lib:format() -> primitive hex conversion completion time lists:map() Armstrong’s for test functions pmap() SMP (2 cores) 0.129 seconds 0.198 seconds (2 schedulers) (+53%) 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 19 Commons CC-BY 3.0 licensed
  • 20. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 20 Commons CC-BY 3.0 licensed
  • 21. 26-APR-2008 1000speakers:4 by JJ1BDX: Creative 21 Commons CC-BY 3.0 licensed