SlideShare a Scribd company logo
Challenges of
Transpiling Smalltalk to JavaScript
Noury Bouraqadi & Dave Mason
International Workshop on Smalltalk Technologies Gdansk, Poland; July 1st to 4th, 2025
Why Transpile Smalltalk to JavaScript?
2
Why Transpile Smalltalk to JavaScript?
ST
Simple & clean semantics
Rich IDE & core libraries
3
JS
Ubiquitous deployment
Performance
Large ecosystem
Why Transpile Smalltalk to JavaScript?
ST
Simple & clean semantics
Rich IDE & core libraries
4
Wednesday
July 2nd 2025
JS
Ubiquitous deployment
Performance
Large ecosystem
● ST + JS = Best of both worlds
● Smalltalk community interest in the Web/JavaScript
○ ESUG Main Track Talk Smalltalk for the Web
5
Transpilation = TRANSlation & comPILATION
Transpiler
100%
Smalltalk
Program
100%
JavaScript
Program
6
Transpilation = TRANSlation & comPILATION
Transpiler
100%
Smalltalk
Program
100%
JavaScript
Program
Valid Valid
7
Transpilation = TRANSlation & comPILATION
Transpiler
100%
Smalltalk
Program
100%
JavaScript
Program
Semantically
Equivalent
Valid Valid
Output
Output
Input Input
8
Semantic Equivalence
Transpiler
100%
Smalltalk
Program
100%
JavaScript
Program
9
How to Transpile Smalltalk to JavaScript?
○ Map Smalltalk’s syntax to JavaScript?
○ Map Smalltalk’s reflective kernel to JavaScript?
○ Handle Smalltalk dependencies with the runtime?
10
How to Transpile Smalltalk to JavaScript?
○ Map Smalltalk’s syntax to JavaScript?
○ Map Smalltalk’s reflective kernel to JavaScript?
○ Handle Smalltalk dependencies with the runtime?
11
How to Transpile Smalltalk to JavaScript?
Empirical Study
based on
10 Year
experience with
○ Map Smalltalk’s syntax to JavaScript?
○ Map Smalltalk’s reflective kernel to JavaScript?
○ Handle Smalltalk dependencies with the runtime?
12
How to Transpile Smalltalk to JavaScript?
Challenges Catalog
1. Primitive Types &
Literals
2. Messages
3. Block Closures
4. Classes
5. Reflection
Empirical Study
based on
10 Year
experience with
13
Challenges Catalog
● JS 𝑢𝑛𝑑𝑒𝑓𝑖𝑛𝑒𝑑 and 𝑛𝑢𝑙𝑙 are Not Objects.
● JS has an Impoverished Numeric Stack.
● ST Automatically Converts
○ Between Small Integers & Large Ones.
● ST Supports Fixed-Point Arithmetic.
● ST has Literal Symbols.
14
Challenges: Primitive Types and Literals
● JS has a 𝑆𝑦𝑚𝑏𝑜𝑙 class, but:
○ No literal symbols
■ Simple to fix
● Map ST symbols to instances of JS Symbol
○ JS Symbol class is not related to String!
■ Complex to fix
● Make Symbol subclass of String
○ Side-effects?
● Override some String methods
15
Example: ST Literal Symbols
● Non-Alphanumeric Characters in ST Message Selectors
● JS Math-Like Message Priorities
● ST Message Cascading
16
Challenges: Messages
● Simple to fix:
○ Replace non-alphanumeric characters with their Ascii code
○ ST keyword selectors: 1 string concatenating keywords
● Complex to fix: None
17
Example: Non-Alphanumeric Characters in Selectors
Smalltalk Blocks:
● Always Bind the Outer Context
● Always Answer Some Value
● Support Non-Local Returns
18
Challenges: Block Closures
● Simple to fix: ST blocks always answer some value
○ ST result := [123]
○ JS result = () =>{return 123}
● Complex to fix: ST blocks support non-local returns
○ ST condition ifTrue: [^123]
○ JS rely on exceptions
19
Example: Block Returns
● Class Variables
● Pool Variables
● Class Extensions
● Stateful Traits
20
Challenges: ST Classes - 1
● Class Initialization & Startup/Shutdown Lists
● Methods Always Have a Return Value
● Methods can Have Pragmas
○ Primitive Pragmas Refer to the Virtual Machine
21
Challenges: ST Classes - 2
● Simple to fix: Class Variables
○ JS Classes are objects with attributes
○ JS encapsulation is optional
class A{
anInstanceMethod(){
x = A.someClassVariable + 42; }
}
A.someClassVariable = 37;
22
Examples - 1
● Complex to fix: Pragmas such as #primitive:
○ Implement the primitive behavior
23
Examples - 2
● ST Reifies Messages Upon Handling Type Errors
● ST Reifies Execution Contexts
● ST and JS have different solutions for Intercepting
Method Evaluation
● Pharo ST Reifies Slots
● Pharo ST classes define Object Format/Layout
24
Challenges: Reflection
● Simple to fix: ST DNU Reifies Messages
○ Extend JS Object with
■ doesNotUnderstand() method
■ default methods for every sent message in ST Code
Object.prototype.zork = function(arg1, arg2){
return this.doesNotUnderstand(“zork”, arguments)}
25
Examples - 1
● Complex to fix: ST Reifies Execution Contexts
○ ST thisContext
26
Examples
Smalltalk & JavaScript
100% semantic equivalence
via transpilation is
difficult if not impossible!
27
Conclusion
● Some challenges are “easy” to address
○ Primitive Types & Literals,
○ Messages,
○ Block Closures
● Several ST capabilities are complex to implement in JS
○ Primitives,
○ thisContext,
○ Reified Slots…
28
Conclusion: Not all challenges are equal
● Beyond Transpilation
○ ST and JS Run-time interoperability (Production)
○ Live-coding with JS objects from the ST (Development)
○ Reuse JS libraries (code + globals) in code transcribed from ST
○ Transpile ST to produce JS libraries for 3rd parties.
● Methodology?
○ Generalizable to other language pairs? Smalltalk & Python?
29
Future Work
Develop in Pharo, Run on JavaScript
PharoJS.org
Kindly Supported by
Thanks to all the contributors!
M
IT
License
Challenges of
Transpiling Smalltalk to JavaScript
Noury Bouraqadi & Dave Mason
International Workshop on Smalltalk Technologies Gdansk, Poland; July 1st to 4th, 2025

