SlideShare a Scribd company logo
What can be done with

Java



but should better be done with


Erlang
Pavlo Baron
            Geek‘s
             Guide    pavlo.baron@codecentric.de
To The Working Life                @pavlobaron
Hey, dude.

What sort of application
should be optimally implemented
using your language?
.NET dude:




         win*
Python dude:




          sci*
Ruby dude:




       cool*
Clojure, Groovy, Scala dude:




        java*
Putonghua dude:




         谢谢
Java dude:




             *
Erlang dude:




fit → do();

_ → badarg.
This dude in front of you

is   very     picky.
So, let' assume that:




                =

                =
List<Integer> l =
    Arrays.asList(1, 2, 3, 4, 5);
List<Integer> r =
    new ArrayList<Integer>();
    for (int i : l) {
      r.add(i * 2);
    }
List<Integer> l =
  Arrays.asList(1, 2, 3, 4, 5);
Iterable<Integer> t =
  Iterables.transform(l,
    new Function<Integer, Integer>() {
      public Integer apply(Integer i) {
        return I * 2;
      }
    });
And this is just a simple map.
It gets even worse
with filter and fold
[X * 2 || X <- lists:seq(1, 5)].
so what?
List<Integer> l = Arrays.asList(1, 2, 3, 4, 5); Iterable<Integer> t = Iterables.transform(l, new Function<Integer, Integer>() {public Integer apply(Integer i) {return I * 2;}});
your colleagues will love it
What can be done with Java, but should better be done with Erlang (@pavlobaron)
That works!
synchronized (this) {
   if (!crawledSites.contains(site)) {
         linkedSites.add(site);
   }
 }

…

public class CountingSemaphore {
   private int signals = 0;
   public synchronized void take() {
        this.signals++;
        this.notify();
   }

    public synchronized void release()
                        throws InterruptedException {
       while (this.signals == 0) wait();
       this.signals--;
    }
}
1> A = 5.
5
2> A = 10.
** exception error: no match of
right hand side value 10
3>
so what?
The simplest way to avoid problems
with concurrency is to share only
immutable data between threads.
Immutable data is data which can
not be changed.

(from a Java concurrency tutorial)
Immutable class:

- all its fields are final
- class declared as final
- “this” reference is not allowed to
escape during construction
Any fields which refer to
mutable data objects:

- are private
- have no setter method
- are never directly returned of
otherwise exposed to a caller
- if they are changed internally
in the class this change is not
visible and has no effect
outside of the class
That works!
What can be done with Java, but should better be done with Erlang (@pavlobaron)
1> F = fun(F) -> F(F) end.
#Fun<erl_eval.6.80247286>
2> F(F).

…..................hours later................

BREAK: (a)bort (c)ontinue (p)roc info
(i)nfo (l)oaded (v)ersion (k)ill (D)b-tables
(d)istribution

a
so what?
...
for (paramFiber = recursion1.doit__1(paramEProc, paramEObject);
          paramFiber == EProc.TAIL_MARKER;
          paramFiber = (EFun)localFiber.getCallee())
     {
       S_O localS_O;
       switch (localFiber.up())
       {
       case 2:
         paramEProc.tail.go(paramEProc, localFiber.down());
         localS_O = new S_O();
         localS_O.f0 = paramEProc;
         localFiber.setState(localS_O, this, 1);
         return null;
       case 3:
         null;
         return null;
       case 1:
         localS_O = (S_O)localFiber.curState;
         paramEProc = (EProc)localS_O.f0;
       case 0:
       }
     }
