This article was first published on the public account ByteDance Web Infra.

This article is from the first issue of Web Infra face to face: Zhao Haiping & Zhang Hongbo on programming languages.

In their rigorous yet humorous dialogue, the readers can see the collision between two different perspectives of industry and academia. Abstract and concrete observations, the two teachers will discuss their respective views on Rust, Go, PHP, WebAssembly, compilers, Haskell, low code, and the meta-universe.

Welcome to our second edition of Web Infra Face to Face, which will invite the authors of Three.js to our live broadcast room on December 21, 2021 at 6pm.

The body of the

Li Yanlun: Today we are very lucky to have Teacher Zhao Haiping and Teacher Zhang Hongbo in the same frame. Let’s say hello to both teacher Hai Ping and teacher Hongbo.

Zhang Hongbo, Zhao Haiping: Hello, everyone

Become attached to Facebook?

Li Yanlun: the experiences of the two teachers are very interesting. Can you briefly introduce them respectively?

Zhao Haiping: I graduated from Peking University, and then I went to the United States. I studied biology at the beginning, and then I particularly liked computers, and then I transferred to computers. Then I went to Work in Silicon Valley, at Facebook from 2007 to 2015, and then I found China very interesting. From 2015 to 2019 at Alibaba, and then byteDance. Byte was added in March last year and has been like this for almost a year and a half.

Zhang Hongbo: MY undergraduate is next door, is tsinghua electronic engineering department. Then, WHEN I went to MSRA (Microsoft Research Asia) as an intern in my senior year, I came into contact with functional programming languages and thought the theory of programming languages was very beautiful. Later, I went to the University of Pennsylvania to study for a PhD in programming languages, but later I went to work directly due to some reasons. I started working at Bloomberg New York, and then I made a prototype of ReScript (BuckleScript) in my spare time. After about three years, the prototype was one of the most successful open source projects at Bloomberg.

When I came back to China and Facebook contacted me, they told me that they were already using ReScript for Messenger, and they made an exception to allow me to work remotely from home all the time for 17 years and now for four and a half years.

Li Yanlun: Ok, I will also ask you about the experience of the two teachers returning to China. Before this activity, we collected some questions from students in advance. In fact, everyone sighed that the two teachers appeared together, which was a dream connection. Because you both worked in Facebook before, many people were interested in your work experience in Facebook. Can you two talk to each other for a minute? Like you met on Facebook? Or did you meet him back home?

Zhao Haiping: Is Hongbo in 2017?

Zhang Hongbo: Yes, yes, 17 years in (Facebook), but I have heard the name of Haiping long ago.

Zhao Haiping: Ha ha ha, I left in March 2015, so we should not overlap. Why don’t you talk about Facebook first, because I think my time is so early, it’s been a long time…

Zhang Hongbo: But actually, MY work at Facebook is not standard, unlike most people’s work at Facebook, because I have been in China since I joined Facebook, except for three weeks at FacebookMenlo Park when I joined Facebook, and then I have been in China since then. The main thing I actually do at Facebook is work on the ReScript compiler, which is useful in Facebook Messenger. Because I am in China, my work is very easy, I only need to be responsible for programming language, and I don’t need to adjust the time difference with them, and I do the work I am interested in, so I have enjoyed myself in these years.

We’ve been working on the compiler for over six years now, and there’s a lot of consistent commits, about 12,000 commits, over a long period of time on the project, including the build system, the IDE.

Zhao Haiping: Then maybe we really represent different stages of Facebook. Maybe Facebook was already a big company when you joined. I joined from 2007 to 2015 when Facebook was growing from a small company to a big one. So you’re lucky in China. As I said, as the company grew, the office changed countless times, people kept turning up, then moved to a bigger place, then turned up, then moved to a bigger place, many times. Then work, basically do not have much time to think about a lot of other problems, is has been solved the problem of online, online there are all kinds of problems at the time, constantly to bring new solutions, to solve new problems, basically is to belong to a rapid growth of a process, is the breath of a process.

Maybe after 2011 and 2012, with the number of people, you feel much better today. I didn’t really have a team until 2011. Before 2011, the team I worked in had no name. At that time, it was called engineer (laugh). A pool was a group of people, and they said that all of you belonged to Engineer without specifying what to do.

Facebook’s first Chinese engineer?

Li yanlun: There is a rumor that Hai Ping is the first Chinese engineer at Facebook. Because I feel haiping teacher is more rigorous, this meme is quite funny, can you explain?

Zhao Haiping: First of all, if you say Chinese, in fact, there were several American Born Chinese earlier. In fact, there are at least two people in front of me. One is Taiwanese, ha ha ha. There is another one who really came from the mainland, but he is a DBA to manage the database.

So you may need to add a lot of attributives, for example, you must be from mainland China, and then you must be a software engineer, not to manage database, and then you can be ranked first.

Advice for novice programmers

Li Yanlun: Because I feel that both teachers have achieved a relatively high level in this career, for example, Teacher Haiping achieved P10 in Ali. Then I would like to ask both teachers how programmers can achieve a relatively high level. Because I am a new programmer now, my dream is to become a P10 programmer one day. I hope the two teachers will give me some practical advice. What advice will the two teachers give me?

Zhao Haiping: Hongbo, why don’t you go first? I think the experience I introduced is not the experience of the last century, or is it not suitable for the current company? (Being persuaded by Teacher Hongbo) Well, I just want to say my own feelings, because I used to be a student of biology, when I was a student of biology, although I was already a doctoral student in the laboratory at that time, I actually started to work. Because I don’t love biology, so every time I go to the biology lab, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired, I’m tired. So one of the biggest lessons I’ve learned in my life is that you have to do what you love. Because of your special hobby, you will spend more time on it.

When I was in the biology lab, there were other people who liked biology so much that they would just read paper because I didn’t like it and I wouldn’t read paper. So if people read paper every day, they would naturally learn biology well. When I was working on computers, I didn’t feel tired because I was very interested in computers. I spent more time than others, so NATURALLY I made progress faster than others. It’s a [positive feedback], because then if you progress faster, you like computers more because you’re doing better than others. The more you like computers, the more you spend. It’s a particularly virtuous circle.

So, I think if you ask me how I grow so fast in my career, I think you have to find your favorite point, and then dig deep, you can grow quickly in your favorite point, because you are willing to spend a lot more time than others. And then at this point, if you really focus, if you really focus on what you love, then maybe maybe the skill level will naturally rise. If your focus is on the technical level, you may not be able to be very engaged. So in fact, this is a matter of more haste, less speed, the more you do not think about it, but the effect may be better. I don’t know what macro wave looks like.

Zhang Hongbo: I agree with Haiping very much. I think we should do what we love. Like I am doing PL, from 08 to now also have more than ten years, if they do not have so much love, it is very difficult to stick to it. In addition, the FIELD of PL is a relatively cold thing to be honest. It is not easy to find a job if you only do PL. However, because you love it so much, if you do the best in this field, you will have no problems in this field. So I think you have to do what you love so you can stick with it. Another thing that I personally feel is that if you want to move up in the company, you have to know the company’s business. While your skills can settle down, take the time to learn the business.

What is the difference between working experience at home and abroad?

Li Yanlun: I see. I’ll go back and let me love my job more. And then come back to the point of working overseas. Because both of you have worked abroad for many years, and then both of you have worked in China for many years. So I’m curious how you both feel about the different experiences of working at home and abroad.

Zhao Haiping: Teacher Hongbo must come first this time, ha ha ha.

Zhang Hongbo: I think haiping should come first, because although I have been in China for many years, my working environment is still abroad, so the contrast is not so strong.

Zhao Haiping: I see. Although you are on Facebook, you are actually in China, not in Office, right?

Zhang hongbo: Yes, actually I haven’t worked for a Chinese company, so I can’t make a comparison.

Zhao Haiping: OK, to be honest, I think Internet companies, whether silicon Valley, Alibaba or Bytedance, are generally very similar. In fact, you can feel the convergence of people saying, you want an open office space, I want this, and then you want to decorate the office, I want to decorate the office, you want to have personal space, I want to do this. I think it’s all pretty much the same. Especially if you like this you have to have a kitchen, you have to have snacks, you have to have something to drink. Then the canteen food must be particularly good, in the Internet companies are very concerned about the feelings of employees. So in general it’s pretty much the same. If I have to make a difference in this detail, I think it might be more like Facebook. If I draw an axis and force these companies on both sides, Alibaba may emphasize more on face-to-face communication between people. There are many activities between people. It is emphasized in the meeting that we must discuss something together.