More Related Content

PDF
A DSTL to bridge concrete and abstract syntax
PDF
ECCV2022 paper reading - MultiMAE: Multi-modal Multi-task Masked Autoencoders...
PPTX
Class[2][29th may] [javascript]
PDF
230915 paper summary learning to world model with language with details - pub...
PDF
BigDecimal: Avoid rounding errors on decimals in JavaScript (Node.TLV 2020)
PDF
Big Decimal: Avoid Rounding Errors on Decimals in JavaScript
PDF
How to build TiDB
PPTX
04-JS.pptx
A DSTL to bridge concrete and abstract syntax
ECCV2022 paper reading - MultiMAE: Multi-modal Multi-task Masked Autoencoders...
Class[2][29th may] [javascript]
230915 paper summary learning to world model with language with details - pub...
BigDecimal: Avoid rounding errors on decimals in JavaScript (Node.TLV 2020)
Big Decimal: Avoid Rounding Errors on Decimals in JavaScript
How to build TiDB
04-JS.pptx

Similar to Challenges of Transpiling Smalltalk to JavaScript (20)

PPTX
04-JS.pptx
PPTX
04-JS.pptx
PDF
DALL-E.pdf
PDF
BigInts In JavaScript: A Case Study In TC39 (JSConf EU 2018)
PDF
oop_java (1) of ice or cse or eee ic.pdf
PDF
TC39: How we work, what we are working on, and how you can get involved (dotJ...
PDF
Anatomy of spark catalyst
PDF
Seq2Seq (encoder decoder) model
PDF
(not= DSL macros)
PDF
Introduction to Machine Learning with Spark
PPTX
Dart the Better JavaScript
PDF
Feature engineering pipelines
PDF
Dictionary Learning in Games - GDC 2014
PDF
Object oriented programming with java pdf
PPTX
Fields in Java and Kotlin and what to expect.pptx
PDF
Loss functions (DLAI D4L2 2017 UPC Deep Learning for Artificial Intelligence)
PDF
Optimization for Deep Networks (D2L1 2017 UPC Deep Learning for Computer Vision)
PDF
Introduction to nand2 tetris
PDF
Set Transfomer: A Framework for Attention-based Permutaion-Invariant Neural N...
04-JS.pptx
04-JS.pptx
DALL-E.pdf
BigInts In JavaScript: A Case Study In TC39 (JSConf EU 2018)
oop_java (1) of ice or cse or eee ic.pdf
TC39: How we work, what we are working on, and how you can get involved (dotJ...
Anatomy of spark catalyst
Seq2Seq (encoder decoder) model
(not= DSL macros)
Introduction to Machine Learning with Spark
Dart the Better JavaScript
Feature engineering pipelines
Dictionary Learning in Games - GDC 2014
Object oriented programming with java pdf
Fields in Java and Kotlin and what to expect.pptx
Loss functions (DLAI D4L2 2017 UPC Deep Learning for Artificial Intelligence)
Optimization for Deep Networks (D2L1 2017 UPC Deep Learning for Computer Vision)
Introduction to nand2 tetris
Set Transfomer: A Framework for Attention-based Permutaion-Invariant Neural N...
Ad

More from ESUG (20)

PDF
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
PDF
Micromaid: A simple Mermaid-like chart generator for Pharo
PDF
Directing Generative AI for Pharo Documentation
PDF
Even Lighter Than Lightweiht: Augmenting Type Inference with Primitive Heuris...
PDF
Composing and Performing Electronic Music on-the-Fly with Pharo and Coypu
PDF
Gamifying Agent-Based Models in Cormas: Towards the Playable Architecture for...
PDF
Analysing Python Machine Learning Notebooks with Moose
PDF
FASTTypeScript metamodel generation using FAST traits and TreeSitter project
PDF
Migrating Katalon Studio Tests to Playwright with Model Driven Engineering
PDF
Package-Aware Approach for Repository-Level Code Completion in Pharo
PDF
Evaluating Benchmark Quality: a Mutation-Testing- Based Methodology
PDF
An Analysis of Inline Method Refactoring
PDF
Identification of unnecessary object allocations using static escape analysis
PDF
Control flow-sensitive optimizations In the Druid Meta-Compiler
PDF
Clean Blocks (IWST 2025, Gdansk, Poland)
PDF
Encoding for Objects Matters (IWST 2025)
PDF
Immersive experiences: what Pharo users do!
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
PDF
Cavrois - an Organic Window Management (ESUG 2025)
PDF
Fluid Class Definitions in Pharo (ESUG 2025)
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
Micromaid: A simple Mermaid-like chart generator for Pharo
Directing Generative AI for Pharo Documentation
Even Lighter Than Lightweiht: Augmenting Type Inference with Primitive Heuris...
Composing and Performing Electronic Music on-the-Fly with Pharo and Coypu
Gamifying Agent-Based Models in Cormas: Towards the Playable Architecture for...
Analysing Python Machine Learning Notebooks with Moose
FASTTypeScript metamodel generation using FAST traits and TreeSitter project
Migrating Katalon Studio Tests to Playwright with Model Driven Engineering
Package-Aware Approach for Repository-Level Code Completion in Pharo
Evaluating Benchmark Quality: a Mutation-Testing- Based Methodology
An Analysis of Inline Method Refactoring
Identification of unnecessary object allocations using static escape analysis
Control flow-sensitive optimizations In the Druid Meta-Compiler
Clean Blocks (IWST 2025, Gdansk, Poland)
Encoding for Objects Matters (IWST 2025)
Immersive experiences: what Pharo users do!
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
Cavrois - an Organic Window Management (ESUG 2025)
Fluid Class Definitions in Pharo (ESUG 2025)
Ad

Recently uploaded (20)

PPTX
Comparative Structure of Integument in Vertebrates.pptx
PPTX
SCIENCE10 Q1 5 WK8 Evidence Supporting Plate Movement.pptx
PDF
Phytochemical Investigation of Miliusa longipes.pdf
PDF
An interstellar mission to test astrophysical black holes
PPTX
TOTAL hIP ARTHROPLASTY Presentation.pptx
PPTX
ANEMIA WITH LEUKOPENIA MDS 07_25.pptx htggtftgt fredrctvg
PPTX
2. Earth - The Living Planet Module 2ELS
PDF
CAPERS-LRD-z9:AGas-enshroudedLittleRedDotHostingaBroad-lineActive GalacticNuc...
PDF
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
PDF
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
PDF
HPLC-PPT.docx high performance liquid chromatography
PPTX
ognitive-behavioral therapy, mindfulness-based approaches, coping skills trai...
PPTX
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
PPTX
Cell Membrane: Structure, Composition & Functions
PPTX
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
PDF
Sciences of Europe No 170 (2025)
PPT
The World of Physical Science, • Labs: Safety Simulation, Measurement Practice
PPTX
Protein & Amino Acid Structures Levels of protein structure (primary, seconda...
PPT
protein biochemistry.ppt for university classes
PPTX
Derivatives of integument scales, beaks, horns,.pptx
Comparative Structure of Integument in Vertebrates.pptx
SCIENCE10 Q1 5 WK8 Evidence Supporting Plate Movement.pptx
Phytochemical Investigation of Miliusa longipes.pdf
An interstellar mission to test astrophysical black holes
TOTAL hIP ARTHROPLASTY Presentation.pptx
ANEMIA WITH LEUKOPENIA MDS 07_25.pptx htggtftgt fredrctvg
2. Earth - The Living Planet Module 2ELS
CAPERS-LRD-z9:AGas-enshroudedLittleRedDotHostingaBroad-lineActive GalacticNuc...
Unveiling a 36 billion solar mass black hole at the centre of the Cosmic Hors...
ELS_Q1_Module-11_Formation-of-Rock-Layers_v2.pdf
HPLC-PPT.docx high performance liquid chromatography
ognitive-behavioral therapy, mindfulness-based approaches, coping skills trai...
cpcsea ppt.pptxssssssssssssssjjdjdndndddd
Cell Membrane: Structure, Composition & Functions
GEN. BIO 1 - CELL TYPES & CELL MODIFICATIONS
Sciences of Europe No 170 (2025)
The World of Physical Science, • Labs: Safety Simulation, Measurement Practice
Protein & Amino Acid Structures Levels of protein structure (primary, seconda...
protein biochemistry.ppt for university classes
Derivatives of integument scales, beaks, horns,.pptx

Challenges of Transpiling Smalltalk to JavaScript

  • 1. Challenges of Transpiling Smalltalk to JavaScript Noury Bouraqadi & Dave Mason International Workshop on Smalltalk Technologies Gdansk, Poland; July 1st to 4th, 2025
  • 2. Why Transpile Smalltalk to JavaScript? 2
  • 3. Why Transpile Smalltalk to JavaScript? ST Simple & clean semantics Rich IDE & core libraries 3 JS Ubiquitous deployment Performance Large ecosystem
  • 4. Why Transpile Smalltalk to JavaScript? ST Simple & clean semantics Rich IDE & core libraries 4 Wednesday July 2nd 2025 JS Ubiquitous deployment Performance Large ecosystem ● ST + JS = Best of both worlds ● Smalltalk community interest in the Web/JavaScript ○ ESUG Main Track Talk Smalltalk for the Web
  • 5. 5 Transpilation = TRANSlation & comPILATION Transpiler 100% Smalltalk Program 100% JavaScript Program
  • 6. 6 Transpilation = TRANSlation & comPILATION Transpiler 100% Smalltalk Program 100% JavaScript Program Valid Valid
  • 7. 7 Transpilation = TRANSlation & comPILATION Transpiler 100% Smalltalk Program 100% JavaScript Program Semantically Equivalent Valid Valid
  • 9. 9 How to Transpile Smalltalk to JavaScript?
  • 10. ○ Map Smalltalk’s syntax to JavaScript? ○ Map Smalltalk’s reflective kernel to JavaScript? ○ Handle Smalltalk dependencies with the runtime? 10 How to Transpile Smalltalk to JavaScript?
  • 11. ○ Map Smalltalk’s syntax to JavaScript? ○ Map Smalltalk’s reflective kernel to JavaScript? ○ Handle Smalltalk dependencies with the runtime? 11 How to Transpile Smalltalk to JavaScript? Empirical Study based on 10 Year experience with
  • 12. ○ Map Smalltalk’s syntax to JavaScript? ○ Map Smalltalk’s reflective kernel to JavaScript? ○ Handle Smalltalk dependencies with the runtime? 12 How to Transpile Smalltalk to JavaScript? Challenges Catalog 1. Primitive Types & Literals 2. Messages 3. Block Closures 4. Classes 5. Reflection Empirical Study based on 10 Year experience with
  • 14. ● JS 𝑢𝑛𝑑𝑒𝑓𝑖𝑛𝑒𝑑 and 𝑛𝑢𝑙𝑙 are Not Objects. ● JS has an Impoverished Numeric Stack. ● ST Automatically Converts ○ Between Small Integers & Large Ones. ● ST Supports Fixed-Point Arithmetic. ● ST has Literal Symbols. 14 Challenges: Primitive Types and Literals
  • 15. ● JS has a 𝑆𝑦𝑚𝑏𝑜𝑙 class, but: ○ No literal symbols ■ Simple to fix ● Map ST symbols to instances of JS Symbol ○ JS Symbol class is not related to String! ■ Complex to fix ● Make Symbol subclass of String ○ Side-effects? ● Override some String methods 15 Example: ST Literal Symbols
  • 16. ● Non-Alphanumeric Characters in ST Message Selectors ● JS Math-Like Message Priorities ● ST Message Cascading 16 Challenges: Messages
  • 17. ● Simple to fix: ○ Replace non-alphanumeric characters with their Ascii code ○ ST keyword selectors: 1 string concatenating keywords ● Complex to fix: None 17 Example: Non-Alphanumeric Characters in Selectors
  • 18. Smalltalk Blocks: ● Always Bind the Outer Context ● Always Answer Some Value ● Support Non-Local Returns 18 Challenges: Block Closures
  • 19. ● Simple to fix: ST blocks always answer some value ○ ST result := [123] ○ JS result = () =>{return 123} ● Complex to fix: ST blocks support non-local returns ○ ST condition ifTrue: [^123] ○ JS rely on exceptions 19 Example: Block Returns
  • 20. ● Class Variables ● Pool Variables ● Class Extensions ● Stateful Traits 20 Challenges: ST Classes - 1
  • 21. ● Class Initialization & Startup/Shutdown Lists ● Methods Always Have a Return Value ● Methods can Have Pragmas ○ Primitive Pragmas Refer to the Virtual Machine 21 Challenges: ST Classes - 2
  • 22. ● Simple to fix: Class Variables ○ JS Classes are objects with attributes ○ JS encapsulation is optional class A{ anInstanceMethod(){ x = A.someClassVariable + 42; } } A.someClassVariable = 37; 22 Examples - 1
  • 23. ● Complex to fix: Pragmas such as #primitive: ○ Implement the primitive behavior 23 Examples - 2
  • 24. ● ST Reifies Messages Upon Handling Type Errors ● ST Reifies Execution Contexts ● ST and JS have different solutions for Intercepting Method Evaluation ● Pharo ST Reifies Slots ● Pharo ST classes define Object Format/Layout 24 Challenges: Reflection
  • 25. ● Simple to fix: ST DNU Reifies Messages ○ Extend JS Object with ■ doesNotUnderstand() method ■ default methods for every sent message in ST Code Object.prototype.zork = function(arg1, arg2){ return this.doesNotUnderstand(“zork”, arguments)} 25 Examples - 1
  • 26. ● Complex to fix: ST Reifies Execution Contexts ○ ST thisContext 26 Examples
  • 27. Smalltalk & JavaScript 100% semantic equivalence via transpilation is difficult if not impossible! 27 Conclusion
  • 28. ● Some challenges are “easy” to address ○ Primitive Types & Literals, ○ Messages, ○ Block Closures ● Several ST capabilities are complex to implement in JS ○ Primitives, ○ thisContext, ○ Reified Slots… 28 Conclusion: Not all challenges are equal
  • 29. ● Beyond Transpilation ○ ST and JS Run-time interoperability (Production) ○ Live-coding with JS objects from the ST (Development) ○ Reuse JS libraries (code + globals) in code transcribed from ST ○ Transpile ST to produce JS libraries for 3rd parties. ● Methodology? ○ Generalizable to other language pairs? Smalltalk & Python? 29 Future Work
  • 30. Develop in Pharo, Run on JavaScript PharoJS.org Kindly Supported by Thanks to all the contributors! M IT License
  • 31. Challenges of Transpiling Smalltalk to JavaScript Noury Bouraqadi & Dave Mason International Workshop on Smalltalk Technologies Gdansk, Poland; July 1st to 4th, 2025