A Visual Functional Programming Language for Scientific Computing
Pete Vilter
CS Senior Thesis, University of Chicago
Advisor: Borja Sotomayor
Unofficial Advisors: Ravi Chugh, Mike Wilde
TOC
Why a new visual PL?
Stepping stone to:
Language Model
Editor
Graph functions
Python
functions
Runs
Language Model: Editing Python
Run it!
Graph syntax
Code generation
Generated code:
def main():
ap0_names = log_call(names, "ap0_names", {})
ap0_names_names = ap0_names["names"]
def lambda0(lambda0_ap1_add_excl_str):
lambda0_ap1_add_excl = log_call(add_excl, "ap1_add_excl", {"str":\� lambda0_ap1_add_excl_str})
lambda0_ap1_add_excl_added = lambda0_ap1_add_excl["added"]
lambda0_ap2_add_hi = log_call(add_hi, "ap2_add_hi", {"str": \
lambda0_ap1_add_excl_added})
lambda0_ap2_add_hi_added = lambda0_ap2_add_hi["added"]
return {"lambda0_ap2_add_hi_added": lambda0_ap2_add_hi_added}
ap3_map = log_call(Map, "ap3_map", {"function": lambda0, "list": ap0_names_names})
ap3_map_mappedList = ap3_map["mappedList"]
ap4_space_join = log_call(space_join, "ap4_space_join", {"list":\
ap3_map_mappedList})
ap4_space_join_joinedList = ap4_space_join["joinedList"]
return {"ap4_space_join_joinedList": ap4_space_join_joinedList}
Example: Word count
Spark:
text_file.flatMap(lambda line: line.split())
.map(lambda word: (word, 1))
.reduceByKey(lambda a, b: a+b)
Progress Monitoring
main
names
Map
space_join
<lambda>
add_excl
add_hi
<lambda>
…
add_excl
add_hi
Progress Monitoring: More
names
Map
space_join
<lambda>
add_excl
add_hi
<lambda>
…
add_excl
add_hi
main
Progress Viz: Future Work
names
Map
space_join
<lambda>
add_excl
add_hi
<lambda>
…
add_excl
add_hi
main
Future work: files
Future work: Swift
Future work: typechecking
String → String
List String
a → b
List a
List b
(a → b) → List a → List b
Future work: typechecking
List String
String → b
List b
Future work: typechecking
String
List String
List String
String → String
Future work: typechecking
Future work: typechecking
Future work: typechecking
ages
ages
Implementation: Basics
Implementation: Time
Diagrams
relative
← alignment →
absolute, derived from relative
absolute
Diagrams
| Canvas | SVG | HTML | Diagrams |
Absolute | Good | Good | Janky | Good |
Relative | DIY | DIY | Good | Good |
Alignment | DIY | DIY | Confusing | Good |
Abs. Derived from Relative | DIY | DIY | Not possible in FRP (layout is side effect) | Good |
Diagrams
Filename | Role | LOC |
Actions.elm | Reactions to mouse input | 120 |
Model.elm | State data structures & algos | 197 |
Styles.elm | What color are things? | 54 |
View.elm | Layout; attaching actions | 285 |
Total (not counting some outside G.E.) | 656 |