...
That works!
What can be done with Java, but should better be done with Erlang (@pavlobaron)
1> F = fun([_|_]) ->
1> io:format("string~n");
1> (B) ->
1> io:format("integer~n")
1> end.
#Fun<erl_eval.6.80247286>
2> F(15).
integer
ok
3> F("whatever").
string
ok
4>
so what?
What can be done with Java, but should better be done with Erlang (@pavlobaron)
That works!
try {
   // Create a new class loader with the directory
   ClassLoader cl = new URLClassLoader(urls);

  // Load in the class
  Class cls = cl.loadClass("MyReloadableClassImpl");

   // Create a new instance of the new class
   myObj = (MyReloadableClass)cls.newInstance();
} catch (IllegalAccessException e) {
} catch (InstantiationException e) {
} catch (ClassNotFoundException e) {
}
Excessive class-reloading using
ClassLoader hierarchies is
expensive and leads to JVM
instance fatigue
That's why it's strongly
recommended to do hot
deployment in app servers
% hot_swap:sum(Num)
% adds 1 to Num
1> c(hot_swap).
{ok,hot_swap}
2> hot_swap:sum(1).
2
...
% hot_swap.erl has changed.
% now it adds 2 to Num
…
3> c(hot_swap).
{ok,hot_swap}
4> hot_swap:sum(1).
3
5>
code_change(OldVsn, State, Extra) ->
  ...code to convert state (and more) during
  code change...
  {ok, NewState}.
so what?
What can be done with Java, but should better be done with Erlang (@pavlobaron)
JVM HotSwap is limited to
method bodies.

OSGi is invasive and
state-unaware
so what?
What can be done with Java, but should better be done with Erlang (@pavlobaron)
your managers will love *Rebel
in production
your ops will love *Rebel
in production
That works!
What can be done with Java, but should better be done with Erlang (@pavlobaron)
1> A = 20.
20
2> self().
<0.32.0>
3> 5 / 0.
** exception error: bad argument in an
arithmetic expression
    in operator '/'/2
      called as 5 / 0
4> self().
<0.36.0>
5> A.
20
6>
so what?
What can be done with Java, but should better be done with Erlang (@pavlobaron)
That works!
What can be done with Java, but should better be done with Erlang (@pavlobaron)
1> bit_size(<<3:5>>).
5
2>
so what?
What can be done with Java, but should better be done with Erlang (@pavlobaron)
That works!
QueueConnectionFactory connFactory =
   new QueueConnectionFactory();
QueueConnection conn = connFactory.createQueueConnection();
QueueSession session = conn.createQueueSession(false,
   Session.AUTO_ACKNOWLEDGE);
Queue q = new Queue("world");
QueueSender sender = session.createSender(q);
TextMessage msg = session.createTextMessage();
msg.setText("Hello there!");
sender.send(msg);

QueueReceiver receiver = session.createReceiver(q);
conn.start();
Message m = receiver.receive();
if (m instanceof TextMessage) {
     TextMessage txt = (TextMessage) m;
}

session.close();
conn.close();
register(serv, spawn(?MODULE, loop, [])),
serv ! {self(), “Hello there!”},
receive
  {_Pid, Msg} ->
  …
end.

…

loop() ->
   receive
     {From, Txt} ->
        …
        loop();
$ erl +P 134217727

Erlang R14B04 (erts-5.8.5) [source] [64-bit]
[smp:8:8] [rq:8] [async-threads:0] [hipe]
[kernel-poll:false]

Eshell V5.8.5 (abort with ^G)
1> erlang:system_info(process_limit).
134217727
2>
so what?
import kilim.Mailbox;
import kilim.Pausable;
import kilim.Task;

public class SimpleTask extends Task {
  static Mailbox<String> mb = new Mailbox<String>();

    public static void main(String[] args) throws Exception {
      new SimpleTask().start();
      Thread.sleep(10);
      mb.putnb("Hello ");
      mb.putnb("Worldn");
      mb.putnb("done");
    }

    public void execute() throws Pausable {
      while (true) {
         String s = mb.get();
         if (s.equals("done")) break;
         System.out.print(s);
      }
      System.exit(0);
    }
}
your ops will love this
in production
That works!
QueueConnectionFactory connFactory =
   new QueueConnectionFactory();
QueueConnection conn = connFactory.createQueueConnection();
QueueSession session = conn.createQueueSession(false,
   Session.AUTO_ACKNOWLEDGE);
Queue q = new Queue("world");
QueueSender sender = session.createSender(q);
TextMessage msg = session.createTextMessage();
msg.setText("Hello there!");
sender.send(msg);

QueueReceiver receiver = session.createReceiver(q);
conn.start();
Message m = receiver.receive();
if (m instanceof TextMessage) {
     TextMessage txt = (TextMessage) m;
}