Zhang Hongbo: DO you pay more attention to corporate culture, I suppose? Still?

Zhao Haiping: Yes, it emphasizes the connection between people. As for Facebook, in fact, it emphasizes the use of software to drive a lot of work processes. Maybe this person and I have always been in the upstream and downstream relationship, in the flow process of a task, but I may not meet this person for a year or two. But the words in Ali seem to be generally people who get to know each other and have the opportunity to get to know each other better.

So I don’t think it’s good or bad, I think Ali might be warmer. But Facebook is more efficient. That byte is actually more like Facebook, and the byte is also very much about the efficiency of the software process. Especially Feibook, I think feibook does a really good job, probably better than a lot of software inside Facebook.

Zhang Hongbo: LET me interview Haiping, because you have all worked in these three companies. What do you think of the working intensity of these three companies?

Zhao Haiping: I don’t think I’m representative, you know? Because on the one hand, the job is not representative. On the other hand, maybe mentally, I’m happy to do something a lot of the time. So I want to emphasize the intensity of work, first of all it’s a sensitive thing, but in fact a lot of times man is a will animal. For example, if you play mah-jongg games until two or three o ‘clock in the morning, you don’t feel tired. Do you think it’s too intense? No, I love it. I could stay up all night, right? See how much you like it. And if you don’t like it, like when I was a biology guy, I could get up at nine in the morning, and I’d be tired, right? So I would say gee, that’s a lot of intensity, so that’s probably a lot of people’s opinion, you ask a lot of people about that and they’re going to say different things.

How far does programming linguistics go

Li Yanlun: Oh, yes, I think because of the question mentioned before, I believe that the partners in the studio should have a certain understanding of the experience of the two teachers.

So let’s get back to today’s topic and talk about programming languages. In the questions we collected, people asked about many different languages, and he didn’t just ask about PHP and ReScript, so you still want to know what the two teachers think about these languages.

I would like to ask you two teachers, what is the degree to master programming linguistics?

Zhang hongbo: Generally speaking, the essence of a language is to provide some API and runtime on which you can do things. So for example objective-C you can write mobile, another one, it gives you an abstraction mechanism, it allows you to do modular programming.

The great thing about JavaScript is that you’re everywhere. But the language itself was a bit sloppy when it was designed, not all of it was designed in a week at the beginning, so it’s not a perfectly designed language at this level of abstraction. So I spent the next decade patching the language.

There is a book called JavaScript The Good Parts, and ACTUALLY I think if you learn JavaScript, you just learn The Good Parts, The Bad Parts and you can ignore them, or only when you really need them, To understand why. And now with TypeScript, you can get rid of a lot of Bad Parts. So you only need to learn to correspond to your useful abstractions, don’t focus in some corners to go.

Li Yanlun: I understand that, in fact, according to the business, right? According to my actual business, and then judge what level I want to learn this language, is that the meaning?

Zhang hongbo: If you need to express an abstract mechanism, classic design patterns will do. You don’t have to worry about the JavaScript language itself, for example, the original JavaScript had the prototype chain, which was a proto property, and I don’t think you need to worry about the details.

Li Yanlun: I understand, I hope the interview does not ask me too much detail, because he will ask deeply in the domestic interview, JS words will also ask about the prototype chain, ask particularly deep.

Zhang Hongbo: Yes, but because ES6 after he has class, in fact, you can not step on this pit, I personally think it can be ignored.

PHP is the root of all evil?

Li Yanlun: Ok. The following question is asked by a netizen to Mr. Haiping. Some people openly say that PHP is the root of all evil on technical blogs. What does Mr. Haiping think is the future of PHP?

Zhao Haiping: I’m sorry that I haven’t seen this blog. It may have a context or be targeted. I don’t know what is this the root of all evil, but because I didn’t read, so I can only guess that must be dissatisfied with PHP, isn’t it, think of the language there are some design is not perfect, there are some very good place, may not have to be able to get rid of for a long time, you complain for so many years, and has always been like this. I guess it might be a case like this.

But I think for a language, like I want to understand this blog, it’s important to understand its context, to understand its context. So if you want to know about PHP, you need to know about it, you need to know about its context, and you need to know about PHP when it was created at the end of the last century, when Web servers were springing up, and there were websites, The Internet just started, and it was a very exciting time. At the same time, everything is very primitive. I don’t know for primitive people who complain about PHP, have they ever heard the word LAMP, it’s a very important word. What is this LAMP? In English the word is called lamp, but in fact it is an abbreviation of four software.

L is for Linux, Apache, MySql, PHP, LAMP is fundamental software for Internet.

This one’s called the patriarch. Do you get it? Now you’re complaining about how bad Yahoo is, sorry, yahoo is the father of the Internet, okay? You have to respect it, the man called Legendary, the man like grandpa, do you understand? There must have been a lot of bad things about him when he came out, right? Why do you think he didn’t change? It’s because we have so many things attached to him, depending on him, to change the words to pull the whole body.

So in fact, it’s not that the person in charge of PHP doesn’t see these flaws, you can go and knock on her door and say, look, I told you this stuff about PHP is bad, but I know it, but I can’t change it okay, so it’s about understanding and embracing. You’re going to understandwhat’s going on, you’re going to understand how does PHP come about? And then why is it where it is today? In fact, there are a lot of times, even for each feature, you think the design of this feature is strange and inexplicable, and it is not good. You need to read its history, why is it like this? You’ll see that there’s probably a very interesting story. So that’s what I’m trying to say: How much love you have for programming language, how much tolerance you can have. So when we see something bad, it turns out to be a very interesting thing. In fact, there are many stories. So I don’t disagree with any of the comments that say PHP is bad, and there are a lot of bad designs out there. But at the same time I understand him, and I know why he’s bad.

Li Yanlun: Wow, when I heard Teacher Haiping talking about LAMP, in fact, my first job was PHPdeveloper, and I used LAMP at that time, and I thought it was OK, and I did business OK, but then I changed my internship to Java, and I thought wow (Java) is so painful. Because PHP writes everything together. And then Java is Controller has to write one layer, Services has to write one layer, and then Java I’m really miserable. But I personally love PHP because it’s fun to write. However, one of my classmates said that there is no perfect programming language in the world, so I would like to ask two teachers what are the disadvantages of PHP?

Zhao Haiping: One of the weaknesses of PHP is that it has a lot of so-called semantics, which is very vague. So for example this false, a lot of value==false how do you explain this? Well, unless you’re going to look it up, you won’t be able to guess it yourself.

This design, which is called hacky, is less formal than Java. So I sometimes suggest that if you go to school to learn a language, maybe you should learn Java. Why? Because Java is designed to be very formal, very canonical, and canonical is very formal, and it has a lot of context, which makes sense. And then a lot of the design of PHP, it’s a little bit arbitrary, it’s a little bit on the fly, for example, as I wrote here today, I defined it this way, and it got wrong all at once for years.

So if you want to ask me what’s wrong with PHP, you can go to the Internet and you can see a lot of examples like this. But like you just said, I think when we were at Facebook, people were complaining about PHP and getting this done pretty quickly. See what I mean? PHP is actually very fast to write things, because it is hacky so it can put this page together very quickly.

Facebook doesn’t care that much about the code being perfect. Why? Because at that time, we did not know what the site should be built, maybe the next day the code will be deleted and written again, so you go to excessive polish the code, sometimes it is better to write quickly, called the process of rapid iteration.

So PHP just matched the model that Facebook was developing, and people didn’t complain that much. But if you go to another company, you care about the stability and continuity of that code. For example, if you’re a finance company and you care about code maintainability, PHP might not be a good language.

Golang’s best and worst

Li Yanlun: Ok, I feel PHP and Java were very popular in the first two years, but in recent years Golang has become very popular after it came out. So I would like to ask you two teachers’ opinions on Golang. Someone asked that they would like to talk about the essence and dregs of Golang.

Zhang hongbo: ACTUALLY, I have used some functions, but I am not proficient in them. I think Golang is a good language.

