Skip to content

Commit c3102b6

Browse files
committed
moonbit interview
1 parent c6642b6 commit c3102b6

File tree

6 files changed

+96
-1
lines changed

6 files changed

+96
-1
lines changed

blog/hongbo.jpeg

7.59 KB
Loading

blog/hongboZhang.scroll

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
authors Breck Yunits
2+
https://x.com/breckyunits Breck Yunits
3+
date 10/31/2024
4+
title A brief interview with Moonbit creator Hongbo Zhang
5+
6+
interviewHeader.scroll
7+
8+
css li a,.scrollParagraph a {color: black;} .links a {text-decoration: underline; color:black;}
9+
10+
Moonbit builds fast Wasm. It is one of the fastest growing languages in PLDB, cracking the top 300 in less than 2 years. We got the chance to talk to Moonbit's creator, Hongbo Zhang, who explained to us why Moonbit exists and the effort that has gone into creating the language, compiler, and tooling behind it. Thank you for your time Hongbo!
11+
dateline
12+
https://www.moonbitlang.com/ Moonbit
13+
../concepts/wasm.html Wasm
14+
https://x.com/bobzhang1988 Hongbo Zhang
15+
../lists/top1000.html top 300
16+
class links
17+
18+
***
19+
20+
? What is new about Moonbit?
21+
22+
## WASM
23+
The original target of MoonBit is Wasm. WebAssembly’s original promise was that many languages could be compiled to it and then run in the browser or other environments. The problem, however, is that existing languages such as Java and Go generate a huge amount of WebAssembly code when compiled, even when they’re just printing “Hello World”. Rust generates small amount of code but it has steep learning curve for average programmer
24+
../concepts/moonbit.html MoonBit
25+
../concepts/java.html Java
26+
../concepts/go.html Go
27+
../concepts/rust.html Rust
28+
29+
MoonBit was built to fully deliver the advantage of WebAssembly. We say WebAssembly is safe and fast, but when Go is compiled to WebAssembly, it generates a very large amount of WebAssembly code, and it’s not fast anymore because the language semantics don’t match very well with the Golang, So we think there’s a opportunity, a big opportunity, to have a language that is designed for the WebAssembly semantics. MoonBit generates a code which is performance-wise comparable to Rust, and it also generates even smaller Wasm code than Rust.
30+
31+
## AI
32+
MoonBit is also exploring the possibility of an AI-native language toolchain.
33+
34+
MoonBit was created the same year that ChatGPT was released, in 2022. Since then, we have seen the potential of AI-assisted coding. Traditional programming languages (such as Python) are mostly designed to interact better with humans, while MoonBit is designed to communicate better with AI. The most common issues with AI-assisted code are security concerns (trained on potentially untrusted source code) and the illusion problem (the inability to understand context). MoonBit's AI-friendly language design aims to reduce these issues through advanced static analysis.
35+
../concepts/python.html Python
36+
37+
As a developer platform, MoonBit deeply integrates its toolchain with AI. Our IDE has a built-in AI assistant for generating code, documentation, and tests, fixing errors, and suggesting code improvements. MoonBit's AI-native language + toolchain design is framing AI coding in a bottom-up way.
38+
39+
***
40+
41+
? What languages have most influenced Moonbit?
42+
43+
In many ways, MoonBit takes inspiration from Rust and Go.
44+
45+
It has pattern matching, static types and type inference, for example. MoonBit is a strongly typed language, like Rust, Kotlin and Java, which means it enforces strict rules about data types. MoonBit took the good parts of Rust, and we try to make it easy to learn.
46+
../features/hasPatternMatching.html pattern matching
47+
../features/hasStaticTyping.html static types
48+
../features/hasTypeInference.html type inference
49+
../concepts/kotlin.html Kotlin
50+
51+
Where MoonBit diverges from Rust is that it ships with a garbage collector, which uses reference counting (RC) similar to Swift’s approach to garbage collecting. MoonBit uses state-of-the-art optimization techniques to eliminate the overhead of reference counting at compile time. So in memory heavy benchmarks, MoonBit performs similarly and sometimes even faster than high performance tracing garbage collector, significantly faster than Swift. This allows it to do automatic memory management.
52+
../features/hasGarbageCollection.html garbage collector
53+
../concepts/swift.html Swift
54+
55+
Another advantage is that MoonBit has very fast compilation. One pain point of Rust is it takes a very long time to compile. MoonBit can compile the whole code in a very fast time like one or two orders of magnitude faster than the Rust compilation.
56+
57+
The way MoonBit influenced by Golang is from the philosophy level: Keep the language simple and invest more in the tooling side. Go has a philosophy of less is more, and we think this is quite important. You have to make the language itself cohesive. We don’t want to continue adding to the syntax.
58+
59+
***
60+
61+
? What would be your advice to people just getting started in creating programming languages?
62+
63+
Before MoonBit, I was the core contributor to the OCaml, created ReScript, and worked on Flow at Meta. For creating production-ready programming languages:
64+
../concepts/ocaml.html OCaml
65+
../concepts/rescript.html ReScript
66+
../concepts/flow.html Flow
67+
68+
1. In my work overseeing the entire supply chain for ReScript, I learned the importance of the synergy between the compilation build system and IDE responsiveness. By considering these factors from the outset, it is possible to better avoid potential issues and enhance development efficiency.
69+
70+
2. ReScript made me realize the importance of fast compilation. The compilation speed far exceeds that of similar tools. A 10% or 20% improvement may not create a strong user experience, but a tenfold increase becomes a significant advantage in speed and can be a major selling point to attract users. This is similar to how the popularity of Go is partly due to its fast compilation compared to C++.
71+
../concepts/cpp.html C++
72+
73+
3. While working on Flow at Meta, I encountered extremely large codebases. Maintaining real-time responsiveness of the IDE in such vast codebases is a tremendous challenge, so a new language should enable the IDE to respond quickly and allow static analysis tools to rapidly understand the code.
74+
75+
4. OCaml was initially designed for an academic audience, resulting in a steep learning curve, which poses certain bottlenecks for industrial applications. A new programming language must gain support from the industry.
76+
77+
5. After leading the construction of the compiler, system language interoperability, standard library design, and IDE setup from 0 to 1, I found myself with a whole new perspective. Initially, I only understood knowledge in the field of programming languages but lacked a global view, not knowing how to layout or coordinate effectively.
78+
79+
****
80+
81+
hongbo.jpeg
82+
caption Image source. Thank you for your time Hongbo!
83+
https://www.linkedin.com/in/hongbo-zhang-a8574157/ Image source
84+
85+
footer.scroll

