735 research outputs found
TreatJS: Higher-Order Contracts for JavaScript
TreatJS is a language embedded, higher-order contract system for JavaScript
which enforces contracts by run-time monitoring. Beyond providing the standard
abstractions for building higher-order contracts (base, function, and object
contracts), TreatJS's novel contributions are its guarantee of non-interfering
contract execution, its systematic approach to blame assignment, its support
for contracts in the style of union and intersection types, and its notion of a
parameterized contract scope, which is the building block for composable
run-time generated contracts that generalize dependent function contracts.
TreatJS is implemented as a library so that all aspects of a contract can be
specified using the full JavaScript language. The library relies on JavaScript
proxies to guarantee full interposition for contracts. It further exploits
JavaScript's reflective features to run contracts in a sandbox environment,
which guarantees that the execution of contract code does not modify the
application state. No source code transformation or change in the JavaScript
run-time system is required.
The impact of contracts on execution speed is evaluated using the Google
Octane benchmark.Comment: Technical Repor
Declarative Policies for Capability Control
In capability-safe languages, components can access a resource only if they possess a capability for that resource. As a result, a programmer can prevent an untrusted component from accessing a sensitive resource by ensuring that the component never acquires the corresponding capability. In order to reason about which components may use a sensitive resource it is necessary to reason about how capabilities propagate through a system. This may be difficult, or, in the case of dynamically composed code, impossible to do before running the system. To counter this situation, we propose extensions to capability-safe languages that restrict the use of capabilities according to declarative policies. We introduce two independently useful semantic security policies to regulate capabilities and describe language-based mechanisms that enforce them. Access control policies restrict which components may use a capability and are enforced using higher-order contracts. Integrity policies restrict which components may influence (directly or indirectly) the use of a capability and are enforced using an information-flow type system. Finally, we describe how programmers can dynamically and soundly combine components that enforce access control or integrity policies with components that enforce different policies or even no policy at all.Engineering and Applied Science
Design and evaluation of contracts for gradual typing
Gradual typing aims to improve the correctness of dynamically typed programs by incrementally adding type information. Sound gradual typing performs static type checking and inserts run-time checks when a type cannot be guaranteed statically. This form of gradual typing offers many features, but also requires that the programmer uses a language with a specialised gradual type system. A lightweight form of gradual typing uses contracts to enforce types at run-time, assigning blame when a type assertion fails. Contracts can be implemented as a library, without requiring a specialised gradual type system. Contracts provide a lower barrier of entry into sound gradual typing.
This thesis investigates the design and evaluation of contracts for gradual typing, focusing on bridging the gap between JavaScript (dynamic) and TypeScript (static). There are two key outcomes regarding theory and practice. Contracts for higher-order intersection and union types can be designed in a uniform way, using blame to derive the semantics of contracts satisfaction. Contracts and gradual typing can be evaluated using the DefinitelyTyped repository, where JavaScript libraries are annotated with TypeScript definition files.
Contract composition is the fundamental method for building complex type assertions. Intersection and union types are well suited for describing patterns common to dynamically typed programs. Our first contribution is to present a calculus of contracts for intersection and union types with blame assignment, giving a uniform treatment to both operators.
A correct model of contracts must include a definition of contract satisfaction. Our second contribution is to show that contract satisfaction can be defined using blame: satisfying programs are those that do not elicit blame when monitored. We define a series of properties mandating how contract satisfaction should compose, ensuring that a contract for a type behaves as one would expect for that type.
Building on our technical developments, our third contribution is a practical evaluation of gradual typing using the DefinitelyTyped repository. We show that contracts can be used to enforce conformance to a definition file, detecting errors in the specification. Our evaluation also reveals that technical concerns associated with implementing contracts using JavaScript proxies are a problem in practice
Towards Practical Gradual Typing
Over the past 20 years, programmers have embraced dynamically-typed programming languages. By now, they have also come to realize that programs in these languages lack reliable type information for software engineering purposes. Gradual typing addresses this problem; it empowers programmers to annotate an existing system with sound type information on a piecemeal basis. This paper presents an implementation of a gradual type system for a full-featured class-based language as well as a novel performance evaluation framework for gradual typing
Mixed Messages: Measuring Conformance and Non-Interference in TypeScript
TypeScript participates in the recent trend among programming
languages to support gradual typing. The DefinitelyTyped Repository
for TypeScript supplies type definitions for over 2000 popular
JavaScript libraries. However, there is no guarantee that
implementations conform to their corresponding declarations.
We present a practical evaluation of gradual typing for TypeScript.
We have developed a tool for use with TypeScript, based on the
polymorphic blame calculus, for monitoring JavaScript libraries and
TypeScript clients against the TypeScript definition. We apply our
tool, TypeScript TPD, to those libraries in the DefinitelyTyped
Repository which had adequate test code to use. Of the 122 libraries
we checked, 62 had cases where either the library or its tests
failed to conform to the declaration.
Gradual typing should satisfy non-interference. Monitoring a program
should never change its behaviour, except to raise a type error
should a value not conform to its declared type. However, our
experience also suggests serious technical concerns with the use of
the JavaScript proxy mechanism for enforcing contracts. Of the 122
libraries we checked, 22 had cases where the library or its tests
violated non-interference
Distributed Agent-Based Online Auction System
This paper concerns the design and development of a distributed agent-based online system for English auctions. The proposed system is composed of two parts: an Agent-based Auction Server and a Web-based Graphical User Interface. The first part of our work brought about the advantages introduced by the multi-agent systems technology to the high-level of abstraction, modularity and performance of the server architecture and its implementation. On the server side, bids submitted by auction participants are handled by a hierarchical organization of agents that can be efficiently distributed on a computer network. This approach avoids the bottlenecks of bid processing that might occur during periods of heavy bidding, like for example snipping. We present experimental results that show a significant improvement of the server throughput compared with the architecture where a single auction manager agent is used for coordinating the participants for each active auction that is registered with the server. The second part of our work involved analysis of external functionalities, implementation and usability of a prototype online auction system that incorporates the Agent-based Auction Server. Our solution is outlined in terms of information flow management and its relation to the functionalities of the system. The main outcome of this part of the work is a clean specification of the information exchanges between the agent and non-agent software components of the system. Special attention is also given to the interoperability, understood here as successful integration of the different data communication protocols and software technologies that we employed for the implementation of the system
- …