For example, interface define, as far as I know, is the first mainstream language to use structuraltyping in industrial languages, of course, many academic languages have already existed. And then it compiles very quickly, and I can’t agree more, speed is important. Golang is missing two things for me, one of which is generics, but now generics have been added. And then the other piece, I think modern languages should have algebraic data types and pattern matching. But it is a pity that Golang, as a new language, has not been introduced, so I think it is also a pity.

Zhao Haiping: Yes, I think so, because Hongbo is the language learning background, so this view is a strong academic characteristics. Let me say the industrial point of view, complement each other.

Golang: I don’t know why, but dross and essence have a strong emotional color. Then I thought it was important to understand and understand PHP as well: why is Google doing Golang? Because what we’ve found over the last five to ten years is actually what the vast majority of companies are writing? In writing distributed computing. It is particularly common that I tune you, you tune it, and it tunes it. You know why microservices are so popular right now because that’s the way it is now, when the team gets big and I split up the engineering task, I’m going to call RPC, right? So this becomes this and a lot of applications become the so-called IOintensive form, that is, it’s not a simple calculation, it’s probably, like 20 years ago, a lot of software is doing a lot of calculations, right? There’s not much RPC because it’s all on the same machine.

And then when you split it up, it’s not so much computing, it’s more IO, so IO, the question is, what is your threading model? Okay, so Java says let me solve this problem, Java says we have thread. If you have 50 threadJava threads, you should not run them. If you have 1000 threadJava threads, you should not run them. Therefore, many ideas and thoughts will come out after we follow the IO how to make the application of IOintensive run well.

And then I finally figured it out. It turns out that we have to use a model like Epoll for user threads, which are lightweight threads in user space, to solve the I/O problem. Go caters to this trend. I wanted other people to be able to jump on this model very quickly, so he changed the concept of goroutine to first classcitizen, so it was really meant to be there.

Of course, you can complain that Go has many bad points. If you ask me, I may point out that his Errorhanding is not very good. He does not have exception. If you go, you must return an error.

This is not a mistake. This programming language is just like this life. There is no right or wrong choice. Don’t beat someone to death with a stick. God, you’re wrong if you’re not exception. I’m sorry to all of you who write the Go language. If you are tired, please check the return value yourself. Don’t say it’s too easy. So it’s a trade-off.

So a tradeoff, you can disagree with the trade-off. But no, the language was invented by someone else who made the decision for you, so understanding why they made the decision will probably make you feel a lot calmer. You can not say what essence or dross, so many people together to create a collective crystallization of wisdom, he is unlikely to have dross in it, but there will be a choice, may be you do not like the choice is entirely possible.

Li Yanlun: Wow, I think there is no right or wrong choice. This really moves my heart. Then, because Teacher Hongbo just said that Golang had a weakness before that it did not support generics, so a student wanted to ask, you said that Golang1.8 after he began to support generics, what do you think about this?

Zhang: I think it’s quite good. Although I don’t have followGolang personally, I heard that it’s the same as Java. You have types when you compile and then remove them later.

WebAssembly

Yanlun Li: Well, we were talking about backend languages, and then we talked about backend languages, and then we had to talk about WebAssembly, which has become so popular in recent years because of WebAssembly, which allows code written in various languages to run on the Web at near-native speed. The back-end code is now ready to run on the Web. I would like to ask you two teachers’ opinions on WebAssembly.

Zhang Hongbo: I correct you on the wrong point that WebAssembly allows languages to run at near-native speed, which is not true. Because you can only say that C++, the underlying language, or the compiled parts of it, can run very fast. But you say JavaScript or PHP could theoretically compile to WebAssembly, but it’s still slow because it’s fast or slow because of the nature of the language. It’s not like you get WebAssembly and all of a sudden it’s faster.

And then WebAssembly, which now has two modes, one is it doesn’t have anything to do with the Web platform, it’s just a generic IR that you can write to in any language, and then you can do computing in the cloud, and then it has an advantage over traditional IR, first of all, it’s cross-platform, Once compiled into WebAssembly, you can throw it on any operating system. The other one, it’s designed with security in mind, it can do security correction quickly, and then it can provide a nice sandbox for use on the back end. But the main thing about the front end is that it can take some computatively complex application and port that to C++, and then compile it into WebAssembly and then call it. For example, some traditional encoding and decoding.

One of the most successful examples used today is to move some old C++ programs to the Web platform. A recent success story is that Adobe photoshop is written in C++ code, and I can take a lot of existing code and write it directly into your Web platform using some of this new technology. That way you can get some of your older apps to a wider audience.

These are two ways to use WebAssembly. Going back to ReScript and PHP, because ReScript is a static language, it compiles to WebAssembly, and calls work, people have tried. A very dynamic language like PHP or JavaScript, right now, even if you move it to WebAssembly, you don’t get any performance gains. You have to cut out a lot of the language features, like TypeScript. Make an AssemblyScript, which is a very, very small subset, and then you can compile it into a working WebAssembly. So WebAssembly is not a way for you to suddenly make anything faster.

Zhao Haiping: Our language group was also interested in WebAssembly, and the points we were interested in were actually for inter-Operability, I don’t care what languages you used to speak, after this compilation, we can invoke this to each other. This is the point that we’re looking at right now, but we’re just starting to look at it, and it’s not that deep. Actually, but I think the WebAssembly thing is kind of interesting, as we get to 2021, we’re actually going to have a lot of languages, and in fact whether you look at WebAssembly, LLVM, In fact, the questions to be answered are basically how to make so many languages well integrated with each other, or save engineering effort. I think this trend may be really quite good.

Zhang hongbo: I would like to mention that WebAssembly has not solved this problem. Like different languages, if it has garbage collection, that interoperability problem is still difficult, not because of WebAssembly it automatically solved.

Zhao Haiping: Yes, there are fundamental problems.

What does Rust think?

Li Yanlun: When it comes to new technologies, Rust has been very popular in recent years. It was created by Mozilla, Facebook, Apple, Google, Amazon and other big companies have used Rust for system infrastructure, encryption, virtualization and more underlying coding. And then a guy at Vercel (next.js), he said Rust would be the infrastructure of the future of JavaScript. So I would like to ask you two teachers, what do you think of Rust?

Zhao Haiping: In fact, there are a lot of people inside Byte who like Rust. The internal user group is very large and many people join the group. And then they ask me if I like Rust, and I’m very cautious, and I’m very afraid of saying the wrong thing, because I’m afraid of saying something good or bad about Rust, and it becomes a side issue, so I’m very cautious. But perhaps in the end we need to support Rust, after all, by encouraging people to try something new. However, the advantages and disadvantages of Rust are obvious. At the moment (2021), Rust’s advantages are no doubt that it doesn’t have a Garbage Collector, that it emphasizes object ownership, that it probably takes a little effort to write, But run without the Garbage Collection barrier, and then be efficient. However, other programs, such as system programs, are relatively safe. The advantages are particularly obvious, and I agree with them, but the disadvantages are also obvious. For example, the compile speed is slow, the base library is incomplete, and the IDE support may not be particularly good. The other one is that it is not easy to learn and the learning curve is quite high. If you want to understand the object ownership, you may have to be a master so that you can fully understand it. So I think we belong to a state where we follow the progress of this community.

Mr. Zhang: I would add that Rust and ReScript have a common origin. If you like Rust, you’ll like ReScript because they all come from that ML (Metalanguage) language, which is a meta-language. Rust’s earliest compilers were written in OCaml. ReScript is Rust taking out the Garbage Collection. You don’t need to learn those lineartypes. If you don’t have a foundation in C++ or C, it may be difficult to understand. So if you like Rust, you will also like ReScript, and ReScript is much better for pattern matching and user experience thanks to GC. But Rust has a very high threshold objectively, mainly in Linear types. Its type has leaked to users. Even though I am only your library user, I also have to understand how this thing, the bar is still relatively high.

What are the fundamental problems that programming languages solve?

Li Yanlun: Thank you for your insights. We have talked a lot about programming languages. We have talked about Go, PHP, ReScript and Rust. I would like to invite you to have a more in-depth talk about the essential problems that programming languages solve. How is it resolved? And then think about asking two teachers to open up.

Zhang Hongbo: I have mentioned the nature of programming language just now, it provides two functions. One is to provide a series of underlying apis, such as GLSL and Shade Language. I can let you operate the GPU. And then another one that provides an abstraction mechanism, like the original assembly, it doesn’t have function, so it basically doesn’t have any abstraction mechanism, and it’s hard for you to do large-scale modular programming.