session.close();
conn.close();
{serv, 'serv@pc'} ! {self(), “Hello there!”},
receive
  {_Pid, Msg} ->
  …
end.

…

loop() ->
   receive
     {From, Txt} ->
        …
        loop();
so what?
import org.gridgain.grid.*;
import org.gridgain.grid.gridify.*;
import org.gridgain.grid.gridify.aop.spring.*;

public final class GridifyHelloWorldSessionExample {
  private GridifyHelloWorldSessionExample() { //ensure singleton }

     @Gridify(taskClass = GridifyHelloWorldSessionTask.class, timeout = 3000)
     public static int sayIt(String phrase) {
       System.out.println(phrase);
       return phrase.length();
     }
    public static void main(String[] args) throws GridException {
       if (args.length == 0) {
              GridFactory.start();
       }
       else {
              GridFactory.start(args[0]);
       }
       try {
              int phraseLen = sayIt("Hello World");
              System.out.println(„number of characters is '" + phraseLen + "'.");
       } finally {
              GridFactory.stop(true);
       }
     }
}
your ops will love this
in production
That works!
One GC per OS process.
Complex generation management.
Different GC stategies.
Stop the world situations possible
One GC per Erlang process.
Simple generation management.
(Mostly) one GC stategy.
Stop the world situations unlikely.
so what?
What can be done with Java, but should better be done with Erlang (@pavlobaron)
That works!
Hey, dude.

So do you imply Erlang is better
than Java for everything?
Erlang dude:



  body() -> [
     #h1 { text="My Simple Application" },
     #label { text="What is your name?" },
     #textbox { },
     #button { text="Submit" }
  ].
Java dude:

             LOL
              at
             you
Ruby on rails dude:

            ROFL
              at
             y'all
Erlang dude:



calc_month(S) ->
   L = ["Jan", "Feb", "Mar", "Apr", "May",
        "Jun", "Jul", "Aug", "Sep", "Oct",
        "Nov", "Dec"],
   find_ix(L, S, 1).
Java dude:

             LOL
              at
             you
Erlang dude:



Doing number crunching, you would
completely utilize the available cores with
few (as many) threads.

Erlang is for time sharing and doesn't
like long blocking processes.
Java dude:

             LOL
              at
             you
C dude:

          ROFL
            at
           y'all
Thank you
Some code examples were
   taken from public blogs / sites

      Most images originate from
               istockphoto.com

            except few ones taken
from Wikipedia and product pages
      or generated through public
                online generators

More Related Content

PDF
Clojure for Java developers - Stockholm
PDF
JavaOne 2013 - Clojure for Java Developers
KEY
Clojure Intro
PDF
Clojure for Java developers
PDF
Java Cheat Sheet
ODP
Ast transformations
PDF
Predictably
ODP
AST Transformations
Clojure for Java developers - Stockholm
JavaOne 2013 - Clojure for Java Developers
Clojure Intro
Clojure for Java developers
Java Cheat Sheet
Ast transformations
Predictably
AST Transformations

What's hot (20)

PDF
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
ODP
Getting started with Clojure
PDF
core.logic introduction
ODP
AST Transformations at JFokus
ODP
Clojure made simple - Lightning talk
PPTX
Kotlin – the future of android
KEY
Google Guava
PDF
Scala vs java 8
PDF
The Logical Burrito - pattern matching, term rewriting and unification
PDF
Privet Kotlin (Windy City DevFest)
PDF
Spock: A Highly Logical Way To Test
PPTX
Building native Android applications with Mirah and Pindah
PDF
Grails/Groovyによる開発事例紹介
PDF
Fun never stops. introduction to haskell programming language
PDF
Clojure, Plain and Simple
PDF
From Java to Parellel Clojure - Clojure South 2019
PPTX
Clojure And Swing
PDF
ConFess Vienna 2015 - Metaprogramming with Groovy
PPSX
Java.lang.object
ODP
Clojure: Practical functional approach on JVM
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
Getting started with Clojure
core.logic introduction
AST Transformations at JFokus
Clojure made simple - Lightning talk
Kotlin – the future of android
Google Guava
Scala vs java 8
The Logical Burrito - pattern matching, term rewriting and unification
Privet Kotlin (Windy City DevFest)
Spock: A Highly Logical Way To Test
Building native Android applications with Mirah and Pindah
Grails/Groovyによる開発事例紹介
Fun never stops. introduction to haskell programming language
Clojure, Plain and Simple
From Java to Parellel Clojure - Clojure South 2019
Clojure And Swing
ConFess Vienna 2015 - Metaprogramming with Groovy
Java.lang.object
Clojure: Practical functional approach on JVM
Ad

Viewers also liked (20)

PDF
20 reasons why we don't need architects (@pavlobaron)
PDF
High Performance Erlang
KEY
Winning the Erlang Edit•Build•Test Cycle
PDF
Clojure class
PDF
Clojure values
PPTX
Erlang - Because s**t Happens by Mahesh Paolini-Subramanya
PDF
Clojure made-simple - John Stevenson
PDF
Messaging With Erlang And Jabber
PDF
Elixir talk
PDF
NDC London 2014: Erlang Patterns Matching Business Needs
PDF
VoltDB and Erlang - Tech planet 2012
ZIP
Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)
ODP
From Perl To Elixir
PDF
Introduction to Erlang for Python Programmers
PDF
Elixir for aspiring Erlang developers
PPTX
Erlang - Because S**t Happens
PDF
Clojure: Towards The Essence of Programming
PDF
Elixir Into Production
PPTX
Clojure for Data Science
KEY
Functional programming in clojure
20 reasons why we don't need architects (@pavlobaron)
High Performance Erlang
Winning the Erlang Edit•Build•Test Cycle
Clojure class
Clojure values
Erlang - Because s**t Happens by Mahesh Paolini-Subramanya
Clojure made-simple - John Stevenson
Messaging With Erlang And Jabber
Elixir talk
NDC London 2014: Erlang Patterns Matching Business Needs
VoltDB and Erlang - Tech planet 2012
Clojure: Functional Concurrency for the JVM (presented at Open Source Bridge)
From Perl To Elixir
Introduction to Erlang for Python Programmers
Elixir for aspiring Erlang developers
Erlang - Because S**t Happens
Clojure: Towards The Essence of Programming
Elixir Into Production
Clojure for Data Science
Functional programming in clojure
Ad

Similar to What can be done with Java, but should better be done with Erlang (@pavlobaron) (20)

PDF
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
PDF
Keynote joearmstrong
PDF
Erlang Message Passing Concurrency, For The Win
ODP
erlang at hover.in , Devcamp Blr 09
PPTX
Does Java Have a Future After Version 8? (Belfast JUG April 2014)
PDF
Why Erlang? - Bar Camp Atlanta 2008
PDF
Introduction To Erlang Final
PPTX
PDF
Erlang, the big switch in social games
PDF
Erlang factory SF 2011 "Erlang and the big switch in social games"
PDF
Tour of language landscape (katsconf)
ODP
An introduction to erlang
KEY
Erlang bootstrap course
PDF
Erlang, an overview
PDF
FP Days: Down the Clojure Rabbit Hole
PDF
Java Pitfalls and Good-to-Knows
PDF
Erlang is not a city in Germany
PDF
Ice mini guide
KEY
Scala Introduction
PDF
Martin Odersky: What's next for Scala
Sioux Hot-or-Not: Functional programming: unlocking the real power of multi-c...
Keynote joearmstrong
Erlang Message Passing Concurrency, For The Win
erlang at hover.in , Devcamp Blr 09
Does Java Have a Future After Version 8? (Belfast JUG April 2014)
Why Erlang? - Bar Camp Atlanta 2008
Introduction To Erlang Final
Erlang, the big switch in social games
Erlang factory SF 2011 "Erlang and the big switch in social games"
Tour of language landscape (katsconf)
An introduction to erlang
Erlang bootstrap course
Erlang, an overview
FP Days: Down the Clojure Rabbit Hole
Java Pitfalls and Good-to-Knows
Erlang is not a city in Germany
Ice mini guide
Scala Introduction
Martin Odersky: What's next for Scala

More from Pavlo Baron (20)

PDF
@pavlobaron Why monitoring sucks and how to improve it
PDF
Why we do tech the way we do tech now (@pavlobaron)
PDF
Qcon2015 living database
PDF
Becoming reactive without overreacting (@pavlobaron)
PPTX
The hidden costs of the parallel world (@pavlobaron)
PDF
data, ..., profit (@pavlobaron)
PDF
Data on its way to history, interrupted by analytics and silicon (@pavlobaron)
PDF
(Functional) reactive programming (@pavlobaron)
PDF
Near realtime analytics - technology choice (@pavlobaron)
PDF
Set this Big Data technology zoo in order (@pavlobaron)
PDF
a Tech guy’s take on Big Data business cases (@pavlobaron)
PDF
Diving into Erlang is a one-way ticket (@pavlobaron)
PDF
Dynamo concepts in depth (@pavlobaron)
PDF
Chef's Coffee - provisioning Java applications with Chef (@pavlobaron)
PDF
From Hand To Mouth (@pavlobaron)
PDF
The Big Data Developer (@pavlobaron)
PDF
NoSQL - how it works (@pavlobaron)
PDF
Theoretical aspects of distributed systems - playfully illustrated (@pavlobaron)
PDF
The Agile Alibi (Pavlo Baron)
PPT
Harry Potter and Enormous Data (Pavlo Baron)
@pavlobaron Why monitoring sucks and how to improve it
Why we do tech the way we do tech now (@pavlobaron)
Qcon2015 living database
Becoming reactive without overreacting (@pavlobaron)
The hidden costs of the parallel world (@pavlobaron)
data, ..., profit (@pavlobaron)
Data on its way to history, interrupted by analytics and silicon (@pavlobaron)
(Functional) reactive programming (@pavlobaron)
Near realtime analytics - technology choice (@pavlobaron)
Set this Big Data technology zoo in order (@pavlobaron)
a Tech guy’s take on Big Data business cases (@pavlobaron)
Diving into Erlang is a one-way ticket (@pavlobaron)
Dynamo concepts in depth (@pavlobaron)
Chef's Coffee - provisioning Java applications with Chef (@pavlobaron)
From Hand To Mouth (@pavlobaron)
The Big Data Developer (@pavlobaron)
NoSQL - how it works (@pavlobaron)
Theoretical aspects of distributed systems - playfully illustrated (@pavlobaron)
The Agile Alibi (Pavlo Baron)
Harry Potter and Enormous Data (Pavlo Baron)

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PPT
Teaching material agriculture food technology
PDF
A comparative analysis of optical character recognition models for extracting...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Getting Started with Data Integration: FME Form 101
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
cuic standard and advanced reporting.pdf
PPTX
A Presentation on Artificial Intelligence
PPTX
1. Introduction to Computer Programming.pptx
Machine learning based COVID-19 study performance prediction
Teaching material agriculture food technology
A comparative analysis of optical character recognition models for extracting...
“AI and Expert System Decision Support & Business Intelligence Systems”
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Getting Started with Data Integration: FME Form 101
gpt5_lecture_notes_comprehensive_20250812015547.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Spectral efficient network and resource selection model in 5G networks
Building Integrated photovoltaic BIPV_UPV.pdf
Big Data Technologies - Introduction.pptx
Encapsulation_ Review paper, used for researhc scholars
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Mobile App Security Testing_ A Comprehensive Guide.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Dropbox Q2 2025 Financial Results & Investor Presentation
Diabetes mellitus diagnosis method based random forest with bat algorithm
cuic standard and advanced reporting.pdf
A Presentation on Artificial Intelligence
1. Introduction to Computer Programming.pptx

What can be done with Java, but should better be done with Erlang (@pavlobaron)

