Skip to content

Commit bd6c7c4

Browse files
ReScript retreat blogpost
1 parent c239a11 commit bd6c7c4

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed
+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
author: rescript-team
3+
date: "2024-07-08"
4+
previewImg: /static/blog/compiler_release_11_1.jpg
5+
title: ReScript Retreat Recap
6+
description: |
7+
Unleashing ReScript from React
8+
---
9+
10+
From the 23rd to the 26th of May, the ReScript team invited many contributors to hack on ReScript. In the end almost all of them responded to the invitation and thus, 15 people from all over the world traveled to Vienna, Austria to meet in person, to do talks, discussions and decisions about and contributions to the ReScript toolchain.
11+
12+
# Day 1
13+
14+
On the first day, we started with some in-depth talks about compiler development. The first talk was about the ReScript parser and formatter, the second one about the compiler itself.
15+
16+
## Brief overview of parser development
17+
18+
A talk by Maxim Valcke (@BinarySearch)
19+
20+
Maxim started with a little bit of history why the parser was made: The existing parser we used with ReScript's predecessor BuckleScript, which is called ReasonML, was created with a parser generator which had the following drawbacks:
21+
22+
- harder to propose changes
23+
- blows up bundle size
24+
- was a bit slower than it could be
25+
26+
So the ReScript parser was made which is completely hand-rolled without the help of a parser generator and it's arguably easier to contribute to, smaller and faster as well. It also supports less of OCaml features, like OCaml's object system, which is probably not needed in a language that compiles to JavaScript only where we have our own object system.
27+
28+
Then he continued to answer the question what we understand about syntax:
29+
30+
- A parser: creates machine understandable text from arbitrary text
31+
- A printer: makes ugly code beautiful
32+
33+
Maxim continued with a hands-on example where he implemented `var` in ReScript. This is of course just an educational example, since we don't really want to give up our clear scoping rules.
34+
35+
Furthermore, the comments table was explained. As comments are not part of the AST (abstract syntax tree), those are stored in a separate comments table in the parser. This is why it sometimes happened that ReScript comments get swallowed after formatting. Luckily, this does not happen so often anymore.
36+
37+
The full talk has been recorded and can be watched here: [TODO - Youtube Link].
38+
39+
## Brief overview of compiler development
40+
41+
A talk by Cristiano Calcagno (@ccrisccris)
42+
43+
Almost seamlessly, Cristiano continued the hands-on example with a very simple example:
44+
45+
```res
46+
let foo = x => x + 1
47+
```
48+
49+
Then he showed how to print the parsetree for such a statement and where to go in the compiler repository to adapt the behavior. Furthermore, uncurried mode handling was explained thoroughly, as it is a really tricky feature. Then he jumped to the next layer which is the typed tree. This one can be shown in both curried and uncurried modes. Those modes make it necessary to keep two versions of the standard library in the compiler.
50+
51+
The next layer is the raw lambda tree, which is the last layer before code generation and has some more wrappers in uncurried mode. The lambda representation is where all the optimization magic happens, like inlining or dead code elimination.
52+
53+
The final layer is the JS dump, which is the actual JavaScript code generation.
54+
55+
Again, the full talk has been recorded and can be watched here: [TODO - Youtube Link].
56+
57+
## Beginning of group work
58+
59+
After the talks and a small break, the contributors split up in multiple small groups of 2-4 people. Every group had a specific topic assigned:
60+
61+
- New Build System (Codename rewatch)
62+
- rescript-lang.org Playground Output
63+
- ReScript Core and how to include it in the compiler
64+
- loops, foreach, iterators
65+
- Syntax, JSX
66+
67+
The contributors worked until the lunch break on those topics, and continued that work until dinner.
68+
69+
# Day 2
70+
71+
First thing in the morning was to conclude the work from the first day, and there were already some interesting advancements.
72+
73+
Group 1, New Build System (Codename rewatch):
74+
75+
- CI build builds rewatch already
76+
77+
Group 2, rescript-lang.org Playground Output
78+
79+
- Console output works
80+
81+
Group 3 ReScript Core
82+
83+
- Removed bs send pipe / data-last apis in v12
84+
85+
Group 4 for loops / iterators
86+
87+
- created a prototype for iterator, just as a library for now where continue and break are modeled as exceptions
88+
89+
Group 5 Syntax / JSX
90+
91+
- comment disappearing in uncurried mode fixed
92+
- enabled uncurried mode in parser tests
93+
- import syntax revisite
94+
d
95+
96+
Next up was a talk about how to contribute to editor tooling.
97+
98+
## Talk about editor tooling
99+
100+
A talk by Gabriel Nordeborn (@zth)
101+
102+
Editor tooling is sometimes broken for some people but it is hard to report what exactly is broken and also hard to get reproductions.
103+
But, in theory, editor tooling with a sound type system should be really good.
104+
105+
We are using the Language Server Protocol (LSP): which is just a node process that calls different analysis tools.
106+
107+
Whenever you build something, the compiler creates one artifact per file that contains type information which the tooling uses.
108+
It receives parameters like the cursor position, what artifact to look up, unsaved contents of the file.
109+
110+
Working on editor tooling is working with broken code a lot. So the main challenge is often to find the correct heuristics to e.g. autocomplete what the user probably wants in that case, on that cursor position, etc.
111+
112+
The full talk has been recorded and can be watched here: [TODO - Youtube Link].
113+
114+
## Discussion about ReScript's Governance
115+
116+
Afterwards we had a group discussion about how to elevator pitch ReScript and about ReScript's roadmap.
117+
118+
The full results of this discussions and the group work can be read at the ReScript forum: https://forum.rescript-lang.org/t/ann-rescript-retreat-roadmap-summary-2024/5275
119+
120+
After the discussion group work continued until the evening. Some people already left after this day.
121+
122+
## Day 3
123+
124+
People continued group work and gathered together at a viennese winery in the evening.
125+
126+
## Day 4
127+
128+
The remaining people even continued work on sunday, with only a couple of hours of city sightseeing and an awesome final Viennese lunch.
129+
130+
## Conclusion
131+
132+
After the retreat, most participants stated that they want to do it again and overall it was a very productive but also fun event for all of us. So it is fairly safe to say that there will be a ReScript Retreat in 2025, at least as long as the ReScript Association is able to stem it financially.
133+
134+
## Our Sponsors
135+
136+
The ReScript Association paid for all the participants hotel rooms and some of the lunches and dinners. On the first three days we worked at a coworking space which was paid for by the Vienna-based company [cca.io](https://www.cca.io/), which also happens to employ two of our contributors.

0 commit comments

Comments
 (0)