This document discusses several Erlang program development tools, including Dialyzer, Typer, Tidier, and PropEr. It provides an overview of each tool's capabilities and benefits. Dialyzer is described as a defect detection tool that uses static analysis to identify discrepancies. Typer displays function specs that are exported or inferred by Dialyzer. Tidier is an automatic refactoring tool that cleans up and modernizes Erlang code through semantics-preserving transformations. PropEr is introduced as a property-based testing tool inspired by QuickCheck. Examples of how each tool can be used are also provided.
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...lennartkats
Language extensions increase programmer productivity by providing concise, often domain-specific syntax, and support for static verification of correctness, security, and style constraints. Language extensions can often be realized through translation to the base language, supported by preprocessors and extensible compilers. However, various kinds of extensions require further adaptation of a base compiler's internal stages and components, for example to support separate compilation or to make use of low-level primitives of the platform (e.g., jump instructions or unbalanced synchronization). To allow for a more loosely coupled approach, we propose an open compiler model based on normalization steps from a high-level language to a subset of it, the core language. We developed such a compiler for a mixed Java and (core) bytecode language, and evaluate its effectiveness for composition mechanisms such as traits, as well as statement-level and expression-level language extensions.
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...lennartkats
Language extensions increase programmer productivity by providing concise, often domain-specific syntax, and support for static verification of correctness, security, and style constraints. Language extensions can often be realized through translation to the base language, supported by preprocessors and extensible compilers. However, various kinds of extensions require further adaptation of a base compiler's internal stages and components, for example to support separate compilation or to make use of low-level primitives of the platform (e.g., jump instructions or unbalanced synchronization). To allow for a more loosely coupled approach, we propose an open compiler model based on normalization steps from a high-level language to a subset of it, the core language. We developed such a compiler for a mixed Java and (core) bytecode language, and evaluate its effectiveness for composition mechanisms such as traits, as well as statement-level and expression-level language extensions.
In this PPT we covered all the points like..Introduction to compilers - Design issues, passes, phases, symbol table
Preliminaries - Memory management, Operating system support for compiler, Compiler support for garbage collection ,Lexical Analysis - Tokens, Regular Expressions, Process of Lexical analysis, Block Schematic, Automatic construction of lexical analyzer using LEX, LEX features and specification.
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Maarten Balliauw
Ever wondered how IDE’s are built? In this talk, we’ll skip the marketing bit and dive into the architecture and implementation of JetBrains Rider. We’ll look at how and why we have built (and open sourced) a reactive protocol, and how the IDE uses a “microservices” architecture to communicate with the debugger, Roslyn, a WPF renderer and even other tools like Unity3D. We’ll explore how things are wired together, both in-process and across those microservices. Let’s geek out!
Complex Legacy System Archiving/Data Retention with MongoDB and XqueryDATAVERSITY
Many organizations today, due to regulatory compliance or other needs, are finding it necessary to archive large volumes of data into long-term storage. Learn how MongoDB provides a flexible, efficient, scalable, long-term document storage that can adapt to your organization's changing needs over time. A case study from US federal government agency with 130 legacy applications that needed to be archived and integrated into a federated view of archive and real-time operational data. Regulations in many industries (eg HIPAA, SOX, Basel 3, FATCA etc) are driving the need for data retention and the need for query processing across archives and operational data.
In this PPT we covered all the points like..Introduction to compilers - Design issues, passes, phases, symbol table
Preliminaries - Memory management, Operating system support for compiler, Compiler support for garbage collection ,Lexical Analysis - Tokens, Regular Expressions, Process of Lexical analysis, Block Schematic, Automatic construction of lexical analyzer using LEX, LEX features and specification.
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Maarten Balliauw
Ever wondered how IDE’s are built? In this talk, we’ll skip the marketing bit and dive into the architecture and implementation of JetBrains Rider. We’ll look at how and why we have built (and open sourced) a reactive protocol, and how the IDE uses a “microservices” architecture to communicate with the debugger, Roslyn, a WPF renderer and even other tools like Unity3D. We’ll explore how things are wired together, both in-process and across those microservices. Let’s geek out!
Complex Legacy System Archiving/Data Retention with MongoDB and XqueryDATAVERSITY
Many organizations today, due to regulatory compliance or other needs, are finding it necessary to archive large volumes of data into long-term storage. Learn how MongoDB provides a flexible, efficient, scalable, long-term document storage that can adapt to your organization's changing needs over time. A case study from US federal government agency with 130 legacy applications that needed to be archived and integrated into a federated view of archive and real-time operational data. Regulations in many industries (eg HIPAA, SOX, Basel 3, FATCA etc) are driving the need for data retention and the need for query processing across archives and operational data.
Riak Search is a distributed data indexing and search platform built on top of Riak. The talk will introduce Riak Search, covering overall goals, architecture, and core functionality, with specific focus on how Erlang is used to manage and execute an ever-changing population of ad hoc query processes.
ElasticSearch - index server used as a document databaseRobert Lujo
Presentation held on 5.10.2014 on http://2014.webcampzg.org/talks/.
Although ElasticSearch (ES) primary purpose is to be used as index/search server, in its featureset ES overlaps with common NoSql database; better to say, document database.
Why this could be interesting and how this could be used effectively?
Talk overview:
- ES - history, background, philosophy, featureset overview, focus on indexing/search features
- short presentation on how to get started - installation, indexing and search/retrieving
- Database should provide following functions: store, search, retrieve -> differences between relational, document and search databases
- it is not unusual to use ES additionally as an document database (store and retrieve)
- an use-case will be presented where ES can be used as a single database in the system (benefits and drawbacks)
- what if a relational database is introduced in previosly demonstrated system (benefits and drawbacks)
ES is a nice and in reality ready-to-use example that can change perspective of development of some type of software systems.
Your smartphone needs a spring cleaning, too. There's a lot of important stuff on your phone, but there are probably a few things you can get rid of as well. Between apps you haven't opened since you downloaded them to photos that are better off in the cloud, here's a roundup of our favorite ways to clear the digital clutter.
There is an increasing interest in functional programming from Java developers and the organisations in which they work. For many companies the challenge now is how to make use of the competitive advantage of functional programming. For developers, how do you adapt your mindset to this newly reimagined paradigm? Through the use of examples and a modular approach to design, Clojure made simple will show how developers can be productive quickly without a major change to their current development life-cycle. We will also cover the Clojure build process, tools and exciting projects out there.
Erlang - Because s**t Happens by Mahesh Paolini-SubramanyaHakka Labs
Mahesh talks about the buddha-nature of Erlang/OTP, pointing out how the various features of the language tie together into one seamless Fault Tolerant whole. Mahesh emphasizes that Erlang begins and ends with Fault Tolerance. Fault Tolerance is baked into the very genes of Erlang/OTP - something that ends up being amazingly useful when building any kind of system. Mahesh Paolini-Subramanya is the V.P. of R&D at Ubiquiti Networks - a manufacturer of disruptive technology platforms for emerging markets. He has spent the recent past building out Erlang-based massively concurrent Cloud Services and VoIP platforms. Mahesh was previously the CTO of Vocalocity after its merger with Aptela, where he was a founder and CTO.
Having a fast, low-friction Edit/Build/Test cycle is one of the best and easiest ways to increase developer productivity across an organization.
This breadth-first tour covers some of the tools we use at Basho to speed up and streamline the Edit/Build/Test cycle for our Erlang projects.
Software Development Automation With Scripting LanguagesIonela
The Scripting languages are deployed in many operative systems, either in UNIX/Linux or Windows. These languages are developed for general purpose process automation and web programming. But you can consider using them for the software development process in many ways. Among these languages, awk and Perl are suitable for automate and speed up software development for embedded systems, because many embedded systems only have cross tool chain, without powerful IDE supports for process automation.
(Costless) Software Abstractions for Parallel ArchitecturesJoel Falcou
Performing large, intensive or non-trivial computing on array like data structures is one of the most common task in scientific computing, video game development and other fields. This matter of fact is backed up by the large number of tools, languages and libraries to perform such tasks. If we restrict ourselves to C++ based solutions, more than a dozen such libraries exists from BLAS/LAPACK C++ binding to template meta-programming based Blitz++ or Eigen. If all of these libraries provide good performance or good abstraction, none of them seems to fit the need of so many different user types.
Moreover, as parallel system complexity grows, the need to maintain all those components quickly become unwieldy. This talk explores various software design techniques - like Generative Programming, MetaProgramming and Generic Programming - and their application to the implementation of a parallel computing librariy in such a way that:
- abstraction and expressiveness are maximized - cost over efficiency is minimized
We'll skim over various applications and see how they can benefit from such tools. We will conclude by discussing what lessons were learnt from this kind of implementation and how those lessons can translate into new directions for the language itself.
VB2013 - Security Research and Development FrameworkAmr Thabet
That's my presentation in VB2013 in Berlin, Germany ... talking about a new development framework for security
it's created for writing security tools, malware analysis tools and network tools
PVS-Studio and static code analysis techniqueAndrey Karpov
What is «static code analysis»? It is a technique that allows, at the same time with unit-tests, dynamic code analysis, code review and others, to increase code quality, increase its reliability and decrease the development time.
Creating Developer-Friendly Docker Containers with ChaperoneGary Wisniewski
Chaperone provides a lean, full-featured environment which simplifies development and deployment of container services while adding minimal overhead (a single process does it all).
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Assuring Contact Center Experiences for Your Customers With ThousandEyes
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
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
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