A popular question on Zhihu is: Why has China produced so many powerful Internet companies but has never designed its own programming language? Users in the comment area have different opinions on this, and most of the respondents are not optimistic about the future of Chinese programming languages.
Recently, however, things have changed subtly. A programming language developed by a Chinese team was unveiled on Hacker News. Hacker News, referred to as HN, is a news community co-founded by Paul Graham, the author of Hackers and Painters, and Y Combinator. Although its interface is relatively simple, the quality of users and comments in the community is very high. If you want to get a place on the homepage, you need to decide through user voting and joint discussions in the community. Objective and real evaluations also make many well-known projects spread through HN in the early stage, such as Dropbox, Rust, Airbnb, etc. HN is in the early stage of promotion Featured in projects and discussions of high-quality content.
In less than a day, the programming language named "Moonbit" (hereinafter referred to as: Moonbit) developed by the Shenzhen team made the headlines of Hacker News and sparked heated discussions in the IT industry.
Internationally renowned Scala and functional programming expert John A De Goes said after trying Moonbit: Moonbit looks very suitable for building applications on @GolemCloud and expressed interest in trying it out.
You Yuxi, the author of the famous front-end framework tool Vue.js, and Wasmedge, a well-known company in the WebAssembly ecosystem, forwarded the announcement on Twitter (X) after trying it out.
Major technology enthusiasts around the world have left messages and comments in the comment area. Some developers were incredible at the speed of compilation after trying it out. Moonbit differentiates itself from Rust by making programming easier through automatic memory management. "I can already imagine the next '100 second' video", "At this speed, it may only take 500 milliseconds (to complete compilation)".
Evan Martin, author of Ninja, a build system for large-scale projects such as Chrome browser, LLVM, and Android, also expressed his expectations for Moonbit in the comment area after the announcement:
At the same time, there are already technical users and language enthusiasts who have combined their existing projects to explore the possibility of combined development with Moonbit.
Regarding the project itself, everyone is currently looking forward to the development of the Moonbit standard library and build system.
After learning about Moonbit, Woonki, an engineer from the well-known company GreenLabs, tried to use Moonbit to rewrite the famous Game of Life. He was amazed by the excellent compilation speed of Moonbit, so he expressed his thoughts on Twitter, expressing his enthusiasm for the future of this language. Excitement and anticipation.
So, what exactly is the much-anticipated Moonbit? Why did it gain so much attention in such a short period of time? Next, let’s take a deeper look at the background and characteristics of this language.
What exactly is Moonbit?
Moonbit: A Webassembly language with fast compilation speed, small Wasm size, and high user-friendliness
Moonbit is an end-to-end solution designed for cloud and edge computing. It not only includes general programming language design, but also covers various aspects such as compilers, build systems, integrated development environments (IDEs), and deployment tools. This enables Moonbit to achieve a high degree of vertical integration, thereby providing users with a better development experience and performance.
Digging into the team behind it, Moonbit was built by Zhang Hongbo, head of the Basic Software Center of IDEA Research Institute, and his experienced team. It took less than 11 months from project approval to completion of language design, IDE, and compiler. and build systems. This team brings together members with more than ten years of professional experience in language design and development. It is worth mentioning that Zhang Hongbo himself has not only contributed to a variety of programming languages, including OCaml, ReScript (formerly ReasonML/BuckleScript) and Flow, but also was the author of almost all key components of the Rescript language tool chain, including the high-speed compiler , standard library and build system, etc.
So, what features does Moonbit have that developers should pay attention to? It mainly includes the following three aspects:
The first is fast compilation speed . Moonbit focuses on global speed, adopts a multi-level intermediate representation (IR) overall program optimization approach, optimizes memory layout to reduce cache invalidations, and provides excellent context for data and control flow analysis. At the same time, Moonbit also performs well in terms of build performance. Through the vertical integration of the tool chain, IDE performance has been greatly improved, which is crucial to the developer experience. According to the test, Moonbit can detect 4000 packages in less than 7s in the no-cache mode of the cold start environment.
The second is the small size of Wasm output . Moonbit significantly reduces the size of the final code by effectively eliminating dead code and omitting language features that hinder this analysis. According to the benchmark results available on GitHub, Moonbit outputs the smallest Wasm size, only about 253 bytes.
The third is high user-friendliness . Moonbit simplifies programming through automatic memory and avoids dangerous elements such as pointers or lvalues. In addition, Moonbit also provides an extensive toolset, including managers, compilers, integrated development environments (IDEs), and a cloud IDE with offline capabilities that does not require container support. Among them, the cloud IDE adopts a different architecture from the traditional cloud IDE. It can be developed offline in the browser, user input can be quickly fed back, and it no longer relies on network broadband.
Here is the trial address of Moonbit. If you are interested, you can play it.
Trial address: https://try.moonbitlang.cn
Moonbit:
Reshaping the future ecosystem of WebAssembly
In the forum area at the bottom of Hackernews, in response to Moonbit's appearance, someone asked Zhang Hongbo: "Does this mean that you will no longer lead the work of Rescript in the future, and gradually focus all your attention on the construction of Moonbit?"
Zhang Hongbo said: In addition to Moonbit’s latecomer advantage of learning the advantages of Go language and Rust language in design, the vertical integration of IDE, compiler and build system has been considered from the beginning of design, which is conducive to the ecological development and stability of the entire programming language in the future. It also responds to the original design intention of Moonbit from the side - today, when the Wasm ecosystem lacks high-quality supply-side, if Energy can create a language that is highly adapted to the standards as a user and consumer, this can form a latecomer development in the entire programming language world. Advantage.
As the basis for computer system software operation and network environment, basic software plays a vital role. Although computer performance has made huge breakthroughs in the past few decades, it is regrettable that the software experience has not improved at the same time, and the potential of software performance has still not been fully exploited. In this context, WebAssembly, a new generation of standard instruction set launched in 2017, has attracted widespread attention due to its high efficiency, lightweight, safety and other features.
However, currently on the WebAssembly platform, the mainstream development languages are still low-level programming languages with relatively high threshold for programmers, such as C++ and Rust. At the same time, although some application-layer languages, such as Go, run on WebAssembly, the code generated by them is huge and cannot fully utilize the advantages of the WebAssembly platform. Therefore, in the WebAssembly ecosystem, although there are dozens of open source consumer-side runtimes, the lack of high-quality supply-side is the biggest challenge currently faced.
In order to fill this ecological gap, the Moonbit team focuses on WebAssembly (Wasm for short) to better support this technology and strive to gain a late-mover advantage in this field. As Zhang Hongbo emphasized in his answer to a popular question on Zhihu, "Making your own language requires a lot of sentiment and is very difficult, but in the long run it is a matter of a country's right to speak on basic software issues."
Driven by this vision, Moonbit was born, blazing a new trail for the future of programming software.
The future of Moonbit
There are many exciting plans and development directions for Moonbit's future.
It is understood that in addition to providing users with the existing online IDE and VS Code extension plug-ins, Moonbit is using the LLM large language model to develop Moonbit GPT to assist programmers in code accuracy and improve development efficiency. Moonbit will reach Beta status in Q2 2024 , while being stable, has a foreign function interface (FFI) to interact with the Wasm host. In future strategic plans, the team will consider integrating Wasm 2.0's Wasm GC into Moonbit and develop Wasm 1.0 GC.
Regarding the long-term plan for the future, Zhang Hongbo also answered in the Hackernews discussion area that Moonbit will be his last project before retirement. The Moonbit team has a very strong determination and long-term vision and will continue to promote Moonbit. development of.
Reference links:
[1] https://www.zhihu.com/question/359906573/answer/1709942996
[2] Hacker News: https://news.ycombinator.com/item?id=37174619
[3] Ninja:https://en.wikipedia.org/wiki/Ninja_(build_system)&scene=ccm&logParams=%7B%22location%22%3A%22ccm_default%22%7D&lang=zh-CN)
[4] Moonbit platform background & application scenario introduction: https://mp.weixin.qq.com/s/HcpB0YiU64J2duPikrr-cw
[5] 月兔(Moonbit): the fast, compact & user friendly language for WebAssembly:https://zh.moonbitlang.com/blog/first-announce/
[6] The programming language Moonbit is open for internal testing: https://mp.weixin.qq.com/s/6m7xd5pUR20bGmTCtcQEFw
Author | Jingchun, Yurong
Reviewer | Zhao Yuying
Source丨infoQ