SlideShare ist ein Scribd-Unternehmen logo
1 von 53
Downloaden Sie, um offline zu lesen
Cool Tools for Modern Erlang
  Program Development


       Kostis Sagonas
Erlang program development




         > erlc file.erl      > rebar compile



Kostis Sagonas             Cool Tools for Modern Erlang Program Development
What this talk is about

    Overview some Erlang software development
    tools that I and my students have built

    Convince you
     −   of their value and benefits of using them
     −   why they should have a key role in your development
         environment

    For tools that are mature
     −   give some hints/advice on how to properly use them
     −   show some new goodies

    For new tools, show/demo their capabilities

Kostis Sagonas                      Cool Tools for Modern Erlang Program Development
Tool #1




                 Dialyzer




Kostis Sagonas        Cool Tools for Modern Erlang Program Development
Dialyzer: A defect detection tool

    Uses static analysis to identify discrepancies in
    Erlang code bases
     −   code points where something is wrong
           
             often a bug
           
             or in any case something that needs fixing

    Fully automatic

    Extremely easy to use

    Fast and scalable

    Sound for defect detection
     −   “Dialyzer is never wrong”

Kostis Sagonas                           Cool Tools for Modern Erlang Program Development
Dialyzer

    Part of the Erlang/OTP distribution since 2007

    Detects
     −   Definite type errors
     −   API violations
     −   Unreachable and dead code
     −   Opacity violations
     −   Concurrency errors
           Data races (-Wrace_conditions)

    Experimental extensions with
     −   Stronger type inference
     −   Detection of message passing errors & deadlocks