So for your users, the first thing I need to know about its API is that, like most industrial languages, it provides similar abstraction capabilities. For example, if you learn C++, you can learn C# quickly because the abstraction pattern is basically the same. But if you study an academic language like Haskell or that Prolog that gives you a whole new experience, it provides another way of abstracting.

Zhao Haiping: Hongbo is a language major, so we must listen to hongbo’s views on this issue.

If you ask me, I probably think about language more in terms of industrial. I think this question is quite good, although very profound, but in fact it also has a practical side. If you think about it, the language we speak today actually lets us do a lot of things like instructComputer, right, to tell the computer what to do for us.

But there are actually two things that it doesn’t do particularly well, or it doesn’t do well yet, or it doesn’t fall within the realm of language, but it’s actually worth asking the question, why isn’t it within the realm of language? What two things? One is the database, database, actually I want to ask macrobo this question, for academic research people, database is a camp, programming language (PL) is a camp, and then the way the two camps actually think about problems, PL people think more in terms of CPU, database people think more in terms of data. Each thought he could contain the whole world.

So actually when you look at the language and actually the database and it interconnects, a lot of times it’s not very, very perfect. Therefore, most of the time, when a language accesses a database, there are so-called data binding, which needs to be solved. There are many problems with serialization and deserialization. It does not include a lot of things like databases, databases, or data in the language.

Of course there are such attempts, but it seems that there are still two camps, database and PL. Why can’t these two camp people be together, why don’t they just mix the two things together? So if you can ask this question, you can actually answer what is the essence of language.

Another thing is distributed computing. There is no language yet that says it can override many machines. I’m going to write a program, and it’s going to click and run on thousands and thousands of machines. Of course we have similar systems, such as Map-Reduce, but it doesn’t rise to the level of language. It doesn’t say I only need one language today, you don’t have to go write this one server one client one, just one language, I write a program and then deploy it to all the different machines, that’s a good question, why don’t languages do that? This is also an answer to the question of the nature of language, and there is no good answer.

So it actually makes sense for us to look at this question today. Why is that? Because we microservices are actually a big chain of calls. One service calls others, and other services call more services. It is a treelike Call tree with dependency. However, there is no language that can describe the whole call tree completely. The compiler can then optimize the tree. How do I optimize to make the whole call efficient, but the language doesn’t answer that question, and now it’s better to leave it up to you to do some scheduling, or to do some optimization yourself, Or use WebAssembly to have some inter-operation between the different microservices.

So I don’t know how to answer that question, and my answer is I don’t know, because I’m not satisfied, I don’t think I fully understand the category of language, where the boundary is, maybe five years, ten years from now language is redefined, it’s all possible, right? Anyone who asks that kind of interesting question can try, can innovate.

Zhang Hongbo: I would like to add that there are distributed languages. As far as I know, there are distributed languages in Berkeley, but they may not be so successful. They’re working with Alibaba, but it’s not a solved problem.

Is the average business programmer involved in language development?

Li Yanlun suppose I am a very ordinary business programmer, do I need to participate in the development of language? If I did, how would I balance business and language development? What are the advantages and disadvantages of my involvement in this matter? I hope you two teachers can talk about it from your own experience, such as how you entered into the language development, how you balance after entering the development? What are the advantages and disadvantages for you?

Zhao Haiping: Because I’m not a language major, I was pushed to do this at Facebook: we ran out of machines, so we had to optimize. And then of course you know PHP is slow, slow means it’s consuming CPU, it’s consuming a lot of machines, so people are trying to optimize PHP, so I was forced to do the language, so at least that’s one way, forced to do the language.

At that time, in our American language group, we were always proud of ourselves, because there was a saying among ourselves at that time: those who do compiler are the best programmer. This sentence is full of bluster, but it also has its point of truth.

Once you have a thorough understanding of compiler, you will undoubtedly be able to understand what you are writing. You know what’s going on, you know how to write it is very efficient, not just to write it, to implement it, but to write it in a way that the machine likes, not just the people like it, but the machine runs very fast. So maybe maybe knowing the language is undoubtedly helpful for everyone’s technical growth, but it is also a very expensive thing to drill into the language. You also know that the course of Compiler may be the most difficult one to pass when you were in school, which is very difficult. I really don’t know whether you are willing to spend such a big cost to make such an effort. Sometimes we have to follow the rules. I really one day I really want to learn, I will learn. But if you have nothing to do today, it doesn’t make sense to force yourself to learn. Macros might be particularly fond of languages?

Zhang Hongbo: I agree with most of them. I would say objectively that the average person probably won’t design a common language in their lifetime, or design a common language for everyone to use. But I think it’s useful to learn language design and compilers. First of all, with a compiler, it has a front end and a back end, and if you know the back end, it’s great to optimize something on the bottom. Personally, I’m very, very familiar with OCaml, and I basically look at the source code for that OCaml, and I know what the assembly code looks like, and I know what the performance is. If you know something about the back end, it’s useful to do performance tuning.

And the front end actually has a lot of useful places, like we have a lot of metaprogramming in the business, like Google’s Protobuffer where you have to do a lot of code generation, and this is where you need to use the compiler front end knowledge. So the compiler front end and back end can also be used in business value. And I’d like to add that the barrier to entry for compilers is not that high anymore. If you’re doing the back end, if you have LVM IR you don’t have to look up the assembly instructions yourself, you just have to look up some generic LVM IR, generate into LVM IR and get the machine code. Then, there are many common parser generators in the front end for you to fit. There are many kinds of tools for you to use and it is easy to use. Sometimes, you don’t need to know its theory.

What got you into ReScript development?

Li Yanlun: Mr. Hongbo, can you tell us what brought you into ReScript development?

Zhang Hongbo: Yes, because I studied Metalanguage for my PhD. What is meta language? There is a very popular concept meta-universe, which is the same meta. A meta-language is a language that is used to manipulate other languages. So it’s kind of like homework, you design a language, you design it, you implement it, so I kind of naturally went into the compiler. Although I have an academic background, I am actually an engineer. I feel that PL, as an academic, has limited influence on the industry. Now most of the popular industrial languages are not out of the class, like C++, Java and Go, in fact, are not out of the PL background. There are a lot of ideas in our academic circles that have not actually flowed into industry. I personally feel that I want to bring what has been deposited over the decades in academia to industry, and these are some of my original ideas. I want to transfer what is good in academia to industry.

Li Yanlun: I understand that you had this idea when you were in school. It started as an interest of yours, such as a side project. How did it become your main occupation?

Zhang Hongbo: Yes, that’s right. Here’s a story. My boss at the time was A Frenchman, and he loved OCaml because OCaml was written in France. I started out as an amateur, developing a compiler called Bucklescript that compiled OCaml directly to the Web, and because my boss loved OCaml so much, I made a demo for him that compiled the compiler itself into JavaScript. Then you can run a compiler in the browser by bootleg the compiler, and then you can see OCaml on the left, and you can see JavaScript on the right. My boss was shocked by this demo at that time, in 2015, and then supported me to do this, so gradually I became a full-time job.

When should you think about designing a language?

Li Yanlun: Wow, that’s cool. I feel that side project was originally something I liked very much, and then it became my main occupation, and my hobby became a feeling of work.

Talking about Teacher Haiping just now, part of the reason for the in-depth study of PHP is that the business has hit a bottleneck. Some of the partners working in domestic Internet companies always feel the lack of writing a language to solve practical business problems. In view of this situation, I would like to ask you two teachers, what is the difference between Chinese and foreign companies here? When should we consider designing a language?

Hai-ping zhao: In fact, I did not intend to make a complete compiler at the beginning. At the beginning of the story, we wrote website with PHP, and then there was a function called ID_to_DB. You gave me a user ID, and I told you which database to hash into. Modulus: a 100 gets the DB number. But as time goes on and on and on and on, the function gets fatter and longer and longer. And then later this PHP function might be a page or two in size.

The problem is that, as more and more services are written in C++, the C++ person also needs to call this function. He also needs to find which MySQLdatabase to access the User’s data through a User ID. He can’t just tune into PHP, can he? What to do? I wrote a C++ program by hand to help him do these things. That how to write, is to see the PHP function implementation, and then to write a C++, but this function has to change every time, every time he changes I have to change the C++ code, change once I have to change.