concepts/flow.scroll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
id flow
44
name Flow
55
appeared 2014
6+
creators Avik Chaudhuri
67
tags pl
78
website https://flow.org/
89
latestVersion v0.236.0

concepts/moonbit.scroll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ description Intelligent developer platform for Cloud and Edge using WASM.
1111
lab International Digital Economy Academy
1212
fileExtensions mbt
1313
writtenIn moonbit json markdown yaml toml bourne-shell
14+
influencedBy rust go
1415

1516
docs https://docs.moonbitlang.com/
1617
repoStats

concepts/rescript.scroll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
id rescript
44
name Rescript
55
appeared 2020
6+
creators Hongbo Zhang
67
tags pl
78
website https://rescript-lang.org/
89
webRepl https://rescript-lang.org/try
@@ -32,6 +33,8 @@ leachim6 ReScript
3233
example
3334
Js.log("Hello World")
3435

36+
githubRepo https://github.com/rescript-lang/rescript-compiler
37+
3538
lineCommentToken //
3639
printToken Js.log
3740
stringToken "

creators/creators.scroll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1818,6 +1818,7 @@ born 1970
18181818

18191819
name Hongbo Zhang
18201820
twitter https://x.com/bobzhang1988
1821+
gits https://github.com/bobzhang
18211822
born 1988
18221823
country China
18231824

@@ -1841,4 +1842,8 @@ wikipedia https://en.wikipedia.org/wiki/Dries_Buytaert
18411842
country Belgium
18421843

18431844
name Yosbel Marin
1844-
gits https://github.com/yosbelms
1845+
gits https://github.com/yosbelms
1846+
1847+
name Avik Chaudhuri
1848+
homepage https://avikchaudhuri.github.io/
1849+
twitter https://twitter.com/__avik

0 commit comments

Comments
 (0)