Kostis Sagonas                       Cool Tools for Modern Erlang Program Development
How to use Dialyzer

    First build a PLT (needs to be done once)
        > dialyzer --build_plt --apps erts kernel stdlib



    Once this finishes, analyze your application
                 > cd my_app
                 > erlc +debug_info -o ebin src/*.erl
                 > dialyzer ebin


    If there are unknown functions, you may need to
    add more stuff to the PLT
           > dialyzer --add_to_plt --apps mnesia inets



Kostis Sagonas                       Cool Tools for Modern Erlang Program Development
Used more and more out there




Kostis Sagonas         Cool Tools for Modern Erlang Program Development
Erlang code bases ‘dialyzed’
agner alice aliter beamjs beehive beepbeep bert-erl bitcask cacherl
cacherl cecho ced chicagoboss chordial chordjerl couchbeam couchdb
cowboy disco distel dynomite edbi efene effigy egearmand-server egeoip
egitd ehotp ejabberd ejson eldap elib elib1 elock ememcached enet
eopenid eper epgsql epm epmail erlang-amf erlang-collectd erlang-
couchdb erlang-facebook erlang-js erlang-jukebox erlang-mysql erlang-
mysql-driver erlang-oauth erlang-protobuffs erlang-rfc4627 erlang-rtmp
erlang-twitter erlang-uuid erlang-websocket erlangit erlaws erlawys erldis
erlgmail erlguten erlide erlmongo erls3 erlsom erlsyslog erlwebsockserver
erlydtl erlyweb ernie esdl esmtp eswf etap etorrent ewgi excavator exmpp
fermal fragmentron fuzed gen-nb gen-paxos gen-smtp getopt giza gproc
herml hovercraft ibrowse innostore iserve jsonerl jungerl ktuo leex lfe
libgeoip-erlang log-roller log4erl lzjb-erlang mcd meck merle misultin
mochiweb mongo-erlang-driver mustache-erl natter neotoma ngerlguten
nitrogen openpoker osmos pgsql phoebus php-app playdar preach proper
protobuffs rabbit rebar redis-erl refactorerl reia reverl reversehttp riak
rogueunlike s3imagehost scalaris server sfmt-erlang sgte simple-bridge
socket-io-erlang sqlite-erlang sshrpc stoplight tcerl thrift-erl tora triq ubf
webmachine wings yatce yatsy yaws yxa zotonic
Kostis Sagonas                            Cool Tools for Modern Erlang Program Development
http://dialyzer.softlab.ntua.gr/




Kostis Sagonas              Cool Tools for Modern Erlang Program Development
Be nice to your fellow developers!




                 Expose type information:
                 make it part of the code



Kostis Sagonas                Cool Tools for Modern Erlang Program Development
Exposing type information
Can happen in either of the following ways:

    Add explicit type guards in key places in the code
     −   Ensures the validity of the information
     −   Has a runtime cost – typically small
     −   Programs may not be prepared to handle failures

    Add type declarations and function specs
     −   Documents functions and module interfaces
     −   Incurs no runtime overhead
     −   Can be used by dialyzer to detect contract violations
     −   Can also be handy for other tools (as we will see later)
Kostis Sagonas                        Cool Tools for Modern Erlang Program Development
Turning @specs into -specs
Often Edoc @spec annotations
  %% @spec batch_rename_mod(OldNamePattern::string(),
  %%                        NewNamePattern::string(),
  %%                        SearchPaths::[string()]) ->
  %%        ok | {error, string()}


Can easily be turned into -spec declarations
       -spec batch_rename_mod(OldNamePattern::string(),
                              NewNamePattern::string(),
                              SearchPaths::[string()]) ->
              'ok' | {'error', string()}.




Kostis Sagonas                  Cool Tools for Modern Erlang Program Development
Turning @specs into -specs
In some other cases
%% @spec duplicated_code(FileName ::filename(),
%%                       MinLines ::integer(),
%%                       MinClones::integer()) -> term()

Type declarations may need to be added
  -type filename() :: string().
  -spec duplicated_code(FileName ::filename(),
                        MinLines ::integer(),
                        MinClones::integer()) -> term().

Or, better, they may already exist in some modules
  -spec duplicated_code(FileName ::file:filename(),
                        MinLines ::integer(),
                        MinClones::integer()) -> term().
Kostis Sagonas                Cool Tools for Modern Erlang Program Development
Turning @specs into -specs
A problem with Edoc annotations is that often they
 are not in accordance with the code
     −   Not surprising – they are comments after all!


I strongly recommend converting @specs gradually
  and fixing the erroneous ones using Dialyzer
     −   First locally (on a module-by-module basis)
     −   Then globally




Kostis Sagonas                      Cool Tools for Modern Erlang Program Development
Strengthening underspecified -specs
 Can take place semi-automatically using Dialyzer
         > dialyzer -Wunderspecs --src -I ../hrl *.erl



refac_duplicated_code.erl:42:
   Type specification for duplicated_code/3 ::
    ([filename()],[integer()],[integer()]) -> term()
   is a supertype of the success typing:
    ([string()],[integer()],[integer()]) -> {'ok',string()}




 Kostis Sagonas                   Cool Tools for Modern Erlang Program Development
Document module interfaces




                  Add -spec declarations
                 for all exported functions




Kostis Sagonas                Cool Tools for Modern Erlang Program Development
Finding missing -specs
New compiler option helps in detecting these:
> erlc +warn_missing_spec -I../hrl refac_rename_var.erl
./refac_rename_var.erl:666: Warning:
    missing specification for function pre_cond_check/4




Kostis Sagonas               Cool Tools for Modern Erlang Program Development
Tool #2




                  Typer




Kostis Sagonas        Cool Tools for Modern Erlang Program Development
TypEr: A type annotator

    Part of Erlang/OTP since 2008

    Displays the function specs which
     −   already exist in a module/set of modules, or
     −   are inferred by dialyzer

    Can help in adding missing specs to files
 > typer --show-exported -I../hrl refac_rename_var.erl
 %% File: "refac_rename_var.erl"
 %% ----------------------------
 -spec pre_cond_check(tuple(),integer(),integer(),atom()) -> boolean().
 -spec rename(syntaxTree(),pos(),atom()) -> {syntaxTree(),boolean()}.
 -spec rename_var(filename(),...,[string()]) ->
               {'ok',string()} | {'error',string()}.


    Can also automatically annotate files
Kostis Sagonas                        Cool Tools for Modern Erlang Program Development
Add types to record fields
-record(hostent,
        {
          h_name,             %%   official name of host
          h_aliases = [],     %%   alias list
          h_addrtype,         %%   host address type
          h_length,           %%   length of address
          h_addr_list = []    %%   list of addresses from ...
         })
                              ⇓
-record(hostent,
        {
           h_name             ::   hostname(), %% official...
           h_aliases = []     ::   [hostname()],
           h_addrtype         ::   ’inet’ | ’inet6’,
           h_length           ::   non_neg_integer(), %% ...
           h_addr_list = []   ::   [ip_address()]     %% ...
        })
Kostis Sagonas                     Cool Tools for Modern Erlang Program Development
How Erlang modules used to look like




Kostis Sagonas     Cool Tools for Modern Erlang Program Development
How modern Erlang modules look




Kostis Sagonas      Cool Tools for Modern Erlang Program Development
Tool #3




                  Tidier




Kostis Sagonas        Cool Tools for Modern Erlang Program Development
Tidier: An automatic refactoring tool

    Uses static analysis and transformation to:
     −   Clean up Erlang code at the source level
     −   Modernize outdated language constructs
     −   Eliminate certain bad code smells from programs
     −   Improve performance of applications




Kostis Sagonas                     Cool Tools for Modern Erlang Program Development
Properties of the transformations

    Semantics preserving
     −   All transformations are conservative

    Improving some aspect of the code
     −   Newer instead of an older/obsolete constructs
     −   Smaller and/or more elegant code
     −   Redundancy elimination
     −   Performance improvement

    Syntactically pleasing and natural
     −   Similar to what an expert Erlang programmer would
         have written if transforming the code by hand

Kostis Sagonas                      Cool Tools for Modern Erlang Program Development
Tidier in action




Kostis Sagonas            Cool Tools for Modern Erlang Program Development
http://tidier.softlab.ntua.gr/




Kostis Sagonas                    Cool Tools for Modern Erlang Program Development
Current set of transformations

    Simple transformations and modernizations

    Record transformations

    List comprehension transformations

    Code simplifications and specializations

    Redundancy elimination transformations

    List comprehension simplifications

    Zip, unzip and deforestations

    Transformations improving runtime performance


Kostis Sagonas                Cool Tools for Modern Erlang Program Development
lib/kernel/src/group.erl:368

     case get_value(binary, Opts, case get(read_mode) of
                                     binary -> true;
                                     _ -> false
                                   end) of
         true -> ...


                              ⇓
case get_value(binary, Opts, get(read_mode) =:= binary) of
    true -> ...




Kostis Sagonas                    Cool Tools for Modern Erlang Program Development
lib/hipe/cerl/cerl_to_icode.erl:2370
            is_pure_op(N, A) ->
                case is_bool_op(N, A) of
                     true -> true;
                     false ->
                        case is_comp_op(N, A) of
                            true -> true;
                            false -> is_type_test(N, A)
                        end
                end.


                                ⇓
       is_pure_op(N, A) ->
           is_bool_op(N, A) orelse is_comp_op(N, A)
                            orelse is_type_test(N, A).


Kostis Sagonas                      Cool Tools for Modern Erlang Program Development
lib/inviso/src/inviso_tool_sh.erl:1638
  get_all_tracing_nodes_rtstates(RTStates) ->
    lists:map(fun ({N,_,_}) -> N end,
              lists:filter(fun ({_,{tracing,_},_}) ->
                                    true;
                                (_) -> false
                           end,
                           RTStates)).

                               ⇓
          get_all_tracing_nodes_rtstates(RTStates) ->
            [N || {N,{tracing,_},_} <- RTStates].




Kostis Sagonas                     Cool Tools for Modern Erlang Program Development
wrangler/src/refac_rename_fun.erl:344
      lists:map(fun ({_, X}) -> X end,
                lists:filter(fun (X) ->
                               case X of
                                  {atom, _X} -> true;
                                  _ -> false
                               end
                             end,
                             R))

                             ⇓
                   [X || {atom, X} <- R]




Kostis Sagonas                   Cool Tools for Modern Erlang Program Development
yaws/src/yaws_ls.erl:255

 mkrandbytes(N) ->
   list_to_binary(lists:map(fun(N) ->
                               random:uniform(256) - 1
                            end, lists:seq(1,N))).

                             ⇓
mkrandbytes(N) ->
  << <<(random:uniform(256)-1)>> || _ <- lists:seq(1,N)>>.




 Kostis Sagonas                  Cool Tools for Modern Erlang Program Development
disco-0.2/master/src/event_server.erl:123
   event_filter(Key, EvList) ->
      Fun = fun ({K, _}) when K == Key ->
                    true;
                 (_) ->
                    false
            end,
      {_, R} = lists:unzip(lists:filter(Fun, EvList)),
      R.

                                   ⇓
                 event_filter(Key, EvList) ->
                    [V || {K, V} <- EvList, K == Key].




Kostis Sagonas                         Cool Tools for Modern Erlang Program Development
Quote from a tidier user


I just ran a little demo for tidier here for ..., ..., ...,
and .... Many laughs and comments like "whose
code is that? Mine?!!" and a couple of "I didn't
know you could write that like that".
I'd like to force everyone to set it up and run tidier
on the code they are responsible for, as a learning
experience for many of the more junior developers
(and for some senior ones as well, apparently...).


Kostis Sagonas                  Cool Tools for Modern Erlang Program Development
Tool #4




                 PropEr




Kostis Sagonas        Cool Tools for Modern Erlang Program Development
PropEr: A property-based testing tool

    Inspired by QuickCheck

    Available open source under GPL

    Has support for
     −   Writing properties and test case generators
           ?FORALL/3, ?IMPLIES, ?SUCHTHAT/3, ?SHRINK/2,
           ?LAZY/1, ?WHENFAIL/2, ?LET/3, ?SIZED/2, 
           aggregate/2, choose2, oneof/1, ...
     −   Concurrent/parallel “statem” testing

    Fully integrated with the language of types and
    specs
     −   Generators often come for free!
Kostis Sagonas                      Cool Tools for Modern Erlang Program Development
Testing simple properties (1)
  -module(simple_props).

  -export([delete/2]).
  %% Properties are automatically exported.
  -include_lib("proper/include/proper.hrl").

  delete(X, L) ->
      delete(X, L, []).

  delete(_, [], Acc) ->
      lists:reverse(Acc);
  delete(X, [X|Rest], Acc) ->
      lists:reverse(Acc) ++ Rest;
  delete(X, [Y|Rest], Acc) ->
      delete(X, Rest, [Y|Acc]).

                 prop_delete() ->
                   ?FORALL({X,L}, {integer(),list(integer())},
                           not lists:member(X, delete(X,L))).
Kostis Sagonas                       Cool Tools for Modern Erlang Program Development
Testing simple properties (2)

%% Testing the base64 module:
%%   encode should be symmetric to decode:

prop_enc_dec() ->
  ?FORALL(Msg, union([binary(), list(range(1,255))]),
       begin
         EncDecMsg = base64:decode(base64:encode(Msg)),
         case is_binary(Msg) of
           true -> EncDecMsg =:= Msg;
           false -> EncDecMsg =:= list_to_binary(Msg)
         end
       end).




Kostis Sagonas                   Cool Tools for Modern Erlang Program Development
Automatically testing specs
       -module(specs).

       -export([divide/2, filter/2, max/1]).

       -spec divide(integer(), integer()) -> integer().
       divide(A, B) ->
           A div B.

       -spec filter(fun((T) -> term()), [T]) -> [T].
       filter(Fun, List) ->
           lists:filter(Fun, List).

       -spec max([T]) -> T.
       max(List) ->
           lists:max(List).


Kostis Sagonas                   Cool Tools for Modern Erlang Program Development
Automatically using types as generators

    We want to test that array:new/0 can handle
    any combination of options

    Why write a custom generator (which may rot)?

    We can use the type in that file as a generator!
        -type array_opt() :: ’fixed’ | non_neg_integer()
                           | {’default’, term()}
                           | {’fixed’, boolean()}
                           | {’size’, non_neg_integer()}.
        -type array_opts() :: array_opt() | [array_opt()].
                 -module(types).
                 -include_lib("proper/include/proper.hrl").

                 prop_new_array_opts() ->
                     ?FORALL(Opts, array:array_opts(),
                             array:is_array(array:new(Opts))).
Kostis Sagonas                        Cool Tools for Modern Erlang Program Development
Tool #5




                  CED




Kostis Sagonas        Cool Tools for Modern Erlang Program Development
CED: Concurrency Error Detector

    Detects some concurrency errors (or verifies their
    absence) by controlling process interleavings
     −   Systematically explores program state space

    Uses existing tests to detect
     −   Exceptions (due to race conditions)
     −   Assertion violations
     −   Deadlocks

    Can consistently reproduce an erroneous
    execution


Kostis Sagonas                     Cool Tools for Modern Erlang Program Development
CED: Example

                 -module(test).

                 -export([foo/0]).

                 foo() ->
                   process_flag(trap_exit, true),
                   Pid = spawn(fun bar/0),
                   link(Pid),
                   receive
                     {'EXIT', Pid, normal} -> ok
                   end.

                 bar() ->
                   ok.



Kostis Sagonas                       Cool Tools for Modern Erlang Program Development
CED: Future extensions

    Use partial order reduction to speed up execution
     −   by avoiding redundant interleavings

    Allow selective instrumentation

    Enhance compatibility with eunit & common_test




Kostis Sagonas                     Cool Tools for Modern Erlang Program Development
Concluding remarks
Described the uses of some tools for modern Erlang
 program development:
     Dialyzer: Automatically identifies bugs or issues in ths
      code that need to be fixed
     Typer: Displays/adds type information to programs
     Tidier: Cleans up Erlang source code
     Proper: Performs semi-automatic property based testing
     CED: Systematically runs a test suite under all/some
      process inter-leavings



Kostis Sagonas                    Cool Tools for Modern Erlang Program Development
Where can I find these tools?
Dialyzer & Typer
     −   They are part of Erlang/OTP
Tidier
     −   Use of the tool is free via tidier’s web site
          http://tidier.softlab.ntua.gr/
     −   The tool is also available by purchasing a license
Proper & CED
     −   They are open source
           https://github.com/manopapad/proper/
           https://github.com/mariachris/CED/

Kostis Sagonas                        Cool Tools for Modern Erlang Program Development
A team effort
Dialyzer
     −   Tobias Lindahl (UU/Klarna)
     −   Maria Christakis & Stavros Aronis (NTUA)
Typer
     −   Tobias Lindahl & Bingwen He (UU)
Tidier
     −   Thanassis Avgerinos (NTUA/CMU)
Proper
     −   Manolis Papadakis & Eirini Arvaniti (NTUA)
CED
     −   Alkis Gotovos & Maria Christakis (NTUA)
Kostis Sagonas                        Cool Tools for Modern Erlang Program Development

Weitere ähnliche Inhalte

Was ist angesagt?

Comparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms SoftwareComparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms Softwarel xf
 
Keynote joearmstrong
Keynote joearmstrongKeynote joearmstrong
Keynote joearmstrongSentifi
 
Cs6660 compiler design
Cs6660 compiler designCs6660 compiler design
Cs6660 compiler designhari2010
 
4 compiler lab - Syntax Ana
4 compiler lab - Syntax Ana4 compiler lab - Syntax Ana
4 compiler lab - Syntax AnaMashaelQ
 
Software languages
Software languagesSoftware languages
Software languagesEelco Visser
 
Pré Descobrimento Do Brasil
Pré Descobrimento Do BrasilPré Descobrimento Do Brasil
Pré Descobrimento Do Brasilecsette
 
P4 P Update January 2009
P4 P Update January 2009P4 P Update January 2009
P4 P Update January 2009vsainteluce
 
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...Shinpei Hayashi
 
Ncm2010 ruo ando
Ncm2010 ruo andoNcm2010 ruo ando
Ncm2010 ruo andoRuo Ando
 
Compiler design
Compiler designCompiler design
Compiler designsanchi29
 
Different phases of a compiler
Different phases of a compilerDifferent phases of a compiler
Different phases of a compilerSumit Sinha
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For ManagersAtul Shridhar
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Maarten Balliauw
 

Was ist angesagt? (20)

Unit 1 cd
Unit 1 cdUnit 1 cd
Unit 1 cd
 
Comparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms SoftwareComparing Cpp And Erlang For Motorola Telecoms Software
Comparing Cpp And Erlang For Motorola Telecoms Software
 
Keynote joearmstrong
Keynote joearmstrongKeynote joearmstrong
Keynote joearmstrong
 
Cs6660 compiler design
Cs6660 compiler designCs6660 compiler design
Cs6660 compiler design
 
Unit 5 cspc
Unit 5 cspcUnit 5 cspc
Unit 5 cspc
 
4 compiler lab - Syntax Ana
4 compiler lab - Syntax Ana4 compiler lab - Syntax Ana
4 compiler lab - Syntax Ana
 
Software languages
Software languagesSoftware languages
Software languages
 
Pré Descobrimento Do Brasil
Pré Descobrimento Do BrasilPré Descobrimento Do Brasil
Pré Descobrimento Do Brasil
 
P4 P Update January 2009
P4 P Update January 2009P4 P Update January 2009
P4 P Update January 2009
 
Ebay News 2000 10 19 Earnings
Ebay News 2000 10 19 EarningsEbay News 2000 10 19 Earnings
Ebay News 2000 10 19 Earnings
 
Ebay News 2001 4 19 Earnings
Ebay News 2001 4 19 EarningsEbay News 2001 4 19 Earnings
Ebay News 2001 4 19 Earnings
 
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
Generating Assertion Code from OCL: A Transformational Approach Based on Simi...
 
Ncm2010 ruo ando
Ncm2010 ruo andoNcm2010 ruo ando
Ncm2010 ruo ando
 
Compiler design
Compiler designCompiler design
Compiler design
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Compiler unit 1
Compiler unit 1Compiler unit 1
Compiler unit 1
 
Different phases of a compiler
Different phases of a compilerDifferent phases of a compiler
Different phases of a compiler
 
Python Intro For Managers
Python Intro For ManagersPython Intro For Managers
Python Intro For Managers
 
In Vogue Dynamic
In Vogue DynamicIn Vogue Dynamic
In Vogue Dynamic
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
 

Andere mochten auch

Complex Legacy System Archiving/Data Retention with MongoDB and Xquery
Complex Legacy System Archiving/Data Retention with MongoDB and XqueryComplex Legacy System Archiving/Data Retention with MongoDB and Xquery
Complex Legacy System Archiving/Data Retention with MongoDB and XqueryDATAVERSITY
 
Blazes: coordination analysis for distributed programs
Blazes: coordination analysis for distributed programsBlazes: coordination analysis for distributed programs
Blazes: coordination analysis for distributed programspalvaro
 
LXC, Docker, and the future of software delivery | LinuxCon 2013
LXC, Docker, and the future of software delivery | LinuxCon 2013LXC, Docker, and the future of software delivery | LinuxCon 2013
LXC, Docker, and the future of software delivery | LinuxCon 2013dotCloud
 
Hyperdex - A closer look
Hyperdex - A closer lookHyperdex - A closer look
Hyperdex - A closer lookDECK36
 
Chloe and the Realtime Web
Chloe and the Realtime WebChloe and the Realtime Web
Chloe and the Realtime WebTrotter Cashion
 
Riak Search - Erlang Factory London 2010
Riak Search - Erlang Factory London 2010Riak Search - Erlang Factory London 2010
Riak Search - Erlang Factory London 2010Rusty Klophaus
 
(Functional) reactive programming (@pavlobaron)
(Functional) reactive programming (@pavlobaron)(Functional) reactive programming (@pavlobaron)
(Functional) reactive programming (@pavlobaron)Pavlo Baron
 
ElasticSearch - index server used as a document database
ElasticSearch - index server used as a document databaseElasticSearch - index server used as a document database
ElasticSearch - index server used as a document databaseRobert Lujo
 
Spring Cleaning for Your Smartphone
Spring Cleaning for Your SmartphoneSpring Cleaning for Your Smartphone
Spring Cleaning for Your SmartphoneLookout
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John StevensonJAX London
 
Erlang - Because s**t Happens by Mahesh Paolini-Subramanya
Erlang - Because s**t Happens by Mahesh Paolini-SubramanyaErlang - Because s**t Happens by Mahesh Paolini-Subramanya
Erlang - Because s**t Happens by Mahesh Paolini-SubramanyaHakka Labs
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
20 reasons why we don't need architects (@pavlobaron)
20 reasons why we don't need architects (@pavlobaron)20 reasons why we don't need architects (@pavlobaron)
20 reasons why we don't need architects (@pavlobaron)Pavlo Baron
 
Winning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleWinning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleRusty Klophaus
 

Andere mochten auch (20)

Complex Legacy System Archiving/Data Retention with MongoDB and Xquery
Complex Legacy System Archiving/Data Retention with MongoDB and XqueryComplex Legacy System Archiving/Data Retention with MongoDB and Xquery
Complex Legacy System Archiving/Data Retention with MongoDB and Xquery
 
Blazes: coordination analysis for distributed programs
Blazes: coordination analysis for distributed programsBlazes: coordination analysis for distributed programs
Blazes: coordination analysis for distributed programs
 
LXC, Docker, and the future of software delivery | LinuxCon 2013
LXC, Docker, and the future of software delivery | LinuxCon 2013LXC, Docker, and the future of software delivery | LinuxCon 2013
LXC, Docker, and the future of software delivery | LinuxCon 2013
 
Brunch With Coffee
Brunch With CoffeeBrunch With Coffee
Brunch With Coffee
 
Hyperdex - A closer look
Hyperdex - A closer lookHyperdex - A closer look
Hyperdex - A closer look
 
Chloe and the Realtime Web
Chloe and the Realtime WebChloe and the Realtime Web
Chloe and the Realtime Web
 
Riak Search - Erlang Factory London 2010
Riak Search - Erlang Factory London 2010Riak Search - Erlang Factory London 2010
Riak Search - Erlang Factory London 2010
 
(Functional) reactive programming (@pavlobaron)
(Functional) reactive programming (@pavlobaron)(Functional) reactive programming (@pavlobaron)
(Functional) reactive programming (@pavlobaron)
 
ElasticSearch - index server used as a document database
ElasticSearch - index server used as a document databaseElasticSearch - index server used as a document database
ElasticSearch - index server used as a document database
 
NkSIP: The Erlang SIP application server
NkSIP: The Erlang SIP application serverNkSIP: The Erlang SIP application server
NkSIP: The Erlang SIP application server
 
Spring Cleaning for Your Smartphone
Spring Cleaning for Your SmartphoneSpring Cleaning for Your Smartphone
Spring Cleaning for Your Smartphone
 
High Performance Erlang
High  Performance  ErlangHigh  Performance  Erlang
High Performance Erlang
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
 
Elixir talk
Elixir talkElixir talk
Elixir talk
 
Erlang - Because s**t Happens by Mahesh Paolini-Subramanya
Erlang - Because s**t Happens by Mahesh Paolini-SubramanyaErlang - Because s**t Happens by Mahesh Paolini-Subramanya
Erlang - Because s**t Happens by Mahesh Paolini-Subramanya
 
Clojure values
Clojure valuesClojure values
Clojure values
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
Clojure class
Clojure classClojure class
Clojure class
 
20 reasons why we don't need architects (@pavlobaron)
20 reasons why we don't need architects (@pavlobaron)20 reasons why we don't need architects (@pavlobaron)
20 reasons why we don't need architects (@pavlobaron)
 
Winning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test CycleWinning the Erlang Edit•Build•Test Cycle
Winning the Erlang Edit•Build•Test Cycle
 

Ähnlich wie Kostis Sagonas: Cool Tools for Modern Erlang Program Developmen

Software Development Automation With Scripting Languages
Software Development Automation With Scripting LanguagesSoftware Development Automation With Scripting Languages
Software Development Automation With Scripting LanguagesIonela
 
Aspect-oriented programming in Perl
Aspect-oriented programming in PerlAspect-oriented programming in Perl
Aspect-oriented programming in Perlmegakott
 
(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel ArchitecturesJoel Falcou
 
Reverse code engineering
Reverse code engineeringReverse code engineering
Reverse code engineeringKrishs Patil
 
Hacking with Reverse Engineering and Defense against it
Hacking with Reverse Engineering and Defense against it Hacking with Reverse Engineering and Defense against it
Hacking with Reverse Engineering and Defense against it Prakashchand Suthar
 
VB2013 - Security Research and Development Framework
VB2013 - Security Research and Development FrameworkVB2013 - Security Research and Development Framework
VB2013 - Security Research and Development FrameworkAmr Thabet
 
the productive programer: mechanics
the productive programer: mechanicsthe productive programer: mechanics
the productive programer: mechanicselliando dias
 
Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to ElixirDiacode
 
C++ advanced PPT.pdf
C++ advanced PPT.pdfC++ advanced PPT.pdf
C++ advanced PPT.pdfDinashMaliya3
 
Open Source RAD with OpenERP 7.0
Open Source RAD with OpenERP 7.0Open Source RAD with OpenERP 7.0
Open Source RAD with OpenERP 7.0Quang Ngoc
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails DevsDiacode
 
OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3Borni DHIFI
 
Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02Wei Sun
 
PVS-Studio and static code analysis technique
PVS-Studio and static code analysis techniquePVS-Studio and static code analysis technique
PVS-Studio and static code analysis techniqueAndrey Karpov
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming languageVasavi College of Engg
 
Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of CompilerPreethi AKNR
 
Creating Developer-Friendly Docker Containers with Chaperone
Creating Developer-Friendly Docker Containers with ChaperoneCreating Developer-Friendly Docker Containers with Chaperone
Creating Developer-Friendly Docker Containers with ChaperoneGary Wisniewski
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review ProcessDr. Syed Hassan Amin
 

Ähnlich wie Kostis Sagonas: Cool Tools for Modern Erlang Program Developmen (20)

Cpcs302 1
Cpcs302  1Cpcs302  1
Cpcs302 1
 
Software Development Automation With Scripting Languages
Software Development Automation With Scripting LanguagesSoftware Development Automation With Scripting Languages
Software Development Automation With Scripting Languages
 
Aspect-oriented programming in Perl
Aspect-oriented programming in PerlAspect-oriented programming in Perl
Aspect-oriented programming in Perl
 
(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures
 
Reverse code engineering
Reverse code engineeringReverse code engineering
Reverse code engineering
 
Hacking with Reverse Engineering and Defense against it
Hacking with Reverse Engineering and Defense against it Hacking with Reverse Engineering and Defense against it
Hacking with Reverse Engineering and Defense against it
 
VB2013 - Security Research and Development Framework
VB2013 - Security Research and Development FrameworkVB2013 - Security Research and Development Framework
VB2013 - Security Research and Development Framework
 
the productive programer: mechanics
the productive programer: mechanicsthe productive programer: mechanics
the productive programer: mechanics
 
Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to Elixir
 
C++ advanced PPT.pdf
C++ advanced PPT.pdfC++ advanced PPT.pdf
C++ advanced PPT.pdf
 
Open Source RAD with OpenERP 7.0
Open Source RAD with OpenERP 7.0Open Source RAD with OpenERP 7.0
Open Source RAD with OpenERP 7.0
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails Devs
 
OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3
 
Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02Dotnetintroduce 100324201546-phpapp02
Dotnetintroduce 100324201546-phpapp02
 
PVS-Studio and static code analysis technique
PVS-Studio and static code analysis techniquePVS-Studio and static code analysis technique
PVS-Studio and static code analysis technique
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
 
01. introduction
01. introduction01. introduction
01. introduction
 
Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
 
Creating Developer-Friendly Docker Containers with Chaperone
Creating Developer-Friendly Docker Containers with ChaperoneCreating Developer-Friendly Docker Containers with Chaperone
Creating Developer-Friendly Docker Containers with Chaperone
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review Process
 

Kürzlich hochgeladen

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 

Kürzlich hochgeladen (20)

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 

Kostis Sagonas: Cool Tools for Modern Erlang Program Developmen

  • 1. Cool Tools for Modern Erlang Program Development Kostis Sagonas
  • 2. Erlang program development > erlc file.erl > rebar compile Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 3. What this talk is about  Overview some Erlang software development tools that I and my students have built  Convince you − of their value and benefits of using them − why they should have a key role in your development environment  For tools that are mature − give some hints/advice on how to properly use them − show some new goodies  For new tools, show/demo their capabilities Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 4. Tool #1 Dialyzer Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 5. Dialyzer: A defect detection tool  Uses static analysis to identify discrepancies in Erlang code bases − code points where something is wrong  often a bug  or in any case something that needs fixing  Fully automatic  Extremely easy to use  Fast and scalable  Sound for defect detection − “Dialyzer is never wrong” Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 6. Dialyzer  Part of the Erlang/OTP distribution since 2007  Detects − Definite type errors − API violations − Unreachable and dead code − Opacity violations − Concurrency errors Data races (-Wrace_conditions)  Experimental extensions with − Stronger type inference − Detection of message passing errors & deadlocks Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 7. How to use Dialyzer  First build a PLT (needs to be done once) > dialyzer --build_plt --apps erts kernel stdlib  Once this finishes, analyze your application > cd my_app > erlc +debug_info -o ebin src/*.erl > dialyzer ebin  If there are unknown functions, you may need to add more stuff to the PLT > dialyzer --add_to_plt --apps mnesia inets Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 8. Used more and more out there Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 9. Erlang code bases ‘dialyzed’ agner alice aliter beamjs beehive beepbeep bert-erl bitcask cacherl cacherl cecho ced chicagoboss chordial chordjerl couchbeam couchdb cowboy disco distel dynomite edbi efene effigy egearmand-server egeoip egitd ehotp ejabberd ejson eldap elib elib1 elock ememcached enet eopenid eper epgsql epm epmail erlang-amf erlang-collectd erlang- couchdb erlang-facebook erlang-js erlang-jukebox erlang-mysql erlang- mysql-driver erlang-oauth erlang-protobuffs erlang-rfc4627 erlang-rtmp erlang-twitter erlang-uuid erlang-websocket erlangit erlaws erlawys erldis erlgmail erlguten erlide erlmongo erls3 erlsom erlsyslog erlwebsockserver erlydtl erlyweb ernie esdl esmtp eswf etap etorrent ewgi excavator exmpp fermal fragmentron fuzed gen-nb gen-paxos gen-smtp getopt giza gproc herml hovercraft ibrowse innostore iserve jsonerl jungerl ktuo leex lfe libgeoip-erlang log-roller log4erl lzjb-erlang mcd meck merle misultin mochiweb mongo-erlang-driver mustache-erl natter neotoma ngerlguten nitrogen openpoker osmos pgsql phoebus php-app playdar preach proper protobuffs rabbit rebar redis-erl refactorerl reia reverl reversehttp riak rogueunlike s3imagehost scalaris server sfmt-erlang sgte simple-bridge socket-io-erlang sqlite-erlang sshrpc stoplight tcerl thrift-erl tora triq ubf webmachine wings yatce yatsy yaws yxa zotonic Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 10. http://dialyzer.softlab.ntua.gr/ Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 11. Be nice to your fellow developers! Expose type information: make it part of the code Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 12. Exposing type information Can happen in either of the following ways:  Add explicit type guards in key places in the code − Ensures the validity of the information − Has a runtime cost – typically small − Programs may not be prepared to handle failures  Add type declarations and function specs − Documents functions and module interfaces − Incurs no runtime overhead − Can be used by dialyzer to detect contract violations − Can also be handy for other tools (as we will see later) Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 13. Turning @specs into -specs Often Edoc @spec annotations %% @spec batch_rename_mod(OldNamePattern::string(), %% NewNamePattern::string(), %% SearchPaths::[string()]) -> %% ok | {error, string()} Can easily be turned into -spec declarations -spec batch_rename_mod(OldNamePattern::string(), NewNamePattern::string(), SearchPaths::[string()]) -> 'ok' | {'error', string()}. Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 14. Turning @specs into -specs In some other cases %% @spec duplicated_code(FileName ::filename(), %% MinLines ::integer(), %% MinClones::integer()) -> term() Type declarations may need to be added -type filename() :: string(). -spec duplicated_code(FileName ::filename(), MinLines ::integer(), MinClones::integer()) -> term(). Or, better, they may already exist in some modules -spec duplicated_code(FileName ::file:filename(), MinLines ::integer(), MinClones::integer()) -> term(). Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 15. Turning @specs into -specs A problem with Edoc annotations is that often they are not in accordance with the code − Not surprising – they are comments after all! I strongly recommend converting @specs gradually and fixing the erroneous ones using Dialyzer − First locally (on a module-by-module basis) − Then globally Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 16. Strengthening underspecified -specs Can take place semi-automatically using Dialyzer > dialyzer -Wunderspecs --src -I ../hrl *.erl refac_duplicated_code.erl:42: Type specification for duplicated_code/3 :: ([filename()],[integer()],[integer()]) -> term() is a supertype of the success typing: ([string()],[integer()],[integer()]) -> {'ok',string()} Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 17. Document module interfaces Add -spec declarations for all exported functions Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 18. Finding missing -specs New compiler option helps in detecting these: > erlc +warn_missing_spec -I../hrl refac_rename_var.erl ./refac_rename_var.erl:666: Warning: missing specification for function pre_cond_check/4 Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 19. Tool #2 Typer Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 20. TypEr: A type annotator  Part of Erlang/OTP since 2008  Displays the function specs which − already exist in a module/set of modules, or − are inferred by dialyzer  Can help in adding missing specs to files > typer --show-exported -I../hrl refac_rename_var.erl %% File: "refac_rename_var.erl" %% ---------------------------- -spec pre_cond_check(tuple(),integer(),integer(),atom()) -> boolean(). -spec rename(syntaxTree(),pos(),atom()) -> {syntaxTree(),boolean()}. -spec rename_var(filename(),...,[string()]) -> {'ok',string()} | {'error',string()}.  Can also automatically annotate files Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 21. Add types to record fields -record(hostent, { h_name, %% official name of host h_aliases = [], %% alias list h_addrtype, %% host address type h_length, %% length of address h_addr_list = [] %% list of addresses from ... }) ⇓ -record(hostent, { h_name :: hostname(), %% official... h_aliases = [] :: [hostname()], h_addrtype :: ’inet’ | ’inet6’, h_length :: non_neg_integer(), %% ... h_addr_list = [] :: [ip_address()] %% ... }) Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 22. How Erlang modules used to look like Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 23. How modern Erlang modules look Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 24. Tool #3 Tidier Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 25. Tidier: An automatic refactoring tool  Uses static analysis and transformation to: − Clean up Erlang code at the source level − Modernize outdated language constructs − Eliminate certain bad code smells from programs − Improve performance of applications Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 26. Properties of the transformations  Semantics preserving − All transformations are conservative  Improving some aspect of the code − Newer instead of an older/obsolete constructs − Smaller and/or more elegant code − Redundancy elimination − Performance improvement  Syntactically pleasing and natural − Similar to what an expert Erlang programmer would have written if transforming the code by hand Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 27. Tidier in action Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 28. http://tidier.softlab.ntua.gr/ Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 29. Current set of transformations  Simple transformations and modernizations  Record transformations  List comprehension transformations  Code simplifications and specializations  Redundancy elimination transformations  List comprehension simplifications  Zip, unzip and deforestations  Transformations improving runtime performance Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 30. lib/kernel/src/group.erl:368 case get_value(binary, Opts, case get(read_mode) of binary -> true; _ -> false end) of true -> ... ⇓ case get_value(binary, Opts, get(read_mode) =:= binary) of true -> ... Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 31. lib/hipe/cerl/cerl_to_icode.erl:2370 is_pure_op(N, A) -> case is_bool_op(N, A) of true -> true; false -> case is_comp_op(N, A) of true -> true; false -> is_type_test(N, A) end end. ⇓ is_pure_op(N, A) -> is_bool_op(N, A) orelse is_comp_op(N, A) orelse is_type_test(N, A). Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 32. lib/inviso/src/inviso_tool_sh.erl:1638 get_all_tracing_nodes_rtstates(RTStates) -> lists:map(fun ({N,_,_}) -> N end, lists:filter(fun ({_,{tracing,_},_}) -> true; (_) -> false end, RTStates)). ⇓ get_all_tracing_nodes_rtstates(RTStates) -> [N || {N,{tracing,_},_} <- RTStates]. Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 33. wrangler/src/refac_rename_fun.erl:344 lists:map(fun ({_, X}) -> X end, lists:filter(fun (X) -> case X of {atom, _X} -> true; _ -> false end end, R)) ⇓ [X || {atom, X} <- R] Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 34. yaws/src/yaws_ls.erl:255 mkrandbytes(N) -> list_to_binary(lists:map(fun(N) -> random:uniform(256) - 1 end, lists:seq(1,N))). ⇓ mkrandbytes(N) -> << <<(random:uniform(256)-1)>> || _ <- lists:seq(1,N)>>. Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 35. disco-0.2/master/src/event_server.erl:123 event_filter(Key, EvList) -> Fun = fun ({K, _}) when K == Key -> true; (_) -> false end, {_, R} = lists:unzip(lists:filter(Fun, EvList)), R. ⇓ event_filter(Key, EvList) -> [V || {K, V} <- EvList, K == Key]. Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 36. Quote from a tidier user I just ran a little demo for tidier here for ..., ..., ..., and .... Many laughs and comments like "whose code is that? Mine?!!" and a couple of "I didn't know you could write that like that". I'd like to force everyone to set it up and run tidier on the code they are responsible for, as a learning experience for many of the more junior developers (and for some senior ones as well, apparently...). Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 37. Tool #4 PropEr Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 38. PropEr: A property-based testing tool  Inspired by QuickCheck  Available open source under GPL  Has support for − Writing properties and test case generators ?FORALL/3, ?IMPLIES, ?SUCHTHAT/3, ?SHRINK/2, ?LAZY/1, ?WHENFAIL/2, ?LET/3, ?SIZED/2,  aggregate/2, choose2, oneof/1, ... − Concurrent/parallel “statem” testing  Fully integrated with the language of types and specs − Generators often come for free! Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 39. Testing simple properties (1) -module(simple_props). -export([delete/2]). %% Properties are automatically exported. -include_lib("proper/include/proper.hrl"). delete(X, L) -> delete(X, L, []). delete(_, [], Acc) -> lists:reverse(Acc); delete(X, [X|Rest], Acc) -> lists:reverse(Acc) ++ Rest; delete(X, [Y|Rest], Acc) -> delete(X, Rest, [Y|Acc]). prop_delete() -> ?FORALL({X,L}, {integer(),list(integer())}, not lists:member(X, delete(X,L))). Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 40. Testing simple properties (2) %% Testing the base64 module: %% encode should be symmetric to decode: prop_enc_dec() -> ?FORALL(Msg, union([binary(), list(range(1,255))]), begin EncDecMsg = base64:decode(base64:encode(Msg)), case is_binary(Msg) of true -> EncDecMsg =:= Msg; false -> EncDecMsg =:= list_to_binary(Msg) end end). Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 41. Automatically testing specs -module(specs). -export([divide/2, filter/2, max/1]). -spec divide(integer(), integer()) -> integer(). divide(A, B) -> A div B. -spec filter(fun((T) -> term()), [T]) -> [T]. filter(Fun, List) -> lists:filter(Fun, List). -spec max([T]) -> T. max(List) -> lists:max(List). Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 42. Automatically using types as generators  We want to test that array:new/0 can handle any combination of options  Why write a custom generator (which may rot)?  We can use the type in that file as a generator! -type array_opt() :: ’fixed’ | non_neg_integer() | {’default’, term()} | {’fixed’, boolean()} | {’size’, non_neg_integer()}. -type array_opts() :: array_opt() | [array_opt()]. -module(types). -include_lib("proper/include/proper.hrl"). prop_new_array_opts() -> ?FORALL(Opts, array:array_opts(), array:is_array(array:new(Opts))). Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 43. Tool #5 CED Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 44. CED: Concurrency Error Detector  Detects some concurrency errors (or verifies their absence) by controlling process interleavings − Systematically explores program state space  Uses existing tests to detect − Exceptions (due to race conditions) − Assertion violations − Deadlocks  Can consistently reproduce an erroneous execution Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 45. CED: Example -module(test). -export([foo/0]). foo() -> process_flag(trap_exit, true), Pid = spawn(fun bar/0), link(Pid), receive {'EXIT', Pid, normal} -> ok end. bar() -> ok. Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 46.
  • 47.
  • 48.
  • 49.
  • 50. CED: Future extensions  Use partial order reduction to speed up execution − by avoiding redundant interleavings  Allow selective instrumentation  Enhance compatibility with eunit & common_test Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 51. Concluding remarks Described the uses of some tools for modern Erlang program development: Dialyzer: Automatically identifies bugs or issues in ths code that need to be fixed Typer: Displays/adds type information to programs Tidier: Cleans up Erlang source code Proper: Performs semi-automatic property based testing CED: Systematically runs a test suite under all/some process inter-leavings Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 52. Where can I find these tools? Dialyzer & Typer − They are part of Erlang/OTP Tidier − Use of the tool is free via tidier’s web site http://tidier.softlab.ntua.gr/ − The tool is also available by purchasing a license Proper & CED − They are open source https://github.com/manopapad/proper/ https://github.com/mariachris/CED/ Kostis Sagonas Cool Tools for Modern Erlang Program Development
  • 53. A team effort Dialyzer − Tobias Lindahl (UU/Klarna) − Maria Christakis & Stavros Aronis (NTUA) Typer − Tobias Lindahl & Bingwen He (UU) Tidier − Thanassis Avgerinos (NTUA/CMU) Proper − Manolis Papadakis & Eirini Arvaniti (NTUA) CED − Alkis Gotovos & Maria Christakis (NTUA) Kostis Sagonas Cool Tools for Modern Erlang Program Development