Later I said that I should have written a Converter specifically for the convert function. This was the beginning of the story. Later, I found that I could convert this function. In fact, many PHP functions can convert, so I gradually expanded it bit by bit.

It’s not that you’re encouraged to start a particularly time-consuming project, and Facebook requires it. It says I’m going to deliver for the next six months, so what is your deliverable for the next six months, you know what I mean? You can’t say: Bye-bye, I’m going to close the door, I’m going to work on a really big project, and I’ll see you in two years. Sorry, it’s not like that. It’s not like that in company. In order to do this project at that time, I did it in my spare time at the beginning. I had my own job to do, but later the project grew bigger and bigger, and gradually I had to hand over my own job to others, so I was able to do it 100%.

So WHEN I started out, I wasn’t a good performer, you know? So maybe in hindsight, without knowing the details, you might think oh My God Facebook encouraged people to do such a big project. That’s not exactly the case. Of course there’s encouragement, saying that encourages you to explore, encourages you to explore different directions, to try things in different directions. He doesn’t say no, you can’t do it. But a lot of basic company rules still need to be followed. I don’t know about Hongbo, but you tell me what you think.

Zhang Hongbo: Yes, I think I agree with Haiping’s point of view, but there is a slight difference between overseas and domestic. If you get the approval from your boss at the beginning of this project, and then you do it, he can allow failure, which will not have too negative impact on your future. He was a little more tolerant of failure.

Li Yanlun: I think haiping had a dilemma, but Hongbo didn’t, because he said he didn’t perform well at the beginning because of language writing. But Hongbo’s main job is language writing. Can you share this experience?

Zhang Hongbo: Mainly because my boss is very helpful. BuckleScript was made in Bloomberg, and the feedback was good at first, and then open source, and the feedback from the open source community was good. Then the company felt it could be supported from a PR perspective, so it survived. So first of all you have a good boss and a supportive company. Because Bloomberg, at the time, was like a quarter of the money is going to be given away, so if you’re going to give it away, you might as well do something more meaningful for us, right?

Li Yanlun: Because the question asks when to think about inventing a new language and when to think about contributing to the current language. Teacher Hongbo created a new language, while Teacher Haiping contributed code to PHP language. So I would like to ask both teachers why teacher Haiping didn’t write a language by himself? Why didn’t Mr. Hongbo contribute to the existing language?

Zhang Hongbo: I want to answer the question just now, because MY present language has not felt that oneself especially feels handy. I would not invent a new language if Go, for example, supported algebraic data typing (ADT) or pattern matching. I design a ReScript of reason, is the industry now, I think common language, it’s not such a good algebraic data type to into the modeling problem of some areas, it lacks some features, I want to send this algebraic data type () to give to the industry, also let more people to accept to this feature, mainly from the Angle to think about it. Of course, some academic languages have their own problems. The implementation of PureScript is very weak, and its compilation performance is not good. For example, PureScript is also a relatively academic language, which has all the required features, but its code generation efficiency is poor. So you can’t use it for production. So I wanted to have a language that provided the abstraction mechanism THAT I needed, the implementation strength was ok, it had good performance, and that’s what I wanted to do.

Zhao Haiping: Yes, if you ask me this question, it has nothing to do with the dilemma I was facing at that time. Why is that? For example, did Facebook ever think about switching languages? Yes, there were four people in the company at that time, four super engineers. They all liked Python so much that they made up their minds. I can name all the four people, and I still remember them after so many years. The four of them are very strong, they like Python very much, they said you should not write in PHP any more, I will rewrite our website in Python, but sorry no other people listen to them, they will continue to write IN PHP and they will not stop. Is that clear? Why is that? Because the site is there run right? You can’t stop, stop and convert to Python and move on? So the four of them were literally burning the midnight oil writing Python.

He can’t write fast enough, you see? You know, the people who write PHP talk a million times, you know? He just converted a few files, there said sorry I commit 10 new files. So in the end the four people who wrote Python had to get away with it.

See what I mean? So any attempt you make to change to another language is futile, so it’s futile, so it’s futile, so it’s futile, so it’s futile, so it’s futile, so it’s futile, so it’s futile, so it’s futile, so it’s futile, so it’s futile, so it’s futile to change to another language. We even had an idea that was even more crazy. We said, for example, there are 200 Engineers, aren’t there? Now we have IPO, we are rich, we can recruit 2000 Engineers and directly give them Java, but later we gave up. I think it’s not allowed to say that, so I have to change the bottom layer of PHP, because you’re like this in the company, and this is what we call a transparent solution, a transparent solution, transparent means I don’t affect other people’s lives. Generally speaking, such a solution is better, everyone can accept, you do not affect others anyway.

Mr. Zhang: Well, companies tend to prefer incremental. They don’t want it to be one-shot incremental. That is too big a risk, but we still hope to have a good language from the point of view of the academic school.

Zhao Haiping: That’s right. That’s right.

That’s a good thing, right? When you’re creating a new language, if you have the opportunity, you renovate it, right? There are a lot of new ideas that are quickly injected into the new language, but I don’t think I’ve had that opportunity, so this question doesn’t apply to me, I don’t have a way to answer it.

How does a language sound good enough?

Li Yanlun: What Teacher Haiping said just now really touched my heart, that there is no right or wrong language, only choice. We have talked so much about programming languages, I would like to invite two teachers to talk about, in your opinion, how to evaluate this language is good enough? What makes a good programming language?

Zhang Hongbo: Because I’ve actually been exposed to a lot of languages, and in general languages it brings you some new ways of thinking, and it just shines in my eyes, and I think it brings you something new, like if I learn C# or Java, it’s almost the same, I feel the same, there’s no difference, Python, Ruby, Perl, I think it’s just a different syntax, all from my academic point of view.

I think there are a few languages that really affect me. The first one is Haskell, which has a nice type system that opens your eyes. It’s a static language. There’s another dynamic language that actually affects me. Like Commonlisp it’s very, very convenient for writing macros and doing language programming. You can write a macro generate a macro and then regenerate a macro. The macro was just a simple compiler that you could do a lot of things with, and both of those languages were pretty impressive to me at the time.

Is TypeScript possible as a statically compiled language?

Li Yanlun: I’m going to ask about Macro in a minute, because we talked about programming languages for a long time. Here’s a more specific question that might interest macrobloggers: Is TypeScript possible as a statically compiled language? If so, what are its prospects?

In fact, there is an attempt in the academic world called STS, static typescript aOT compilation of a subset of typescript. There is also an industry experiment like AssemblyScript, which is also a subset of TypeScript. The problem is that subsets are basically incompatible with the TypeScript ecosystem.

AssemblyScript uses only a small feature. There are even attempts to compile JavaScript into IoT, but it’s also a dynamic query by nature, and you won’t get a more efficient binary. Unless you cut out some of its bad features, then it’s not TypeScript anymore.

Li yanlun: So there is no way it will become a statically compiled language anytime soon?

Mr. Zhang: I don’t think it’s likely in the long run, because that’s its historical baggage. That’s why TypeScript is so popular, because it’s fully compatible with JavaScript.

Li Yanlun: When Teacher Hongbo talked about macros just now, one of the students happened to ask when macros are needed in a language. Why do scripting languages rarely have macros? Can’t interpreted languages have macros? I’d like to ask two teachers to expand on Macro.

Zhang Hongbo: I can say, first to correct the question, why scripting languages rarely have macros, this question seems wrong. Because like Common Lisp, the macro ancestor of Lisp, generally interpreted languages have macros. So hygenicmacro’s earliest studies came from scheme and racket, which are both dynamic languages. So the question doesn’t seem right.

Dynamic languages, interpreted languages have macros, and they’re actually easier to do this than static languages, because dynamic languages have no types and macros are easier to do than static languages. Like ReScript, there are macros, and we also provide a compiler plug-in that allows you to reexpand code to generate other code at compile time. But the problem is that macros make it very difficult for you to do things with the tools that the language provides, because you can do arbitrary calculations with that expansion, which is very difficult with an IDE. One of the things that makes rust’s IDE problematic is its macros, because Rust has macros, and with macros your IDE is very hard to do. So I want to correct that dynamic languages also have macros easier, static languages also have macros, but static languages make your tools harder to do.

Li Yanlun: what does Teacher Haiping think of Hong?

Zhao Haiping: You can discuss this with Hongbo. In fact, generics are trying to achieve some of the goals of macros, but they can be a little bit safer, a little bit safer.

