9 research outputs found

    Semantics-Driven Interoperability between Scala.js and JavaScript

    Get PDF
    Hundreds of programming languages compile to JavaScript. Yet, most of them fail, at one level or another, to provide satisfactory interoperability with JavaScript APIs. This is limiting, as interoperability is at least required to manipulate web pages through the DOM API, but also to use the ecosystem of existing JavaScript libraries. This paper presents the interoperability features of Scala.js, which solves the shortcomings of previous approaches. Scala. js offers a separate hierarchy of JavaScript types, whose operations have semantics borrowed from ECMAScript 2015. The interoperability features are complete with respect to ECMAScript 2015, save for two exceptions which are still being worked on. This allows Scala. js programs to perform any operation that an ECMAScript program could do, thereby guaranteeing that they can talk to any JavaScript library

    Cross-Platform Language Design

    Get PDF
    Programming languages are increasingly compiled to multiple runtimes, each featuring their own rich structures such as their object model. Furthermore, they need to interact with other languages targeting said runtimes. A language targeting only one runtime can be designed to tailor its semantics to those of that runtime, for easy interoperability with other languages. However, in a language targeting multiple runtimes with differing semantics, it is difficult to cater to each of them while retaining a common behavior across runtimes. We call \emph{cross-platform language} a language that aims at being both \emph{portable} across platforms and \emph{interoperable} with each target platform. Portability is the ability for a program or a library to cross-compile for multiple platforms, and behave the same way on all of them. Interoperability is the ability to communicate with other languages on the same platform. While many cross-compiling languages focus on one of these two properties---only adding support for the other one as an afterthought---, languages that are designed from the ground up to support both are rare. In this thesis, we present the design of Scala.js, the dialect of Scala targeting the JavaScript platform, which turned Scala into a cross-platform language. On the one hand, Scala programs can be cross-compiled for the JVM and JavaScript with portable semantics. On the other hand, whereas Scala/JVM interoperates with Java, Scala.js interoperates with JavaScript, allowing to use any JavaScript library. Along the dissertation, we give insights that can be transferred to the design of other cross-platform languages, although with a bias towards those targeting the JVM and JavaScript. The first and most obvious challenge is to reconcile the static nature of Scala's object model with JavaScript's dynamic one. Besides the ability to mutate a class hierarchy at run-time in JavaScript, there are fundamental differences between the two models, in particular the difference between compile-time overloading and run-time overloading. We discuss how such semantic mismatches can live in harmony within the language. The second challenge is to obtain good performance from a language where interoperability with a dynamic and unknown part of the program is pervasive. To that end, we design and specify an intermediate representation (IR) with first-class support for dynamically typed interoperability features in addition to statically typed JVM-style operations. Despite its tight integration with the open world of JavaScript, most of the IR can be considered as a closed world where advanced whole-program optimizations can be performed. The performance of the overall system is evaluated and shown to be competitive with hand-written JavaScript, and even with Scala/JVM in some cases

    Scala.js: Type-Directed Interoperability with Dynamically Typed Languages

    Get PDF
    Interoperability between statically typed and dynamically typed languages is increasingly important, as can be witnessed by the many statically typed languages targeting JavaScript. Interoperating with both the object-oriented and functional features of JavaScript is essential, if only to manipulate the DOM, yet existing languages have very poor support for this. We present Scala.js, a dialect of Scala compiling to JavaScript. Its interoperability system is based on a powerful and intuitive framework for type-directed interoperability with dynamically typed languages. The framework combines facade types for JavaScript values; user-defined, implicit, type-directed cross-language conversions; and a Dynamic type building on facade types and implicit conversions. It accommodates both the functional and object-oriented features of Scala and JavaScript, and provides very natural interoperability between the two languages. It is expressive enough to represent the DOM and jQuery APIs, among others, both in its statically typed and dynamically typed flavors

    Staattisesti tyypitetyt ohjelmointikielet JavaScript-ekosysteemissä: tyyppijärjestelmien näkökulma

    Get PDF
    JavaScript is a ubiquitous programming language with usage in web, mobile applications and server software. The status of the language as the de-facto programming language of the web has made the language ecosystem advanced with a great number of userspace libraries and major companies working on efficient runtime systems. The core language, however, has numerous known difficulties caused by the initial design and persisted by the requirements for backwards-compatibility. In the last decade, a number of programming languages have chosen JavaScript as the compile target of the language. Type theory and its application, programming language type systems, is an essential area of study in the design of programming languages. Every high-level programming language features a type system that greatly influences the ways of designing and implementing programs in the language. This thesis examines a group of selected statically-typed programming languages that compile to JavaScript. The core topics of research in this thesis are the motivation for new JS-compiled languages, the type system design of the languages, and the future direction of the JavaScript ecosystem based on the current trends and parallels to other programming ecosystems. The results of the work include identifying several trends in type systems for the JS ecosystem and the web. These include unsound yet convenient partially inferred type systems for object-oriented and multi-paradigm programming and fully inferred extended Hindley-Milner type systems for primarily functional programming languages. Additionally, different options for the advancement of the programming ecosystem, including type annotations, inference of dynamically typed languages and new compile targets, are explored. Finally, based on the design choices of the languages researched, we provide several recommendations for safe and productive statically typed programming in the JavaScript ecosystem.JavaScript on laajalti käytetty ohjelmointikieli, jonka käyttö ulottuu web- ja mobiilisovelluksiin sekä palvelinohjelmistoon. Kielen asema web-kehityksen de-facto-ohjelmointikielenä on luonut sen ympärille laajan ohjelmistoekosysteemin, joka kattaa suuren määrän ohjelmistokirjastoja sekä tehokkaita ajoympäristöjä. Itse kieli aiheuttaa tästä huolimatta vaikeuksia alkuperäisten suunnitteluvirheiden ja vaaditun taaksepäinyhteensopivuuden vuoksi. Viimeisen vuosikymmenen aikana useampi ohjelmointikieli on alkanut käyttää JavaScriptia käännöskohteenaan. Tyyppiteoria ja sen sovellus, ohjelmointikielten tyyppijärjestelmät, on tärkeä tutkimusala liittyen ohjelmointikielten suunnitteluun. Tyyppijärjestelmä on osa jokaista korkean tason ohjelmoinikieltä ja vaikuttaa täten suuresti itse ohjelmointikielen muihin ominaisuuksiin ja käyttöön. Tämä tutkimus käsittelee joukkoa staattisesti tyypitettyjä ohjelmointikieliä, jotka kääntyvät JavaScript-koodiksi. Tutkimuksen ytimessä ovat uusien kielten kehityksen motiivit, kielten tyyppijärjestelmien suunnittelu ja ominaisuudet sekä JavaScript-ekosysteemin mahdolliset tulevaisuuden suunnat. Työn tuloksena tunnistamme useita trendejä tyyppijärjestelmien suunnittelussa JavaScript-ekosysteemiin. Näihin kuuluu käytännölliset, mutta teoriassa epäturvalliset tyyppijärjestelmät olio- ja moniparadigmaohjelmoinkieliin sekä funktionaalisten ohjelmointikielien Hindley-Milner-pohjaiset tyyppijärjestelmät, joissa muuttujien tyypit pystytään täysin päättelemään ilman ohjelman kirjoittajan annotaatioita. Lisäksi nostamme esiin useita tulevaisuuden suuntia, jotka voisivat viedä JS-ekosysteemiä eteenpäin. Näihin kuuluvat tyyppiannotaatiot, dynaamisten kielten tyyppi-inferenssi ja uudet käännöskohteet web-ekosysteemiin. Lopuksi annamme tutkimuksen perusteella suosituksia ominaisuuksista ja suunnitteluratkaisuista, jotka voisivat mahdollistaa tehokkaan ja turvallisen ohjelmistokehityksen JavaScript-ekosysteemissä tulevaisuudessa

    ScaFi: Integration and Performance Analysis with Scala Native

    Get PDF
    Aggregate Computing is an emerging paradigm for complex distributed systems where a vast number of distributed devices are involved in a global computation and must cooperate to produce a collective result. This situation is common in the Internet of Things, large-scale urban events, drone coordination and smart cities. Modern Aggregate Computing APIs are normally based on the Field Calculus that offers the basis for the global-to-local computation abstraction, providing Computational Fields. Moreover, these APIs also rely on abstraction layers that hide the complexity of the environment from the sight of the developer (complexity "hidden under the hood"), offering a simple and friendly way to develop this kind of applications. An Internal Domain-specific language that offers these features is Scala with Computational Fields (ScaFi), a Scala framework implementing aggregate programming mechanisms. A critical concept for these types of libraries is portability since their nature implies the possibility of being run over a wide range of different devices. The work shown in this thesis offers a solution to improve the portability and flexibility of ScaFi integrating Scala Native, a Scala ahead-of-time compiler that makes it possible to directly compile Scala code over devices that do not support the JVM (enabling the so-called Cross-compilation). Cross-compilation between different platforms is a very desirable feature for a programming language because it makes the language much more flexible. For this reason, it is often included in many modern languages such as Kotlin and Rust. To conclude, several tests are done to validate the stability and the performance of the integration and in order to prove that the implementation proposed can efficiently extend the number of devices on which ScaFi can be run

    Design and Implementation of a Portable Framework for Application Decomposition and Deployment in Edge-Cloud Systems

    Get PDF
    The emergence of cyber-physical systems has brought about a significant increase in complexity and heterogeneity in the infrastructure on which these systems are deployed. One particular example of this complexity is the interplay between cloud, fog, and edge computing. However, the complexity of these systems can pose challenges when it comes to implementing self-organizing mechanisms, which are often designed to work on flat networks. Therefore, it is essential to separate the application logic from the specific deployment aspects to promote reusability and flexibility in infrastructure exploitation. To address this issue, a novel approach called "pulverization" has been proposed. This approach involves breaking down the system into smaller computational units, which can then be deployed on the available infrastructure. In this thesis, the design and implementation of a portable framework that enables the "pulverization" of cyber-physical systems are presented. The main objective of the framework is to pave the way for the deployment of cyber-physical systems in the edge-cloud continuum by reducing the complexity of the infrastructure and exploit opportunistically the heterogeneous resources available on it. Different scenarios are presented to highlight the effectiveness of the framework in different heterogeneous infrastructures and devices. Current limitations and future work are examined to identify improvement areas for the framework

    Unification of Compile-Time and Runtime Metaprogramming in Scala

    Get PDF
    Metaprogramming is a technique that consists in writing programs that treat other programs as data. This paradigm of software development contributes to a multitude of approaches that improve programmer productivity, including code generation, program analysis and domain-specific languages. Many programming languages and runtime systems provide support for metaprogramming. Programming platforms often distinguish the notions of compile-time and runtime metaprogramming, depending on the phase of the program lifecycle when metaprograms execute. It is common for different lifecycle phases to be hosted in different environ- ments, so it is also common for different kinds of metaprogramming to provide different capabilities to metaprogrammers. In this dissertation, we present an exploration of the idea of unifying compile-time and runtime metaprogramming in Scala. We focus on the practical aspect of the exploration; most of the described designs are available as popular software products, and some of them have become part of the standard distribution of Scala. First, guided by the motivation to consolidate disparate metaprogramming techniques available in earlier versions of Scala, we introduce scala.reflect, a unified metaprogram- ming framework that uses a language model derived from the Scala compiler to run metaprograms both at compile time and at runtime. Secondly, armed by the newfound metaprogramming powers, we describe Scala macros, a language-integrated compile-time metaprogramming facility based on scala.reflect. Thanks to the comprehensive nature of scala.reflect, macros are able to work with both syntactic and semantic information about Scala programs, enabling a wide range of previously impractical or impossible use cases. Finally, based on our experience and user feedback, we identify key strengths and weaknesses of scala.reflect and macros. We propose scala.meta, a new unified metapro- gramming framework, and inline/meta, a new macro system based on scala.meta, that take the best from their predecessors and address the most important problems

    Supporting model based safety and security assessment of high assurance systems

    Get PDF
    Doctor of PhilosophyDepartment of Computer ScienceJohn M HatcliffModern embedded systems are more complex than ever due to intricate interaction with the physical world in a system environment and sophisticated software in a resource-constrained context. Cyber attacks in software-reliant and networked safety-critical systems lead to consideration of security aspects from the system’s inception. Model-Based Development (MBD) is one approach that has been an effective development practice because of the abstraction mechanism that hides the complicated lower-level details of software and hardware components. Standards play an essential role in embedded development to ensure the safety of the users and environment. In safety-critical domains like avionics, automotive, and medical devices, standards provide best practices and consistent approaches across the community. The Analysis and Design Language (AADL) is a standardized modeling language that includes patterns that reflect best architectural practices inspired by multiple safety-critical domains. The work described in this dissertation comprises numerous contributions that support a model analysis framework for AADL that aims to help developers design and assure safety and security requirements and demonstrate system conformance to specific categories of standards. This first contribution is Awas - an open-source framework for performing reachability analysis on AADL models annotated with information flow annotations at varying degrees of detail. The framework provides highly scalable interactive visualizations of flows with dynamic querying capabilities. Awas provide a simple domain-specific language to ease posing various queries to check information flow properties in the model. The second contribution is a process for integrating risk management tasks of ISO 14971 - the primary risk management standard in the medical device domain — with AADL modeling, specifically with AADL’s error modeling (EM) of fault and error propagations. This work uses an open-source patient-controlled analgesic (PCA) pump - the largest open-source AADL model to illustrate the integration of risk management process with AADL and provides the first mapping of AADL EM to ISO 14971 concepts. It also provides industry engineers, academic researchers, and regulators with a complex example that can be used to investigate methodologies and methods of integrating MBD and risk management. The third contribution is a technique to model and analyze security properties such as confidentiality, authentication, and resource partitioning within AADL models. This effort comprises an AADL annex language to model multi-level security domains along with classification of system elements and data using those domains and a tool to infer security levels and check information leaks. The annex language and the tools are evaluated and integrated into the AADL development environment for a seamless workflow
    corecore