Oscar Chan

EECS Department, University of California, Berkeley

Technical Report No. UCB/EECS-2022-157

May 20, 2022

http://www2.eecs.berkeley.edu/Pubs/TechRpts/2022/EECS-2022-157.pdf

This paper presents a compiler framework for the Snap! blocks programming language. Snap! is a web browser language using JavaScript to run the interface and the original interpretation of the language, therefore it is sensible to use JavaScript as the destination language as well. The compiler reads each Snap! block sent to it within a warp block and translates it to the equivalent JavaScript function that powers the block and powers the Sprites on the Snap! graphical interface. Control looping blocks like the forever, for, and repeat return control to the Snap! graphical interface by using JavaScript Generators pausing themselves in the middle to redraw the graphics and then come back to the block and continues running the compiled program. When the compiled code is executed on several tasks, it was able to attain a speedup that is significantly noticeable for a sizeable program compared to the interpreter and the interpreter-version of warp, but for simple programs, the interpreter warp performed better or as good, and more work needs to be done to support more Snap! blocks.

Advisors: Brian Harvey


BibTeX citation:

@mastersthesis{Chan:EECS-2022-157,
    Author= {Chan, Oscar},
    Title= {A Compiler in Snap!: Compiling a Block-Based Language},
    School= {EECS Department, University of California, Berkeley},
    Year= {2022},
    Month= {May},
    Url= {http://www2.eecs.berkeley.edu/Pubs/TechRpts/2022/EECS-2022-157.html},
    Number= {UCB/EECS-2022-157},
    Abstract= {This paper presents a compiler framework for the Snap! blocks programming language. Snap! is a web browser language using JavaScript to run the interface and the original interpretation of the language, therefore it is sensible to use JavaScript as the destination language as well. The compiler reads each Snap! block sent to it within a warp block and translates it to the equivalent JavaScript function that powers the block and powers the Sprites on the Snap! graphical interface. Control looping blocks like the forever, for, and repeat return control to the Snap! graphical interface by using JavaScript Generators pausing themselves in the middle to redraw the graphics and then come back to the block and continues running the compiled program. When the compiled code is executed on several tasks, it was able to attain a speedup that is significantly noticeable for a sizeable program compared to the interpreter and the interpreter-version of warp, but for simple programs, the interpreter warp performed better or as good, and more work needs to be done to support more Snap! blocks.},
}

EndNote citation:

%0 Thesis
%A Chan, Oscar 
%T A Compiler in Snap!: Compiling a Block-Based Language
%I EECS Department, University of California, Berkeley
%D 2022
%8 May 20
%@ UCB/EECS-2022-157
%U http://www2.eecs.berkeley.edu/Pubs/TechRpts/2022/EECS-2022-157.html
%F Chan:EECS-2022-157