Yes, there are two kinds of generics, like C++ generics, whose type information is really used for code generation, and like Java and ReScript, whose type information is only used for verification, which is not used for code generation.

Zhao Haiping: I would like to say why generics finally make all languages more or less to support some, in fact, there is just need inside. In fact, the world we want to program is multi-dimensional.

In this multi-dimensional situation, no matter how much I write a program like object oriented, there are always some dimensions that are forgotten, and only macros can cover that dimension so that there are other similarities between different objects, and then macros are needed.

Zhang Hongbo: Yes, that’s right. Why do we use macros? Because our language doesn’t have enough abstraction mechanisms, so we introduced macros. So having macros in general may indicate a lack of abstraction in the language.

How does the compiler bootstrap?

Li Yanlun: Because we talk about a lot of languages, and we can’t talk about languages without compilers.

Can we have two teachers talk about how compilers bootstrap? This seems to be a chicken-and-egg problem. I’d like to hear your opinion.

Zhang Hongbo: I can say, in fact, there are a lot of situations. For example, how does OCaml do self-lift? I first wrote an interpreter in C, which can interpret some bytecode, and then I defined the OCaml code as this bytecode, which is what my compiler wrote, and then the bytecode relies on a C interpreter, so you can bootload, as long as you have a C compiler on your machine.

The other way is, I have a compiler that compiles my language into C code, so as long as I have a C compiler on my machine, I can bootload it.

There is another situation, C language compiler also not all machines are some, I made a new chip, he is not C compilers right, then use cross-compilation, I know you another architecture, its assembly format I know, I can on the Intel machine, compiled into the ARM of a binary format. And then I copy it over, so I can do bootstrap as well.

Zhao Haiping: I think there are a lot of times, some language special emphasis on this, may on the one hand is a kind of spiritual cleanliness, I do not rely on anyone.

Zhang Hongbo: yes, generally will use their own language, because they write their own language will have a kind of inexplicable pleasure, so we all like this kind of self-lift.

But there are a lot of problems, because there are a lot of dependencies when it comes to bootstrap, so there are a lot of problems when you change the language.

It has a sequential, which part to change and then which part to change, it has a dependency, you can’t change it all at once, then it breaks.

Zhao Haiping: so how to say, programmer is more mischievous. (smile)

Zhang Hongbo: Yes, so generally speaking, to wait for the language development more mature later to carry out self-promotion.

It’s not a good development model if you start developing your own language before it’s very mature. Let me take Rust as an example. Rust was originally written in OCaml, and after many years, when Rust was relatively stable, it was considered to be kicked out with the OCaml compiler and replaced with Rust. If it had been self-lifting from the start, it would have been a lot of work.

Hindley Milner type system?

Li Yanlun: Someone asked if the two teachers could cite the relationship between Hindley Milner type system and actual business development.

Zhang Hongbo: HM system at that time Robin Miler put forward, he took the Turing award by this. It’s based on the lambda calculus, which initially has no type, untypedlambda calculates, and then on top of that, I need to add some types to constrain it, and then I get an HM type system. Its main purpose is to make type inference to this language. In the actual business is actually very few, mainly lies in the language development, I want to design a good type system will be used.

And now the new type system, it’s not even the original HM type system, because HM is slower. Now the new HM is based on the HM type system, but not the old one. There will be some acceleration methods, such as OCaml’s level-based acceleration based on layering, not quite the original HM type system.

How many Parser types are there?

Li Yanlun: Talking about the compiler, I want to know how many ways to write parser? What do you recommend for a common ready-made wheel? I’d like to invite two teachers to talk about Parser.

Zhang Hongbo: Parser mainly depends on your use, for example, I mainly write parser for this language, generally speaking, the industry is handwritten. Because I want to provide a good error message, and I only have to write it once and then I don’t have to write it again. I write a C++ parser and I don’t have to write it anymore, right? So because I’m thinking about making the error messages more friendly, they’re usually handwritten.

There are lots of Parser generators if you’re using them as tools. Tree Sitter, a popular open-source service on Github, has a degree of error notification after you’ve written the syntax, and it’s incremental. For example, if I change a few things in this editor, the generated syntax tree reuses the previous syntax tree, and it does not reparse everything. This is a parse generator that has become popular recently.

Things like old Parser, like ANTLR, a JVM-based Parse Generator.

Zhao Haiping: Yes, that ANTLR is really famous. So creating a new language isn’t that hard.

Compilation without producing an AST?

Li Yanlun, do you have a compilation method that does not generate AST?

In fact, many years ago, this was the norm, there was basically no AST, because memory was too precious at that time, or if you produce AST, it will consume a lot of memory, and the compilation speed is very slow. So none of the original compilers had AST. As you get better and better with computers, the memory hardware gets better and better, so there are different parses, you can keep the AST, and there are layers of AST, there are lower layers of AST, and then there are type checked AST, and then there are different IR. But the oldest compilers that started out didn’t have AST, and now almost all do. But if you need to be extremely concerned about compiler performance, you don’t need to build an AST either. As far as I know, things like QuickJS don’t seem to have it, because it wants to generate code in one go, so it compiles faster, in which case it doesn’t generate an AST.

Compiler optimization goals?

Li Yanlun: what is the main optimization target of the compiler?

Zhang Hongbo: I can say a few words briefly, but actually my main job is not to do the back end (compiler back end). In general, the compiler in its theory, is not an optimal compiler. So optimization can always be done for a lifetime, because there is no optimal one in theory. However, in the field of back-end (compiler back-end), as far as I know, there are not too many breaks through. The main practice in the industry now is to focus on a certain field, for example, AI is now more targeted at neural network, and then code generation, or GPU code generation. General-purpose compilers, as far as I know, don’t have much break through, don’t have a lot of room for innovation.

Hai-ping zhao: Yeah, that’s what I want to say, like a lot of people say why do we have a Go team at Byte, because if you get a compiler from the community, the optimization of it can be general, but if we look at these particular scenarios within our byte, Maybe it’s a different story.

Therefore, most of the time, we do some optimization, which is targeted optimization, the optimization method of the virus optimization in which special scenarios, which is more ideal, and give up the general optimization approach.

For the simplest example, inline, how big a function is inline? This is a very arbitrary Google developer at the heart of Go who may not be making the right decisions for your company.

So you can go to some parameters like tune, and if it happens to have the right parameter you might be lucky. There may be optimizations that he thinks are unimportant, or he may think are important, but in your case, it’s completely different.

We were talking yesterday about a key-value in a MapStructure, and when we hash the key, it has a randomization process, which is something that Go introduced in a later version, but in our opinion, This process is unnecessary. But the community thinks it’s necessary. So this is what I want to say, in some particular situations, there are some ideas and practices that are different.

Then our team has a task, still hope we can save some CPU, is by changing these optimization direction. So I think what Hongbo said just now is quite right, there is no absolute answer, or according to the scene.

Zhang Hongbo: In fact, I recently had an example where I was modifying a function that was using a generic function of the language, and it was slow, but you know the data source only had those possibilities, and you could get rid of a lot of branch logic that you didn’t need, and it was a very low-level function itself, but then we found out that it was 20% better, A very big impact is optimization for specific areas.

The advantages of the ReScript

Li Yanlun: We all know that Mr. Hongbo wrote a language called ReScript. Later, there will be live coding. Would you like to share the details of ReScript first?

Zhang Hongbo: Yes, language development has two veins, one is Algol family, like C, C++, C#, Java belong to Algol family. Another is functional programming, Lisp system, Lisp after ML, the first mainly used to do AI and theorem proof. OCaml was developed in France after ML. ReScript is an ML family of languages derived from OCaml. Compared with the traditional language, I think the biggest advantages of ReScript, it especially suitable for the two scenarios, one is data modeling, because it has the original algebraic data type (ADT), and support the native pattern matching, so you can define a complex type, and then do some pattern matching, data from a certain type into another format, It’s incredibly easy. That’s the first advantage. The second advantage is that it has type inference, so you basically don’t have to write any types, and the compiler can automatically infer all the types it needs. This is different from TypeScript because the TypeScript type system is not guaranteed to be correct. The TypeScript type system tells you roughly that it is the type, but it doesn’t strictly prove that it is the type. That way, the Typescript type system will be much easier to design, and you’ll be free to add fancy features. The ReScript type system is correct, the compiler tells you it’s this type, so it’s that type.

