Static TypeScript: an implementation of a static compiler for the TypeScript language | Proceedings of the 16th ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes (original) (raw)

Authors Info & Claims

Published: 21 October 2019 Publication History

Abstract

While the programming of microcontroller-based embeddable devices typically is the realm of the C language, such devices are now finding their way into the classroom for CS education, even at the level of middle school. As a result, the use of scripting languages (such as JavaScript and Python) for microcontrollers is on the rise.

We present Static TypeScript (STS), a subset of TypeScript (itself, a gradually typed superset of JavaScript), and its compiler/linker toolchain, which is implemented fully in TypeScript and runs in the web browser. STS is designed to be useful in practice (especially in education), while being amenable to static compilation targeting small devices. A user’s STS program is compiled to machine code in the browser and linked against a precompiled C++ runtime, producing an executable that is more efficient than the prevalent embedded interpreter approach, extending battery life and making it possible to run on devices with as little as 16 kB of RAM (such as the BBC micro:bit).

This paper is primarily a description of the STS system and the technical challenges of implementing embedded programming platforms in the classroom.

References

[1]

Jonny Austin, Howard Baker, Thomas Ball, James Devine, Joe Finney, Peli de Halleux, Steve Hodges, Michal Moskal, and Gareth Stockdale. 2019. The BBC micro:bit – from the UK to the World. Commun. ACM (to appear) (2019).

[2]

BBC. 2017. BBC micro:bit celebrates huge impact in first year, with 90% of students saying it helped show that anyone can code. https: //www.bbc.co.uk/mediacentre/latestnews/2017/microbit-first-year .

[3]

Gavin M. Bierman, Martín Abadi, and Mads Torgersen. 2014. Understanding TypeScript. In ECOOP 2014 - Object-Oriented Programming -28th European Conference, Uppsala, Sweden, July 28 - August 1, 2014. Proceedings. 257–281.

[4]

Hans-J Boehm, Russ Atkinson, and Michael Plass. 1995. Ropes: an alternative to strings. Software: Practice and Experience 25, 12 (1995), 1315–1330.

[5]

Satish Chandra, Colin S. Gordon, Jean-Baptiste Jeannin, Cole Schlesinger, Manu Sridharan, Frank Tip, and Young-Il Choi. 2016. Type inference for static compilation of JavaScript. In Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2016, part of SPLASH 2016, Amsterdam, The Netherlands, October 30 - November 4, 2016. 410–429.

[6]

Wontae Choi, Satish Chandra, George Necula, and Koushik Sen. 2015. SJS: A type system for JavaScript with fixed object layout. In International Static Analysis Symposium. Springer, 181–198.

[7]

James Devine, Joe Finney, Peli de Halleux, Michal Moskal, Thomas Ball, and Steve Hodges. 2018. MakeCode and CODAL: intuitive and efficient embedded systems programming for education. In Proceedings of the 19th ACM SIGPLAN/SIGBED International Conference on Languages, Compilers, and Tools for Embedded Systems, LCTES 2018, Philadelphia, PA, USA, June 19-20, 2018. 19–30.

[8]

Evgeny Gavrin, Sung-Jae Lee, Ruben Ayrapetyan, and Andrey Shitov. 2015. Ultra Lightweight JavaScript Engine for Internet of Things. In SPLASH Companion 2015. 19–20.

[9]

Damien George. 2018. MicroPython. http://www.micropython.org .

[10]

Isaac Gouy. 2018. The Computer Language Benchmarks Game. https: //benchmarksgame-team.pages.debian.net/benchmarksgame/ .

[11]

Apple Inc. 2018. JetStream Benchmarks 1.1. https://www. browserbench.org/JetStream/in-depth.html .

[12]

Adafruit Industries. 2018. CircuitPython. https://github.com/adafruit/ circuitpython .

[13]

A. Rastogi, N. Swamy, C. Fournet, G. M. Bierman, and P. Vekris. 2015. Safe & Efficient Gradual Typing for TypeScript. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 167–180.

[14]

G. Richards, F. Z. Nardelli, and J. Vitek. 2015. Concrete Types for TypeScript. In 29th European Conference on Object-Oriented Programming, ECOOP 2015. 76–100.

[15]

Samsung. 2018. JerryScript. http://jerryscript.org .

[16]

Sue Sentance, Jane Waite, Steve Hodges, Emily MacLeod, and Lucy Yeomans. 2017. "Creating Cool Stuff": Pupils’ Experience of the BBC Micro:Bit. In Proceedings of the 2017 ACM SIGCSE Technical Symposium on Computer Science Education (SIGCSE ’17). ACM, 531–536.

[17]

Manuel Serrano. 2018. JavaScript AOT compilation. In Proceedings of the 14th ACM SIGPLAN International Symposium on Dynamic Languages. ACM, 50–63.

[18]

Jeremy G. Siek and Walid Taha. 2007. Gradual Typing for Objects. In ECOOP 2007 - Object-Oriented Programming, 21st European Conference, Berlin, Germany, July 30 - August 3, 2007, Proceedings. 2–27.

[19]

Artifex Software. 2018. MuJS. https://mujs.com/ .

[20]

Cesanta Software. 2018. mJS. https://github.com/cesanta/mjs .

[21]

Patrick Soquet. 2017. XS7. https://www.moddable.com/XS7-TC-39 .

[22]

Sami Vaarala. 2018. DukTape. https://duktape.org/ .

[23]

Gordon Williams. 2017. Making Things Smart: Easy Embedded JavaScript Programming for Making Everyday Objects into Intelligent Machines. Maker Media.

Information & Contributors

Information

Published In

cover image ACM Conferences

MPLR 2019: Proceedings of the 16th ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes

October 2019

171 pages

Copyright © 2019 ACM.

Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 21 October 2019

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. JavaScript
  2. TypeScript
  3. compiler
  4. interpreter
  5. microcontrollers
  6. virtual machine

Qualifiers

Conference

Upcoming Conference

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

Reflects downloads up to 14 Nov 2024

Other Metrics

Citations

View Options

Get Access

Login options

Check if you have access through your login credentials or your institution to get full access on this article.

Sign in

Full Access

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Affiliations

Thomas Ball

Peli de Halleux

Michał Moskal