Scala actors erlang
Upcoming SlideShare
Loading in...5
×
 

Scala actors erlang

on

  • 1,525 views

 

Statistics

Views

Total Views
1,525
Views on SlideShare
1,525
Embed Views
0

Actions

Likes
2
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Imaging somewhere in the universe an Iron Ball
  • 10 times the size of the earth, and every 10th million year a fly
  • Lands on the Iron Ball and wonders around a bit.The time it for the fly to wear down the Iron Ball is tiny winy bit of time in the concept of forever.
  • Erlang do have shared memory, light weight processes that communicate through messages
  • val variable = 3;Variable = 3.
  • 1 200 000 actors since the queues are actors as well
  • Pid = spawn(fun()->area_server:loop() end).Pid = {circle, 2.3}.Pid =
  • Show receiveWithin

Scala actors erlang Scala actors erlang Presentation Transcript

  • Scala Actors from an Erlangperspective
  • Who am I• Reidar Sollid (Reidar is an ancient Viking name, and means warrior and protector of the home)• I am now a Consutlant at Bouvet• My background is from R&D and Telecom transport networks from Nera Networks( now Ceragon) and Ericsson.
  • Motivation• Most Scala devs comes from Java• Hacking Scala with a Java mindset limits your use of Scala• Erlang is a pure actor base language• Getting the mindset from Erlang into Scala broadens the horizon• Java + Erlang = Scala
  • The concept of forever• This is a loaner from Joe Armstrong, he is a lot funnier than I am but I guess you get the point • I hope he don’t mind
  • 10 x the size of the
  • The fly
  • Nine nines 99.999999999• Standard for Telecom equipment is five nines 99.999 (5.2 minutes downtime/year)• The Ericsson AXD301 has 2 million lines of Erlang code and nine nines
  • Shared memory
  • Concurrency and shared memory
  • Erlang• The world is concurrent• Things in the world dont share data• Things communicate with messages• Things fail – Joe Armstrong
  • What is Erlang• Created and maintained by Ericsson (now open source)• Functional, single assignment, strict evaluation, dynamic typing• Actor model, concurrent oriented, fault tolerant, soft-real- time• Light weight processes that communicate using message passing (an Erlang process is more light weight than a Java thread)• Erlang started life as a modified prolog• Erlang shell, escript and compiled *.beam bytecode
  • Variables and pattern matching• Variables starts with capital letter or underscore• Variables are immutable, Erlang does not have mutable variables• They are variables because they can be assigned or not assigned• Erlang variables are the same as val variables in Scala
  • Erlang variable demo
  • Scala variable demo
  • Atoms and tuples• An atom is a global constant starting with lower case• Scala has an equivalent called Symbol• A tuple is an ordered set of elements• Erlang doesn’t have classes so we use tuples (see also records)
  • The spawn keyword• spawn(Fun) -> pid()• Spawns out a new process and returns the Process Identifier <0.13.1>• Normally we assign the PID to a variable• Pid = hello_world:start()
  • The *Real* Erlang "Hello, World!" http://egarson.blogspot.com/2008/03/real-erlang-hello-world.html
  • Pattern Matching , 29.09.2012
  • Tail recursion @tailrec
  • Tail recursion tail recursion as seen here is not making the memory grow because when the virtual machine sees a function calling itself in a tail position (the last expression to be evaluated in a function), it eliminates the current stack frame.
  • Scala react or receive • React is the “normal” actor, lightweight process • Receive spins out a new Java thread • In the paper * – 1.80GHz Intel Pentium M processor with 1024 MB memory, running Sun’s Java HotSpot™VM 1.5.0 under Linux 2.6.15 – Max heap size set to 512 MB – 5000 threads – 600 000 processes (1 200 000 actors) • React uses partial functions to send the process to the heap, react has return type Nothing • Receive runs on the stack and is heavyweight JVM threads (like Java) *Actors That Unify Threads and Events P. Haller, M. Odersky
  • Area server Erlang
  • Area server in Scala
  • Remote processes Erlang
  • Remote actors Scala
  • Supervisors in Erlang/OTP andAKKA Supervisor Process Process Process Page , 29.09.2012 Actor model baksia
  • Supervising supervisors RootSupervisor SupervisorSupervisor Process Process Process ProcessProcess Process Page , 29.09.2012 Actor model baksia