So to summarize, it has two advantages. One is that it’s very good for data modeling, you can easily convert data A into data B, and it has very good type inference, you don’t have to write any type, the compiler can deduce it for you.

Li Yanlun: Can you give an example in a real business scenario?

Zhang: ReScript is actually a standard TypeScript. If you can use TypeScript in your business, you can basically write ReScript in your business. The core of focus right now is that you can compile it into JavaScript so that you can use it for development, and because of the type system, it’s easy to do large-scale refactoring. So basically anywhere you can run JavaScript, you can run ReScript.

Li Yanlun: are there any examples of internal use in the industry?

Zhang hongbo: Facebook messager is written in ReScript. We also provide native React support, so whenever you develop React you can write it in ReScript. Another one is that I saw an online 3D editing engine written by a Chinese, which is also a cool thing. ReScript is perfect for large-scale development, where the benefits are greater if your code is up to ten thousand lines, for example, and the maintainability and quality improvements are huge. If your code is only a few hundred lines long, you probably don’t need such an Indirection layer.

Like that text editor, Tinymce, is probably the best text editor I know of. It has about 80,000 lines of ReScript code with real-time synchronization rewritten in ReScript.

Zhao Haiping: LET me ask you a question, you just said that the large-scale scene, do you think it is because of the strong type is helpful?

Zhang Hongbo: I think there are two points. One is that your type system is safe. If you have a lot of bugs in your type system, there will be a lot of problems if you refactor it.

Another is that the compiler has to be fast enough. If your compiler is slow, I’ll have to wait until I get back from a cup of coffee to see an error. (smile)

So one of ReScript’s great strengths is that our compilers are absolutely fast enough, both algorithmically and engineering.

Li Yanlun: Another question about ReScript is when will the Chinese document of ReScript be published?

Zhang hongbo: Because I am on maternity leave recently, because Facebook is still relatively good, there are still four months maternity leave. So the document should be published next year.

What does open source do?

Li Yanlun: I would like to ask you two teachers about open source and how to expand the open source community. Recently, the open source trend in China is also quite hot. I would like to hear your experience and experience.

Zhang Hongbo: Open source is a marketing problem, and we programmers are not good at it. Therefore, the first step is to overcome mental overhead, and strive to sell your stuff instead of writing your own code. The second thing is that you document your stuff well, because no matter how good your stuff is, people don’t understand it, and your code is just as good as documention.

Another thing I think, big V promotion is very useful. Why ReScript had some business users in the beginning, I think, was because we had some big V support. Like the guy who invented React, Jodan Walker, he was a huge fan of it at Facebook at the time, so he helped us promote it a lot. We also had two global user conferences in Vienna and a global user conference in Chicago, both of which were attended by large numbers of people. So big V’s support is important.

And then I’ll tell you a lesson, and it’s a profound lesson. Backward compatibility, maybe at the library level, but the language is probably more educational. Once you release a version of the language, any semantic changes you make will cause problems. So I particularly understand that PHP has a lot of bad stuff, but I don’t want to change it for backwards compatibility reasons. Of course, we programmers will have some cleanliness, a thing is not designed well at the beginning, always want to modify it. But once you modify it, it can cause many, many ripple effects. This is a profound experience for me.

Zhao Haiping: LET me talk about this from an abstract point of view. In fact, a common feature of programming languages and open source communities is that they are the product of collective wisdom. If you look at language today, do you think the role of its creator is important? Of course it was important, but as it grew in the community after the first version, it was actually the wisdom of the crowd, and people talked about it and talked about it and molded the language into this shape.

So this is a characteristic of The Times. In the era of 2021, nothing can be done alone. This is a big experience for me after RETURNING to China. In my opinion, the individual ability of engineers in China is not weak, even compared with those in Silicon Valley. However, in terms of group wisdom, when we build a thing together and build it very, very high in a group, it may not be our strength. We’re probably doing our bit more.

Therefore, the open source community is actually a sign that if you build something particularly well in an open source community, you can express its ability to build it, so that everyone can work together to accumulate and crystallize the wisdom of the group, and then continue to develop and grow.

Let the collective wisdom take on a life of its own, even if Hongbo is on maternity leave, but the community keeps pushing ReScript forward and it takes on a life of its own. So macrowaves may have bred ReScript, but ReScript, like a child, grows up on its own. I think this is particularly important.

So if you look at a lot of things in the United States, it’s the crystallization of the collective wisdom, if you look at Wall Street, the construction of the financial system over the years. Hollywood movie manufacturing, even Silicon Valley, so many companies make chips, isn’t that the wisdom of crowds? Many companies are involved in the pile-up of chip technology.

This is what we have to learn, we have to learn the wisdom of crowds, we have to learn tolerance and tolerance. Don’t start to find fault, more to see the advantages, more to see why, why others have such ideas.

Then we are very tolerant and happy to build something together. We can disagree, we can argue, but we’re going to pile this thing up and make it go higher and higher. So I think we can practice and train from the open source community, train our ability to build the wisdom of crowds.

Li Yanlun: When Teacher Haiping talked about this point, I was deeply touched. Our team has recently opened an open source product called Modern.js, and we hope you can join us to build and make this project better. I also hope that everyone can treat byte’s open source products or Ali’s open source products with more goodwill, and embrace open source products and actively build them together. In this way, our domestic open source community will be better and better.

Zhang Hongbo: It is true that open source requires many people. You can’t make it by one person, and it requires a lot of communication skills. So sometimes when we communicate, we do find that we need to improve our communication skills, and we do it together.

Type systems or programming language books recommended

Li Yanlun: Well, I’m looking forward to your participation in the open source project to show our group wisdom to overseas countries. We have excellent programmers and we want to let them know our strength.

The next question is, if I want to get started with type systems or if I want to develop a programming language, what books do you two teachers recommend?

Zhang Hongbo: There are not many approachable books about type systems. Because if you look at a type system book, it’s basically all Greek letters. There is one that I think I can recommend, Types and Programming Languages by Benjamin C. Pierce, which has an acronym called TAPL. It starts with the simplest lambda calculus, the type system. Then, from The perspective of Functional language, I think there is another book written very well, called The Functional Approach to Programming, which is especially suitable for programmers. The examples it gives are very interesting, and you can basically follow them to understand them. And it ends with an example of virtual machines, from learning the language at the beginning to implementing a type system, virtual machines. But this book, it’s older, it’s from the 70s and 80s, and it uses a very old syntax called Caml Light, but it’s also very easy to read. So I highly recommend it.

The last time I looked at Dedicated Programming language was when I was studying Complier at Princeton ML in New Jersey. But it is a good old book, belongs to the classic kind, is our textbook.

Zhang Hongbo: that book is also quite good actually, call tiger book is? But in fact the compiler so many years of development is not as fast as AI, in fact, the old book is still ok, or a good book (www.cs.princeton.edu/~appel/mode…) .

Skip live coding here

How does Transpiler balance speed and agility?

Li Yanlun: Time is limited today, so let’s stop here for teacher Hongbo’s live coding for now. Let’s just ask questions from the audience.

One question that came back to transpiler was how to balance conversion speed and plug-in ease of use for writing transpilers. AST or CST for data structure?

Zhang Hongbo: LET me expand briefly, because there are a lot of terms used. The AST is the abstract syntax tree, and the CST is the ConcretesynTax tree, which contains comments.

In general, if you’re doing an IDE or you’re doing codemod, like IF I’m converting one code to another, and I want to keep comments, I want to use CST. So again, it depends on your use case. If, like ReScript, you only need to produce other code and don’t need to worry about CommNet, the AST is a bit simpler and easier to generate.

If you need to codemod, rewrite some code, then you need to use CST. I would add that pasring is the first and easiest step for a compiler to generate a syntax tree, which takes very little time in the entire compiler pipeline. Generally speaking, you don’t have to worry too much about performance.

What’s the real time waster? Type checking, type inference, this can be square complexity, or even exponential complexity. Assembly code generation, register allocation is also very time consuming. The analytic part is basically linear, fast.

What mistakes are easy to make in language design?

Li Yanlun: We also talked about the historical burden of PHP before. Some of our online friends asked us what kind of design decisions are made during the design of a programming language, so that it may decide to break a certain feature or continue to develop with historical burden.