  • 1. What can be done with Java but should better be done with Erlang
  • 2. Pavlo Baron Geek‘s Guide [email protected] To The Working Life @pavlobaron
  • 3. Hey, dude. What sort of application should be optimally implemented using your language?
  • 4. .NET dude: win*
  • 6. Ruby dude: cool*
  • 10. Erlang dude: fit → do(); _ → badarg.
  • 11. This dude in front of you is very picky.
  • 12. So, let' assume that: = =
  • 13. List<Integer> l = Arrays.asList(1, 2, 3, 4, 5); List<Integer> r = new ArrayList<Integer>(); for (int i : l) { r.add(i * 2); }
  • 14. List<Integer> l = Arrays.asList(1, 2, 3, 4, 5); Iterable<Integer> t = Iterables.transform(l, new Function<Integer, Integer>() { public Integer apply(Integer i) { return I * 2; } });
  • 15. And this is just a simple map. It gets even worse with filter and fold
  • 16. [X * 2 || X <- lists:seq(1, 5)].
  • 18. List<Integer> l = Arrays.asList(1, 2, 3, 4, 5); Iterable<Integer> t = Iterables.transform(l, new Function<Integer, Integer>() {public Integer apply(Integer i) {return I * 2;}});
  • 22. synchronized (this) { if (!crawledSites.contains(site)) { linkedSites.add(site); } } … public class CountingSemaphore { private int signals = 0; public synchronized void take() { this.signals++; this.notify(); } public synchronized void release() throws InterruptedException { while (this.signals == 0) wait(); this.signals--; } }
  • 23. 1> A = 5. 5 2> A = 10. ** exception error: no match of right hand side value 10 3>
  • 25. The simplest way to avoid problems with concurrency is to share only immutable data between threads. Immutable data is data which can not be changed. (from a Java concurrency tutorial)
  • 26. Immutable class: - all its fields are final - class declared as final - “this” reference is not allowed to escape during construction
  • 27. Any fields which refer to mutable data objects: - are private - have no setter method - are never directly returned of otherwise exposed to a caller - if they are changed internally in the class this change is not visible and has no effect outside of the class
  • 30. 1> F = fun(F) -> F(F) end. #Fun<erl_eval.6.80247286> 2> F(F). …..................hours later................ BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution a
  • 32. ... for (paramFiber = recursion1.doit__1(paramEProc, paramEObject); paramFiber == EProc.TAIL_MARKER; paramFiber = (EFun)localFiber.getCallee()) { S_O localS_O; switch (localFiber.up()) { case 2: paramEProc.tail.go(paramEProc, localFiber.down()); localS_O = new S_O(); localS_O.f0 = paramEProc; localFiber.setState(localS_O, this, 1); return null; case 3: null; return null; case 1: localS_O = (S_O)localFiber.curState; paramEProc = (EProc)localS_O.f0; case 0: } } ...
  • 35. 1> F = fun([_|_]) -> 1> io:format("string~n"); 1> (B) -> 1> io:format("integer~n") 1> end. #Fun<erl_eval.6.80247286> 2> F(15). integer ok 3> F("whatever"). string ok 4>
  • 39. try { // Create a new class loader with the directory ClassLoader cl = new URLClassLoader(urls); // Load in the class Class cls = cl.loadClass("MyReloadableClassImpl"); // Create a new instance of the new class myObj = (MyReloadableClass)cls.newInstance(); } catch (IllegalAccessException e) { } catch (InstantiationException e) { } catch (ClassNotFoundException e) { }
  • 40. Excessive class-reloading using ClassLoader hierarchies is expensive and leads to JVM instance fatigue
  • 41. That's why it's strongly recommended to do hot deployment in app servers
  • 42. % hot_swap:sum(Num) % adds 1 to Num 1> c(hot_swap). {ok,hot_swap} 2> hot_swap:sum(1). 2 ... % hot_swap.erl has changed. % now it adds 2 to Num … 3> c(hot_swap). {ok,hot_swap} 4> hot_swap:sum(1). 3 5>
  • 43. code_change(OldVsn, State, Extra) -> ...code to convert state (and more) during code change... {ok, NewState}.
  • 46. JVM HotSwap is limited to method bodies. OSGi is invasive and state-unaware
  • 49. your managers will love *Rebel in production
  • 50. your ops will love *Rebel in production
  • 53. 1> A = 20. 20 2> self(). <0.32.0> 3> 5 / 0. ** exception error: bad argument in an arithmetic expression in operator '/'/2 called as 5 / 0 4> self(). <0.36.0> 5> A. 20 6>
  • 62. QueueConnectionFactory connFactory = new QueueConnectionFactory(); QueueConnection conn = connFactory.createQueueConnection(); QueueSession session = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); Queue q = new Queue("world"); QueueSender sender = session.createSender(q); TextMessage msg = session.createTextMessage(); msg.setText("Hello there!"); sender.send(msg); QueueReceiver receiver = session.createReceiver(q); conn.start(); Message m = receiver.receive(); if (m instanceof TextMessage) { TextMessage txt = (TextMessage) m; } session.close(); conn.close();
  • 63. register(serv, spawn(?MODULE, loop, [])), serv ! {self(), “Hello there!”}, receive {_Pid, Msg} -> … end. … loop() -> receive {From, Txt} -> … loop();
  • 64. $ erl +P 134217727 Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:8:8] [rq:8] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.8.5 (abort with ^G) 1> erlang:system_info(process_limit). 134217727 2>
  • 66. import kilim.Mailbox; import kilim.Pausable; import kilim.Task; public class SimpleTask extends Task { static Mailbox<String> mb = new Mailbox<String>(); public static void main(String[] args) throws Exception { new SimpleTask().start(); Thread.sleep(10); mb.putnb("Hello "); mb.putnb("Worldn"); mb.putnb("done"); } public void execute() throws Pausable { while (true) { String s = mb.get(); if (s.equals("done")) break; System.out.print(s); } System.exit(0); } }
  • 67. your ops will love this in production
  • 69. QueueConnectionFactory connFactory = new QueueConnectionFactory(); QueueConnection conn = connFactory.createQueueConnection(); QueueSession session = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); Queue q = new Queue("world"); QueueSender sender = session.createSender(q); TextMessage msg = session.createTextMessage(); msg.setText("Hello there!"); sender.send(msg); QueueReceiver receiver = session.createReceiver(q); conn.start(); Message m = receiver.receive(); if (m instanceof TextMessage) { TextMessage txt = (TextMessage) m; } session.close(); conn.close();
  • 70. {serv, 'serv@pc'} ! {self(), “Hello there!”}, receive {_Pid, Msg} -> … end. … loop() -> receive {From, Txt} -> … loop();
  • 72. import org.gridgain.grid.*; import org.gridgain.grid.gridify.*; import org.gridgain.grid.gridify.aop.spring.*; public final class GridifyHelloWorldSessionExample { private GridifyHelloWorldSessionExample() { //ensure singleton } @Gridify(taskClass = GridifyHelloWorldSessionTask.class, timeout = 3000) public static int sayIt(String phrase) { System.out.println(phrase); return phrase.length(); } public static void main(String[] args) throws GridException { if (args.length == 0) { GridFactory.start(); } else { GridFactory.start(args[0]); } try { int phraseLen = sayIt("Hello World"); System.out.println(„number of characters is '" + phraseLen + "'."); } finally { GridFactory.stop(true); } } }
  • 73. your ops will love this in production
  • 75. One GC per OS process. Complex generation management. Different GC stategies. Stop the world situations possible
  • 76. One GC per Erlang process. Simple generation management. (Mostly) one GC stategy. Stop the world situations unlikely.
  • 80. Hey, dude. So do you imply Erlang is better than Java for everything?
  • 81. Erlang dude: body() -> [ #h1 { text="My Simple Application" }, #label { text="What is your name?" }, #textbox { }, #button { text="Submit" } ].
  • 82. Java dude: LOL at you
  • 83. Ruby on rails dude: ROFL at y'all
  • 84. Erlang dude: calc_month(S) -> L = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], find_ix(L, S, 1).
  • 85. Java dude: LOL at you
  • 86. Erlang dude: Doing number crunching, you would completely utilize the available cores with few (as many) threads. Erlang is for time sharing and doesn't like long blocking processes.
  • 87. Java dude: LOL at you
  • 88. C dude: ROFL at y'all
  • 90. Some code examples were taken from public blogs / sites Most images originate from istockphoto.com except few ones taken from Wikipedia and product pages or generated through public online generators