Zhao Haiping: This may be a lot of users to use, but may become your burden, a lot of code depends on you. If you have a lot of respect for the code, you might be afraid to change it, and that might cause someone’s code to have to be rewritten. But if it is a fundamental problem, it may be a long-term problem. I don’t think there really is a good answer, because this question can be absolutely case by case, and every language can have this kind of tricky moment at some point. So as I said, A lot of times it’s A choice between A and B, and in some cases it’s right, but in other cases it’s not as good as the other choice.

At this point, if you look at it from the point of view of swarm intelligence, if it’s a swarm intelligence, then he or she starts to struggle. Some people want to do this, some people want to do that, so there may be a game decision process. This is the history of language. It becomes part of its history. Macrobo do you have any good rules or principles to help you think?

Zhang Hongbo: This question is inevitable, because when one first starts to design a language, he can hardly think of so many questions. And then when users used it, it turned out that there was a design problem. When this thing comes out, it’s a difficult question whether you want to change it or not.

Like Rust, it took a long, long time to get to version 1.0. It was like 2015 or 2016. It had been in development for six or seven years before, and it wasn’t even called 1.0. Why is that? It just tells you that it can change the code at any time, so IF I manage your expectations, I can change it at any time, it’s better to give you (the language designer) a longer tolerance time. So I’ll probably open source and call it 0.1, 0.2, but I won’t call it 1.0, just tell users that it’s expected to change at any time, so it might be easier to communicate.

But once you get to 1.0, you might get attacked by a mob if you change it.

What about low code?

Li Yanlun: The next question is about the field of low code, which is very popular recently. What do you think of the endless low code solutions and the development direction of low code in the future?

Zhao Haiping: It’s interesting. Before, Microsoft had an idea that we could create a lot of components, and then other people could grab them and use them. I could configure components. Finally, there is a catalog with various components. The whole catalog is so complex and huge that searching and finding the components you want to use becomes a very complicated task.

I don’t know about low code, but if drag and drop you mean something like UML, if the problem you’re trying to solve is categories, there are only a few categories, then drag and drop can greatly improve efficiency. However, if you need to change the details of the drag object, it may not save you much in terms of the complexity of the problem. So maybe it won’t be a universal solution.

But in some cases, there’s no doubt that it does a lot of good, right? If you think about it, our entire Macintosh, Apple MacOS operation is essentially turning some of the most common commands into mouse-like drag-and-drop actions. But there will still be people who know a lot about Mac, and people who don’t know a lot about Mac. For those of you who don’t know much about macs, they know about these drags and drags, but they still get stuck when you run into complicated problems.

Therefore, THE future development of this direction, I think, may be to find a particularly suitable scene in some of their so-called niche or small or large fields, in their own proprietary field may be very useful.

What’s holding Haskell back from entering the industry?

Li Yanlun: Just now, we talked about Haskell. Someone asked, Haskell has many powerful programming paradigms, but it seems that haskell cannot be used even in some unexpected scenarios. I would like to ask you two teachers, what are the factors that hinder the use of Haskell in industry? Is it difficult to learn or poor documentation? Or other factors?

Zhang Hongbo: Haskell is definitely a combination of many factors. It is not caused by a single factor. Haskell has a lot of good things, but also a lot of problems. I think the biggest problem with Haskell is that you have to give something up when you let people use it. For example, if I want to use Haskell’s good type system, I can’t easily modify the data. So it’s not strictly better, you have to give something up in order to get a good, safe type system.

For example, when we learn data structures and algorithms as children, almost 80% of the time, we have to modify memory. So when you use Haskell, 50 percent, 80 percent of the stuff doesn’t work, you have to use a pure functional language, you can’t use that stuff anymore.

ReScript doesn’t have that problem, as I just showed you with Live coding, you can still copy it, you can still change it, you can still use the old stuff. But you can use something better instead of throwing everything away. Haskell is a pure thing, and you can’t use anything else after you use mine.

Zhao Haiping: I have a term for this phenomenon, which is highly contagious.

Zhang hongbo: Yes, you have to give up what you have learned.

Zhao Haiping: It is highly contagious. It needs to take over quickly. Everyone needs to change to functional style.

I used to work with a young guy who was a BIG fan of Haskell. He hated to write everything in Haskell. Then he said to me one day, let’s use Haskell to do our project. I said no problem, but on one condition, you need to change all parts into Haskell, I am OK. If not, only change the part you want to change, and then how to play with the rest. So this generalization is a huge problem.

It is contagious. On the other hand, it is difficult to learn. Its functional style still has a different idea.

Zhang hongbo: in fact, I think the learning difficulty is certainly some, but I think compared with C++, it is relatively easy. Maybe because I have been exposed to C++ since I was a child, I have learned C++ for so many years, so you think it is not difficult. However, you have not learned haskell very much, so you cannot say that it is harder than C++ in just one semester. I think if I learn C++ for the same period of time, maybe C++ is still more difficult.

Li Yanlun: I think in terms of language history, Haskell is kind of like the big brother behind it. I know a lot of languages have been influenced by it. Even after the introduction of hooks like React, the concept of functional programming gained momentum, and I think functional programming itself was influenced by Haskell. I think haskell is a very mysterious language for me, but it affects my work and life all the time.

Zhang Hongbo: Yes, because we are in the academic field, we are basically clustered on Haskell. Your doctoral thesis may be to add a feature and extension to Haskell. The academic world is basically doing research on Haskell. So it attracts a lot of people in this area. But if you really use it in industry, you have to have a lot of restrictions.

A programming language in the meta-universe?

Li Yanlun: Last question, I want to talk about the recent hot topics. Metaverse is so hot right now that Metaverse, even Hongbo’s current company and Haiping’s former company have changed their names to Meta. So what do you think will be the dominant programming language in the future metasomes?

Zhao Haiping: I don’t know if you’ve seen Roblox Company, but I think that’s where Mateverse started our conversation. If you ask me what the main programming language in Mateverse is, I think I can use it right away. It’s low code. Have you seen the programming in Roblox? It’s low code.

Zhang Hongbo: Really? I’ll have to try it when I get back.

Zhao Haiping: Yes, I don’t need very strong programming skill, but I can quickly build up a world with some logic in it. That’s definitely a good example of low code.

Zhang hongbo: How is that different from Minecraft?

Zhao Haiping: Very similar very similar.

A way out for domestic programming languages?

Li Yanlun: Another student pays attention to China and would like to ask the two teachers, what is the outlet of domestic programming language? In what domain are new programming languages likely to emerge?

Zhang hongbo: I think the first thing you need to do with a domestic programming language is to let go of the idea that you are a domestic language. It should be a language that does well and happens to be domestic. Not based on the fact that we are a native language and so on. It’s just that the language is so good, and it happens to be Chinese. Don’t be obsessed with what’s domestic.

And I feel that if a language is well done, it must be for the whole world. Rather than a user base with a single feature, it is based in China but global.

Zhao Haiping: Another point is that it must have emerged at the right moment. There is a scene that needs a language. As an example, when I was at Ali, they were working on quantum computers, so in order for me to program on quantum computers, I needed a language. See, that makes sense, right? If the quantum computer is a computing model developed by Alibaba, then the programming language is made in China. That doesn’t mean China created a programming language.

Zhang Hongbo: Yes, that’s right. If you look at the Hongmeng system, you need to program on it, so you naturally need a programming language, right? There is also a new version of WebGPU that does GPU manipulation, it requires a new Shading language, it also has a language called WGLS which is different from GLSL. So when you have a new platform, it’s natural to come out with a new language.

Li Yanlun: I really want to keep the dialogue going forever, but I don’t have enough time today. Thank you very much for your time. This is the end of today’s interview. And thank you very much to those of you who are watching.

Let me briefly introduce our activity, Web Infra Face to face: it is a technology sharing activity held by our Web Infra team and our friends in the nuggets community. Its origin is not that we have KPI/OKR requirements, but technology sharing within our Web Infra. Because some of the teachers we invited were very interesting, and some students outside the byte wanted to listen to it, so we wanted to develop it into students inside and outside the byte can listen to it. We will make a series, and we will invite the big shots in the industry to share each time.

When we were talking about the metasverse, the front end students would probably think of WebGL, and when we talk about WebGL, we would definitely think of three.js. So next time we’ll have Ricardo, author of Three.js, talk about WebGL.

You can follow ByteDanceWeb Infra’s public account, as well as the Gold Digging Technology community. Looking forward to our next meeting!