Lex Friedman 访谈 Chris Lattner - 中英双语

2024-08-26 约 118460 字 预计阅读 237 分钟

Lex Friedman 访谈 Chris Lattner - 中英双语

Information!

克里斯·拉特纳(英语:Chris Lattner,1978年—),美国著名程式设计师,LLVM专案的主要发起人与作者之一,Swift语言的创始人,并于2022年3月离开Swift核心团队,Clang编译器的作者。现为他共同创立的人工智能公司Modular AI的执行长。

Lex Fridman 对 Chris Lattner 的播客采访的 20 个要点总结:

关于 Mojo 语言

  1. Mojo 是 Python 的超集: Mojo 被设计成与 Python 完全兼容,允许程序员逐步采用 Mojo 的新功能,而无需重写现有的 Python 代码。

  2. AI 优先: Mojo 优先考虑 AI 应用的需求,但旨在成为一种通用的编程语言,适用于更广泛的领域。

  3. 性能提升: Mojo 的设计目标是实现大幅度的性能提升,最高可达 Python 的 35,000 倍,通过编译器优化、值语义、消除引用计数等手段。

  4. 类型系统: Mojo 拥有可选的渐进式类型系统,程序员可以自由选择使用或不使用类型。

  5. 元编程: Mojo 支持编译时元编程,允许程序员在编译时执行 Python 风格的元编程操作,提高效率和表现力。

  6. 自动调优: Mojo 提供自动调优功能,帮助程序员找到最佳的代码参数,以适应不同的硬件平台,提高性能。

  7. 内存管理: Mojo 采用值语义和所有权系统,有效地管理内存,减少 bug,并提高性能。

  8. 错误处理: Mojo 的错误处理机制与返回值机制类似,高效且适用于各种硬件平台。

  9. 并行化: Mojo 提供向量化和并行化工具,帮助程序员充分利用现代硬件的并行计算能力。

  10. 兼容性: Mojo 可以直接运行许多 Python 代码,并提供与 CPython 包和库的互操作性,方便程序员逐步迁移。

关于 Modular 公司

  1. Modular 致力于解决 AI 软件的复杂性: Modular 旨在通过构建新的软件栈来简化 AI 开发和部署,解决当前 AI 基础设施碎片化和复杂性问题。

  2. Modular 引擎: Modular 引擎可以提升 TensorFlow 和 PyTorch 的性能,并提供更好的可预测性和工具支持,无需程序员重写代码。

  3. 异构运行时: Modular 构建异构运行时,协调不同硬件设备的协同工作,例如 CPU、GPU 和各种 AI 加速器,提高效率。

关于 Python 和编程语言的未来

  1. Python 的粘性: Python 拥有庞大的生态系统、易用性、低启动时间和活跃的社区,这些都使其成为最流行的编程语言之一。

  2. 超越 Python: Mojo 的目标是继承 Python 的优点,并解决其性能和可移植性方面的不足,为 Python 程序员提供更强大的工具。

  3. 硬件多样性: AI 硬件的快速发展和多样化对软件开发带来了挑战,需要更加通用的编程模型和工具。

  4. AI 对编程的影响: LLM 的代码生成能力将改变编程方式,自动化许多机械化的任务,并帮助程序员更高效地工作。

  5. 编程的未来: 未来的编程将更加注重抽象和自动化,并需要能够适应日益复杂和异构的硬件环境。

Chris Lattner 的观点

  1. 以问题为导向: Chris 强调从实际问题和客户痛点出发,构建真正解决问题的产品和技术。

  2. 团队合作与文化: Chris 认为构建多元化、互补的团队,并营造良好的企业文化,对于公司的成功至关重要。

中英对照全文

Lex: It’s been, I think two years since we last talked.

Chris: Yep.

Lex: And then in that time you somehow went and co-created a new programming language called Mojo. So it’s optimized for AI. It’s a superset of Python. Let’s look at the big picture. What is the vision for Mojo?"

Lex: 我们上次谈话好像是两年前了。

Chris: 是的。

Lex: 在那段时间里,你竟然去共同创造了一种新的编程语言,叫做 Mojo。它是为人工智能优化的,是 Python 的超集。让我们来看看它的宏观愿景。Mojo 的愿景是什么?

Chris: For Mojo? Well, so I mean, I think you have to zoom out. So I’ve been working on a lot of related technologies for many, many years. So I’ve worked on LLVM and a lot of things in mobile and servers and things like this, but the world’s changing. And what’s happened with AI is we have new GPUs and new machine learning accelerators and other ASICs and things like that that make AI go real fast. At Google, I worked on TPUs. That’s one of the biggest, largest-scale deployed systems that exist for AI. And really what you see is, if you look across all of the things that are happening in the industry, there’s this new compute platform coming. And it’s not just about CPUs, or GPUs, or TPUs, or NPUs, or IPUs, or whatever, all the PUs, (chuckles) right? It’s about, how do we program these things, right? And so for software folks like us, right, it doesn’t do us any good if there’s this amazing hardware that we can’t use. And one of the things you find out really quick is that having the theoretical capability of programming something and then having the world’s power and the innovation of all the smart people in the world get unleashed on something can be quite different. And so really, where Mojo came from was starting from a problem of, we need to be able to take machine learning, take the infrastructure underneath it and make it way more accessible, way more usable, way more understandable by normal people and researchers and other folks that are not themselves like experts in GPUs and things like this. And then through that journey, we realized, “Hey, we need syntax for this. We need to do a programming language.” "

Chris: 对于 Mojo 来说?我认为你需要放眼全局。我多年来一直在研究许多相关技术,比如 LLVM,以及移动设备、服务器等领域,但世界正在发生变化。人工智能领域出现了新的 GPU、新的机器学习加速器、以及其他的 ASIC 等,这些都使得人工智能发展速度非常快。我在谷歌参与了 TPU 的研发,它是目前最大规模部署的人工智能系统之一。如果你观察整个行业正在发生的事情,你会发现一个新的计算平台正在兴起。它不仅仅是关于 CPU、GPU、TPU、NPU、IPU 等等,所有的处理器,对吧?(轻笑) 关键在于我们如何对这些东西进行编程,对吧?对于像我们这样的软件人员来说,如果拥有强大的硬件却无法使用,那将毫无意义。你会很快发现,理论上能够对某事物进行编程,与让全世界的力量和所有聪明人的创新能力都集中在某事物上,这两者之间存在着很大的差异。Mojo 的诞生正是源于这样的问题:我们需要将机器学习及其底层基础设施变得更容易被普通用户、研究人员和其他非 GPU 专家的人员所理解和使用。在这一过程中,我们意识到,我们需要为此设计语法,我们需要一种编程语言。

Lex: So one of the main features of the language, I say so fully in jest, is that it allows you to have the file extension to be an emoji or the fire emoji, which is one of the first emojis used as a file extension I’ve ever seen in my life. And then you ask yourself the question, why in the 21st century, we’re not using Unicode for file extensions? This, I mean, it’s an epic decision. I think, clearly, the most important decision you made the most, but you could also just use M-O-J-O as the file extension."

Lex: 我认为,这个语言的主要功能之一,我完全是在开玩笑,就是它允许你使用 emoji 作为文件扩展名,比如火焰 emoji,这是我见过的第一个用作文件扩展名的 emoji。然后你就会问自己,为什么在 21 世纪,我们不使用 Unicode 作为文件扩展名?我的意思是,这是一个史诗般的决定。我认为,显然,这是你做出的最重要的决定,但你也可以只使用 M-O-J-O 作为文件扩展名。

Chris: Well, so, okay. So take a step back. I mean, come on, Lex. You think that the world’s ready for this? This is a big moment in the world, right?

Lex: We’re releasing this onto the world. (chuckles)

Chris: This is innovation.

Lex: I mean, it really is kinda brilliant. Emojis are such a big part of our daily lives, why isn’t it not in programming?"

Chris: 好吧,好吧。那退一步说。我是说,拜托,Lex。你认为世界已经为这个做好了准备吗?这是一个伟大的时刻,对吧?

Lex: 我们正在向世界发布它。(轻笑)

Chris: 这是创新。

Lex: 我的意思是,这真的很聪明。emoji 是我们日常生活中如此重要的一部分,为什么它不在编程中出现呢?

Chris: Well, and like you take a step back and look at what file extensions are, right? They’re basically metadata, right? And so why are we spending all the screen space on them and all this stuff? Also, you know, you have them stacked up next to text files and PDF files and whatever else. Like, if you’re gonna do something cool, you want it to stand out, right? And emojis are colorful. They’re visual. They’re beautiful, right?"

Chris: 嗯,就像你退一步看看文件扩展名是什么,对吧?它们基本上是元数据,对吧?那么,为什么我们要在它们身上花费所有屏幕空间呢?而且,你知道,你把它们堆放在文本文件、PDF 文件等等旁边。就像,如果你要做一些很酷的事情,你希望它脱颖而出,对吧?emoji 是丰富多彩的,它们是可视化的,它们很漂亮,对吧?

Lex: Yeah. What’s been the response so far from… Is there support on like Windows, on operating systems…"

Lex: 是的。到目前为止,人们的反应如何?像 Windows 这样的操作系统是否支持它?…

Chris: Yeah, yeah. The one problem I’ve seen is that Git doesn’t escape it, right? And so it thinks that the fire emoji is unprintable. And so it, like, prints out weird hex things if you use the command line Git tool, but everything else, as far as I’m aware, works fine. And I have faith that Git can be improved. So I’m not worried."

Chris: 是的,是的。我遇到的一个问题是 Git 不转义它,对吧?所以它认为火焰 emoji 是不可打印的。所以,如果你使用命令行 Git 工具,它会打印出奇怪的十六进制字符,但据我所知,其他一切都正常。我相信 Git 可以改进,所以我不担心。

Lex: And so GitHub is fine.

Chris: GitHub is fine, yep. GitHub is fine. Visual Studio Code, Windows, like all this stuff, totally ready because people have internationalization in their normal…

Lex: Yeah.

Chris: …part of their paths. So let’s just, like, take the next step, right? Somewhere between, “Oh, wow, that makes sense. Cool, I like new things,” to “Oh my god, you’re killing my baby! Like, what are you talking about? This can never be. Like, I can never handle this! How am I gonna type this?” (imitates bees buzzing) …like, all these things. And so this is something where I think that the world will get there. We don’t have to bet the whole farm on this. I think we can provide both paths, but I think it’ll be great."

Lex: 所以 GitHub 也没问题。

Chris: GitHub 也没问题,是的。GitHub 也没问题。Visual Studio Code、Windows,所有这些东西,都完全准备好了,因为人们已经在他们的正常路径中使用了国际化…

Lex: 是的。

Chris: …作为他们路径的一部分。所以,让我们迈出下一步,对吧?从‘哇,这很有道理,我很喜欢新事物’,到‘天啊,你在扼杀我的孩子!你在说什么?这不可能实现。我永远无法接受!我怎么能输入这个?’(模仿蜜蜂嗡嗡声)……所有这些反应都有。所以我认为世界最终会接受它。我们不必孤注一掷,我认为我们可以提供两种选择,但我相信这将会很棒。

Lex: When can we have emojis as part of the code? I wonder.

Chris: Yeah. So I mean, lots of languages provide that. So I think that we have partial support for that. It’s probably not fully done yet, but yeah, you can do that. For example, in Swift, you can do that for sure. So an example we gave at Apple was the dog cow."

Lex: 我想知道,我们什么时候可以使用 emoji 作为代码的一部分?

Chris: 是的。我的意思是,很多语言都提供了这个功能。所以我认为我们已经部分支持了这个功能,可能还没有完全完成,但是,是的,你可以做到。例如,在 Swift 中,你肯定可以做到。我们在苹果公司给出的一个例子是狗牛。

Lex: Yeah.

Chris: So that’s a classical Mac heritage thing. And so you use the dog and the cow emoji together, and that could be your variable name, but of course, the internet went and made a pile of poop for everything.

Lex: Yeah.

Chris: So, you know, if you wanna name your function “pile of poop,” then you can totally go to town and see how that gets through code review. (Lex chuckling)"

Lex: 是的。

Chris: 所以这是一个经典的 Mac 传统。所以你可以把狗和牛的 emoji 放在一起,这可以作为你的变量名,但是当然,互联网上到处都是一堆便便。

Lex: 是的。

Chris: 所以,你知道,如果你想把你的函数命名为‘一堆便便’,那么你完全可以试试看它如何在代码审查中通过。(Lex 轻笑)

Lex: Okay. So let me just ask a bunch of random questions. So is Mojo primarily designed for AI, or is it a general-purpose programming…?"

Lex: 好的。让我问一些随机的问题。那么,Mojo 主要用于人工智能吗?还是一种通用的编程语言……?

Chris: Yeah, good question. So it’s AI first. And so AI is driving a lot of the requirements. And so, Modular is building and designing and driving Mojo forward. And it’s not because it’s an interesting project, theoretically, to build. It’s because we need it. And so at Modular, we’re really tackling the AI infrastructure landscape and the big problems in AI and the reasons that is so difficult to use and scale and adopt and deploy, and like, all these big problems in AI. And so, we’re coming at it from that perspective. Now, when you do that, when you start tackling these problems, you realize that the solution to these problems isn’t actually an AI-specific solution. And so, while we’re doing this, we’re building Mojo to be a fully general programming language. And that means that you can obviously tackle GPUs and CPUs and, like, these AI things, but it’s also a really great way to build NumPy and other things like that, or, you know, just if you look at what many Python libraries are today, often they’re a layer of Python for the API, and they end up being C and C++ code underneath them. That’s very true in AI. That’s true in lots of other domains as well. And so anytime you see this pattern, that’s an opportunity for Mojo to help simplify the world and help people have one thing."

Chris: 是的,好问题。它首先是面向人工智能的。人工智能驱动着很多需求,Modular 正在构建、设计并推动 Mojo 的发展。这并非因为它在理论上是一个有趣的项目,而是因为我们需要它。在 Modular,我们正在解决人工智能基础设施领域的问题,解决人工智能中存在的重大问题,解决它难以使用、扩展、采用和部署的原因,解决所有这些人工智能中存在的重大问题。我们正是从这个角度出发来解决问题的。当你开始着手解决这些问题时,你会意识到这些问题的解决方案实际上并不是专门针对人工智能的。因此,我们在构建 Mojo 时,目标是使其成为一种完全通用的编程语言。这意味着它显然可以处理 GPU、CPU 以及人工智能相关的事情,但它也是构建 NumPy 和其他类似库的一种非常好的方式,或者,你知道,如果你看看今天许多 Python 库的结构,它们通常是 Python API 的一层,而底层是 C 和 C++ 代码。这在人工智能领域非常普遍,在许多其他领域也是如此。所以,每当你看到这种模式,就是 Mojo 可以帮助简化世界,帮助人们用一种语言解决问题的机会。

Lex: So optimize through simplification by having one thing. So you mentioned Modular. Mojo is the programming language. Modular is the whole software stack."

Lex: 所以,通过使用一种语言来简化和优化。你提到了 Modular。Mojo 是编程语言,Modular 是整个软件栈。

Chris: So just over a year ago, we started this company called Modular.

Lex: Yeah.

Chris: Okay, what Modular’s about is, it’s about taking AI and up-leveling it into the next generation, right? And so if you take a step back, what’s gone on in the last five, six, seven, eight years is that we’ve had things like TensorFlow and PyTorch and these other systems come in. You’ve used them. You know this. And what’s happened is these things have grown like crazy, and they get tons of users. It’s in production deployment scenarios. It’s being used to power so many systems. I mean, AI’s all around us now. It used to be controversial years ago, but now it’s a thing. But the challenge with these systems is that they haven’t always been thought out with current demands in mind. And so, you think about it. Where were LLMs eight years ago? (chuckles) Well, they didn’t exist, right? AI has changed so much, and a lot of what people are doing today are very different than when these systems were built. And meanwhile, the hardware side of this has gone into a huge mess. There’s tons of new chips and accelerators, and every big company’s announcing a new chip every day, it feels like. And so between that, you have like moving systems on one side, moving systems on the other side, and it just turns into this gigantic mess, which makes it very difficult for people to actually use AI, particularly in production deployment scenarios. And so, what Modular’s doing is we’re helping build out that software stack to help solve some of those problems so then people can be more productive and get more AI research into production. Now, what Mojo does is it’s a really, really, really important piece of that. And so that is, you know, part of that engine and part of the technology that allows us to solve these problems."

Chris: 就在一年多前,我们创办了一家名为 Modular 的公司。

Lex: 是的。

Chris: Modular 的目标是将人工智能提升到下一代,对吧?如果你回顾过去五、六、七、八年,你会发现像 TensorFlow 和 PyTorch 这样的系统出现了。你用过它们,你知道这一点。这些系统发展得非常迅速,拥有大量的用户,被用于生产部署场景,为许多系统提供动力。我的意思是,人工智能现在无处不在。几年前它还存在争议,但现在它已经成为现实。但这些系统的挑战在于,它们在设计时并没有考虑到当前的需求。你想想,八年前大型语言模型在哪里?(轻笑) 它们根本不存在,对吧?人工智能已经发生了巨大的变化,今天人们所做的事情与这些系统创建时已经大不相同了。与此同时,硬件方面也变得一团糟。大量的新芯片和加速器涌现,感觉每天都有大公司发布新的芯片。一边是不断变化的系统,另一边也是不断变化的系统,最终变成了一团乱麻,这使得人们很难真正使用人工智能,尤其是在生产部署场景中。Modular 正在做的是帮助构建软件栈,以解决其中的一些问题,从而提高人们的生产力,并将更多的人工智能研究成果投入生产。Mojo 正是其中非常重要的一部分,它是推动我们解决这些问题的引擎和技术的一部分。

Lex: So Mojo is a programming language that allows you to do the higher-level programming, the low-level programming, like do all kinds of programming in that spectrum that gets you closer and closer to the hardware."

Lex: 所以 Mojo 是一种编程语言,它允许你进行高层编程和底层编程,让你可以在这个范围内进行各种编程,让你越来越接近硬件。

Chris: So take a step back. So, Lex, what do you love about Python?"

Chris: 退一步说。Lex,你喜欢 Python 的哪些方面?

Lex: Oh, boy. Where do I begin? What is love? What do I love about Python?

Chris: You’re a guy who knows love. I know this.

Lex: Yes. How intuitive it is, how it feels like I’m writing natural language English.

Chris: Yeah.

Lex: How, when I can not just write, but read other people’s code, somehow I can understand it faster. It’s more condensed than other languages, like ones I’m really familiar with, like C++ and C. There’s a bunch of sexy little features.

Chris: Yeah.

Lex: …we’ll probably talk about some of them, but list comprehensions and stuff like this.

Chris: Well, so Py… And don’t forget the entire ecosystem of all the packages.

Lex: Oh, yeah. There’s probably huge…

Chris: ‘Cause there’s always something. If you wanna do anything, there’s always a package.

Lex: Yeah, so it’s not just the ecosystem of the packages and the ecosystem of the humans that do it. That’s an interesting dynamic because I think…

Chris: That’s good. Yeah.

Lex: …something about the usability and the ecosystem makes the thing viral, it grows, and then it’s a virtuous cycle, I think.

Chris: Well, and there’s many things that went into that. Like, so I think that ML was very good for Python. And so, I think that TensorFlow and PyTorch and these systems embracing Python really took and helped Python grow, but I think that the major thing underlying it is that Python’s like the universal connector, right? It really helps bring together lots of different systems so you can compose them and build out larger systems without having to understand how it works. But then, what is the problem with Python? (chuckles)"

Lex: 哦,天哪,我该从哪里开始呢?什么是爱?我喜欢 Python 的什么?

Chris: 你是个懂爱的人,我知道。

Lex: 是的。我喜欢它的直观性,感觉就像在写自然语言英语一样。

Chris: 是的。

Lex: 不仅可以写,还可以读别人的代码,不知何故,我能更快地理解它。它比其他语言更简洁,比如我非常熟悉的 C++ 和 C。它有很多很棒的小功能。

Chris: 是的。

Lex: …我们可能会谈到其中的一些,比如列表推导式之类的。

Chris: 嗯,所以 Python……别忘了它拥有一个完整的软件包生态系统。

Lex: 哦,是的,那可能非常庞大……

Chris: 因为总有一些东西可以用。如果你想做任何事情,总有一个软件包可以帮助你。

Lex: 是的,所以这不仅仅是软件包的生态系统,还有使用它的人的生态系统。这是一个有趣的动态,因为我认为……

Chris: 那很好,是的。

Lex: …可用性和生态系统让它像病毒一样传播,它不断发展壮大,然后就形成了一个良性循环,我认为。

Chris: 嗯,有很多因素促成了这一点。我认为机器学习对 Python 非常有利。我认为 TensorFlow 和 PyTorch 这些系统拥抱 Python,确实推动了 Python 的发展,但我认为最重要的是 Python 就像一个万能连接器,对吧?它确实有助于将许多不同的系统整合在一起,这样你就可以组合它们,构建更大的系统,而无需理解其工作原理。但是,Python 的问题是什么?(轻笑)

Lex: Well, I guess you could say several things, but probably that it’s slow.

Chris: I think that’s usually what people complain about, right? And so, slow. I mean, other people would complain about tabs and spaces versus curly braces, or whatever, but I mean, those people are just wrong ‘cause it is…

Lex: Yeah.

Chris: …actually just better to use indentation."

Lex: 嗯,我想你可以说很多,但可能是它很慢。

Chris: 我认为这通常是人们抱怨的地方,对吧?所以,很慢。我的意思是,其他人会抱怨制表符和空格与花括号的问题,或者其他什么,但我的意思是,那些人只是错了,因为……

Lex: 是的。

Chris: …实际上,使用缩进更好。

Lex: Wow, strong words. (Chris laughing) So actually, I just went on a small tangent. Let’s actually take that. Let’s take all kinds of tangents.

Chris: Oh, come on, Lex. You can push me on it. I can take it.

Lex: Design, designed. Listen, I’ve recently left Emacs for VS Code.

Chris: Okay.

Lex: And the kinda hate mail I had to receive because on the way to doing that I also said, I’ve considered Vim…

Chris: Yep.

Lex: …and chose not to and went with VS Code, and just…

Chris: You’re touching on deep religions, right?

Lex: Anyway, tabs are an interesting design decision. And so you’ve really written a new programming language here.

Chris: Totally, yeah.

Lex: Yes, it is a superset of Python, but you can make a bunch of different interesting decisions here."

Lex: 哇,说得太狠了。(Chris 笑) 实际上,我刚刚跑题了。让我们继续跑题吧,让我们把各种各样的题外话都谈谈。

Chris: 哦,拜托,Lex。你可以逼我,我能承受。

Lex: 设计,设计。听着,我最近放弃了 Emacs,转而使用 VS Code。

Chris: 好的。

Lex: 我收到了各种仇恨邮件,因为在转用 VS Code 的过程中,我还说过我考虑过 Vim……

Chris: 是的。

Lex: …但最终没有选择它,而是选择了 VS Code,结果……

Chris: 你触及了深层的宗教信仰,对吧?

Lex: 不管怎样,制表符是一个有趣的设计决定。所以你在这里真的写了一种新的编程语言。

Chris: 完全正确,是的。

Lex: 是的,它是 Python 的超集,但你可以在这里做出很多不同的有趣决定。

Chris: Well, so let me explain why, right? So I mean, you can explain this in many rational ways. I think that indentation is beautiful, but that’s not a rational explanation, right, but I can defend it rationally, right? So first of all, Python has millions of programmers. It’s huge. It’s everywhere.

Lex: Yeah. It owns machine learning, right? And so, factually, it is the thing, right?

Chris: Second of all, if you look at it, C code, C++ code, Java, whatever, Swift, curly brace languages also run through formatting tools and get indented. And so if they’re not indented correctly, first of all, will twist your brain around. (chuckles) It can lead to bugs. There’s notorious bugs that have happened across time where the indentation was wrong or misleading, and it wasn’t formatted right, and so it turned into an issue, right? And so, what ends up happening in modern large-scale code bases is people run automatic formatters. So now what you end up with is indentation and curly braces. Well, if you’re gonna have, you know, the notion of grouping, why not have one thing, right, and get rid of all the clutter and have a more beautiful thing, right? Also, you look at many of these languages, it’s like, okay, well, you can have curly braces, or you can omit them if there’s one statement, or you just like enter this entire world of complicated design space that objectively you don’t need if you have Python-style indentation, so."

Chris: 嗯,让我解释一下原因,好吗?我的意思是,你可以用很多理性的方式来解释这一点。我认为缩进很美观,但这并不是一个理性的解释,对吧,但我可以用理性来辩护,对吧?首先,Python 有数百万的程序员,它非常庞大,无处不在。

Lex: 是的。它统治了机器学习领域,对吧?所以,事实上,它是王者,对吧?

Chris: 其次,如果你仔细观察,C 代码、C++ 代码、Java 代码,等等,Swift,这些使用花括号的语言也会通过格式化工具进行缩进。如果缩进不正确,首先,会让你头昏脑涨。(轻笑) 它可能会导致错误。历史上出现过一些臭名昭著的错误,就是因为缩进错误或误导,格式不正确,最终导致了问题,对吧?因此,在现代大型代码库中,人们最终会使用自动格式化工具。所以现在你最终得到了缩进和花括号。好吧,如果你要表达分组的概念,为什么不用一种方式呢,对吧?去掉所有的杂乱,让代码更美观,对吧?此外,你看看很多这些语言,就好像,好吧,你可以使用花括号,或者如果只有一条语句,你可以省略它们,或者你就进入了一个复杂的设计空间,而如果你使用 Python 风格的缩进,你客观上并不需要这个空间,所以。

Lex: Yeah, I would love to actually see statistics on errors made because of indentation. Like, how many errors are made in Python versus in C++ that have to do with basic formatting, all that kinda stuff? I would love to see."

Lex: 是的,我真的很想看看因为缩进而导致的错误统计数据。比如,在 Python 和 C++ 中,有多少错误是与基本格式相关的?我真的很想看看。

Chris: I think it’s probably pretty minor because once you get, like, you use VS Code, I do too. So if you get VS Code set up, it does the indentation for you, generally, right?

Lex: Yep.

Chris: And so you don’t, you know, it’s actually really nice to not have to fight it. And then what you can see is the editors telling you how your code will work by indenting it, which I think is pretty cool."

Chris: 我认为这可能很小,因为一旦你使用了 VS Code,就像你一样,我也用。所以,如果你设置好了 VS Code,它通常会为你自动缩进,对吧?

Lex: 是的。

Chris: 所以你不需要,你知道,实际上不必与它抗争,这真的很棒。然后你可以看到编辑器通过缩进告诉你代码是如何工作的,我认为这很酷。

Lex: I honestly don’t think I’ve ever… I don’t remember having an error in Python because I indented stuff wrong.

Chris: Yeah. So, I mean, I think that there’s, again, this is a religious thing. And so I can joke about it, and I love to kind of, you know, I realize that this is such a polarizing thing, and everybody wants to argue about it. And so I like poking at the bear a little bit, right? But frankly, right, come back to the first point, Python has… like, it’s huge."

Lex: 老实说,我不认为我曾经……我不记得在 Python 中因为缩进错误而导致过错误。

Chris: 是的。所以,我的意思是,我认为,这又是一个宗教信仰问题。所以我可以开个玩笑,我喜欢,你知道,我意识到这是一个两极分化的问题,每个人都想争论它。所以我喜欢稍微戳一下熊,对吧?但坦率地说,回到第一个观点,Python 有……它非常庞大。

Lex: Yeah.

Chris: It’s in AI. It’s the right thing. For us, like, we see Mojo as being an incredible part of the Python ecosystem. We’re not looking to break Python or change it, or quote-unquote, “fix it.” We love Python for what it is. Our view is that Python is just not done yet. And so if you look at, you know, you mentioned Python being slow. Well, there’s a couple of different things that go into that, which we can talk about if you want. But one of them is that it just doesn’t have those features that you would use to do C-like programming. And so if you say, okay, well, I’m forced out of Python into C, for certain use cases, well, then what we’re doing is we’re saying, “Okay, well, why is that? Can we just add those features that are missing from Python back up to Mojo?” And then you can have everything that’s great about Python, all the things that you’re talking about that you love, plus, not be forced out of it when you do something a little bit more computationally intense, or weird, or hardware-y, or whatever it is that you’re doing."

Lex: 是的。

Chris: 它在人工智能领域,它是正确的选择。对我们来说,我们认为 Mojo 是 Python 生态系统中一个不可思议的部分。我们不想破坏 Python,也不想改变它,或者说修复它。我们喜欢 Python 本来的样子。我们的观点是,Python 还没有完成它的使命。所以,如果你看看,你知道,你提到了 Python 很慢。嗯,这其中有很多不同的原因,如果你想谈的话,我们可以谈谈。但其中一个原因是,它没有那些你可以用来进行类似 C 语言编程的功能。所以,如果你说,好吧,我被迫在某些用例中放弃 Python,转而使用 C 语言,那么我们正在做的是,我们在说,好吧,为什么会出现这种情况?我们能不能把 Python 中缺少的那些功能添加到 Mojo 中去? 这样你就可以拥有 Python 的所有优点,所有你正在谈论的你喜欢的东西,而且,当你做一些计算量更大、更奇怪、更偏向硬件的事情,或者其他任何你正在做的事情时,你就不必被迫放弃 Python 了。

Lex: Well, a million questions I wanna ask, but high level again…

Chris: Yeah.

Lex: …is it compiled, or is it an interpreted language? So Python is just-in-time compilation. What’s Mojo?"

Lex: 嗯,我有一百万个问题想问,但再次回到高层次……

Chris: 是的。

Lex: …它是编译型语言,还是解释型语言?Python 是即时编译的。Mojo 是什么?

Chris: So Mojo, a complicated answer, does all the things. So it’s interpreted, it’s JIT compiled, and it’s statically compiled. (chuckles) And so this is for a variety of reasons. So one of the things that makes Python beautiful is that it’s very dynamic. And because it’s dynamic, one of the things they added is that it has this powerful metaprogramming feature. And so if you look at something like PyTorch or TensorFlow, or, I mean, even a simple use case, like, you define a class that has the plus method, right, you can overload the dunder methods, like dunder add, for example, and then the plus method works on your class. And so it has very nice and very expressive dynamic metaprogramming features. In Mojo, we want all those features to come in. Like, we don’t wanna break Python, we want it all to work. But the problem is, is you can’t run those super dynamic features on an embedded processor, or on a GPU, right? Or if you could, you probably don’t want to just because of the performance. And so, we entered this question of saying, okay, how do you get the power of this dynamic metaprogramming into a language that has to be super efficient in specific cases? And so, what we did was we said, okay, well, take that interpreter. Python has an interpreter in it, right? Take that interpreter and allow it to run at compile time. And so now what you get is you get compiled-time metaprogramming. And so this is super interesting, super powerful, because one of the big advantages you get is you get Python-style expressive APIs, you get the ability to have overloaded operators. And if you look at what happens inside of, like, PyTorch, for example, with automatic differentiation and eager mode and, like, all these things, they’re using these really dynamic and powerful features at runtime, but we can take those features and lift them so that they run at compile time."

Chris: 对于 Mojo,一个复杂的答案是,它可以做所有的事情。所以它是解释型的,也是即时编译的,同时也是静态编译的。(轻笑) 这有很多原因。Python 之所以美妙,是因为它非常动态。因为它很动态,所以他们添加的一个功能就是它拥有强大的元编程功能。所以,如果你看看 PyTorch 或 TensorFlow 这样的东西,或者,我的意思是,即使是一个简单的用例,比如,你定义一个类,它有加法方法,对吧?你可以重载双下划线方法,比如双下划线加法,然后加法方法就可以在你的类上工作了。所以它有非常好的,非常有表现力的动态元编程功能。在 Mojo 中,我们希望所有这些功能都能得到保留。我们不想破坏 Python,我们希望它所有的功能都能正常工作。但问题是,你不能在嵌入式处理器或 GPU 上运行这些超级动态的功能,对吧?或者,即使可以,你可能也不想这样做,因为性能的原因。所以,我们提出了这样一个问题:好吧,如何将这种动态元编程的力量融入到一种在特定情况下必须超级高效的语言中?所以,我们所做的是,我们说,好吧,那就使用解释器。Python 中有一个解释器,对吧?使用解释器,并允许它在编译时运行。所以现在你得到的是编译时元编程。这非常有趣,非常强大,因为它的一大优势是,你可以获得 Python 风格的表现力 API,你可以获得重载运算符的能力。如果你看看 PyTorch 内部发生了什么,例如,自动微分、立即执行模式以及所有这些东西,它们在运行时使用了这些非常动态和强大的功能,但我们可以将这些功能提升到编译时运行。

Lex: ‘Cause C++ has metaprogramming with templates.

Chris: Yep.

Lex: But it’s really messy."

Lex: 因为 C++ 有使用模板的元编程。

Chris: 是的。

Lex: 但它真的很混乱。

Chris: It’s super messy. It was accidentally, I mean, different people have different interpretations. My interpretation is that it was made accidentally powerful. It was not designed to be Turing-complete, for example, but that was discovered kind of along the way, accidentally. And so, there have been a number of languages in the space. And so they usually have templates or code instantiation, code-copying features of various sorts. Some more modern languages or some newer languages, let’s say, like, you know, they’re fairly unknown. Like Zig, for example, says, okay, well, let’s take all of those types you can run it, all those things you can do at runtime and allow them to happen at compile time. And so one of the problems with C++, I mean, which is one of the problems with C++ is…"

Chris: 它非常混乱。它是偶然的,我的意思是,不同的人有不同的解释。我的解释是,它是偶然变得强大的。例如,它最初并不是为了图灵完备而设计的,但这只是在开发过程中偶然发现的。所以,在这个领域已经出现了一些语言。它们通常有模板或代码实例化,各种各样的代码复制功能。一些更现代的语言,或者说一些更新的语言,它们还不太为人所知。例如,Zig 语言,它说,好吧,让我们把所有这些类型,所有你可以在运行时做的事情,都放到编译时去做。所以 C++ 的一个问题,我的意思是,C++ 的一个问题是…

Lex: There we go. Strong words. We’re gonna offend everybody today.

Chris: Oh, that’s okay. I mean, everybody hates me for a variety of reasons anyway, I’m sure, right? (chuckles) I’ve written up…

Lex: That’s the way they show love, is to hurt you.

Chris: I have written enough C++ code to earn a little bit of grumpiness with C++, but one of the problems with it is that the metaprogramming system templates is just a completely different universe from the normal runtime programming world. And so if you do metaprogramming and programming, it’s just like a different universe, different syntax, different concepts, different stuff going on. And so, again, one of our goals with Mojo is to make things really easy to use, easy to learn, and so there’s a natural stepping stone. And so as you do this, you say, okay, well, I have to do programming at runtime, I have to do programming at compile time. Why are these different things?"

Lex: 来了,来了。措辞犀利。今天我们要得罪所有人了。

Chris: 哦,没关系。我的意思是,我相信,无论如何,每个人都因为各种原因讨厌我,对吧?(轻笑) 我写过……

Lex: 这就是他们表达爱的方式,就是伤害你。

Chris: 我写过足够多的 C++ 代码,足以让我对 C++ 有些怨言,但它的一个问题是,元编程系统模板与普通的运行时编程世界完全不同。所以,如果你同时进行元编程和编程,就像是在两个不同的世界里,不同的语法,不同的概念,不同的事情在发生。所以,我们的目标之一就是让 Mojo 非常易于使用,易于学习,所以这是一个自然的垫脚石。所以,当你这样做的时候,你会说,好吧,我必须在运行时进行编程,我必须在编译时进行编程。为什么这两者是不同的呢?

Lex: How hard is that to pull it off? ‘Cause that sounds, to me, as a fan of metaprogramming, and C++ even, how hard is it to pull that off? That sounds really, really exciting. ‘Cause you can do the same style programming at compile time and at runtime. That’s really, really exciting.

Chris: Yep, yep. And so, I mean, in terms of the compiler implementation details, it’s hard. I won’t be shy about that. It’s super hard. It requires, I mean, what Mojo has underneath the covers is a completely new approach to the design of the compiler itself. And so this builds on these technologies like MLIR that you mentioned. That also includes other, like, caching and other interpreters and JIT compilers and other stuff like that…"

Lex: 这有多难实现?因为在我看来,作为一个元编程的爱好者,甚至是 C++ 的爱好者,这听起来非常非常令人兴奋。因为你可以在编译时和运行时使用相同的编程风格。这真的非常非常令人兴奋。

Chris: 是的,是的。所以,我的意思是,就编译器实现细节而言,这很难。我不会回避这一点,它超级难。它需要,我的意思是,Mojo 的底层是一个全新的编译器设计方法。它建立在你提到的 MLIR 等技术之上,还包括其他一些东西,比如缓存、其他解释器、即时编译器等等……

Lex: So you have like an interpreter inside the…

Chris: Within the compiler, yes.

Lex: Oh, man.

Chris: And so it really takes the standard model of programming languages and kind of twists it and unifies it with the runtime model, which I think is really cool."

Lex: 所以你就像在编译器里有一个解释器……

Chris: 在编译器内部,是的。

Lex: 哦,天哪。

Chris: 所以它真的采用了编程语言的标准模型,并对其进行了扭曲,将其与运行时模型统一起来,我认为这真的很酷。

Lex: Right.

Chris: And to me, the value of that is that, again, many of these languages have metaprogramming features. Like they grow macros or something, right? Lisp, right?

Lex: Yes.

Chris: I know your roots, right? (Lex chuckling) You know, and this is a powerful thing, right? And so, you know, if you go back to Lisp, one of the most powerful things about it is that it said that the metaprogramming and the programming are the same, right? And so, that made it way simpler, way more consistent, way easier to understand, reason about, and it made it more composable. So if you build a library, you can use it both at runtime and compile time, which is pretty cool."

Lex: 对。

Chris: 对我来说,它的价值在于,很多语言都有元编程功能。比如它们会发展出宏或者其他什么东西,对吧?Lisp,对吧?

Lex: 是的。

Chris: 我知道你的根源,对吧?(Lex 轻笑) 你知道,这是一件很强大的事情,对吧?所以,你知道,如果你回到 Lisp,它最强大的地方之一就是它说元编程和编程是一样的,对吧?所以,这使得它更简单,更一致,更容易理解,更容易推理,而且它更具可组合性。所以,如果你构建一个库,你可以在运行时和编译时都使用它,这很酷。

Lex: Yeah. And for machine learning, I think metaprogramming, I think we could generally say, is extremely useful. And so you get features, I mean, I’ll jump around, but the feature of auto-tuning and adaptive compilation just blows my mind."

Lex: 是的。对于机器学习来说,我认为元编程,我认为我们可以说,是非常有用的。所以你得到了很多功能,我的意思是,我会跳来跳去,但自动调优和自适应编译的功能让我大吃一惊。

Chris: Yeah. Well, so okay. So let’s come back to that.

Lex: All right.

Chris: So what is machine learning, like what, or what is a machine learning model? Like, you take a PyTorch model off the internet, right?"

Chris: 是的,好吧,好吧。让我们回到这个问题上来。

Lex: 好的。

Chris: 那么,什么是机器学习?或者说,什么是机器学习模型?比如,你从网上下载了一个 PyTorch 模型,对吧?

Lex: Yeah.

Chris: It’s really interesting to me because what PyTorch and what TensorFlow and all these frameworks are kinda pushing compute into is they’re pushing into, like, this abstract specification of a compute problem, which then gets mapped in a whole bunch of different ways, right? And so, this is why it became a metaprogramming problem, is that you wanna be able to say, cool, I have this neural net. Now run it with batch size a thousand, right? Do a mapping across batch. Or, okay, I wanna take this problem. Now run it across a thousand CPUs or GPUs, right? And so, like, this problem of like, describe the compute, and then map it and do things and transform it, or like, actually, it’s very profound. And that’s one of the things that makes machine learning systems really special."

Lex: 是的。

Chris: 这对我来说很有趣,因为 PyTorch 和 TensorFlow 以及所有这些框架都在推动计算,它们正在推动对计算问题的抽象规范,然后以各种不同的方式进行映射,对吧?所以,这就是为什么它变成了一个元编程问题,因为你想要能够说,酷,我有这个神经网络,现在用一千个批次的大小运行它,对吧?做一个跨批次的映射,或者,好吧,我想解决这个问题,现在在一千个 CPU 或 GPU 上运行它,对吧?所以,就像,描述计算,然后映射它,做一些事情,转换它,或者,实际上,这是非常深刻的,这就是让机器学习系统真正特别的原因之一。

Lex: Maybe can you describe auto-tuning, and how do you pull off, I mean, I guess adaptive compilation is what we’re talking about is metaprogramming. How do you pull off…

Chris: Yes.

Lex: …auto-tuning? I mean, is that as profound as I think it is? It just seems like a really, like, you know, we’ll mention list comprehensions. To me, from a quick glance of Mojo, which by the way, I have to absolutely, like, dive in, as I realize how amazing this is, I absolutely must dive in it, that looks like just an incredible feature for machine learning people."

Lex: 也许你能描述一下自动调优,以及你是如何实现的,我的意思是,我想自适应编译就是我们所说的元编程。你是如何实现……

Chris: 是的。

Lex: …自动调优的?我的意思是,它有我想象的那么深刻吗?它看起来真的很像,你知道,我们会提到列表推导式,对我来说,从快速浏览 Mojo 来看,顺便说一下,我必须绝对地,像,深入研究,当我意识到这有多棒的时候,我绝对必须深入研究它,这看起来对机器学习的人来说是一个不可思议的功能。

Chris: Yeah. Well, so what is auto-tuning? So take a step back. Auto-tuning is a feature in Mojo. So very little of what we’re doing is actually research. Like, many of these ideas have existed in other systems and other places. And so, what we’re doing is we’re pulling together good ideas, remixing them, and making them into a, hopefully, a beautiful system, right? And so auto-tuning, the observation is that turns out, hardware system’s algorithms are really complicated. Turns out maybe you don’t actually want to know how the hardware works, (chuckles) right? A lot of people don’t, right? And so there are lots of really smart hardware people, I know a lot of them, where they know everything about, “Okay, the cache size is this and the number of registers is that. And if you use this what length of vector, it’s gonna be super efficient because it maps directly onto what it can do” and, like, all this kinda stuff, or, “the GPU has SMs, and it has a warp size of,” whatever, right, all this stuff that goes into these things, or, “the tile size of a TPU is 128,” like, these factoids, right? My belief is that most normal people, and I love hardware people, also I’m not trying to offend literally everybody on the internet, but most programmers actually don’t wanna know this stuff, right? And so, if you come at it from the perspective of, how do we allow people to build both more abstracted but also more portable code because, you know, it could be that the vector length changes, or the cache size changes, or it could be that the tile size of your matrix changes, or the number, you know, an A100 versus an H100 versus a Volta versus a, whatever, GPU have different characteristics, right? A lot of the algorithms that you run are actually the same, but the parameters, these magic numbers you have to fill in, end up being really fiddly numbers that an expert has to go figure out. And so what auto-tuning does is says, okay, well, guess what? There’s a lot of compute out there, right? So, instead of having humans go randomly try all the things or do a grid search or go search some complicated multi-dimensional space, how about we have computers do that, right? And so, what auto-tuning does is you can say, “Hey, here’s my algorithm.” If it’s a matrix operation, or something like that, you can say, “Okay, I’m gonna carve it up into blocks. I’m gonna do those blocks in parallel, and I wanna this, with 128 things that I’m running on, I wanna cut it this way or that way or whatever.” And you can say, “Hey, go see which one’s actually empirically better on the system.” "

Chris: 是的。什么是自动调优?让我们退一步说。自动调优是 Mojo 中的一个功能。我们所做的实际上很少是研究。这些想法中的很多都存在于其他系统和其他地方。所以,我们所做的是将好的想法汇集在一起,重新组合,并使之成为一个,希望是一个美丽的系统,对吧?所以自动调优,观察结果是,硬件系统的算法真的很复杂。结果可能是你实际上并不想知道硬件是如何工作的,(轻笑) 对吧?很多人都不想知道,对吧?所以有很多非常聪明的硬件人员,我认识很多这样的人,他们知道所有关于,好吧,缓存大小是多少,寄存器数量是多少,如果你使用这个长度的向量,它会超级高效,因为它直接映射到它能做的事情等等,或者,GPU 有 SM,它有一个 warp 大小为,无论什么,对吧,所有这些东西都进入这些东西,或者,TPU 的 tile 大小是 128,像这样的事实,对吧?我的信念是,大多数正常人,我爱硬件人员,我也不是想冒犯互联网上的每一个人,但大多数程序员实际上并不想知道这些东西,对吧?所以,如果你从这个角度来看,我们如何允许人们构建更抽象但更可移植的代码,因为,你知道,可能是向量长度改变了,或者缓存大小改变了,或者可能是你的矩阵的 tile 大小改变了,或者数量,你知道,A100 与 H100 与 Volta 与,无论什么,GPU 有不同的特性,对吧?你运行的很多算法实际上是相同的,但参数,这些你必须填写的魔法数字,最终变成了一个专家必须去弄清楚的非常繁琐的数字。所以自动调优所做的是说,好吧,猜猜看?那里有很多计算,对吧?所以,与其让人类随机地尝试所有的事情,或者做一个网格搜索,或者去搜索一些复杂的多维空间,不如让计算机来做,对吧?所以,自动调优所做的是你可以说,嘿,这是我的算法。 如果它是一个矩阵运算,或者类似的东西,你可以说,好吧,我要把它分割成块,我要并行地做这些块,我想要这个,我运行的 128 个东西,我想这样或那样或无论如何切割它。 你可以说,嘿,去看看哪一个在系统上实际上经验上更好。

Lex: And then the result of that you cache for that system. You save it.

Chris: Yep. And so, come back to twisting your compiler brain, right? So not only does the compiler have an interpreter that’s used to do metaprogramming, that compiler, that interpreter, that metaprogramming now has to actually take your code and go run it on a target machine, (chuckles) see which one it likes the best, and then stitch it in and then keep going, right?"

Lex: 然后你把结果缓存到那个系统中。你保存它。

Chris: 是的。所以,回到扭曲你的编译器大脑,对吧?所以编译器不仅有一个用来做元编程的解释器,那个编译器,那个解释器,那个元编程现在必须实际地获取你的代码,并在目标机器上运行它,(轻笑) 看看它最喜欢哪一个,然后把它缝合进去,然后继续,对吧?

Lex: So part of the compilation is machine-specific.

Chris: Yeah. Well, so I mean, this is an optional feature, right? So you don’t have to use it for everything, but yeah. So one of the things that we’re in the quest of is ultimate performance, right?"

Lex: 所以编译的一部分是特定于机器的。

Chris: 是的。我的意思是,这是一个可选的功能,对吧?所以你不必把它用于所有事情,但是,是的。所以我们追求的事情之一是终极性能,对吧?

Lex: Yes.

Chris: Ultimate performance is important for a couple of reasons, right? So if you’re an enterprise, you’re looking to save costs and compute and things like this. Ultimate performance translates to, you know, fewer servers. Like if you care about the environment, hey, better performance leads to more efficiency, right? I mean, you could joke and say, like, you know, Python’s bad for the environment, (chuckles) right? And so if you move to Mojo, it’s like, at least 10x better just outta the box, and then keep going, right?"

Lex: 是的。

Chris: 终极性能很重要,有几个原因,对吧?所以,如果你是企业,你希望节省成本和计算量等等。终极性能意味着,你知道,更少的服务器。就像,如果你关心环境,嘿,更好的性能会导致更高的效率,对吧?我的意思是,你可以开玩笑地说,你知道,Python 对环境有害,(轻笑) 对吧?所以,如果你迁移到 Mojo,它就像,至少开箱即用就比以前好 10 倍,然后继续,对吧?

Lex: Yeah.

Chris: But performance is also interesting ‘cause it leads to better products.

Lex: Yeah.

Chris: And so in the space of machine learning, right, if you reduce the latency of a model so that it runs faster, so every time you query the server running the model it takes less time, well, then the product team can go and make the model bigger. Well, that’s actually makes it so you have a better experience as a customer. And so a lot of people care about that."

Lex: 是的。

Chris: 但性能也很有趣,因为它会导致更好的产品。

Lex: 是的。

Chris: 所以在机器学习领域,对吧,如果你减少模型的延迟,让它运行得更快,所以每次你查询运行模型的服务器,它需要的时间更少,那么产品团队就可以去让模型更大。好吧,这实际上让你作为一个客户有更好的体验。所以很多人关心这个。

Lex: So for auto-tuning, for like tile size, you mentioned 128 for TPU, you would specify like a bunch of options to try, just in the code…

Chris: Yeah. Yep.

Lex: …just simple statement, and then you could just…

Chris: Yep.

Lex: …set and forget and know, depending wherever it compiles, it’ll actually be the fastest.

Chris: And, yeah, exactly. And the beauty of this is that it helps you in a whole bunch of different ways, right? So if you’re building… So often what’ll happen is that, you know, you’ve written a bunch of software yourself, right? You wake up one day, you say, “I have an idea. I’m gonna go code up some code.” I get to work, I forget about it, I move on with life. I come back six months, or a year, or two years, or three years later, you dust it off, and you go use it again in a new environment. And maybe your GPU is different. Maybe you’re running on a server instead of a laptop. Maybe you’re, whatever, right? And so, the problem now is you say, okay, well, I mean, again, not everybody cares about performance, but if you do, you say, okay, well, I wanna take advantage of all these new features. I don’t wanna break the old thing though, right? And so the typical way of handling this kinda stuff before is, you know, if you’re talking about C++ templates, or you’re talking about C with macros, you end up with #ifdefs. You get like all these weird things that get layered in, make the code super complicated, and then, how do you test it, right? Becomes this crazy complexity, multi-dimensional space that you have to worry about. And, you know, that just doesn’t scale very well."

Lex: 所以对于自动调优,比如 tile 大小,你提到了 TPU 的 128,你会指定一堆选项来尝试,就在代码中……

Chris: 是的,是的。

Lex: …只是一句简单的声明,然后你就可以……

Chris: 是的。

Lex: …设置好然后忘记它,知道无论它在哪里编译,它实际上都会是最快的。

Chris: 是的,没错。它的美妙之处在于,它以各种不同的方式帮助你,对吧?所以如果你正在构建……经常发生的情况是,你知道,你自己写了一堆软件,对吧?有一天你醒来,你说,我有一个想法,我要去编写一些代码。 我开始工作,我忘记了它,我继续生活。六个月后,或者一年后,或者两年后,或者三年后,你把它掸掉灰尘,你再去一个新的环境中使用它。也许你的 GPU 不同了,也许你在服务器上运行而不是笔记本电脑上,也许你,无论什么,对吧?所以,现在的问题是,你说,好吧,我的意思是,再说一遍,不是每个人都关心性能,但如果你关心,你说,好吧,我想利用所有这些新功能,但我不想破坏旧的东西,对吧?所以以前处理这类事情的典型方法是,你知道,如果你说的是 C++ 模板,或者你说的是带有宏的 C,你最终会得到 #ifdefs,你会得到所有这些奇怪的东西,它们被分层,使代码超级复杂,然后,你如何测试它,对吧?变成了这种疯狂的复杂性,多维空间,你必须担心,你知道,这不能很好地扩展。

Lex: Actually, lemme just jump around, before I go to some specific features, like the increase in performance here that we’re talking about can be just insane.

Chris: Yeah.

Lex: You write that Mojo can provide a 35,000x speed up over Python. How does it do that?"

Lex: 实际上,让我跳来跳去,在我去一些特定的功能之前,比如我们在这里谈论的性能提升可以是疯狂的。

Chris: 是的。

Lex: 你写道,Mojo 可以提供比 Python 快 35000 倍的速度。它是如何做到的?

Chris: Yeah, so I can even do more, but we’ll get to that. So first of all, when we say that, we’re talking about what’s called CPython. It’s the default Python that everybody uses. When you type Python 3, that’s like typically the one you use, right? CPython is an interpreter. And so interpreters, they have an extra layer of, like, byte codes and things like this that they have to go read, parse, interpret, and it makes them kind of slow from that perspective. And so, one of the first things we do is we moved to a compiler. And so just moving to a compiler, getting the interpreter out of the loop, is 2 to 5 to 10x speed up, depending on the code. So just out of the gate, it’s using more modern techniques, right? Now, if you do that, one of the things you can do is you can start to look at how CPython started to lay out data. And so, one of the things that CPython did, and this isn’t part of the Python spec necessarily, but this is just sets of decisions, is that if you take an integer, for example, it’ll put it in an object, ‘cause in Python, everything’s an object. And so they do the very logical thing of keeping the memory representation of all objects the same. So all objects have a header, they have like payload data. And what this means is that every time you pass around an object, you’re passing around a pointer to the data. Well, this has overhead, right? Turns out that modern computers don’t like chasing pointers very much and things like this. It means that you have to allocate the data. It means you have to reference count it, which is another way that Python uses to keep track of memory. And so, this has a lot of overhead. And so if you say, okay, let’s try to get that out of the heap, out of a box, out of an indirection and into the registers, that’s another 10x, more."

Chris: 是的,我甚至可以做得更多,但我们稍后再谈。首先,当我们说这句话的时候,我们说的是 CPython。这是每个人都在使用的默认 Python。当你输入 Python 3 的时候,这通常是你使用的版本,对吧?CPython 是一个解释器。所以解释器,它们有一个额外的层,比如字节码和类似的东西,它们必须去读取、解析、解释,这使得它们从这个角度来看有点慢。所以,我们做的第一件事就是迁移到编译器。所以,仅仅是迁移到编译器,让解释器退出循环,就可以根据代码的不同,获得 2 到 5 到 10 倍的速度提升。所以,一开始,它就使用了更现代的技术,对吧?现在,如果你这样做,你可以做的一件事就是开始观察 CPython 是如何开始布局数据的。所以,CPython 做的一件事,这不是 Python 规范的一部分,但这只是一组决定,就是,例如,如果你取一个整数,它会把它放在一个对象中,因为在 Python 中,一切都是对象。所以,他们做了一件非常合乎逻辑的事情,就是保持所有对象的内存表示相同。所以,所有对象都有一个头部,它们有像有效载荷数据一样的东西。这意味着,每次你传递一个对象的时候,你都在传递一个指向数据的指针。好吧,这有开销,对吧?事实证明,现代计算机不喜欢追逐指针之类的东西。这意味着,你必须分配数据。这意味着,你必须引用计数它,这是 Python 用来跟踪内存的另一种方法。所以,这有很多开销。所以,如果你说,好吧,让我们试着把它从堆中取出,从一个盒子中取出,从一个间接寻址中取出,放到寄存器中,那就是另一个 10 倍,更多。

Lex: So it adds up. If you’re reference counting every single…

Chris: Absolutely.

Lex: …every single thing you create, that adds up.

Chris: Yep. And if you look at, you know, people complain about the Python GIL, this is one of the things that hurts parallelism. That’s because the reference counting, right? And so the GIL and reference counting are very tightly intertwined in Python. It’s not the only thing, but it’s very tightly intertwined. And so then you lean into this and you say, okay, cool. Well, modern computers, they can do more than one operation at a time. And so they have vectors. What is a vector? Well, a vector allows you to, instead of taking one piece of data, doing an add or multiply and then pick up the next one, you can now do a 4, 8, or 16 or 32 at a time, right? Well, Python doesn’t expose that because of reasons. And so now you can say, okay, well, you can adopt that. Now you have threads. Now you have like additional things, like you can control memory hierarchy. And so, what Mojo allows you to do is it allows you to start taking advantage of all these powerful things that have been built into the hardware over time. The library gives very nice features. So you can say, just parallelize this. Do this in parallel, right? So it’s very, very powerful weapons against slowness, which is why people have been, I think, having fun, like, just taking code and making go fast because it’s just kind of an adrenaline rush to see like how fast you can get things."

Lex: 所以加起来了。如果你对每一个……

Chris: 绝对的。

Lex: …你创建的每一个东西都进行引用计数,那就加起来了。

Chris: 是的。如果你看看,你知道,人们抱怨 Python GIL,这是损害并行性的事情之一。那是因为引用计数,对吧?所以 GIL 和引用计数在 Python 中紧密地交织在一起。这不是唯一的事情,但它们紧密地交织在一起。所以,然后你倾向于这一点,你说,好吧,酷。现代计算机,它们可以一次执行多个操作。所以,它们有向量。什么是向量?好吧,向量允许你,而不是取一个数据,做一个加法或乘法,然后取下一个,你现在可以一次做 4 个,8 个,或者 16 个或 32 个,对吧?好吧,Python 由于某些原因没有公开这一点。所以,现在你可以说,好吧,你可以采用这一点。现在,你有线程了。现在,你有了额外的东西,比如你可以控制内存层次结构。所以,Mojo 允许你做的是,它允许你开始利用所有这些随着时间的推移被构建到硬件中的强大的东西。库提供了非常好的功能。所以,你可以说,只需并行化这个。并行地做这个,对吧?所以,这是对抗缓慢的非常非常强大的武器,这就是为什么我认为人们一直很开心,比如,只是拿代码,让它变得更快,因为看到你能多快地得到东西,这是一种肾上腺素激增。

Lex: Before I talk about some of the interesting stuff with parallelization and all that, let’s first talk about, like, the basics. We talked the indentation, right? So this thing looks like Python. It’s sexy and beautiful like Python, as I mentioned.

Chris: Yep.

Lex: Is it a typed language? So what’s the role of types?"

Lex: 在我谈论一些关于并行化的有趣的事情之前,让我们先谈谈,比如,基础知识。我们谈论了缩进,对吧?所以,这东西看起来像 Python,它像 Python 一样性感和美丽,正如我提到的。

Chris: 是的。

Lex: 它是一种类型化语言吗?所以,类型的作用是什么?

Chris: Yeah, good question. So Python has types. It has strings, it has integers, it has dictionaries and, like, all that stuff, but they all live at runtime, right? And so, because all those types live at runtime in Python, you never or you don’t have to spell them. (chuckles) Python also has, like, this whole typing thing going on now, and a lot of people use it.

Lex: Yeah.

Chris: I’m not talking about that. That’s kind of a different thing. We can go back to that if you want, but typically the, you know, you just say I have a def, and my def takes two parameters. I’m gonna call them A and B, and I don’t have to write the type, okay? So that is great, but what that does is that forces what’s called a consistent representation. So these things have to be a pointer to an object with the object header, and they all have to look the same. And then when you dispatch a method, you go through all the same different paths, no matter what the receiver, whatever that type is. So what Mojo does is it allows you to have more than one kind of type. And so what it does is allows you to say, okay, cool, I have an object, and objects behave like Python does. And so it’s fully dynamic, and that’s all great. And for many things, classes, like, that’s all very powerful and very important. But if you wanna say, hey, it’s an integer, and it’s 32 bits, or it’s 64 bits or whatever it is, or it’s a floating-point value and it’s 64 bits, well, then the compiler can take that, and it can use that to do way better optimization. And it turns out, again, getting rid of the indirections, that’s huge. Means you can get better code completion ‘cause the compiler knows what the type is, and so it knows what operations work on it. And so, that’s actually pretty huge. And so what Mojo does is allows you to progressively adopt types into your program. And so you can start, again, it’s compatible with Python, and so then you can add however many types you want, wherever you want them. And if you don’t wanna deal with it, you don’t have to deal with it, right? And so one of, you know, our opinions on this, (chuckles), it’s that it’s not that types are the right thing or the wrong thing, it’s that they’re a useful thing."

Chris: 是的,好问题。所以 Python 有类型。它有字符串,它有整数,它有字典,以及所有类似的东西,但它们都存在于运行时,对吧?所以,因为所有这些类型都存在于 Python 的运行时,你永远不需要,或者你不必拼写它们。(轻笑) Python 现在也有整个类型系统,很多人都在使用它。

Lex: 是的。

Chris: 我不是在谈论那个。那是一个不同的东西。如果你愿意,我们可以回头再谈,但通常情况下,你知道,你只是说我有一个 def,我的 def 接受两个参数,我要把它们叫做 A 和 B,我不必写类型,好吗?所以,这很好,但它所做的是强制所谓的统一表示。所以,这些东西必须是一个指向对象的指针,带有对象头部,它们必须看起来一样。然后,当你分派一个方法的时候,你都要经历所有相同的路径,无论接收者是什么,无论类型是什么。所以,Mojo 所做的是它允许你拥有不止一种类型的类型。所以,它所做的是允许你说,好吧,酷,我有一个对象,对象的行为就像 Python 一样。所以,它是完全动态的,这都很好。对于很多东西,类,就像,这都是非常强大和非常重要的。但如果你想说,嘿,它是一个整数,它是 32 位的,或者它是 64 位的,或者它是其他什么,或者它是一个浮点数,它是 64 位的,那么编译器可以接受它,它可以使用它来做更好的优化。事实证明,再次,摆脱间接寻址,这是巨大的。这意味着,你可以获得更好的代码补全,因为编译器知道类型是什么,所以它知道什么操作可以作用于它。所以,这实际上是相当巨大的。所以,Mojo 所做的是允许你逐步地将类型添加到你的程序中。所以,你可以从头开始,再次,它与 Python 兼容,所以,然后你可以添加你想要的任意数量的类型,无论你想要它们在哪里。如果你不想处理它,你就不必处理它,对吧?所以,你知道,我们对此的看法之一,(轻笑) 是,不是说类型是对的还是错的,而是说它们是有用的。

Lex: So it’s kind of optional. It’s not strict typing. Like, you don’t have to specify the type.

Chris: Exactly.

Lex: Okay. So it’s starting from the thing that Python’s kinda reaching towards right now with trying to inject types into it, what it’s doing."

Lex: 所以,它是一种可选的。它不是严格类型化的。比如,你不必指定类型。

Chris: 没错。

Lex: 好的。所以,它从 Python 现在试图注入类型的方向开始,它正在做的事情。

Chris: Yeah, with a very different approach, but yes, yeah.

Lex: So what’s the different approach? I’m actually one of the people (sighs) that have not been using types very much in Python. So I haven’t…

Chris: That’s okay. Why did you sigh?"

Chris: 是的,方法非常不同,但是,是的,是的。

Lex: 那么,有什么不同的方法呢?实际上,我是一个 (叹气) 没有在 Python 中使用很多类型的人。所以我没有……

Chris: 没关系。你为什么叹气?

Lex: It just, well, because I know the importance. It’s like adults use strict typing. And so I refuse to grow up in that sense. It’s a kind of rebellion, but I just know that it probably reduces the amount of errors, even just for, forget about performance improvements, it probably reduces errors when you do strict typing."

Lex: 只是,好吧,因为我知道它的重要性。就像成年人使用严格类型化一样。所以,从这个意义上说,我拒绝长大。这是一种反叛,但我只是知道,它可能会减少错误的数量,即使只是为了,忘记性能的提高,它可能会减少你进行严格类型化时的错误。

Chris: Yeah, so, I mean, I think it’s interesting if you look at that, right? And the reason I’m giving you a hard time then is that…

Lex: Yes.

Chris: …there’s this cultural norm, this pressure, this, like, there has to be a right way to do things. Like, you know…

Lex: Yes.

Chris: …grown-ups only do it one way. And if you don’t do that…

Lex: Yes.

Chris: …you should feel bad, right? Like, some people feel like Python’s a guilty pleasure or something, and that’s like, when it gets serious, I need to go rewrite it, right? Well, I mean, cool.

Lex: Exactly.

Chris: I understand history, and I understand kinda where this comes from, but I don’t think it has to be a guilty pleasure (chuckles), right?

Lex: Yeah.

Chris: So if you look at that, you say, why do you have to rewrite it? Well, you have to rewrite it to deploy. Well, why do you wanna deploy? Well, you care about performance, or you care about predictability, or you want, you know, a tiny thing on the server that has no dependencies, or, you know, you have objectives that you’re trying to attain. So what if Python can achieve those objectives? So if you want types, well, maybe you want types because you wanna make sure you’re passing the right thing. Sure, you can add a type. If you don’t care, you’re prototyping some stuff, you’re hacking some things out, you’re, like, pulling some random code off the internet, it should just work (chuckles), right? And you shouldn’t be, like, pressured. You shouldn’t feel bad about doing the right thing or the thing that feels good. Now, if you’re in a team, right, you’re working at some massive internet company, and you have 400 million lines of Python code, well, they may have a house rule that you use types, right?"

Chris: 是的,所以,我的意思是,我认为如果你看看那个,很有趣,对吧?我之所以刁难你,是因为……

Lex: 是的。

Chris: …有一种文化规范,这种压力,这种,就像,必须有一个正确的方法来做事情。就像,你知道……

Lex: 是的。

Chris: …成年人只有一种做事方式。如果你不这样做……

Lex: 是的。

Chris: …你应该感到难过,对吧?就像,有些人觉得 Python 是一种负罪的快乐,或者其他什么,这就像,当事情变得严肃的时候,我需要去重写它,对吧?好吧,我的意思是,酷。

Lex: 没错。

Chris: 我理解历史,我理解这一切是怎么来的,但我认为它不一定是负罪的快乐 (轻笑),对吧?

Lex: 是的。

Chris: 所以,如果你看看那个,你说,你为什么要重写它?好吧,你必须重写它才能部署。好吧,你为什么要部署?好吧,你关心性能,或者你关心可预测性,或者你想要,你知道,服务器上的一个小东西,没有依赖性,或者,你知道,你有你想要实现的目标。那么,如果 Python 可以实现这些目标呢?所以,如果你想要类型,好吧,也许你想要类型,因为你想确保你传递的是正确的东西。当然,你可以添加一个类型。如果你不在乎,你正在原型化一些东西,你正在破解一些东西,你就像,从互联网上拉取一些随机的代码,它应该可以工作 (轻笑),对吧?你不应该,像,感到压力。你不应该因为做正确的事情或者感觉良好的事情而感到难过。现在,如果你在一个团队中,对吧,你在某个大型互联网公司工作,你有 4 亿行 Python 代码,好吧,他们可能有一个内部规则,你必须使用类型,对吧?

Lex: Yeah.

Chris: …because it makes it easier for different humans to talk to each other and understand what’s going on and bugs at scale, right? And so there are lots of good reasons why you might wanna use types, but that doesn’t mean that everybody should use ’em all the time, right? So what Mojo does is it says, cool. Well, allow people to use types, and if you use types, you get nice things out of it, right? You get better performance and things like this, right? But Mojo is a full, compatible superset of Python, right? And so that means it has to work without types. (chuckles) It has to support all the dynamic things. It has to support all the packages. It has to support for comprehension, list comprehensions and things like this, right? And so that starting point, I think, is really important. And I think that, again, you can look at why I care so much about this. And there’s many different aspects of that, one of which is the world went through a very challenging migration from Python 2 to Python 3, right?"

Lex: 是的。

Chris: …因为它让不同的人更容易互相交流,更容易理解正在发生的事情,以及大规模的错误,对吧?所以,有很多很好的理由让你可能想要使用类型,但这并不意味着每个人都应该一直使用它们,对吧?所以,Mojo 所做的是它说,酷。好吧,允许人们使用类型,如果你使用类型,你会得到一些好处,对吧?你会得到更好的性能,以及类似这样的东西,对吧?但 Mojo 是 Python 的一个完整的,兼容的超集,对吧?所以,这意味着它必须在没有类型的情况下工作。(轻笑) 它必须支持所有动态的东西。它必须支持所有软件包。它必须支持理解,列表理解,以及类似这样的东西,对吧?所以,我认为这个起点非常重要。我认为,再次,你可以看看为什么我如此关心这个。有很多不同的方面,其中之一是世界经历了一个非常具有挑战性的从 Python 2 到 Python 3 的迁移,对吧?

Lex: Yes.

Chris: This migration took many years, and it was very painful for many teams, right?

Lex: Yeah.

Chris: And there’s of a lot of things that went on in that. I’m not an expert in all the details, and I honestly don’t wanna be. I don’t want the world to have to go through that, (chuckles) right?"

Lex: 是的。

Chris: 这个迁移花了许多年,对很多团队来说非常痛苦,对吧?

Lex: 是的。

Chris: 这其中发生了很多事情。我不是所有细节方面的专家,老实说,我并不想成为专家。我不想让世界再经历一次这样的事情,(轻笑) 对吧?

Lex: Yeah.

Chris: And, you know, people can ignore Mojo. And if it’s not their thing, that’s cool. But if they wanna use Mojo, I don’t want them to have to rewrite all their code."

Lex: 是的。

Chris: 而且,你知道,人们可以忽略 Mojo。如果它不适合他们,那也很好。但如果他们想使用 Mojo,我不希望他们必须重写所有的代码。

Lex: Yeah, I mean this, okay, the superset part is just, I mean, there’s so much brilliant stuff here. That definitely is incredible. We’ll talk about that.

Chris: Yeah.

Lex: First of all, how’s the typing implemented differently in Python versus Mojo?"

Lex: 是的,我的意思是,好吧,超集部分只是,我的意思是,这里有太多精彩的东西了。这绝对是不可思议的。我们会谈谈这个。

Chris: 是的。

Lex: 首先,Python 和 Mojo 中的类型实现有什么不同?

Chris: Yeah.

Lex: So this heterogeneous flexibility you said is definitely implemented."

Chris: 是的。

Lex: 所以,你说的这种异构的灵活性绝对是实现了的。

Chris: Yeah, so I’m not a full expert (chuckles) in the whole backstory on types in Python. So I’ll give you that. I can give you my understanding. My understanding is, basically, like many dynamic languages, the ecosystem went through a phase where people went from writing scripts to writing large-scale, huge code bases in Python. And at scale, it kinda helps to have types.

Lex: Yeah.

Chris: People wanna be able to reason about interfaces. Do you expect a string or an int or, like, these basic things, right? And so, what the Python community started doing is it started saying, okay, let’s have tools on the side, checker tools, right, that go and, like, enforce invariants, check for bugs, try to identify things. These are called static analysis tools generally. And so these tools run over your code and try to look for bugs. What ended up happening is there’s so many of these things, so many different weird patterns and different approaches on specifying the types and different things going on, that the Python community realized and recognized, “Hey, hey, hey, there’s a thing here.” (chuckles) And so what they started to do is they started to standardize the syntax for adding types to Python. Now, one of the challenges that they had is that they’re coming from kinda this fragmented world where there’s lots of different tools, they have different trade-offs and interpretations, and the types mean different things. And so if you look at types in Python, according to the Python spec, the types are ignored, right? So, according to the Python spec, you can write pretty much anything (chuckles) in a type position, okay? Technically, you can write any expression, okay? Now, that’s beautiful because you can extend it. You can do cool things, you can write, build your own tools, you can build your own house linter or something like that, right? But it’s also a problem because any existing Python program may be using different tools, and they have different interpretations. And so if you adopt somebody’s package into your ecosystem, try to run the tool you prefer, it may throw out tons of weird errors and warnings and problems just because it’s incompatible with how these things work. Also, because they’re added late and they’re not checked by the Python interpreter, it’s always kinda more of a hint that it is a requirement. Also, the CPython implementation can’t use them for performance. And so it’s really…"

Chris: 是的,所以,我对 Python 中类型的整个背景故事并不完全了解。(轻笑) 所以,我会告诉你我的理解。我的理解是,基本上,像许多动态语言一样,生态系统经历了一个阶段,人们从编写脚本到用 Python 编写大规模的,巨大的代码库。而在规模上,有类型是有帮助的。

Lex: 是的。

Chris: 人们希望能够推理接口。你期望的是字符串还是整数,或者像这样的基本东西,对吧?所以,Python 社区开始做的是,它开始说,好吧,让我们在旁边有一些工具,检查器工具,对吧,它们可以去,像,强制执行不变量,检查错误,尝试识别东西。这些通常被称为静态分析工具。所以,这些工具会在你的代码上运行,并尝试寻找错误。最终发生的事情是,有这么多这样的东西,这么多不同的奇怪的模式,以及指定类型的不同方法,以及不同的正在发生的事情,以至于 Python 社区意识到并认识到,嘿,嘿,嘿,这里有一个东西。(轻笑) 所以,他们开始做的是,他们开始标准化将类型添加到 Python 的语法。现在,他们面临的挑战之一是,他们来自一个有点碎片化的世界,那里有很多不同的工具,它们有不同的权衡和解释,类型的含义也不同。所以,如果你看看 Python 中的类型,根据 Python 规范,类型是被忽略的,对吧?所以,根据 Python 规范,你可以在类型位置写几乎任何东西 (轻笑),好吗?从技术上讲,你可以写任何表达式,好吗?现在,这很美妙,因为你可以扩展它。你可以做很酷的事情,你可以写,构建你自己的工具,你可以构建你自己的内部 linter 或者类似的东西,对吧?但这也是一个问题,因为任何现有的 Python 程序都可能使用不同的工具,它们有不同的解释。所以,如果你将某人的软件包添加到你的生态系统中,尝试运行你喜欢的工具,它可能会抛出大量的奇怪的错误和警告和问题,仅仅因为它与这些东西的工作方式不兼容。此外,因为它们添加得很晚,而且没有被 Python 解释器检查,所以,它总是一种提示,而不是一个要求。此外,CPython 实现不能将它们用于性能。所以,它真的是……

Lex: I mean, that’s a big one, right? So you can’t utilize for the compilation, for the just-in-time compilation. Okay.

Chris: Yep, yep, exactly. And this all comes back to the design principle of, they’re kinda hints, they’re kind of, the definition’s a little bit murky. It’s unclear exactly the interpretation in a bunch of cases. And so, because of that, you can’t actually, even if you want to, it’s really difficult to use them to say like, “It is going to be an int, and if it’s not, it’s a problem,” right? A lot of code would break if you did that, so. So in Mojo, right, so you can still use those kind of type annotations, it’s fine. But in Mojo, if you declare a type and you use it, then it means it is going to be that type. And the compiler helps you check that, and enforce it, and it’s safe, and it’s not a, like, best-effort hint kind of a thing."

Lex: 我的意思是,那是一个很大的问题,对吧?所以,你不能在编译时,在即时编译时利用它。好的。

Chris: 是的,是的,没错。这一切都回到了设计原则,它们有点像提示,它们有点像,定义有点模糊。在很多情况下,确切的解释是不清楚的。所以,正因为如此,你实际上不能,即使你想,也很难使用它们来说,比如,它将是一个整数,如果不是,那就是一个问题,对吧?如果你这样做,很多代码都会崩溃,所以。所以在 Mojo 中,对吧,你仍然可以使用那些类型的类型注释,这很好。但在 Mojo 中,如果你声明了一个类型并使用了它,那么它就意味着它将是那个类型。编译器会帮助你检查它,并强制执行它,它是安全的,它不是一个,比如,尽力而为的提示。

Lex: So if you try to shove a string type thing into an integer…

Chris: You get an error from the compiler.

Lex: …from the compiler, compile time. Nice, okay. What kinda basic types are there?"

Lex: 所以,如果你试图将一个字符串类型的东西塞进一个整数……

Chris: 你会从编译器得到一个错误。

Lex: …从编译器,编译时。很好,好的。有什么基本类型?

Chris: Yeah. So Mojo is pretty hardcore in terms of what it tries to do in the language, which is the philosophy there is that we, again, if you look at Python, right, Python’s a beautiful language because it’s so extensible, right? And so all of the different things in Python, like for loops and plus, and like, all these things can be accessed through these __ methods, okay? So you have to say, okay, if I make something that is super fast, I can go all the way down to the metal. Why do I need to have integers built into the language, right? And so, what Mojo does is it says, okay, well, we can have this notion of structs. So you have classes in Python. Now you can have structs. Classes are dynamic, structs are static. Cool. We can get high performance. We can write C++ kind of code with structs if you want. These things mix and work beautifully together, but what that means is that you can go and implement strings and ints and floats and arrays and all that kinda stuff in the language, right? And so, that’s really cool because, you know, to me, as an idealizing compiler, language type of person, what I wanna do is I wanna get magic out of the compiler and put it in the libraries because if somebody can, you know, if we can build an integer that’s beautiful and it has an amazing API, and it does all the things you’d expect an integer to do, we don’t like it. Maybe you want a big integer. Maybe you want, like, a sideways integer, I don’t know, like, what all the space of integers are, then you can do that, and it’s not a second-class citizen. And so if you look at certain other languages, like C++, one I also love and use a lot, int is hardcoded in the language, but complex is not. And so, isn’t it kinda weird that, you know, you have this std:complex class, but you have int, and complex tries to look like a natural numeric type and things like this. But integers and floating-point have these, like, special promotion rules and other things like that, that are magic, and they’re hacked into the compiler. And because of that, you can’t actually make something that works like the built-in types."

Chris: 是的。所以,Mojo 在语言中试图做的事情方面是相当硬核的,它的理念是,我们,再次,如果你看看 Python,对吧,Python 是一种美丽的语言,因为它非常可扩展,对吧?所以,Python 中的所有不同的东西,比如 for 循环和加号,以及所有这些东西,都可以通过这些 __ 方法访问,好吗?所以,你必须说,好吧,如果我做了一些超级快的东西,我可以一路走到金属。为什么我需要在语言中内置整数,对吧?所以,Mojo 所做的是它说,好吧,我们可以有结构体的概念。所以,你在 Python 中有类。现在,你可以有结构体了。类是动态的,结构体是静态的。酷。我们可以获得高性能。如果你愿意,我们可以用结构体编写类似 C++ 的代码。这些东西混合在一起,工作得很漂亮,但这意味着,你可以在语言中实现字符串、整数、浮点数、数组,以及所有类似的东西,对吧?所以,这真的很酷,因为,你知道,对我来说,作为一个理想化的编译器,语言类型的人,我想要做的是,我想要从编译器中取出魔法,并把它放到库中,因为如果有人可以,你知道,如果我们可以构建一个美丽的整数,它有一个惊人的 API,它做了所有你期望整数做的事情,我们不喜欢它。也许你想要一个大整数。也许你想要,比如,一个横向的整数,我不知道,比如,所有整数的空间是什么,那么你可以这样做,它不是一个二等公民。所以,如果你看看其他一些语言,比如 C++,我也很喜欢并经常使用的一种,int 是硬编码在语言中的,但 complex 不是。所以,这难道不奇怪吗,你知道,你有这个 std:complex 类,但你有 int,complex 试图看起来像一个自然的数字类型,以及类似的东西。但整数和浮点数有这些,比如,特殊的提升规则,以及其他类似的东西,它们是魔法,它们被黑进了编译器。正因为如此,你实际上无法做出像内置类型一样工作的东西。

Lex: Is there something provided as a standard because, you know, because it’s AI first, you know, numerical types are so important here. So is there something, like a nice standard implementation of integers and floats?"

Lex: 是否有一些作为标准提供的东西,因为,你知道,因为它首先是 AI,你知道,数字类型在这里非常重要。所以,是否有一些,比如整数和浮点数的良好的标准实现?

Chris: Yeah, so we’re still building all that stuff out. So we provide integers and floats and all that kinda stuff. We also provide like buffers and tensors and things like that you’d expect in an ML context. Honestly, we need to keep designing and redesigning and working with the community to build that out and make that better. That’s not our strength right now. Give us six months or a year, and I think it’ll be way better, but the power of putting in the library means that we can have teams of experts that aren’t compiler engineers that can help us design and refine and drive this forward."

Chris: 是的,所以,我们仍在构建所有这些东西。所以,我们提供整数和浮点数,以及所有类似的东西。我们还提供缓冲区和张量,以及你在 ML 上下文中期望的类似的东西。老实说,我们需要不断地设计和重新设计,并与社区合作,来构建它,并使它变得更好。这不是我们现在的强项。给我们六个月或一年的时间,我认为它会变得更好,但放到库中的力量意味着,我们可以有专家团队,他们不是编译器工程师,可以帮助我们设计,改进,并推动它前进。

Lex: So one of the exciting things we should mention here is that this is new and fresh. This cake is unbaked. It’s almost baked. You can tell it’s delicious, but it’s not fully ready to be consumed."

Lex: 所以,我们应该在这里提到的一个令人兴奋的事情是,这是新的,新鲜的。这个蛋糕还没有烤好。它快烤好了。你可以看出它很美味,但它还没有完全准备好被食用。

Chris: Yep. That’s very fair. It is very useful, but it’s very useful if you’re a super low-level programmer right now. And what we’re doing is we’re working our way up the stack. And so, the way I would look at Mojo today in May 2023 is that it’s like a 0.1. So I think that, you know, a year from now, it’s gonna be way more interesting to a variety of people. But what we’re doing is we decide to release it early so that people can get access to it and play with it. We can build it with the community. We have a big roadmap, fully published, being transparent about this, and a lot of people are involved in this stuff. And so what we’re doing is we’re really optimizing for building this thing the right way. And building it the right way is kind of interesting, working with the community because everybody wants it yesterday. And so sometimes it’s kind of, you know, there’s some dynamics there, but I think…

Lex: Yeah.

Chris: …it’s the right thing."

Chris: 是的。这很公平。它非常有用,但如果你现在是一个超级底层的程序员,它就非常有用。我们正在做的是,我们正在努力向上发展。所以,我今天,2023 年 5 月,看待 Mojo 的方式是,它就像一个 0.1 版本。所以,我认为,你知道,一年后,它会对各种各样的人来说更有趣。但我们正在做的是,我们决定提前发布它,以便人们可以访问它,玩弄它。我们可以与社区一起构建它。我们有一个很大的路线图,完全公开,对此保持透明,很多人都参与其中。所以,我们正在做的是,我们真的在优化,以正确的方式构建这个东西。以正确的方式构建它很有趣,与社区合作,因为每个人都希望它昨天就存在。所以,有时它有点像,你知道,那里有一些动态,但我认为……

Lex: 是的。

Chris: …这是正确的事情。

Lex: So there’s a Discord also. So the dynamics is pretty interesting.

Chris: Yeah.

Lex: Sometimes the community probably can be very chaotic and introduce a lot of stress. Guido famously quit over the stress of the Walrus operator. I mean, it’s, you know…

Chris: Yeah, yeah.

Lex: …it broke…

Chris: …the straw that broke the camel’s back.

Lex: Exactly. And so like, it could be very stressful to develop, but can you just add a tangent upon a tangent? Is it stressful to work through the design of various features here, given that the community is recently involved?"

Lex: 还有一个 Discord。所以,动态很有趣。

Chris: 是的。

Lex: 有时,社区可能会非常混乱,并带来很大的压力。Guido 因为海象运算符的压力而退出了,这是很有名的。我的意思是,你知道……

Chris: 是的,是的。

Lex: …它打破了……

Chris: …压垮骆驼的最后一根稻草。

Lex: 没错。所以,就像,开发可能会非常有压力,但你能否再加一个题外话?考虑到社区最近才参与进来,在这里完成各种功能的设计是否很有压力?

Chris: Well, so I’ve been doing open development and community stuff for decades now. (chuckles) Somehow this has happened to me. So I’ve learned some tricks, but the thing that always gets me is I wanna make people happy, right? And so maybe not all people, all happy, all the time, but generally…

Lex: Yeah.

Chris: …I want people to be happy, right? And so the challenge is that, again, we’re tapping into some long, some deep-seated, long tensions and pressures both in the Python world, but also in the AI world, in the hardware world and things like this. And so, people just want us to move faster, right? And so, again, our decision was, “Let’s release this early. Let’s get people used to it or access to it and play with it. And like, let’s build in the open,” which we could have, you know, had the language monk sitting in the cloister up on the hilltop, like, beavering away trying to build something. But in my experience, you get something that’s way better if you work with the community, right? And so, yes, it can be frustrating, can be challenging for lots of people involved. And, you know, if you, I mean, you mentioned our Discord. We have over 10,000 people on the Discord, 11,000 people or something. Keep in mind, we released Mojo like two weeks ago. (chuckles) Yeah. So…"

Chris: 嗯,所以,我已经做了几十年的开放式开发和社区工作了。(轻笑) 不知怎么的,这件事发生在我身上了。所以,我已经学到了一些技巧,但总让我感到困扰的是,我想让人们快乐,对吧?所以,也许不是所有人,所有的时间都快乐,但通常……

Lex: 是的。

Chris: …我希望人们快乐,对吧?所以,挑战在于,再次,我们正在挖掘一些长期的,一些根深蒂固的,长期的紧张和压力,无论是在 Python 世界,还是在 AI 世界,在硬件世界,以及类似这样的东西。所以,人们只是希望我们更快地行动,对吧?所以,再次,我们的决定是,让我们尽早发布它。让我们让人们习惯它,或者访问它,玩弄它。就像,让我们在公开场合构建,我们可以,你知道,让语言僧侣坐在山顶的修道院里,像,努力地试图构建一些东西。但根据我的经验,如果你与社区合作,你会得到更好的东西,对吧?所以,是的,它可能会令人沮丧,对很多参与其中的人来说可能具有挑战性。而且,你知道,如果你,我的意思是,你提到了我们的 Discord。我们在 Discord 上有超过 10000 人,11000 人,或者类似的数字。记住,我们大约两周前发布了 Mojo。(轻笑) 是的,所以……

Lex: It’s very active.

Chris: So it’s very cool, but what that means is that, you know, 10, 11,000 people all will want something different, right? And so what we’ve done is we’ve tried to say, “Okay, cool. Here’s our roadmap.” And the roadmap isn’t completely arbitrary. It’s based on, “Here’s the logical order in which to build these features or add these capabilities and things like that.” And what we’ve done is we’ve spun really fast on like bug fixes. And so, we actually have very few bugs, which is cool, I mean, actually for a project in this state, but then what we’re doing is we’re dropping in features very deliberately."

Lex: 它非常活跃。

Chris: 所以,这很酷,但这意味着,你知道,10000,11000 人都想要不同的东西,对吧?所以,我们所做的是,我们试图说,好吧,酷。这是我们的路线图。 路线图不是完全武断的。它是基于,这是构建这些功能或添加这些功能的逻辑顺序。 我们所做的是,我们对错误修复进行了非常快速的迭代。所以,我们实际上很少有错误,这很酷,我的意思是,实际上,对于一个处于这种状态的项目来说,但我们正在做的是,我们正在非常刻意地添加功能。

Lex: I mean, this is fun to watch ‘cause you got the two gigantic communities of, like, hardware, like systems engineers, and then you have the machine learning Python people that are like higher level.

Chris: Yeah.

Lex: And it’s just two, like, armies, like…

Chris: They’ve both, they’ve been at war, yeah. (Lex chuckling) They’ve been at war, right? And so here’s…"

Lex: 我的意思是,这很有趣,因为你得到了两个巨大的社区,比如,硬件,比如系统工程师,然后你有机器学习 Python 人员,他们就像更高层次的。

Chris: 是的。

Lex: 这就像两支军队,像……

Chris: 他们都,他们一直在交战,是的。(Lex 轻笑) 他们一直在交战,对吧?所以,这里是……

Lex: It’s a Tolkien novel, or something. Okay.

Chris: Well, so here’s a test. And again, like, it’s super funny for something that’s only been out for two weeks, right? People are so impatient, right? But, okay, cool, let’s fast forward a year. Like, in a year’s time, Mojo will be actually quite amazing and solve tons of problems and be very good. People still have these problems, right? And so you look at this and you say, and the way I look at this at least, is to say, okay, well, we’re solving big, long-standing problems. To me, again, working on many different problems, I wanna make sure we do it right, right? There’s like a responsibility you feel because if you mess it up (chuckles), right, there’s very few opportunities to do projects like this and have them really have an impact on the world. If we do it right, then maybe we can take those feuding armies and actually heal some of those wounds, right?"

Lex: 这就像托尔金的小说,或者其他什么。好的。

Chris: 好吧,这是一个测试。再次,就像,对于一个只发布了两周的东西来说,这超级有趣,对吧?人们太不耐烦了,对吧?但是,好吧,酷,让我们快进一年。就像,在一年的时间里,Mojo 实际上会相当惊人,解决大量的问题,并变得非常好。人们仍然有这些问题,对吧?所以,你看看这个,你说,至少我看待它的方式是,好吧,我们正在解决大的,长期存在的问题。对我来说,再次,处理许多不同的问题,我想确保我们做得正确,对吧?你有一种责任感,因为如果你搞砸了 (轻笑),对吧,很少有机会做这样的项目,并让它们真正对世界产生影响。如果我们做得正确,那么也许我们可以把那些争斗的军队,实际上治愈他们的一些伤口,对吧?

Lex: Yeah.

Chris: This feels like a speech by George Washington or Abraham Lincoln or something.

Lex: And you look at this, and it’s like, okay, well, how different are we?

Chris: Yeah.

Lex: We all want beautiful things. We all want something that’s nice. We all wanna be able to work together. We all want our stuff to be used, right? And so, if we can help heal that, now I’m not optimistic that all people will use Mojo, and they’ll stop using C++, like, that’s not my goal (chuckles), right? But if we can heal some of that, I think that’d be pretty cool. That’d be nice."

Lex: 是的。

Chris: 这感觉像是乔治·华盛顿或亚伯拉罕·林肯的演讲,或者其他什么。

Lex: 你看看这个,就像,好吧,我们有多么不同?

Chris: 是的。

Lex: 我们都想要美丽的东西。我们都想要美好的东西。我们都希望能够一起工作。我们都希望我们的东西被使用,对吧?所以,如果我们可以帮助治愈这一点,现在,我对所有人都会使用 Mojo,他们会停止使用 C++,并不乐观,就像,这不是我的目标 (轻笑),对吧?但如果我们可以治愈其中的一些,我认为那会很酷。那会很好。

Lex: Yeah. And we start by putting the people who like braces into the Gulag. No. (chuckles)

Chris: So there are proposals for adding braces to Mojo, and we just, we tell them no."

Lex: 是的。我们首先把喜欢花括号的人关进古拉格。不。(轻笑)

Chris: 所以,有一些建议是将花括号添加到 Mojo 中,我们只是,我们告诉他们不行。

Lex: Oh, interesting.

Chris: Oh, okay. (laughs) (Chris laughing) Politely, yeah. Anyway. So there’s a lot of amazing features on the roadmap and those already implemented. It’d be awesome if I could just ask you a few things. So…

Chris: Yeah, go for it.

Lex: So the other performance improvement comes from immutability. So what’s this var and this let thing that we got going on? And what’s immutability?"

Lex: 哦,有趣。

Chris: 哦,好吧。(笑) (Chris 笑) 礼貌地,是的。无论如何。所以,路线图上有很多惊人的功能,以及已经实现的功能。如果我可以问你几个问题,那就太棒了。所以……

Chris: 是的,问吧。

Lex: 所以,另一个性能改进来自于不可变性。所以,我们正在进行的这个 var 和这个 let 是什么?什么是不可变性?

Chris: Well, so…

Lex: Yeah. So one of the things that is useful, and it’s not always required, but it’s useful, is knowing whether something can change out from underneath you, right? And so, in Python, you have a pointer to an array, right? And so you pass that pointer to an array around to things. If you pass into a function, they may take that and scroll away in some other data structure. And so you get your array back, and you go to use it. And now somebody else is, like, putting stuff in your array. How do you reason about that?"

Chris: 嗯,所以……

Lex: 是的。所以,有一件事是有用的,它并不总是必需的,但它是有用的,那就是知道一些东西是否可以从你下面改变,对吧?所以,在 Python 中,你有一个指向数组的指针,对吧?所以,你把这个指向数组的指针传递给其他的东西。如果你传递给一个函数,它们可能会接受它,并在其他一些数据结构中滚动它。所以,你得到了你的数组,你去使用它。现在,其他人,就像,把东西放在你的数组中。你如何推理这件事?

Lex: Yeah.

Chris: It gets to be very complicated and leads to lots of bugs, right? And so one of the things that, you know, again, this is not something Mojo forces on you, but something that Mojo enables, is this thing called value semantics. And what value semantics do is they take collections, like an array, like dictionaries, also tensors and strings and things like this that are much higher level, and make them behave like proper values. And so, it makes it look like, if you pass these things around, you get a logical copy of all the data. And so, if I pass you an array, it’s your array. You can go do what you want to it. You’re not gonna hurt my array. Now, that is an interesting and very powerful design principle. It defines away a ton of bugs. You have to be careful to implement it in an efficient way."

Lex: 是的。

Chris: 它变得非常复杂,并导致很多错误,对吧?所以,有一件事,你知道,再次,这不是 Mojo 强加给你的,而是 Mojo 启用的一件事,叫做值语义。值语义所做的是,它们接受集合,比如数组,比如字典,还有张量和字符串,以及类似这样的东西,它们是更高层次的,并使它们的行为像适当的值。所以,它看起来就像,如果你传递这些东西,你会得到所有数据的逻辑副本。所以,如果我传递给你一个数组,那就是你的数组。你可以对它做任何你想做的事情。你不会伤害我的数组。现在,这是一个有趣且非常强大的设计原则。它定义了许多错误。你必须小心地以一种有效的方式实现它。

Lex: Yeah. Is there a performance hit that’s significant?

Chris: Generally not if you implement it the right way, but it requires a lot of very low-level, getting-the-language-right bits."

Lex: 是的。是否有明显的性能损失?

Chris: 如果你以正确的方式实现它,通常不会有,但它需要很多非常底层的,让语言正确的东西。

Lex: I assume that’d be a huge performance hit ‘cause the benefit is really nice ‘cause you don’t get into these…

Chris: Absolutely. Well, the trick is you can’t do copies. So you have to provide the behavior of copying without doing the copy."

Lex: 我假设这会是一个巨大的性能损失,因为好处真的很棒,因为你不会陷入这些……

Chris: 绝对的。好吧,诀窍是你不能做副本。所以,你必须提供复制的行为,而不进行复制。

Lex: Yeah. How do you do that? (Chris laughing) How do you do that?

Chris: It’s not magic. It’s just…

Lex: Okay.

Chris: …it’s actually pretty cool. Well, so first, before we talk about how that works, let’s talk about how it works in Python, right? So in Python, you define a person class, or maybe a person class is a bad idea. You define a database class, right? And a database class has an array of records, something like that, right? And so the problem is, is that if you pass in a record or a class instance into the database, it’ll take a hold of that object, and then it assumes it has it. And if you’re passing an object in, you have to know that that database is gonna take it, and therefore you shouldn’t change it after you put it in the database, right? This is…"

Lex: 是的。你是怎么做到的?(Chris 笑) 你是怎么做到的?

Chris: 这不是魔法。它只是……

Lex: 好的。

Chris: …它实际上很酷。好吧,所以,首先,在我们谈论它是如何工作之前,让我们谈谈它在 Python 中是如何工作的,对吧?所以,在 Python 中,你定义一个人类,或者也许人类是一个坏主意。你定义一个数据库类,对吧?数据库类有一个记录数组,类似这样的东西,对吧?所以,问题是,如果你将一条记录或一个类实例传递到数据库中,它会持有那个对象,然后它假设它拥有它。如果你正在传递一个对象,你必须知道数据库会接受它,因此,你不应该在把它放到数据库之后改变它,对吧?这是……

Lex: You just kinda have to know that.

Chris: You just have to kinda know that, right? And so, you roll out version one of the database. You just kinda have to know that. Of course, Lex uses his own database, right?

Lex: Yeah.

Chris: Right, ‘cause you built it. You understand how this works, right? Somebody else joins the team, they don’t know this, right?

Lex: Yes.

Chris: And so now they suddenly get bugs, you’re having to maintain the database, you shake your fist, you argue. The 10th time this happens, you’re like, okay, we have to do something different, right? And so, what you do is you go change your Python code, and you change your database class to copy the record every time you add it. And so what ends up happening is you say, okay, I will do what’s called a defensive copy inside the database. And then that way, if somebody passes something in, I will have my own copy of it, and they can go do whatever, and they’re not gonna break my thing, (chuckles) okay? This is usually the two design patterns. If you look in PyTorch, for example, this is cloning a tensor. Like, there’s a specific thing, and you have to know where to call it. And if you don’t call it in the right place, you get these bugs, and this is state-of-the-art, right? So, a different approach, so it’s used in many languages, so I’ve worked with it in Swift, is you say, okay, well, let’s provide value semantics. And so, we wanna provide the view that you get a logically independent copy, but we wanna do that lazily. And so what we do is we say, okay, if you pass something into a function, it doesn’t actually make a copy. What it actually does is it just increments a reference to it. And if you pass it around, you stick in your database, it can go into the database, you own it. And then you come back outta the stack. Nobody’s copied anything. You come back outta the stack, and then the caller lets go of it. Well, then you’ve just handed it off to the database, you’ve transferred it, and there’s no copies made. Now, on the other hand, if, you know, your coworker goes and hands you a record, and you pass it in, you stick it in the database, and then you go to town, and you start modifying it, what happens is you get a copy lazily on demand. And so what this does, this gives you copies only when you need them. So it defines the way the bugs, but it also generally reduces the number of copies in practice. And so it’s…"

Lex: 你只是有点必须知道这一点。

Chris: 你只是有点必须知道这一点,对吧?所以,你推出了数据库的第一个版本。你只是有点必须知道这一点。当然,Lex 使用他自己的数据库,对吧?

Lex: 是的。

Chris: 对,因为是你构建的。你理解这是如何工作的,对吧?其他人加入团队,他们不知道这一点,对吧?

Lex: 是的。

Chris: 所以,现在他们突然遇到了错误,你不得不维护数据库,你挥舞着拳头,你争论。当这种情况发生第 10 次的时候,你会想,好吧,我们必须做一些不同的事情,对吧?所以,你所做的是,你去改变你的 Python 代码,你改变你的数据库类,每次添加记录的时候都复制它。所以,最终发生的事情是,你说,好吧,我会在数据库内部做一个所谓的防御性复制。然后,这样,如果有人传递了一些东西,我就会有我自己的副本,他们可以去做任何事情,他们不会破坏我的东西,(轻笑) 好吗?这通常是两种设计模式。例如,如果你看看 PyTorch,这就是克隆张量。就像,有一个特定的东西,你必须知道在哪里调用它。如果你没有在正确的地方调用它,你会得到这些错误,这是最先进的,对吧?所以,一种不同的方法,所以它在很多语言中被使用,所以我在 Swift 中使用过它,就是你说,好吧,让我们提供值语义。所以,我们想提供这样一种观点,你得到一个逻辑上独立的副本,但我们想懒惰地做到这一点。所以,我们所做的是,我们说,好吧,如果你将一些东西传递到一个函数中,它实际上并没有复制它。它实际上所做的是,它只是增加对它的引用。如果你传递它,你把它放在你的数据库中,它可以进入数据库,你拥有它。然后,你从栈中出来。没有人复制任何东西。你从栈中出来,然后调用者放开它。好吧,然后你刚刚把它交给了数据库,你已经转移了它,没有复制任何东西。现在,另一方面,如果,你知道,你的同事去,递给你一条记录,你传递它,你把它放在数据库中,然后你去城里,你开始修改它,发生的事情是,你会按需得到一个副本。所以,这所做的是,这只是在你需要的时候给你副本。所以,它定义了错误的方式,但它也通常在实践中减少了副本的数量。所以,它……

Lex: But the implementation details are tricky here, I assume.

Chris: Yes, yes.

Lex: Something with reference counting, but to make it performant across a number of different kinds of objects?"

Lex: 但我认为这里的实现细节很棘手。

Chris: 是的,是的。

Lex: 一些关于引用计数的东西,但要让它在许多不同类型的对象上表现良好?

Chris: Yeah. Well, so you need a couple of things. So this concept has existed in many different worlds. And so it’s, again, it’s not novel research at all, right? The magic is getting the design right so that you can do this in a reasonable way, right? And so, there’s a number of components that go into this. One is, when you’re passing around, so we’re talking about Python and reference counting and the expense of doing that, when you’re passing values around, you don’t wanna do extra reference counting for no good reason. And so, you have to make sure that you’re efficient, and you transfer ownership instead of duplicating references and things like that, which is a very low-level problem. You also have to adopt this, and you have to build these data structures. And so if you say, you know, Mojo has to be compatible with Python, so of course, the default list is a reference semantic list that works the way you’d expect in Python, but then you have to design a value semantic list. And so, you just have to implement that, and then you implement the logic within. And so, the role of the language here is to provide all the low-level hooks that allow the author of the type to be able to get and express this behavior without forcing it into all cases or hardcoding this into the language itself."

Chris: 是的。好吧,所以,你需要几样东西。所以,这个概念存在于许多不同的世界中。所以,它,再次,它根本不是新颖的研究,对吧?神奇之处在于正确地设计,以便你可以以合理的方式做到这一点,对吧?所以,这里面有很多组成部分。一个是,当你传递的时候,所以,我们正在谈论 Python 和引用计数,以及这样做的成本,当你传递值的时候,你不想无缘无故地做额外的引用计数。所以,你必须确保你是高效的,你转移所有权,而不是复制引用,以及类似的东西,这是一个非常底层的问题。你还必须采用这个,你必须构建这些数据结构。所以,如果你说,你知道,Mojo 必须与 Python 兼容,所以,当然,默认的列表是一个引用语义列表,它的工作方式与你在 Python 中期望的一样,但你必须设计一个值语义列表。所以,你只需要实现它,然后你在内部实现逻辑。所以,语言在这里的作用是提供所有低级钩子,允许类型的作者能够获得和表达这种行为,而不需要在所有情况下强制它,或者将它硬编码到语言本身。

Lex: But there’s ownership? So you’re constantly transferring, you’re tracking who owns the thing.

Chris: Yes. And so, there’s a whole system called ownership. And so, this is related to work done in the Rust community. Also, the Swift community has done a bunch of work, and there’s a bunch of different other languages that have all kind of… C++ actually has copy constructors and destructors and things like that. And so, and I mean, C++ has everything. So it has move constructors and has like this whole world of things. And so this is a body of work that’s kind of been developing for many, many years now. And so, Mojo takes some of the best ideas out of all these systems and then remixes in a nice way so that you get the power of something like the Rust programming language, but you don’t have to deal with it when you don’t want to, which is a major thing in terms of teaching and learning and being able to use and scale these systems."

Lex: 但是有所有权吗?所以,你一直在转移,你一直在跟踪谁拥有这个东西。

Chris: 是的。所以,有一个叫做所有权的整个系统。所以,这与 Rust 社区所做的工作有关。此外,Swift 社区也做了一些工作,还有很多其他不同的语言,它们都有各种各样的……C++ 实际上有复制构造函数和析构函数,以及类似的东西。所以,我的意思是,C++ 拥有一切。所以,它有移动构造函数,并且有像整个世界的东西。所以,这是一项已经发展了很多年的工作。所以,Mojo 从所有这些系统中吸取了一些最好的想法,然后以一种很好的方式重新组合,这样你就可以获得像 Rust 编程语言那样的力量,但当你不想的时候,你不必处理它,这在教学和学习,以及能够使用和扩展这些系统方面是一件很重要的事情。

Lex: How does that play with argument conventions? What are they? Why are they important? How does the value semantics, how does the transfer ownership work with the arguments when they’re passing definitions?"

Lex: 这与参数约定是如何相处的?它们是什么?为什么它们很重要?值语义,传递所有权是如何与参数一起工作的,当它们传递定义的时候?

Chris: Yeah. So if you go deep into systems programming land, so this isn’t, again, this is not something for everybody, but if you go deep into systems programming land, what you encounter is you encounter these types that get weird. (chuckles) So if you’re used to Python, you think about everything. I can just copy it around. I can go change it and mutate it and do these things, and it’s all cool. If you get into systems programming land, you get into these things, like, I have an atomic number, or I have a mutex, or I have a uniquely owned database handle, things like this, right? So these types, you can’t necessarily copy. Sometimes you can’t necessarily even move them to a different address. And so what Mojo allows you to do is it allows you to express, “Hey, I don’t wanna get a copy of this thing. I wanna actually just get a reference to it.” And by doing that, what you can say is, you can say, okay, if I’m defining something weird like a, you know, atomic number or something, it’s like, it has to be… So an atomic number is an area in memory that multiple threads can access at a time without synchronous, without locks, right? And so, like, the definition of atomic numbers, multiple different things have to be poking at that, therefore they have to agree on where it is, (chuckles) right? So you can’t just, like, move it out from underneath one because it kinda breaks what it means. And so, that’s an example of a type that you can’t copy, you can’t move it. Like, once you create it, it has to be where it was, right? Now, if you look at many other examples, like a database handle, right, so, okay, well, what happens? How do you copy a database handle? Do you copy the whole database? That’s not something you necessarily wanna do. There’s a lot of types like that where you wanna be able to say that they are uniquely owned. So there’s always one of this thing, or if I create a thing, I don’t copy it. And so what Mojo allows you to do is it allows you to say, “Hey, I wanna pass around in reference to this thing without copying it,” and so it has borrowed conventions. So you can say, you can use it, but you don’t get to change it. You can pass it by mutable reference. And so if you do that, then you get a reference to it, but you can change it. And so, it manages all that kinda stuff."

Chris: 是的。所以,如果你深入到系统编程领域,所以,这不是,再次,这不是适合每个人的东西,但如果你深入到系统编程领域,你遇到的是,你遇到这些变得奇怪的类型。(轻笑) 所以,如果你习惯了 Python,你会想到所有东西。我可以到处复制它。我可以去改变它,改变它,做这些事情,这都很酷。如果你进入系统编程领域,你会遇到这些东西,比如,我有一个原子数,或者我有一个互斥体,或者我有一个唯一拥有的数据库句柄,类似这样的东西,对吧?所以,这些类型,你不一定可以复制。有时,你甚至不能把它们移动到不同的地址。所以,Mojo 允许你做的是,它允许你表达,嘿,我不想得到这个东西的副本。我实际上只想得到对它的引用。 通过这样做,你可以说的是,你可以说,好吧,如果我正在定义一些奇怪的东西,比如,你知道,原子数或者其他什么东西,它就像,它必须是……所以,原子数是内存中的一个区域,多个线程可以在没有同步的情况下,在没有锁的情况下,同时访问它,对吧?所以,就像,原子数的定义,多个不同的东西必须在戳它,因此,它们必须就它在哪里达成一致,(轻笑) 对吧?所以,你不能,就像,把它从一个下面移开,因为它有点破坏了它的意思。所以,这是一个你不能复制的类型的例子,你不能移动它。就像,一旦你创建了它,它就必须在它原来的地方,对吧?现在,如果你看看很多其他的例子,比如一个数据库句柄,对吧,所以,好吧,会发生什么?你如何复制一个数据库句柄?你复制整个数据库吗?这不是你一定想做的事情。有很多这样的类型,你希望能够说它们是唯一拥有的。所以,总是只有一个这样的东西,或者,如果我创建了一个东西,我不复制它。所以,Mojo 允许你做的是,它允许你说,嘿,我想在不复制它的情况下传递对这个东西的引用,所以,它有借用约定。所以,你可以说,你可以使用它,但你不能改变它。你可以通过可变引用传递它。所以,如果你这样做,那么你会得到对它的引用,但你可以改变它。所以,它管理所有这类东西。

Lex: So it’s just a really nice implementation of, like, C++ has…

Chris: Yeah.

Lex: …you know, different kinds of pointers.

Chris: Reference, yeah, has pointers.

Lex: Smart, smart, different kinds of implementations of smart pointers that you can…

Chris: Yeah.

Lex: …explicitly define, this allows you. But you’re saying that’s more like the weird case versus the common case?"

Lex: 所以,它只是一个非常好的实现,比如,C++ 有……

Chris: 是的。

Lex: …你知道,不同类型的指针。

Chris: 引用,是的,有指针。

Lex: 智能的,智能的,你可以……

Chris: 是的。

Lex: …显式定义的不同类型的智能指针实现,这允许你这样做。但你是说,这更像是奇怪的情况,而不是常见的情况?

Chris: Well, it depends on where, I mean, I don’t think I’m a normal person, so…

Lex: Yes.

Chris: …I’m not one to call other people weird.

Lex: Yeah. (Chris chuckling) But, you know, if you talk to a typical Python programmer, you’re typically not thinking about this, right? This is a lower level of abstraction. Now, certainly, if you talk to a C++ programmer, certainly if you talk to a Rust programmer, again, they’re not weird, they’re delightful. Like, these are all good people, right? Those folks will think about it all the time, right? And so, I look at this as, there’s a spectrum between very deep, low-level systems, “I’m gonna go poke the bits and care about how they’re laid out in memory,” all the way up to application and scripting and other things like this. And so, it’s not that anybody’s right or wrong, it’s about how do we build one system that scales."

Chris: 好吧,这取决于在哪里,我的意思是,我不认为我是一个普通人,所以……

Lex: 是的。

Chris: …我不是一个会说别人奇怪的人。

Lex: 是的。(Chris 轻笑) 但是,你知道,如果你和一个典型的 Python 程序员交谈,你通常不会想到这个,对吧?这是一个更低的抽象层次。现在,当然,如果你和一个 C++ 程序员交谈,当然,如果你和一个 Rust 程序员交谈,再次,他们不奇怪,他们很可爱。就像,这些人都是好人,对吧?那些人会一直想着它,对吧?所以,我把它看作是,在非常深,非常底层的系统之间有一个范围,我要去戳位,关心它们是如何在内存中布局的,一直到应用程序和脚本,以及其他类似的东西。所以,不是说谁是对的还是错的,而是关于我们如何构建一个可以扩展的系统。

Lex: By the way, the idea of an atomic number has been something that always brought me deep happiness because the flip side of that, the idea that threads can just modify stuff asynchronously, just the whole idea of concurrent programming, is a source of infinite distrust for me."

Lex: 顺便说一下,原子数的想法一直是我深感快乐的东西,因为它的另一面,线程可以异步修改东西的想法,整个并发编程的想法,对我来说是无限不信任的来源。

Chris: Well, so this is where you jump into, you know, again, you zoom out and get out of programming languages or compilers, and you just look at what the industry has done. My mind is constantly blown by this, right? And you look at what, you know, Moore’s law, Moore’s Law is this idea that, like, computers, for a long time, single-thread performance just got faster and faster and faster and faster for free. But then physics and other things intervened, and power consumption, like other things, started to matter. And so, what ended up happening is we went from single-core computers to multi-core, then we went to accelerators, right? And this trend towards specialization of hardware is only gonna continue. And so for years, us programming language nerds and compiler people have been saying, okay, well, how do we tackle multi-core, right? For a while it was like, “Multi-core is the future! We have to get on top of this thing!” And then it was multi-core is the default. “What are we doing with this thing?” And then it’s like, there’s chips with hundreds of cores in them. (chuckles) What will happen, right?"

Chris: 好吧,所以,这就是你跳进去的地方,你知道,再次,你放大,走出编程语言或编译器,你只是看看这个行业做了什么。我的想法不断地被这个东西震撼,对吧?你看看什么,你知道,摩尔定律,摩尔定律是这样的想法,就像,计算机,很长一段时间,单线程性能只是越来越快,越来越快,越来越快,免费。但是,物理和其他东西介入,功耗,像其他东西,开始变得重要。所以,最终发生的事情是,我们从单核计算机到多核,然后我们去了加速器,对吧?这种硬件专业化的趋势只会继续下去。所以,多年来,我们这些编程语言书呆子和编译器人员一直在说,好吧,我们如何处理多核,对吧?有一段时间,它就像,多核是未来!我们必须掌握这个东西! 然后,多核是默认的。我们用这个东西做什么? 然后,它就像,有芯片中有数百个核心。(轻笑) 会发生什么,对吧?

Lex: Yeah.

Chris: And so I’m super inspired by the fact that, you know, in the face of this, you know, those machine learning people invented this idea of a tensor, right? And what’s a tensor? A tensor is like an arithmetic and algebraic concept. It’s like an abstraction around a gigantic parallelizable dataset, right? And because of that, and because of things like TensorFlow and PyTorch, we’re able to say, okay, we’ll express the math of the system. This enables you to do automatic differentiation, enables you to do, like, all these cool things. And it’s an abstracted representation. Well, because you have that abstract representation, you can now map it onto these parallel machines without having to control, okay, put that byte here, put that byte there, put that byte there. And this has enabled an explosion in terms of AI, compute, accelerators, like, all the stuff. And so that’s super, super exciting."

Lex: 是的。

Chris: 所以,我超级受这个事实的启发,你知道,面对这个,你知道,那些机器学习的人发明了这个张量的想法,对吧?什么是张量?张量就像一个算术和代数的概念。它就像一个围绕巨大可并行化数据集的抽象,对吧?正因为如此,也因为像 TensorFlow 和 PyTorch 这样的东西,我们能够说,好吧,我们将表达系统的数学。这使你能够进行自动微分,使你能够做,像,所有这些很酷的事情。它是一个抽象的表示。好吧,因为你有了这个抽象的表示,你现在可以把它映射到这些并行机器上,而不需要控制,好吧,把这个字节放在这里,把那个字节放在那里,把那个字节放在那里。这导致了人工智能,计算,加速器,像,所有东西的爆炸式增长。所以,这是超级,超级令人兴奋的。

Lex: What about the deployment and the execution across multiple machines?

Chris: Yeah.

Lex: So you write that the Modular compute platform dynamically partitions models with billions of parameters and distributes their execution across multiple machines, enabling unparalleled efficiency. By the way, the use of unparalleled in that sentence… Anyway. (Chris chuckling) Enabling unparalleled efficiency, scale, and the reliability for the largest workloads. So how do you do this abstraction of distributed deployment of large models?"

Lex: 那么,跨多台机器的部署和执行呢?

Chris: 是的。

Lex: 所以,你写道,Modular 计算平台动态地划分具有数十亿参数的模型,并将它们的执行分布在多台机器上,从而实现无与伦比的效率。顺便说一下,在这个句子中使用无与伦比……无论如何。(Chris 轻笑) 为最大的工作负载实现无与伦比的效率,规模和可靠性。那么,你是如何做到这种大型模型的分布式部署的抽象的?

Chris: Yeah. So one of the really interesting tensions, so there’s a whole bunch of stuff that goes into that. I’ll pick a random walk through it. If you go back and replay the history of machine learning, right? I mean, the brief, most recent history of machine learning, ‘cause this is, as you know, very deep…

Lex: Yeah.

Chris: I knew Lex when he had an AI podcast.

Lex: Yes. (Chris chuckling)

Chris: Right? So, if you look at just TensorFlow and PyTorch, which is pretty recent history in the big picture, right? But TensorFlow is all about graphs. PyTorch, I think pretty unarguably ended up winning. And why did it win? Mostly because of the usability, right? And the usability of PyTorch is, I think, huge. And I think, again, that’s a huge testament to the power of taking abstract, theoretical, technical concepts and bringing it to the masses, right? Now, the challenge with what the TensorFlow versus the PyTorch design points was that TensorFlow’s kinda difficult to use for researchers, but it was actually pretty good for deployment. PyTorch is really good for researchers, it’s kinda not super great for deployment, right? And so, I think that we, as an industry, have been struggling. And if you look at what deploying a machine learning model today means, is that you’ll have researchers who are, I mean, wicked smart, of course, but they’re wicked smart at model architecture and data and calculus and (chuckles) like, all, like, they’re wicked smart in various domains. They don’t wanna know anything about the hardware deployment or C++, or things like this, right? And so, what’s happened is you get people who train the model, they throw it over the fence, and then you have people that try to deploy the model. Well, every time you have Team A does X, they throw it over the fence, Team B does Y, like, you have a problem, because, of course, it never works the first time. And so you throw over the fence, they figure out, okay, it’s too slow, won’t fit, doesn’t use the right operator, the tool crashes, whatever the problem is, then they have to throw it back over the fence. And every time you throw a thing over a fence, it takes three weeks of project managers and meetings and things like this. And so, what we’ve seen today is that getting models in production can take weeks or months. Like, it’s not atypical, right? I talk to lots of people, and you talk about, like, VP of software at some internet company trying to deploy a model, and they’re like, “Why do I need a team of 45 people? (chuckles) Like, it’s so easy training a model. Why can’t I deploy it?” Right? And if you dig into this, every layer is problematic. So if you look at the language piece, I mean, this is the tip of the iceberg. It’s a very exciting tip of the iceberg for folks, but you’ve got Python on one side and C++ on the other side. Python doesn’t really deploy. I mean, it can, theoretically, technically, in some cases, but often a lot of production teams will wanna get things out of Python because they get better performance and control and whatever else. So Mojo can help with that. If you look at serving, so you talk about gigantic models, well, a gigantic model won’t fit on one machine, right? And so now you have this model, it’s written in Python, it has to be rewritten in C++. Now it also has to be carved up so that half of it runs on one machine, half of it runs on another machine, or maybe it runs on 10 machines. Well, so now, suddenly, the complexity is exploding, right? And the reason for this is that if you look into TensorFlow or PyTorch, these systems, they weren’t really designed for this world, right? They were designed for, you know, back in the day when we were starting and doing things where it was a different, much simpler world, like, you wanted to run ResNet-50 or some ancient model architecture like this. It was a completely different world than…"

Chris: 是的。所以,真正有趣的地方在于,这里面有很多东西。我将随机选择一个方向来讲解。如果你回顾一下机器学习的历史,对吧?我的意思是,简要的,最近的机器学习的历史,因为,正如你所知,它非常深奥……

Lex: 是的。

Chris: 我认识 Lex 的时候,他有一个关于人工智能的播客。

Lex: 是的。(Chris 轻笑)

Chris: 对吧?所以,如果你只看 TensorFlow 和 PyTorch,从全局来看,它们的历史相当近,对吧?但 TensorFlow 的核心是图。我认为 PyTorch 最终毫无疑问地赢了。它为什么赢了?主要是因为它的可用性,对吧?我认为 PyTorch 的可用性非常强大。我认为,这再次证明了将抽象的,理论的,技术的概念带给大众的力量,对吧?现在,TensorFlow 和 PyTorch 设计点的挑战是,TensorFlow 对研究人员来说有点难用,但它实际上非常适合部署。PyTorch 对研究人员来说非常好用,但它不太适合部署,对吧?所以,我认为,作为一个行业,我们一直在挣扎。如果你看看今天部署机器学习模型意味着什么,你会发现,研究人员,我的意思是,他们非常聪明,当然,但他们在模型架构和数据和微积分方面非常聪明,(轻笑) 就像,所有,就像,他们在各个领域都非常聪明。他们不想知道任何关于硬件部署或 C++,或类似的东西,对吧?所以,发生的事情是,你得到训练模型的人,他们把它扔过栅栏,然后你有尝试部署模型的人。好吧,每次你让 A 队做 X,他们把它扔过栅栏,B 队做 Y,就像,你有一个问题,因为,当然,它第一次永远不会工作。所以,你扔过栅栏,他们弄清楚,好吧,它太慢了,不合适,没有使用正确的运算符,工具崩溃了,无论问题是什么,然后他们必须把它扔回栅栏。每次你把一个东西扔过栅栏,都需要三周的项目经理和会议,以及类似的东西。所以,我们今天看到的是,将模型投入生产可能需要几周或几个月的时间。就像,这不是非典型的,对吧?我和很多人交谈过,你谈论,比如,某个互联网公司的软件副总裁试图部署一个模型,他们就像,为什么我需要一个 45 人的团队?(轻笑) 就像,训练一个模型是如此容易。为什么我不能部署它? 对吧?如果你深入研究这个问题,你会发现每一层都有问题。所以,如果你看看语言部分,我的意思是,这只是冰山一角。对人们来说,这是冰山一角的一个非常令人兴奋的部分,但你一边是 Python,另一边是 C++。Python 并没有真正部署。我的意思是,它可以,理论上,技术上,在某些情况下,但通常很多生产团队会想从 Python 中摆脱出来,因为他们可以获得更好的性能和控制,以及其他任何东西。所以,Mojo 可以在这方面提供帮助。如果你看看服务,所以,你谈论的是巨型模型,好吧,巨型模型不能放在一台机器上,对吧?所以,现在你有了这个模型,它是用 Python 编写的,它必须用 C++ 重写。现在,它还必须被分割,这样它的一半在一台机器上运行,另一半在另一台机器上运行,或者也许它在 10 台机器上运行。好吧,所以,现在,突然,复杂性爆炸了,对吧?原因是,如果你看看 TensorFlow 或 PyTorch,这些系统,它们并没有真正为这个世界设计,对吧?它们是为,你知道,在我们开始和做事情的时候设计的,那时是一个不同的,更简单的世界,比如,你想运行 ResNet-50 或类似的古老模型架构。这是一个完全不同的世界,比……

Lex: Trained on one GPU."

Lex: 在一个 GPU 上训练。

Chris: Exactly. AlexNet."

Chris: 没错。AlexNet。

Lex: Doing it on one GPU. (chuckles)"

Lex: 在一个 GPU 上做。(轻笑)

Chris: Yeah, AlexNet, right? The major breakthrough, and the world has changed, right? And so now, the challenge is, is that TensorFlow, PyTorch, these systems, they weren’t actually designed for LLMs, like, that was not a thing. And so, where TensorFlow actually has amazing power in terms of scale and deployment and things like that, and I think Google is, I mean, maybe not unmatched, but they’re, like, incredible, in terms of their capabilities and gigantic scale, many researchers using PyTorch, right? And so, PyTorch doesn’t have those same capabilities. And so what Modular can do is it can help with that. Now, if you take a step back, and you say, like, what is Modular doing, right? So, Modular has like a bitter enemy that we’re fighting against in the industry. And it’s one of these things where everybody knows it, but nobody is usually willing to talk about it."

Chris: 是的,AlexNet,对吧?重大的突破,世界已经改变了,对吧?所以,现在,挑战是,TensorFlow,PyTorch,这些系统,它们实际上并不是为大型语言模型设计的,就像,那不是一回事。所以,TensorFlow 实际上在规模和部署方面有惊人的力量,我认为谷歌是,我的意思是,也许不是无与伦比的,但他们,就像,不可思议的,就他们的能力和巨大的规模而言,很多研究人员使用 PyTorch,对吧?所以,PyTorch 没有那些相同的能力。所以,Modular 可以做的是,它可以在这方面提供帮助。现在,如果你退一步,你说,就像,Modular 在做什么,对吧?所以,Modular 有一个我们在行业中与之斗争的死敌。这是一件每个人都知道的事情,但通常没有人愿意谈论它。

Lex: The bitter enemy."

Lex: 死敌。

Chris: The bitter thing that we have to destroy that we’re all struggling with, and it’s like all around, it’s like fish can’t see water, it’s complexity.

Lex: Sure, yes. It’s complexity.

Chris: Right?"

Chris: 我们必须摧毁的痛苦的事情,我们都在与之斗争,它就像在周围,就像鱼看不到水,它是复杂性。

Lex: 当然,是的。它是复杂性。

Chris: 对吧?

Lex: That was very philosophical, very well said. (Chris chuckling)

Chris: And so, if you look at it, yes, it is on the hardware side."

Lex: 那很有哲理,说得很好。(Chris 轻笑)

Chris: 所以,如果你看看它,是的,它在硬件方面。

Lex: Yes.

Chris: All these accelerators, all these software stacks that go with the accelerators, all these, like, there’s massive complexity over there. You look at what’s happening on the modeling side, a massive amount of complexity. Like, things are changing all the time. People are inventing. Turns out the research is not done. (chuckles)

Lex: Yeah.

Chris: And so, people wanna be able to move fast. Transformers are amazing, but there’s a ton of diversity even within transformers, and what’s the next transformer, right? And you look into serving. Also, huge amounts of complexity. It turns out that all the cloud providers, right, have all their very weird, but very cool hardware for networking and all this kinda stuff. And it’s all very complicated. People aren’t using that. You look at classical serving, right? There’s this whole world of people who know how to write high-performance servers with zero-copy networking and, like, all this fancy asynchronous I/O, and, like, all these fancy things in the serving community, very little that has pervaded into the machine learning world, right? And why is that? Well, it’s because, again, these systems have been built up over many years. They haven’t been rethought, there hasn’t been a first principles approach to this. And so what Modular’s doing is we’re saying, “Okay, we’ve built many of these things, right?” So I’ve worked on TensorFlow and TPUs and things like that. Other folks on our team have, like, worked on PyTorch Core. We’ve worked on ONNX runtime. We’ve worked on many of these other systems. And so, built systems like the Apple accelerators and all that kinda stuff, like, our team is quite amazing. And so, one of the things that roughly everybody at Modular’s grumpy about is that when you’re working on one of these projects, you have a first-order goal: get the hardware to work, get the system to enable one more model, get this product out the door, enable the specific workload, or make it solve this problem for this product team, right? And nobody’s been given a chance to actually do that step back. And so we, as an industry, we didn’t take two steps forward. We took, like, 18 steps forward in terms of all this really cool technology across compilers and systems and runtimes and heterogeneous computing, like, all this kinda stuff. And, like, all this technology has been, you know, I wouldn’t say beautifully designed, but it’s been proven in different quadrants. Like, you know, you look at Google with TPUs, massive, huge exaflops of compute strapped together into machines that researchers are programming in Python in a notebook. That’s huge. That’s amazing."

Lex: 是的。

Chris: 所有这些加速器,所有与加速器配套的软件栈,所有这些,就像,那里有巨大的复杂性。你看看建模方面正在发生的事情,大量的复杂性。就像,事情一直在变化。人们在发明。事实证明,研究还没有完成。(轻笑)

Lex: 是的。

Chris: 所以,人们希望能够快速行动。Transformer 是惊人的,但即使在 Transformer 内部,也有大量的多样性,下一个 Transformer 是什么,对吧?你看看服务。也是,大量的复杂性。事实证明,所有的云提供商,对吧,都有他们非常奇怪,但非常酷的网络硬件,以及所有这类东西。而且,这一切都非常复杂。人们没有使用它。你看看经典的服务,对吧?有这样一个世界,他们知道如何编写高性能服务器,零拷贝网络,以及,像,所有这些花哨的异步 I/O,以及,像,所有这些花哨的东西在服务社区,很少有渗透到机器学习世界,对吧?这是为什么呢?好吧,这是因为,再次,这些系统已经建立了很多年。它们没有被重新思考,没有第一性原理的方法来解决这个问题。所以,Modular 正在做的是,我们说,好吧,我们已经建立了很多这样的东西,对吧? 所以,我做过 TensorFlow 和 TPU,以及类似的东西。我们团队中的其他人,比如,做过 PyTorch Core。我们做过 ONNX runtime。我们做过很多其他的系统。所以,构建像苹果加速器这样的系统,以及所有类似的东西,就像,我们的团队相当惊人。所以,Modular 的每个人都感到不满的一件事是,当你正在做这些项目中的一个的时候,你有一个第一阶目标:让硬件工作,让系统能够支持另一个模型,让这个产品上市,支持特定的工作负载,或者让它为这个产品团队解决这个问题,对吧?没有人有机会真正地退后一步。所以,作为一个行业,我们没有向前迈出两步。我们向前迈出了,比如,18 步,就所有这些非常酷的技术而言,跨越编译器,系统,运行时和异构计算,像,所有这些东西。而且,像,所有这些技术,你知道,我不会说设计得很漂亮,但它已经在不同的象限中得到了验证。就像,你知道,你看看谷歌的 TPU,巨大的,巨大的 exaflops 的计算能力捆绑在一起,进入研究人员在笔记本电脑中用 Python 编程的机器。这是巨大的。这是惊人的。

Lex: That’s amazing. That’s incredible."

Lex: 那太神奇了。那太不可思议了。

Chris: Right? It’s incredible. And so you look at the technology that goes into that, and the algorithms are actually quite general. And so, lots of other hardware out there and lots of other teams out there don’t have the sophistication, or the, maybe the years working on it, or the budget, or whatever that Google does, right? And so, they should be getting access to the same algorithms, but they just don’t have that, right? And so, what Modular’s doing, so we’re saying, “Cool, this is not research anymore.” Like, we’ve built auto-tuning in many systems. We’ve built programming languages, right? And so, like, have implemented C++, have implemented Swift, have implemented many of these things. And so, you know, it’s hard, but it’s not research. And you look at accelerators. Well, we know there’s a bunch of different, weird kind of accelerators, but they actually cluster together, right? And you look at GPUs. Well, there’s a couple of major vendors of GPUs, and they maybe don’t always get along, but their architectures are very similar. You look at CPUs. CPUs are still super important for the deployment side of things, and you see new architectures coming out from all the cloud providers and things like this, and they’re all super important to the world, right, but they don’t have the 30 years of development that the entrenched people do, right? And so, what Modular can do is we’re saying, “Okay, all this complexity, like, it’s not bad complexity, it’s actually innovation, (chuckles) right?” And so, it’s innovation that’s happening, and it’s for good reasons, but I have sympathy for the poor software people, right? I mean, again, I’m a generally software person too. I love hardware, but software people wanna build applications and products and solutions that scale over many years. They don’t wanna build a solution for one generation of hardware with one vendor’s tools, right? And because of this, they need something that scales with them. They need something that works on cloud and mobile, right, because, you know, their product manager said, “Hey, I want it to have lower latency, and it’s better for personalization,” or whatever they decide, right? Products evolve. And so, the challenge with the machine learning technology and the infrastructure we have today in the industry is that it’s all these point solutions. And because there are all these point solutions, it means that as your product evolves, you have to, like, switch different technology stacks or switch to a different vendor. And what that does is that slows down progress."

Chris: 对吧?太不可思议了。所以,你看看其中的技术,算法实际上相当通用。所以,外面的很多其他的硬件和很多其他的团队没有这种复杂性,或者,也许没有多年的工作经验,或者预算,或者谷歌所做的任何事情,对吧?所以,他们应该可以访问相同的算法,但他们只是没有,对吧?所以,Modular 正在做的事情,所以,我们说,酷,这不再是研究了。 就像,我们已经在很多系统中构建了自动调优。我们已经构建了编程语言,对吧?所以,就像,已经实现了 C++,已经实现了 Swift,已经实现了其中很多东西。所以,你知道,这很难,但这不是研究。你看看加速器。好吧,我们知道,有很多不同的,奇怪的加速器,但它们实际上是聚集在一起的,对吧?你看看 GPU。好吧,GPU 有几个主要的供应商,他们可能并不总是相处融洽,但他们的架构非常相似。你看看 CPU。CPU 对于部署方面仍然非常重要,你会看到所有云提供商都推出了新的架构,以及类似的东西,它们对世界都非常重要,对吧,但它们没有那些根深蒂固的人所拥有的 30 年的开发经验,对吧?所以,Modular 可以做的是,我们说,好吧,所有这些复杂性,就像,它不是坏的复杂性,它实际上是创新,(轻笑) 对吧? 所以,这是正在发生的创新,而且,这是有充分理由的,但我同情那些可怜的软件人员,对吧?我的意思是,再次,我也是一个一般的软件人员。我热爱硬件,但软件人员想要构建可以扩展多年的应用程序,产品和解决方案。他们不想用一个供应商的工具为一代硬件构建一个解决方案,对吧?正因为如此,他们需要一些可以与他们一起扩展的东西。他们需要一些可以在云和移动设备上工作的东西,对吧,因为,你知道,他们的产品经理说,嘿,我希望它有更低的延迟,它更适合个性化,或者他们决定的任何东西,对吧?产品在进化。所以,我们今天在行业中拥有的机器学习技术和基础设施的挑战是,它们都是这些点解决方案。因为,有所有这些点解决方案,这意味着,随着你的产品进化,你必须,比如,切换不同的技术栈,或者切换到不同的供应商。它所做的是,它减缓了进步。

Lex: So basically, a lot of the things we’ve developed in those little silos for machine learning tasks, you want to make that the first-class citizen of a general-purpose programming language that can then be compiled across all these kinds of hardware."

Lex: 所以,基本上,我们为机器学习任务在那些小筒仓中开发的很多东西,你想让它成为一种通用编程语言的一等公民,然后可以跨所有这些类型的硬件编译。

Chris: Well, so it’s not really about a programming language. I mean, the programming language is a component of the mission, right? And the mission is, or not literal, but our joking mission is “to save the world from terrible AI software.”

Lex: Excellent. I love it.

Chris: Okay? (chuckles) So, you know, if you look at this mission, you need a syntax. So yeah, you need a programming language, right? And like, we wouldn’t have to build the programming language if one existed, right? So if Python was already good enough, then cool, we would’ve just used it, right? We’re not just doing very large-scale, expensive engineering projects for the sake of it. Like, it’s to solve a problem, right? It’s also about accelerators. It’s also about exotic numerics, and bfloat16, and matrix multiplication, and convolutions, and, like, this kinda stuff. Within the stack, there are things like kernel fusion. That’s an esoteric, but really important thing that leads to much better performance and much more general research hackability together, right?"

Chris: 好吧,所以,它实际上不是关于一种编程语言。我的意思是,编程语言是任务的一部分,对吧?任务是,或者不是字面上的,但我们开玩笑的任务是拯救世界免受可怕的人工智能软件的侵害。

Lex: 太好了。我喜欢它。

Chris: 好吗?(轻笑) 所以,你知道,如果你看看这个任务,你需要一个语法。所以,是的,你需要一种编程语言,对吧?而且,就像,如果已经存在一种编程语言,我们就不必构建它,对吧?所以,如果 Python 已经足够好了,那么,酷,我们就会直接使用它,对吧?我们不仅仅是为了它而做非常大规模的,昂贵的工程项目。就像,它是为了解决一个问题,对吧?它也是关于加速器。它也是关于奇异的数字,bfloat16,矩阵乘法,卷积,以及,像,这类东西。在栈中,有像内核融合这样的东西。这是一个深奥的,但非常重要的事情,它可以带来更好的性能和更普遍的研究可破解性,对吧?

Lex: And that’s enabled by the ASICs. That’s enabled by certain hardware. So it’s like, where’s the dance between… I mean, there’s several questions here. Like, how do you add…

Chris: Yep.

Lex: …a piece of hardware to the stack if a new piece of… like, if I have this genius invention of a specialized accelerator…

Chris: Yeah.

Lex: …how do I add that to the Modular framework? And also, how does Modular, as a standard, start to define the kinds of hardware that should be developed?"

Lex: 这是由 ASIC 实现的。这是由某些硬件实现的。所以,它就像,两者之间的舞蹈在哪里……我的意思是,这里有几个问题。就像,你如何添加……

Chris: 是的。

Lex: …一块硬件到栈中,如果一块新的……就像,如果我有一个专门的加速器的天才发明……

Chris: 是的。

Lex: …我如何将它添加到 Modular 框架中?而且,Modular 作为一种标准,是如何开始定义应该开发的硬件类型的?

Chris: Yeah, so let me take a step back and talk about status quo, okay?

Lex: Yes.

Chris: And so if you go back to TensorFlow 1, PyTorch 1, this kinda timeframe, and these have all evolved and gone way more complicated, so let’s go back to the glorious, simple days, right? These things basically were CPUs and CUDA. And so, what you do is you say, go do a dense layer. And a dense layer has a matrix multiplication in it, right? And so, when you say that you say, go do this big operation, a matrix multiplication. And if it’s on a GPU, kick off a CUDA kernel. If it’s on a CPU, go do, like, an Intel algorithm or something like that with an Intel MKL, okay? Now, that’s really cool if you’re either Nvidia or Intel, right? But then more hardware comes in, right? And on one axis, you have more hardware coming in. On the other hand, you have an explosion of innovation in AI. And so, what happened with both TensorFlow and PyTorch is that the explosion of innovation in AI has led to, it’s not just about matrix multiplication and convolution. These things have now, like, 2,000 different operators. And on the other hand, you have, I don’t know how many pieces of hardware there are out there, it’s a lot (chuckles), okay? It’s not even hundreds. It’s probably thousands, okay? And across all of the edge and across like all the different things…"

Chris: 是的,所以,让我退一步,谈谈现状,好吗?

Lex: 是的。

Chris: 所以,如果你回到 TensorFlow 1,PyTorch 1,这种时间框架,这些都进化了,变得更加复杂,所以,让我们回到光荣的,简单的日子,对吧?这些东西基本上是 CPU 和 CUDA。所以,你所做的是,你说,去做一个密集层。密集层中有一个矩阵乘法,对吧?所以,当你说的时候,你说,去做这个大的操作,矩阵乘法。如果它在 GPU 上,启动一个 CUDA 内核。如果它在 CPU 上,去做,像,一个英特尔算法,或者类似的东西,用一个英特尔 MKL,好吗?现在,如果你要么是英伟达,要么是英特尔,那真的很酷,对吧?但是,然后更多的硬件出现了,对吧?在一个轴上,你有更多的硬件出现。另一方面,人工智能的创新爆炸了。所以,TensorFlow 和 PyTorch 发生的事情是,人工智能的创新爆炸导致了,它不仅仅是矩阵乘法和卷积。这些东西现在,就像,有 2000 个不同的运算符。另一方面,你有,我不知道那里有多少块硬件,有很多 (轻笑),好吗?甚至不是数百。可能是数千,好吗?跨越所有的边缘,跨越所有不同的东西……

Lex: That are used at scale."

Lex: 那些被大规模使用的。

Chris: Yeah, exactly. I mean…

Lex: Also, it’s not just, like, a handful.

Chris: AI is everywhere. Yeah.

Lex: It’s not a handful of TPU alternatives. It’s…

Chris: Correct. It’s every phone, often with many different chips inside of it…

Lex: Right.

Chris: …from different vendors, from…

Lex: Right.

Chris: …like, AI is everywhere. It’s a thing, right?"

Chris: 是的,没错。我的意思是……

Lex: 而且,它不仅仅是,像,一小撮。

Chris: 人工智能无处不在。是的。

Lex: 它不是一小撮 TPU 替代品。它是……

Chris: 没错。它是每一部手机,通常里面有很多不同的芯片……

Lex: 对。

Chris: …来自不同的供应商,来自……

Lex: 对。

Chris: …就像,人工智能无处不在。它是一件事,对吧?

Lex: Why are they all making their own chips? Like, why is everybody making their own thing?

Chris: Well, so…

Lex: Is that a good thing, first of all?"

Lex: 为什么他们都在制造自己的芯片?就像,为什么每个人都在制造自己的东西?

Chris: 好吧,所以……

Lex: 首先,这是一件好事吗?

Chris: So Chris’s philosophy on hardware, right?"

Chris: 所以,Chris 对硬件的哲学,对吧?

Lex: Yeah.

Chris: So my philosophy is that there isn’t one right solution, right? And so, I think that, again, we’re at the end of Moore’s law, specialization happens.

Lex: Yeah.

Chris: If you’re building, if you’re training GPT-5, you want some crazy supercomputer data center thingy. If you’re making a smart camera that runs on batteries, you want something that looks very different. If you’re building a phone, you want something that looks very different. If you have something like a laptop, you want something that looks maybe similar but a different scale, right? And so, AI ends up touching all of our lives. Robotics, right? And, like, lots of different things. And so, as you look into this, these have different power envelopes. There’s different trade-offs in terms of the algorithms. There’s new innovations in sparsity and other data formats and things like that. And so, hardware innovation, I think, is a really good thing, right? And what I’m interested in is unlocking that innovation. There’s also, like, analog and quantum and, like, all the really weird stuff, right?"

Lex: 是的。

Chris: 所以,我的哲学是,没有一个正确的解决方案,对吧?所以,我认为,再次,我们正处于摩尔定律的终结,专业化正在发生。

Lex: 是的。

Chris: 如果你正在构建,如果你正在训练 GPT-5,你想要一些疯狂的超级计算机数据中心的东西。如果你正在制造一个用电池供电的智能相机,你想要一些看起来非常不同的东西。如果你正在构建一部手机,你想要一些看起来非常不同的东西。如果你有一个像笔记本电脑这样的东西,你想要一些看起来可能相似但规模不同的东西,对吧?所以,人工智能最终会触及我们所有人的生活。机器人,对吧?而且,像,很多不同的东西。所以,当你深入研究这个问题的时候,你会发现它们有不同的功耗范围。在算法方面,有不同的权衡。在稀疏性和其他数据格式方面,有新的创新。所以,我认为,硬件创新是一件非常好的事情,对吧?我感兴趣的是释放这种创新。还有,像,模拟和量子,以及,像,所有真正奇怪的东西,对吧?

Lex: Yeah.

Chris: And so, if somebody can come up with a chip that uses analog computing, and it’s 100x more power efficient, think what that would mean in terms of the daily impact on the products we use. That’d be huge. Now, if you’re building an analog computer, you may not be a compiler specialist, right? These are different skillsets, right? And so you can hire some compiler people if you’re running a big company, maybe, but it turns out these are really, like, exotic new generations of compilers. (chuckles) Like, this is a different thing, right? So if you take a step back out, and come back to what is the status quo, the status quo is that if you’re Intel or you’re Nvidia, you keep up with the industry, and you chase, and, okay, there’s 1,900 now, there’s 2,000 now, there’s 2,100. And you have a huge team of people that are, like, trying to keep up and tune and optimize. And even when one of the big guys comes out with a new generation of their chip, they have to go back and rewrite all these things, right? So, really, it’s only powered by having hundreds of people that are all, like, frantically trying to keep up. And what that does is that keeps out the little guys, and sometimes they’re not so little guys, the big guys that are also just not in those dominant positions. And so, what has been happening, and so you talk about the rise of new exotic, crazy accelerators, is people have been trying to turn this from a, “Let’s go write lots of special kernels” problem into a compiler problem. And so we, and I contributed to this as well, (chuckles) we, as an industry, went into a, like, “Let’s go make this a compiler problem” phase, let’s call it. And much of the industry is still in this phase, by the way. So I wouldn’t say this phase is over. And so the idea is to say, look, okay, what a compiler does is it provides a much more general, extensible, hackable interface for dealing with the general case, right? And so, within machine learning algorithms, for example, people figured out that, hey, if I do a matrix multiplication, and I do a ReLU, right, the classic activation function, it is way faster to do one pass over the data and then do the ReLU on the output where I’m writing out the data, ‘cause ReLU is just a maximum operation, right? Max at zero. And so it’s an amazing optimization. Take MatMul, ReLU, squished together in one operation, now I have MatMul ReLU. Well, wait a second. If I do that, now, I just went from having, you know, two operators to three. But now I figure out, okay, well, there’s a lot of activation functions. What about a leaky value? What about… like, a million things that are out there, right? And so, as I start fusing these in, now I get permutations of all these algorithms, right? And so what the compiler people said is they said, “Hey, well, cool. Well, I will go enumerate all the algorithms, and I will enumerate all the pairs, and I will actually generate a kernel for you.” And I think that this has been very, very useful for the industry. This is one of the things that powers Google TPUs. PyTorch 2’s, like, rolling out really cool compiler stuff with Triton, this other technology, and things like this. And so the compiler people are kind of coming into their fore and saying, like, “Awesome, this is a compiler problem. We’ll compile it.” Here’s the problem. (chuckles) Not everybody’s a compiler person. I love compiler people, trust me, right? But not everybody can, or should be, a compiler person. It turns out that there are people that know analog computers really well, or they know some GPU internal architecture thing really well, or they know some crazy, sparse, numeric, interesting algorithm that is the cusp of research, but they’re not compiler people. And so one of the challenges with this new wave of technology trying to turn everything into a compiler, ‘cause again, it has excluded a ton of people. And so you look at what does Mojo do, what does the Modular stack do, it brings programmability back into this world. Like, it enables, I wouldn’t say normal people, but, like, a new, you know, a different kind of delightful nerd that cares about numerics, or cares about hardware, or cares about things like this, to be able to express that in the stack and extend the stack without having to actually go hack the compiler itself."

Lex: 是的。

Chris: 所以,如果有人能想出一个使用模拟计算的芯片,而且它的功率效率提高了 100 倍,想想这对我们日常使用的产品意味着什么。那将是巨大的。现在,如果你正在构建一台模拟计算机,你可能不是一个编译器专家,对吧?这些是不同的技能,对吧?所以,如果你正在经营一家大公司,你也许可以雇佣一些编译器人员,但事实证明,这些都是真正奇异的新一代编译器。(轻笑) 就像,这是一件不同的事情,对吧?所以,如果你退后一步,回到现状是什么,现状是,如果你是英特尔,或者你是英伟达,你跟上行业,你追赶,而且,好吧,现在有 1900 个,现在有 2000 个,现在有 2100 个。你有一个庞大的团队,就像,试图跟上,调整和优化。即使当一个大公司推出了他们芯片的新一代,他们也不得不回去重写所有这些东西,对吧?所以,真的,它只是由数百人提供动力,他们都像,疯狂地试图跟上。它所做的是,它排斥了小公司,有时,他们不是那么小的公司,大公司也恰好不在那些主导地位。所以,正在发生的事情,所以,你谈论的是新的奇异的,疯狂的加速器的兴起,是人们一直在试图把这个问题从一个让我们去写很多特殊的内核问题变成一个编译器问题。所以,我们,我也为此做出了贡献,(轻笑) 我们,作为一个行业,进入了一个,比如,让我们把它变成一个编译器问题阶段,让我们这样称呼它。顺便说一下,这个行业的大部分仍然处于这个阶段。所以我不会说这个阶段已经结束了。所以,这个想法是说,看,好吧,编译器所做的是,它提供了一个更通用的,可扩展的,可破解的接口,来处理一般情况,对吧?所以,例如,在机器学习算法中,人们发现,嘿,如果我做一个矩阵乘法,我做一个 ReLU,对吧,经典的激活函数,对数据进行一次传递,然后对输出进行 ReLU,在那里我写出数据,要快得多,因为 ReLU 只是一个最大值运算,对吧?最大值为零。所以,这是一个惊人的优化。取 MatMul,ReLU,在一个操作中压缩在一起,现在我有 MatMul ReLU。好吧,等一下。如果我这样做,现在,我刚刚从,你知道,两个运算符到三个。但现在我发现,好吧,有很多激活函数。那么泄漏值呢?那么……像,外面有一百万个东西,对吧?所以,当我开始融合这些,现在我得到了所有这些算法的排列,对吧?所以,编译器人员说的是,他们说,嘿,好吧,酷。好吧,我会枚举所有的算法,我会枚举所有的对,我实际上会为你生成一个内核。 我认为,这对这个行业非常有用。这是为谷歌 TPU 提供动力的东西之一。PyTorch 2,像,用 Triton 推出了非常酷的编译器,这种其他的技术,以及类似的东西。所以,编译器人员有点走到了前台,说,像,太棒了,这是一个编译器问题。我们会编译它。 问题来了。(轻笑) 不是每个人都是编译器人员。我爱编译器人员,相信我,对吧?但不是每个人都能,或者应该,成为编译器人员。事实证明,有些人非常了解模拟计算机,或者他们非常了解一些 GPU 内部架构,或者他们知道一些疯狂的,稀疏的,数字的,有趣的算法,这是研究的尖端,但他们不是编译器人员。所以,这一波新技术试图将一切都变成编译器的挑战之一是,因为它再次排斥了很多人。所以,你看看 Mojo 做了什么,Modular 栈做了什么,它把可编程性带回了这个世界。就像,它使,我不会说普通人,但,像,一个新的,你知道,一个不同的类型的令人愉快的书呆子,关心数字,或者关心硬件,或者关心类似的东西,能够在栈中表达,并扩展栈,而不需要真正去破解编译器本身。

Lex: So extend the stack on the algorithm side.

Chris: Yeah.

Lex: And then on the hardware side.

Chris: Yeah. So again, go back to, like, the simplest example of int, right? And so, what both Swift and Mojo and other things like this did is we said, okay, pull magic out of the compiler and put it in the standard library, right? And so, what Modular’s doing with the engine that we’re providing, and, like, this very deep technology stack, right, which goes into heterogeneous runtimes and, like, a whole bunch of really cool, really cool things, this whole stack allows that stack to be extended and hacked and changed by researchers and by hardware innovators and by people who know things that we don’t know (chuckles) ‘cause, you know, Modular has some smart people, but we don’t have all the smart people, it turns out, right?"

Lex: 所以在算法方面扩展栈。

Chris: 是的。

Lex: 然后在硬件方面。

Chris: 是的。所以,再次,回到,比如,int 最简单的例子,对吧?所以,Swift 和 Mojo,以及其他类似的东西所做的是,我们说,好吧,把魔法从编译器中拉出来,放到标准库中,对吧?所以,Modular 用我们提供的引擎正在做的事情,以及,像,这个非常深的技术栈,对吧,它进入异构运行时,以及,像,一大堆非常酷的,非常酷的东西,整个栈允许研究人员,硬件创新者,以及知道我们不知道的事情的人扩展,破解和改变那个栈 (轻笑) 因为,你知道,Modular 有一些聪明的人,但事实证明,我们没有所有聪明的人,对吧?

Lex: What are heterogeneous runtimes?"

Lex: 什么是异构运行时?

Chris: Yeah. So what is heterogeneous, right? So heterogeneous just means many different kinds of things together. And so, the simplest example you might come up with is a CPU and a GPU. And so it’s a simple heterogeneous computer to say, “I’ll run my data loading and preprocessing and other algorithms on the CPU. And then once I get it into the right shape, I shove it into the GPU. I do a lot of matrix multiplication and convolutions and things like this. And then I get it back out, and I do some reductions and summaries, and I shove it across the wire, to, across the network, to another machine,” right? And so you’ve got now what are effectively two computers, a CPU and a GPU, talking to each other, working together in a heterogeneous system. But that was 10 years ago (chuckles), okay? You look at a modern cell phone. A modern cell phone, you’ve got CPUs, and they’re not just CPUs, there’s like big.LITTLE CPUs, and there’s multiple different kinds of CPUs that are kind…"

Chris: 是的。所以,什么是异构的,对吧?所以,异构的意思是,很多不同类型的东西在一起。所以,你可能想到的最简单的例子是 CPU 和 GPU。所以,这是一台简单的异构计算机,说,我将在 CPU 上运行我的数据加载,预处理和其他算法。然后,一旦我把它变成正确的形状,我就把它塞进 GPU。我做很多矩阵乘法,卷积,以及类似的东西。然后,我把它拿出来,我做一些简化和总结,我把它推到电线上,到,跨网络,到另一台机器,对吧?所以,你现在有了两台计算机,CPU 和 GPU,它们互相交谈,在一个异构系统中一起工作。但那是 10 年前的事情了 (轻笑),好吗?你看看现代手机。现代手机,你有 CPU,而且,它们不仅仅是 CPU,还有像 big.LITTLE CPU,还有多种不同类型的 CPU,它们有点像……

Lex: Yep.

Chris: …of working together. They’re multi-core. You’ve got GPUs, you’ve got neural network accelerators, you’ve got dedicated hardware blocks for media, so for video decode and JPEG decode and things like this. And so you’ve got this massively complicated system, and this isn’t just cell phones. Every laptop these days is doing the same thing. And all these blocks can run at the same time and need to be choreographed, right? And so again, one of the cool things about machine learning is it’s moving things to like dataflow graphs and a higher level of abstractions, and tensors, and these things that it doesn’t specify, “Here’s how to do the algorithm.” It gives the system a lot more flexibility in terms of how to translate or map it or compile it onto the system that you have. And so, what you need, you know, the bottom-est part of the layer there, is a way for all these devices to talk to each other. And so, this is one thing that, you know, I’m very passionate about. I mean, you know, I’m a nerd, but all these machines and all these systems are effectively parallel computers running at the same time, sending messages to each other. And so they’re all fully asynchronous. Well, this is actually a small version of the same problem you have in a data center, right? In a data center, you now have multiple different machines, sometimes very specialized, sometimes with GPUs or TPUs in one node and sometimes with disks in other nodes. And so, you get a much larger-scale heterogeneous computer. And so, what ends up happening is you have this, like, multi-layer abstraction of hierarchical parallelism, hierarchical, asynchronous communication, and making that, again, my enemy, is complexity. By getting that away from being different specialized systems at every different part of the stack, and having more consistency and uniformity, I think we can help lift the world and make it much simpler and actually get used."

Lex: 是的。

Chris: …一起工作。它们是多核的。你有 GPU,你有神经网络加速器,你有专门的媒体硬件块,所以,用于视频解码,JPEG 解码,以及类似的东西。所以,你有了这个极其复杂的系统,这不仅仅是手机。现在,每台笔记本电脑都在做同样的事情。所有这些块都可以同时运行,并且需要编排,对吧?所以,再次,关于机器学习的一件很酷的事情是,它正在将事情转移到数据流图和更高级别的抽象,以及张量,以及这些它没有指定的东西,这是如何做算法的。 它给了系统更多的灵活性,就如何翻译或映射它,或编译它到你的系统上。所以,你需要,你知道,那里最底层的,是所有这些设备互相交谈的一种方式。所以,这是一件,你知道,我非常热衷的事情。我的意思是,你知道,我是一个书呆子,但所有这些机器,所有这些系统,实际上都是并行计算机,同时运行,互相发送消息。所以,它们都是完全异步的。好吧,这实际上是你数据中心中遇到的相同问题的缩小版,对吧?在数据中心,你现在有多台不同的机器,有时非常专业化,有时在一个节点中有 GPU 或 TPU,有时在其他节点中有磁盘。所以,你得到了一台更大规模的异构计算机。所以,最终发生的事情是,你有了这个,像,多层抽象的层次并行,层次的,异步通信,并使它,再次,我的敌人,是复杂性。通过让它远离栈中每个不同部分的不同专业化系统,并拥有更多的一致性和统一性,我认为,我们可以帮助提升世界,使它更简单,并真正地被使用。

Lex: Well, how do you leverage, like, the strengths of the different specialized systems? So, looking inside the smartphone, like, there’s, what, like…

Chris: Yeah.

Lex: …I don’t know, five, six computers essentially inside the smartphone?"

Lex: 好吧,你如何利用,比如,不同专业化系统的优势?所以,看看智能手机内部,比如,有,像……

Chris: 是的。

Lex: …我不知道,基本上有五,六台计算机在智能手机内部?

Chris: Yeah.

Lex: How do you, without trying to minimize the explicit, making it explicit which computer is supposed to be used for which operation?"

Chris: 是的。

Lex: 你是如何,在不试图最小化显式的情况下,使它显式地说明哪台计算机应该用于哪个操作的?

Chris: Yeah. So there’s a pretty well-known algorithm, and what you’re doing is you’re looking at two factors. You’re looking at the factor of sending data from one thing to another, right, ‘cause it takes time to get it from that side of the chip to that side of the chip and things like this. And then, you’re looking at what is the time it takes to do an operation on a particular block. So take CPUs. CPUs are fully general. They can do anything, right? But then you have a neural net accelerator that’s really good at matrix multiplication, okay? And so, you say, okay, well, if my workload is all matrix multiplication, I start up, I send the data over the neural net thing, it goes and does matrix multiplication. When it’s done, it sends me back the result. All is good, right? And so, the simplest thing is just saying, do matrix operations over there, right? But then you realize you get a little bit more complicated because you can do matrix multiplication on a GPU, you can do it on a neural net accelerator, you can do it on CPU, and they’ll have different trade-offs and costs, and it’s not just matrix multiplication. And so, what you actually look at is you look at, I have generally a graph of compute. I wanna do a partitioning. I wanna look at the communication, the bisection bandwidth, and, like, the overhead…

Lex: Overheads.

Chris: …and the sending of all these different things, and build a model for this and then decide, okay, it’s an optimization problem of where do I wanna place this compute?"

Chris: 是的。所以,有一个非常著名的算法,你正在做的是,你正在看两个因素。你正在看将数据从一个东西发送到另一个东西的因素,对吧,因为它需要时间才能从芯片的那一边到芯片的这一边,以及类似的东西。然后,你正在看在一个特定的块上执行一个操作需要多长时间。所以,以 CPU 为例。CPU 是完全通用的。它们可以做任何事情,对吧?但是,你有一个神经网络加速器,它非常擅长矩阵乘法,好吗?所以,你说,好吧,如果我的工作负载都是矩阵乘法,我启动,我将数据发送到神经网络的东西,它去执行矩阵乘法。当它完成后,它将结果发送给我。一切都很好,对吧?所以,最简单的事情就是说,在那里做矩阵运算,对吧?但是,然后你意识到,它变得有点复杂,因为你可以在 GPU 上做矩阵乘法,你可以在神经网络加速器上做,你可以在 CPU 上做,它们会有不同的权衡和成本,而且,不仅仅是矩阵乘法。所以,你实际上看的是,你看,我通常有一个计算图。我想做一个划分。我想看看通信,二分带宽,以及,像,开销……

Lex: 开销。

Chris: …以及所有这些不同东西的发送,并为此构建一个模型,然后决定,好吧,这是一个优化问题,我想把这个计算放在哪里?

Lex: So it’s the old-school theoretical computer science problem of scheduling.

Chris: Yep.

Lex: And then, presumably, it’s possible to, somehow, magically include auto-tune into this.

Chris: Absolutely. So, I mean, in my opinion, this is an opinion, not everybody would agree with this, but in my opinion, the world benefits from simple and predictable systems at the bottom you can control. But then once you have a predictable execution layer, you can build lots of different policies on top of it, right? And so one policy can be that the human programmer says, “Do that here, do that here, do that here, do that here,” and, like, fully manually controls everything, and the systems should just do it, right? But then you quickly get in the mode of like, I don’t wanna have to tell it to do it (chuckles)."

Lex: 所以,这是老派的理论计算机科学中的调度问题。

Chris: 是的。

Lex: 然后,大概,有可能,以某种方式,神奇地将自动调优包含进去。

Chris: 绝对的。所以,我的意思是,在我看来,这是一个观点,不是每个人都会同意这一点,但在我看来,世界受益于底部简单且可预测的系统,你可以控制。但是,一旦你有一个可预测的执行层,你就可以在它上面构建很多不同的策略,对吧?所以,一种策略可以是,人类程序员说,在这里做,在这里做,在这里做,在这里做,而且,像,完全手动控制一切,系统应该只是去做,对吧?但是,然后你很快就会进入这样的模式,比如,我不想告诉它去做 (轻笑)。

Lex: Yeah.

Chris: And so, the next logical step that people typically take is they write some terrible heuristic. “Oh, if it’s a MatMul operation, do it over there. Or if it’s floating-point, do it on the GPU. If it’s integer, do it on the CPU,” like, something like that, right? And then you then get into this mode of, like, people care more and more and more, and you say, okay, well, let’s actually, like, make the heuristic better. Let’s get into auto-tuning. Let’s actually do a search of the space to decide, well, what is actually better, right? Well, then you get into this problem where you realize this is not a small space. This is a many-dimensional, hyperdimensional space that you cannot exhaustively search. So do you know of any algorithms that are good at searching very complicated spaces for…"

Lex: 是的。

Chris: 所以,人们通常采取的下一个逻辑步骤是,他们写一些可怕的启发式方法。哦,如果它是一个 MatMul 操作,就在那里做。或者,如果它是浮点数,就在 GPU 上做。如果它是整数,就在 CPU 上做,像这样的东西,对吧?然后,你就进入了这种模式,比如,人们越来越关心,你说,好吧,让我们实际上,像,让启发式方法更好。让我们进入自动调优。让我们实际上对空间进行搜索,以决定,好吧,什么实际上更好,对吧?好吧,然后你就进入了这个问题,你意识到,这不是一个小空间。这是一个多维的,超维的空间,你不能穷举搜索。所以,你知道有任何算法擅长在非常复杂的空间中搜索……

Lex: Don’t tell me you’re gonna turn this into a machine learning problem.

Chris: So then you turn it into a machine learning problem, and then you have a space of genetic algorithms and reinforcement learning and, like, all these concerns."

Lex: 别告诉我你要把它变成一个机器学习问题。

Chris: 所以,然后你把它变成一个机器学习问题,然后你就有了一个遗传算法和强化学习的空间,以及,像,所有这些问题。

Lex: Can you include that into the stack, into the Modular stack?

Chris: Yeah, yeah. And so…

Lex: Where does it sit? Where does it live? Is it a separate thing, or is it part of the compilation?"

Lex: 你能把它包含在栈中,Modular 栈中吗?

Chris: 是的,是的。所以……

Lex: 它在哪里?它住在哪里?它是独立的东西,还是编译的一部分?

Chris: So you start from simple and predictable models. And so you can have full control, and you can have coarse-grain knobs that, like, nudge systems so you don’t have to do this. But if you really care about getting the best, you know, the last ounce out of a problem, then you can use additional tools. The cool thing is you don’t wanna do this every time you run a model. You wanna figure out the right answer and then cache it. (chuckles) And once you do that, you can say, okay, cool. Well, I can get up and running very quickly. I can get good execution out of my system. I can decide if something’s important, and if it’s important, I can go throw a bunch of machines at it and do a big, expensive search over the space using whatever technique I feel like. It’s really up to the problem. And then when I get the right answer, cool, I can just start using it, right? And so, you can get out of this, this trade-off between, okay, am I gonna, like, spend forever doing a thing or do I get up and running quickly? And as a quality result, like, these are actually not in contention with each other if the system’s designed to scale."

Chris: 所以,你从简单且可预测的模型开始。所以,你可以完全控制,你可以有粗粒度的旋钮,比如,轻推系统,这样你就不用这样做了。但是,如果你真的关心获得最好的结果,你知道,从一个问题中榨取最后一滴,那么你可以使用额外的工具。很酷的是,你不想每次运行模型的时候都这样做。你想找到正确的答案,然后缓存它。(轻笑) 一旦你这样做了,你就可以说,好吧,酷。好吧,我可以很快地启动并运行。我可以从我的系统中获得良好的执行。我可以决定一些东西是否重要,如果它重要,我可以向它扔一堆机器,用我喜欢的任何技术对空间进行一次大的,昂贵的搜索。这真的取决于问题。然后,当我得到正确的答案时,酷,我可以直接开始使用它,对吧?所以,你可以摆脱这种,这种权衡,好吧,我是否要,像,永远地做一件事,或者我是否要快速地启动并运行?作为一个高质量的结果,像,如果系统设计成可扩展的,这些实际上并不互相争夺。

Lex: You started and did a little bit of a whirlwind overview of how you get the 35,000x speed-up or more over Python. Jeremy Howard did a really great presentation about sort of the basic, like, looking at the code, here’s how you get the speed-up. Like you said, that’s something probably developers can do for their own code to see how you can get these gigantic speed-ups. But can you maybe speak to the machine learning task in general? How do you make some of this code fast, and specifics. Like, what would you say is the main bottleneck for machine learning tasks? So are we talking about MatMul, matrix multiplication? How do you make that fast?"

Lex: 你开始做了一个关于如何获得比 Python 快 35000 倍或更多的速度的旋风式概述。Jeremy Howard 做了一个非常棒的演示,关于基本的,比如,看着代码,这是你如何获得速度提升的。就像你说的,这可能是开发人员可以为他们自己的代码做的事情,看看如何获得这些巨大的速度提升。但是,你能不能大体上谈谈机器学习任务?你如何使这些代码中的一部分变得更快,以及具体的细节。比如,你会说机器学习任务的主要瓶颈是什么?所以,我们是在谈论 MatMul,矩阵乘法吗?你如何使它变得更快?

Chris: So I mean, if you just look at the Python problem, right? You can say, “How do I make Python faster?” And there’s been a lot of people that have been working on the, “Okay, how do I make Python 2x faster, or 10x faster, or something like that,” right? And there’ve been a ton of projects in that vein, right? Mojo started from the, “What can the hardware do?” Like, what is the limit of physics? What is the speed of light?

Lex: Yeah. What is the…

Chris: Yeah, yeah.

Lex: …like, how fast can this thing go? And then, how do I express that, right?"

Chris: 所以,我的意思是,如果你只看 Python 问题,对吧?你可以说,我如何使 Python 变得更快? 而且,有很多一直在研究这个问题的人,好吧,我如何使 Python 变得快 2 倍,或者快 10 倍,或者类似的东西,对吧?而且,有很多这方面的项目,对吧?Mojo 从,硬件能做什么? 开始。比如,物理的极限是什么?光速是多少?

Lex: 是的。什么是……

Chris: 是的,是的。

Lex: …比如,这东西能跑多快?然后,我如何表达它,对吧?

Chris: Yeah.

Lex: And so it wasn’t anchored relatively on, “Make Python a little bit faster.” It’s saying, “Cool, I know what the hardware can do. Let’s unlock that,” right?"

Chris: 是的。

Lex: 所以,它并没有相对地锚定在,让 Python 稍微快一点。 它说的是,酷,我知道硬件能做什么。让我们解锁它,对吧?

Chris: I mean, maybe I’m a special kinda nerd, but you look at that, what is the limit of physics? How fast can these things go, right? When you start looking at that, typically it ends up being a memory problem, right? And so today, particularly with these specialized accelerators, the problem is that you can do a lot of math within them, but you get bottlenecked sending data back and forth to memory, whether it be local memory, or distant memory, or disk, or whatever it is. And that bottleneck, particularly as the training sizes get large, as you start doing tons of inferences all over the place, like, that becomes a huge bottleneck for people, right? So again, what happened is we went through a phase of many years where people took the special case and hand-tuned it and tweaked it and tricked it out, and they knew exactly how the hardware worked and they knew the model, and they made it fast. Didn’t generalize. (chuckles) And so you can make, you know, ResNet-50 or AlexNet, or something, Inception v1, like, you can do that, right? Because the models are small, they fit in your head, right? But as the models get bigger, more complicated, as the machines get more complicated, it stops working, right? And so this is where things like kernel fusion come in. So what is kernel fusion? This is this idea of saying, “Let’s avoid going to memory, and let’s do that by building a new hybrid kernel and a numerical algorithm that actually keeps things in the accelerator” instead of having to write it all the way out to memory, right? What’s happened with these accelerators now is you get multiple levels of memory. Like in a GPU, for example, you’ll have global memory and local memory, and, like, all these things. If you zoom way into how hardware works, the register file is actually a memory. (chuckles) So the registers are like an L0 cache. And so, a lot of taking advantage of the hardware ends up being fully utilizing the full power in all of its capability. And this has a number of problems, right? One of which is again, the complexity of disaster, right? There’s too much hardware. Even if you just say, “Let’s look at the chips from one line of vendor, like Apple, or Intel, or whatever it is,” each version of the chip comes out with new features, and they change things so that it takes more time or less to do different things, and you can’t rewrite all the software whenever a new chip comes out, right? And so, this is where you need a much more scalable approach. And this is what Mojo and what the Modular stack provides, is it provides this infrastructure and the system for factoring all this complexity and then allowing people to express algorithms, you talk about auto-tuning, for example, express algorithms in a more portable way so that when a new chip comes out, you don’t have to rewrite it all. So to me, like, you know, I kinda joke, like, what is a compiler? Well, there’s many ways to explain that. You convert thing A into thing B and you convert source code to machine code. Like, you can talk about many, many things that compilers do, but to me, it’s about a bag of tricks. It’s about a system and a framework that you can hang complexity. It’s a system that can then generalize, and it can work on problems that are bigger than fit in one human’s head. (chuckles) Right? And so, what that means, what a good stack and what the Modular stack provides, is the ability to walk up to it with a new problem, and it’ll generally work quite well. And that’s something that a lot of machine learning infrastructure and tools and technologies don’t have. Typical state-of-the-art today is you walk up, particularly if you’re deploying, if you walk up with a new model, you try to push it through the converter, and the converter crashes. That’s crazy. The state of ML tooling today is not anything that a C programmer would ever accept, right? And it’s always been this kind of flaky set of tooling that’s never been integrated well, and it’s never worked together because it’s not designed together. It’s built by different teams, it’s built by different hardware vendors, it’s built by different systems, it’s built by different internet companies. They’re trying to solve their problems, right? And so that means that we get this fragmented, terrible mess of complexity."

Chris: 是的。

Lex: 所以,它并没有相对地锚定在,让 Python 稍微快一点。 它说的是,酷,我知道硬件能做什么。让我们解锁它,对吧?

Chris: 我的意思是,也许我是一个特殊类型的书呆子,但你看看,物理的极限是什么?这些东西能跑多快,对吧?当你开始研究这个问题的时候,它通常会变成一个内存问题,对吧?所以,今天,特别是对于这些专门的加速器,问题是,你可以在它们内部做很多数学运算,但是,你发送数据到内存,无论是本地内存,还是远程内存,还是磁盘,或者其他什么,都会遇到瓶颈。这个瓶颈,特别是当训练规模变大的时候,当你开始在各个地方做大量的推理的时候,就像,这对人们来说变成了一个巨大的瓶颈,对吧?所以,再次,发生的事情是,我们经历了一个多年的阶段,人们采取了特殊情况,手工调整它,调整它,并把它调整出来,他们确切地知道硬件是如何工作的,他们知道模型,他们使它变得更快。没有泛化。(轻笑) 所以,你可以做,你知道,ResNet-50 或 AlexNet,或者其他什么,Inception v1,像,你可以做到,对吧?因为模型很小,它们适合你的脑袋,对吧?但是,随着模型变得更大,更复杂,随着机器变得更复杂,它就停止工作了,对吧?所以,这就是像内核融合这样的东西出现的地方。什么是内核融合?这是一个这样的想法,说,让我们避免去内存,让我们通过构建一个新的混合内核和一个数字算法来做到这一点,它实际上将东西保存在加速器中,而不是必须一直写到内存中,对吧?现在,这些加速器发生的事情是,你得到了多级内存。比如,在 GPU 中,例如,你会有全局内存和本地内存,以及,像,所有这些东西。如果你放大到硬件的工作原理,寄存器文件实际上是一个内存。(轻笑) 所以,寄存器就像一个 L0 缓存。所以,很多利用硬件的优势最终都是充分利用其全部能力的全部力量。这有很多问题,对吧?其中一个是,再次,灾难的复杂性,对吧?硬件太多了。即使你只是说,让我们看看来自一个供应商的芯片,比如苹果,或者英特尔,或者其他什么,芯片的每个版本都会有新的功能,他们会改变东西,这样它做不同的事情需要更多的时间或更少的时间,而且,你不能每次新芯片出来的时候都重写所有的软件,对吧?所以,这就是你需要一个更可扩展的方法的地方。这就是 Mojo 和 Modular 栈所提供的,它提供了这个基础设施和系统,用于分解所有这些复杂性,然后允许人们表达算法,例如,你谈论自动调优,以一种更可移植的方式表达算法,这样当新芯片出来的时候,你就不必重写所有东西。所以,对我来说,就像,你知道,我有点开玩笑,比如,什么是编译器?好吧,有很多方法可以解释。你将 A 转换成 B,你将源代码转换成机器代码。就像,你可以谈论编译器做的很多,很多事情,但对我来说,它是一个技巧包。它是一个系统,一个框架,你可以挂上复杂性。它是一个系统,它可以泛化,它可以处理比一个人脑袋里更大的问题。(轻笑) 对吧?所以,这意味着,一个好的栈和 Modular 栈所提供的,是能够带着一个新的问题走到它面前,它通常会工作得很好。这是很多机器学习基础设施,工具和技术所没有的东西。今天典型的最先进的技术是,你走上前去,特别是如果你正在部署,如果你带着一个新的模型走上前去,你试图把它推到转换器中,转换器崩溃了。那太疯狂了。今天,ML 工具的状态不是任何 C 程序员能够接受的,对吧?它一直是这种不稳定的工具集,从来没有很好地集成,而且,它从来没有一起工作过,因为它不是一起设计的。它是由不同的团队构建的,它是由不同的硬件供应商构建的,它是由不同的系统构建的,它是由不同的互联网公司构建的。他们正在试图解决他们的问题,对吧?所以,这意味着,我们得到了这个支离破碎的,可怕的复杂性混乱。

Lex: So I mean, the specifics of, and Jeremy showed this…

Chris: Yeah.

Lex: …there’s the vectorized function, which I guess is built into Mojo?

Chris: Vectorized, as he showed, is built into the library.

Lex: Into the library, it’s done in the library.

Chris: Yep.

Lex: Vectorize, parallelize.

Chris: Yep.

Lex: Which vectorize is more low-level, parallelize is higher level. There’s the tiling thing, which is how he demonstrated the auto-tune, I think."

Lex: 所以,我的意思是,具体的,Jeremy 展示了这个……

Chris: 是的。

Lex: …有向量化函数,我想它是内置在 Mojo 中的?

Chris: 向量化,正如他展示的,是内置在库中的。

Lex: 在库中,它是在库中完成的。

Chris: 是的。

Lex: 向量化,并行化。

Chris: 是的。

Lex: 哪个向量化更低级,并行化更高级。有 tiling 的东西,我认为这是他演示自动调优的方式。

Chris: So think about this in, like, levels, hierarchical levels of abstraction, right? If you zoom all the way into a compute problem, you have one floating-point number, right? And so then you say, okay, I can do things one at a time in an interpreter. (chuckles) It’s pretty slow, right? So I can get to doing one at a time in a compiler, like in C. I can get to doing 4, or 8 or 16 at a time with vectors. That’s called vectorization. Then you can say, “Hey, I have a whole bunch of different… you know, what a multi-core computer is is it’s basically a bunch of computers, right? So they’re all independent computers that they can talk to each other, and they share memory.” And so now what parallelize does is says, okay, run multiple instances on different computers, and now, they can all work together in parallel, right? And so what you’re doing is you’re saying, keep going out to the next level out. And as you do that, how do I take advantage of this? So tiling is a memory optimization, right? It says, okay, let’s make sure that we’re keeping the data close to the compute part of the problem instead of sending it all back and forth through memory every time I load a block."

Chris: 所以,想想这个,比如,层次,抽象的层次层次,对吧?如果你一路放大到一个计算问题,你有一个浮点数,对吧?然后你说,好吧,我可以在解释器中一次做一件事。(轻笑) 它很慢,对吧?所以,我可以在编译器中一次做一件事,比如在 C 中。我可以使用向量一次做 4 个,或者 8 个,或者 16 个。这叫做向量化。然后你可以说,嘿,我有一大堆不同的……你知道,多核计算机基本上就是一堆计算机,对吧?所以,它们都是独立的计算机,它们可以互相交谈,它们共享内存。 所以,现在,并行化所做的是说,好吧,在不同的计算机上运行多个实例,现在,它们都可以并行地一起工作,对吧?所以,你正在做的是,你说,继续向外走,到下一个层次。当你这样做的时候,我如何利用这个优势?所以,tiling 是内存优化,对吧?它说,好吧,让我们确保我们将数据保持在问题的计算部分附近,而不是每次我加载一个块的时候都通过内存来回发送。

Lex: And the size of the block, size is, that’s how you get to the auto-tune to make sure it’s optimized.

Chris: Right, yeah. Well, so all of these, the details matter so much to get good performance. This is another funny thing about machine learning and high-performance computing that is very different than C compilers we all grew up with, where, you know, if you get a new version of GCC or a new version of Clang or something like that, you know, maybe something will go 1% faster, right? And so, compiler engineers will work really, really, really hard to get half a percent out of your C code, something like that. But when you’re talking about an accelerator, or an AI application, or you’re talking about these kinds of algorithms, now these are things people used to write in Fortran, for example, right? If you get it wrong, it’s not 5% or 1%, it could be 2x or 10x, (chuckles) right? If you think about it, you really want to make use of the full memory you have, the cache, for example. But if you use too much space, it doesn’t fit in the cache. Now you’re gonna be thrashing all the way back out to main memory. And these can be 2x, 10x, major performance differences. And so this is where getting these magic numbers and these things right is really actually quite important."

Lex: 块的大小,大小是,这就是你如何进行自动调优以确保它被优化的。

Chris: 对,是的。好吧,所以,所有这些,细节都很重要,以获得良好的性能。这是关于机器学习和高性能计算的另一个有趣的事情,它与我们从小到大使用的 C 编译器非常不同,在那里,你知道,如果你得到一个新版本的 GCC,或者一个新版本的 Clang,或者类似的东西,你知道,也许一些东西会快 1%,对吧?所以,编译器工程师会非常,非常,非常努力地从你的 C 代码中获得 0.5%,类似这样的东西。但是,当你谈论一个加速器,或者一个 AI 应用程序,或者你谈论的是这些类型的算法,现在,这些是人们过去用 Fortran 编写的东西,例如,对吧?如果你弄错了,它不是 5% 或 1%,它可能是 2 倍或 10 倍,(轻笑) 对吧?如果你想想,你真的想充分利用你拥有的所有内存,例如缓存。但是,如果你使用了太多的空间,它不适合缓存。现在,你将一直 thrashing 回到主内存。这些可能是 2 倍,10 倍,主要的性能差异。所以,这就是获得这些魔法数字和这些东西的正确性实际上非常重要的地方。

Lex: So you mentioned that Mojo is a superset of Python. Can you run Python code as if it’s Mojo code?"

Lex: 所以,你提到了 Mojo 是 Python 的超集。你能像运行 Mojo 代码一样运行 Python 代码吗?

Chris: Yes, yes, (Lex chuckling) and this has two sides of it. So Mojo’s not done yet. So I’ll give you a disclaimer. Mojo’s not done yet, but already we see people that take small pieces of Python code, move it over, they don’t change it, and you can get 12x speed ups. Like somebody was just tweeting about that yesterday, which is pretty cool, right? And again, interpreters, compilers, right? And so, without changing any code, without… Also, this is not JIT compiling or doing anything fancy. This is just basic stuff. Move it straight over. Now Mojo will continue to grow out. And as it grows out, it will have more and more and more features. And our North Star is to be a full superset of Python. And so you can bring over, basically, arbitrary Python code and have it just work. It may not always be 12x faster, but it should be at least as fast, and way faster in many cases, is the goal, right? Now, it’ll take time to do that. And Python is a complicated language. There’s not just the obvious things, but there’s also non-obvious things that are complicated. Like, we have to be able to talk to CPython packages, to talk to the C API, and there’s a bunch of pieces to this."

Chris: 是的,是的,(Lex 轻笑) 这有两个方面。所以,Mojo 还没有完成。所以,我会给你一个免责声明。Mojo 还没有完成,但我们已经看到,人们拿一小段 Python 代码,把它移过来,他们没有改变它,你就可以获得 12 倍的速度提升。就像昨天有人在推特上谈论这件事,这很酷,对吧?再次,解释器,编译器,对吧?所以,在不改变任何代码的情况下,没有……而且,这不是 JIT 编译,或者做任何花哨的事情。这只是基本的东西。直接把它移过来。现在,Mojo 将继续发展。随着它的发展,它将拥有越来越多的功能。我们的北极星是成为 Python 的一个完整的超集。所以,你可以带来,基本上,任意的 Python 代码,并让它正常工作。它可能并不总是快 12 倍,但它的目标是至少一样快,在很多情况下,要快得多,对吧?现在,这需要时间。Python 是一种复杂的语言。不仅仅是显而易见的东西,还有一些不显而易见的东西也很复杂。比如,我们必须能够与 CPython 包对话,与 C API 对话,这里面有很多东西。

Lex: So you have to, I mean, just to make explicit the obvious that may not be so obvious until you think about it. So, you know, to run Python code, that means you have to run all the Python packages and libraries.

Chris: Yeah, yeah.

Lex: So that means what? What’s the relationship between Mojo and CPython, the interpreter that’s…

Chris: Yep.

Lex: …presumably would be tasked with getting those packages to work?"

Lex: 所以,你必须,我的意思是,只是为了明确那些显而易见的东西,直到你想到它,它才可能那么显而易见。所以,你知道,要运行 Python 代码,这意味着你必须运行所有的 Python 包和库。

Chris: 是的,是的。

Lex: 所以,这意味着什么?Mojo 和 CPython,解释器,之间的关系是什么……

Chris: 是的。

Lex: …大概,会被赋予让那些包工作的任务?

Chris: Yep. So in the fullness of time, Mojo will solve for all the problems, and you’ll be able to move Python packages over and run them in Mojo.

Lex: Without the CPython.

Chris: Without CPython, someday, right? Not today, but someday.

Lex: Yeah, and that’ll be a beautiful day because then you’ll get a whole bunch of advantages, and you’ll get massive speed-ups, and things like this.

Chris: But you can do that one at a time, right? You can move packages one at a time.

Lex: Exactly.

Chris: But we’re not willing to wait for that. (chuckles) Python is too important. The ecosystem is too broad. We wanna both be able to build Mojo out, we also wanna do it the right way without time, like, without intense time pressure. We’re obviously moving fast, but. And so, what we do is we say, okay, well, let’s make it so you can import an arbitrary existing package, arbitrary including, like, you write your own on your local disk (chuckles) or whatever. It’s not like a standard, like, an arbitrary package, and import that using CPython because CPython already runs all the packages, right? And so what we do is we built an integration layer where we can actually use CPython, again, I’m practical, and to actually just load and use all the existing packages as they are. The downside of that is you don’t get the benefits of Mojo for those packages, right? And so, they’ll run as fast as they do in the traditional CPython way, but what that does is that gives you an incremental migration path. And so if you say, hey, cool, well, here’s a, you know, the Python ecosystem is vast. I want all of it to just work, but there’s certain things that are really important. And so if I’m doing weather forecasting, or something (chuckles), well, I wanna be able to load all the data, I wanna be able to work with it, and then I have my own crazy algorithm inside of it. Well, normally I’d write that in C++. If I can write in Mojo and have one system that scales, well, that’s way easier to work with."

Chris: 是的。所以,在时间的充裕下,Mojo 将解决所有问题,你将能够将 Python 包移过来,并在 Mojo 中运行它们。

Lex: 没有 CPython。

Chris: 没有 CPython,总有一天,对吧?不是今天,但总有一天。

Lex: 是的,那将是一个美好的日子,因为那时你将获得一大堆优势,你将获得巨大的速度提升,以及类似这样的东西。

Chris: 但你可以一次做一个,对吧?你可以一次移动一个包。

Lex: 没错。

Chris: 但我们不愿意等待。(轻笑) Python 太重要了。生态系统太广泛了。我们希望能够构建 Mojo,我们也希望以正确的方式进行,没有时间,像,没有强烈的时间压力。我们显然正在快速行动,但是。所以,我们所做的是,我们说,好吧,让我们让它可以导入任意的现有包,任意的包括,像,你在你的本地磁盘上写你自己的 (轻笑) 或者其他什么。它不像一个标准的,像,一个任意的包,并使用 CPython 导入它,因为 CPython 已经运行了所有的包,对吧?所以,我们所做的是,我们构建了一个集成层,在那里我们可以实际使用 CPython,再次,我很实际,并实际上只是加载和使用所有现有的包,因为它们是。这样做的缺点是,你没有得到 Mojo 对那些包的好处,对吧?所以,它们会以传统的 CPython 方式运行一样快,但它所做的是,它给了你一个增量迁移路径。所以,如果你说,嘿,酷,好吧,这里有一个,你知道,Python 生态系统是巨大的。我希望它都能正常工作,但有一些东西真的很重要。所以,如果我正在做天气预报,或者其他什么东西 (轻笑),好吧,我希望能够加载所有的数据,我希望能够处理它,然后我有一个我自己的疯狂的算法在里面。好吧,通常情况下,我会用 C++ 编写它。如果我可以用 Mojo 编写,并拥有一个可扩展的系统,好吧,那要容易得多。

Lex: Is it hard to do that, to have that layer that’s running CPython? Because is there some communication back and forth?"

Lex: 这样做难吗,拥有运行 CPython 的那层?因为有一些来回的通信吗?

Chris: Yes, it’s complicated. I mean, this is what we do. So I mean, we make it look easy, but it is complicated. But what we do is we use the CPython existing interpreter. So it’s running its own byte codes, and that’s how it provides full compatibility. And then it gives us CPython objects, and we use those objects as is. And so that way, we’re fully compatible with all the CPython objects, and all the, you know, it’s not just the Python part, it’s also the C packages, the C libraries underneath them because they’re often hybrid. And so we can fully run, and we’re fully compatible with all that. And the way we do that is that we have to play by their rules, right? And so, we keep objects in that representation when they’re coming from that world."

Chris: 是的,这很复杂。我的意思是,这就是我们所做的。所以,我的意思是,我们让它看起来很简单,但它很复杂。但我们所做的是,我们使用 CPython 现有的解释器。所以,它运行自己的字节码,这就是它提供完全兼容性的方式。然后,它给了我们 CPython 对象,我们按原样使用这些对象。所以,这样,我们完全兼容所有的 CPython 对象,以及所有的,你知道,不仅仅是 Python 部分,还有 C 包,它们下面的 C 库,因为它们通常是混合的。所以,我们可以完全运行,我们完全兼容所有这些。我们这样做的方法是,我们必须遵守它们的规则,对吧?所以,当对象来自那个世界时,我们保持它们的表示。

Lex: What’s the representation that’s being used?"

Lex: 正在使用什么表示?

Chris: In memory. We’d have to know a lot about how the CPython interpreter works. It has, for example, reference counting, but also different rules on how to pass pointers around and things like this. Super low-level, fiddly. And it’s not like Python, it’s like how the interpreter works, okay? And so, that gets all exposed out, and then you have to define wrappers around the low-level C code, right? And so, what this means is you have to know not only C, which is a different world from Python obviously, not only Python…

Lex: But the wrappers.

Chris: …but the interpreter, and the wrappers, and the implementation details, and the conventions, and it’s just this really complicated mess. And when you do that, now, suddenly, you have a debugger that debugs Python, they can’t step into C code, right? So you have this two-world problem, right? And so, by pulling this all into Mojo, what you get is you get one world. You get the ability to say, “Cool, I have untyped, very dynamic, beautiful, simple code. Okay, I care about performance, for whatever reason, right?” There’s lots of reasons you might care. And so then you add types, you can parallelize things, you can vectorize things, you can use these techniques, which are general techniques to solve a problem, and then you can do that by staying in the system. And if you have that one Python package that’s really important to you, you can move it to Mojo. You get massive performance benefits on that and other advantages. You know, if you like static types, it’s nice if they’re enforced. Some people like that, right, rather than being hints. So there’s other advantages too. And then you can do that incrementally as you go."

Chris: 在内存中。我们必须了解很多关于 CPython 解释器如何工作的知识。例如,它有引用计数,但也有关于如何传递指针的不同规则,以及类似的东西。超级底层的,繁琐的。而且,它不像 Python,它就像解释器如何工作,好吗?所以,所有这些都被暴露出来,然后你必须在低级 C 代码周围定义包装器,对吧?所以,这意味着,你不仅要了解 C,这显然是一个与 Python 不同的世界,不仅要了解 Python……

Lex: 还有包装器。

Chris: …还有解释器,包装器,实现细节,以及约定,这只是一团非常复杂的混乱。当你这样做的时候,现在,突然,你有一个调试 Python 的调试器,它们不能进入 C 代码,对吧?所以,你有这个两个世界的问题,对吧?所以,通过将所有这些都拉入 Mojo,你得到的是,你得到了一个世界。你得到了说,酷,我有无类型的,非常动态的,美丽的,简单的代码。好吧,我关心性能,无论出于什么原因,对吧? 的能力。有很多理由让你可能关心。所以,然后你添加类型,你可以并行化东西,你可以向量化东西,你可以使用这些技术,它们是解决问题的一般技术,然后你可以通过留在系统中来做到这一点。如果你有一个对你来说非常重要的 Python 包,你可以把它移到 Mojo。你将获得巨大的性能优势和其他优势。你知道,如果你喜欢静态类型,如果它们被强制执行,那就太好了。有些人喜欢这样,对吧,而不是提示。所以,还有其他的优势。然后,你可以随着时间的推移,逐步地做到这一点。

Lex: So one different perspective on this would be, why Mojo instead of making CPython faster, redesigning CPython?"

Lex: 所以,对此的一个不同的观点是,为什么是 Mojo,而不是让 CPython 更快,重新设计 CPython?

Chris: Yeah, well, I mean, you could argue Mojo is redesigning CPython, but why not make CPython faster and better and other things like that? There’s lots of people working on that. So actually, there’s a team at Microsoft that is really improving… I think CPython 3.11 came out in October or something like that, and it was, you know, 15% faster, 20% faster across the board, which is pretty huge given how mature Python is and things like this. And so, that’s awesome. I love it. Doesn’t run on GPU. (chuckles) It doesn’t do AI stuff. Like, it doesn’t do vectors, doesn’t do things. 20 percent’s good, 35,000 times is better, right? So, like, they’re definitely… I’m a huge fan of that work, by the way, and it composes well with what we’re doing. It’s not like we’re fighting or anything like that. It’s actually just, it’s goodness for the world, but it’s just a different path, right? And again, we’re not working forwards from making Python a little bit better. We’re working backwards from, what is the limit of physics?"

Chris: 是的,好吧,我的意思是,你可以说 Mojo 正在重新设计 CPython,但为什么不让 CPython 更快,更好,以及其他类似的东西呢?有很多的人在做这方面的工作。所以,实际上,微软有一个团队正在真正地改进……我认为 CPython 3.11 是在 10 月份或者类似的时候发布的,而且,你知道,它快了 15%,全面快了 20%,考虑到 Python 的成熟度,以及类似的东西,这是相当巨大的。所以,那太棒了。我喜欢它。它不能在 GPU 上运行。(轻笑) 它不做 AI 的东西。比如,它不做向量,不做事情。20% 很好,35000 倍更好,对吧?所以,像,他们绝对是……顺便说一下,我是那项工作的超级粉丝,它与我们正在做的事情很好地结合在一起。这不像我们在战斗,或者类似的东西。它实际上只是,它是对世界有益的,但它只是一条不同的道路,对吧?再次,我们不是从让 Python 稍微好一点开始的。我们是从物理的极限反向工作的。

Lex: What’s the process of importing Python code to Mojo? Is there… What’s involved in that process?

Chris: Yeah.

Lex: Is there tooling for that?"

Lex: 将 Python 代码导入 Mojo 的过程是什么?有什么……这个过程中涉及到什么?

Chris: 是的。

Lex: 有这方面的工具吗?

Chris: Not yet. So we’re missing some basic features right now, and so we’re continuing to drop out new features, like, on a weekly basis, but, you know, at the fullness of time, give us a year and a half, maybe two years."

Chris: 还没有。所以,我们现在缺少一些基本的功能,所以,我们正在继续推出新的功能,比如,每周一次,但是,你知道,在时间的充裕下,给我们一年半,也许两年。

Lex: Is it an automatable process?"

Lex: 这是一个可以自动化的过程吗?

Chris: So when we’re ready, it’ll be very automatable, yes."

Chris: 所以,当我们准备好的时候,它将是非常可自动化的,是的。

Lex: Is it automatable? Like, is it possible to automate, in the general case, of Python…

Chris: Yeah.

Lex: …to Mojo conversion? And you’re saying it’s possible.

Chris: Well, so, and this is why, I mean, among other reasons why we use tabs (chuckles), right?"

Lex: 它是可以自动化的吗?比如,在一般情况下,是否可以自动化,Python……

Chris: 是的。

Lex: …到 Mojo 的转换?你是说这是可能的。

Chris: 好吧,所以,这就是为什么,我的意思是,除了我们使用制表符的其他原因 (轻笑),对吧?

Lex: Yes.

Chris: So, first of all, by being a superset…

Lex: Yep.

Chris: …it’s like C versus C++. Can you move C code to C++? Yeah, right?"

Lex: 是的。

Chris: 所以,首先,通过成为一个超集……

Lex: 是的。

Chris: …这就像 C 和 C++。你能将 C 代码移到 C++ 吗?是的,对吧?

Lex: Yes.

Chris: And you can move C code to C++, and then you can adopt classes, you can adopt templates, you can adopt other references or whatever C++ features you want after you move C code to C++. Like, you can’t use templates in C, right? And so if you leave it at C, fine. You can’t use the cool features, but it still works, right? And C and C++ work together. And so, that’s the analogy, right? Now, here, right, there’s not a Python is bad and Mojo is good (chuckles), right? Mojo just gives you superpowers, right? And so, if you wanna stay with Python, that’s cool, but the tooling should be actually very beautiful and simple because we’re doing the hard work of defining a superset."

Lex: 是的。

Chris: 你可以将 C 代码移到 C++,然后你可以采用类,你可以采用模板,你可以采用其他的引用,或者任何你想要的 C++ 功能,在你将 C 代码移到 C++ 之后。就像,你不能在 C 中使用模板,对吧?所以,如果你把它留在 C 中,很好。你不能使用酷的功能,但它仍然可以工作,对吧?C 和 C++ 可以一起工作。所以,这就是类比,对吧?现在,在这里,对吧,没有 Python 是坏的,Mojo 是好的 (轻笑),对吧?Mojo 只是给了你超能力,对吧?所以,如果你想留在 Python,那很酷,但工具实际上应该非常漂亮和简单,因为我们正在做定义一个超集的艰苦工作。

Lex: Right. So you’re right. So there’s several things to say there, but also the conversion tooling should probably give you hints as to, like, how you can improve the code?

Chris: Yeah, exactly. Once you’re in the new world, then you can build all kinds of cool tools to say, like, “Hey, should you adopt this feature?” And we haven’t built those tools yet, but I fully expect those tools will exist. And then you can, like, you know, quote-unquote, “modernize your code”, or however you wanna look at it, right? So I mean, one of the things that I think is really interesting about Mojo is that there have been a lot of projects to improve Python over the years. Everything from, you know, getting Python run on the Java virtual machine, PyPy, which is a JIT compiler. There’s tons of these projects out there that have been working on improving Python in various ways. They fall into one or two camps. So PyPy is a great example of a camp that is trying to be compatible with Python. Even there, not really. Doesn’t work with all the C packages and stuff like that, but they’re trying to be compatible with Python. There’s also another category of these things where they’re saying, “Well, Python is too complicated, and, you know, I’m gonna cheat on the edges. And, you know, like, integers in Python can be an arbitrary-size integer. Like, if you care about it fitting in a, going fast in a register in a computer, that’s really annoying, right?” And so you can choose to pass on that, right? You can say, “Well, people don’t really use big integers that often, therefore I’m gonna just not do it, and it’ll be fine,” not a Python superset."

Lex: 对。所以,你是对的。所以,那里有几件事要说,但转换工具也应该给你提示,比如,你如何改进代码?

Chris: 是的,没错。一旦你进入新世界,你就可以构建各种酷的工具,比如,嘿,你应该采用这个功能吗? 我们还没有构建这些工具,但我完全期望这些工具会存在。然后你可以,像,你知道,引号,引号,现代化你的代码,或者你喜欢的任何方式,对吧?所以,我的意思是,我认为关于 Mojo 的一个真正有趣的事情是,多年来有很多改进 Python 的项目。从,你知道,让 Python 在 Java 虚拟机上运行,PyPy,它是一个 JIT 编译器。有很多这样的项目一直在以各种方式改进 Python。它们属于一两个阵营。所以,PyPy 是一个很好的例子,它试图与 Python 兼容。即使在那里,也不是真的。它不适用于所有的 C 包和类似的东西,但他们正在试图与 Python 兼容。还有另一类东西,他们说,好吧,Python 太复杂了,而且,你知道,我要在边缘作弊。而且,你知道,像,Python 中的整数可以是任意大小的整数。比如,如果你关心它是否适合一个,在计算机的寄存器中快速运行,那真的很烦人,对吧? 所以,你可以选择传递它,对吧?你可以说,好吧,人们实际上并没有经常使用大整数,因此,我就不做了,它会很好,不是 Python 的超集。

Lex: Yeah.

Chris: (chuckles) Or you can do the hard thing and say, “This is Python, and you can’t be a superset of Python without being a superset of Python.” And that’s a really hard technical problem, but it’s, in my opinion, worth it, right? And it’s worth it because it’s not about any one package. It’s about this ecosystem. It’s about what Python means for the world. And it also means we don’t wanna repeat the Python 2 to Python 3 transition. Like, we want people to be able to adopt this stuff quickly. And so, by doing that work, we can help lift people."

Lex: 是的。

Chris: (轻笑) 或者,你可以做困难的事情,并说,这是 Python,你不能成为 Python 的超集,而不成为 Python 的超集。 这是一个非常困难的技术问题,但在我看来,它是值得的,对吧?它是值得的,因为它不是关于任何一个包。它是关于这个生态系统。它是关于 Python 对世界的意义。它也意味着我们不想重复 Python 2 到 Python 3 的过渡。就像,我们希望人们能够快速地采用这些东西。所以,通过做这项工作,我们可以帮助提升人们。

Lex: Yeah, the challenge, it’s really interesting, technical, philosophical challenge of really making a language a superset of another language. It’s breaking my brain a little bit."

Lex: 是的,挑战,真正让一种语言成为另一种语言的超集的挑战,真的很有趣,技术上的,哲学上的挑战。它让我有点崩溃。

Chris: Well, it paints you into corners. So again, I’m very happy with Python, right? So all joking aside, I think that the indentation thing is not the actual important part of the problem.

Lex: Yes. (Chris chuckling)

Chris: Right? But the fact that Python has amazing dynamic metaprogramming features, and they translate to beautiful static metaprogramming features, I think, is profound. I think that’s huge, right? And so Python, I’ve talked with Guido about this, it’s like, it was not designed to do what we’re doing. That was not the reason they built it this way, but because they really cared, and they were very thoughtful about how they designed the language, it scales very elegantly in this space. But if you look at other languages, for example, C and C++, right, if you’re building a superset, you get stuck with the design decisions of the subset, right? And so, you know, C++ is way more complicated because of C and the legacy than it would’ve been if they would’ve, theoretically, designed a from-scratch thing. And there’s lots of people right now that are trying to make C++ better, and recent syntax C++, it’s gonna be great, we’ll just change all the syntax. But if you do that, now, suddenly, you have zero packages. You don’t have compatibility."

Chris: 好吧,它把你逼到了角落。所以,再次,我对 Python 非常满意,对吧?所以,撇开所有的玩笑不谈,我认为缩进的事情并不是问题的真正重要部分。

Lex: 是的。(Chris 轻笑)

Chris: 对吧?但事实是,Python 有惊人的动态元编程功能,而且,它们可以转换成美丽的静态元编程功能,我认为,这是深刻的。我认为,这很巨大,对吧?所以,Python,我和 Guido 谈过这个,它就像,它不是为了做我们正在做的事情而设计的。那不是他们这样构建它的原因,但因为他们真的很关心,他们对如何设计语言非常周到,它在这个空间中非常优雅地扩展。但是,如果你看看其他语言,例如,C 和 C++,对吧,如果你正在构建一个超集,你就会被子集的设计决策所困扰,对吧?所以,你知道,C++ 比它理论上从头设计的东西要复杂得多,因为它有 C 和遗留问题。现在有很多人正在试图让 C++ 变得更好,最近的 C++ 语法,它将会很棒,我们只需要改变所有的语法。但是,如果你这样做,现在,突然,你就没有包了。你没有兼容性。

Lex: If you could just linger on that. What are the biggest challenges of keeping that superset status? What are the things you’re struggling with? Does it all boil down to having a big integer?"

Lex: 如果你能在那上面多停留一会儿。保持超集状态的最大挑战是什么?你正在努力解决什么问题?这一切都归结为拥有一个大整数吗?

Chris: No, I mean, it’s…

Lex: What are the other things like?"

Chris: 不,我的意思是,它是……

Lex: 其他的东西是什么样的?

Chris: Usually, it’s the long tail, weird things. So let me give you a war story."

Chris: 通常,它是长尾,奇怪的东西。所以,让我给你讲一个战争故事。

Lex: Okay.

Chris: So war story in the space is, you go away… Back in time, the project I worked on is called Clang. Clang, what it is, is a C++ parser, right? And when I started working on Clang, it must have been like 2006 or something, less, or 2007, something. 2006 when I first started working on it, right? It’s funny how time flies.

Lex: Yeah, yeah.

Chris: I started that project, and I’m like, okay, well, I wanna build a C parser, a C++ parser for LLVM. It’s gonna be the… GCC is yucky. You know, this is me in earlier times. It’s yucky, it’s unprincipled, it has all these weird features, like all these bugs, like, it’s yucky. So I’m gonna build a standards-compliant C and C++ parser. It’s gonna be beautiful, it’ll be amazing, well-engineered, all the cool things an engineer wants to do. And so I started implementing and building it out and building it out and building it out, and then I got to include stdio.h, and all of the headers in the world use all the GCC stuff (chuckles), okay?"

Lex: 好的。

Chris: 所以,这个领域的战争故事是,你走开……回到过去,我做的项目叫做 Clang。Clang,它是什么,是一个 C++ 解析器,对吧?当我开始做 Clang 的时候,那一定是 2006 年,或者更早,或者 2007 年,类似的。2006 年,当我第一次开始做它的时候,对吧?时间过得真快,真有趣。

Lex: 是的,是的。

Chris: 我开始了那个项目,我就像,好吧,我想为 LLVM 构建一个 C 解析器,一个 C++ 解析器。它将是……GCC 很恶心。你知道,这是我早期的想法。它很恶心,它没有原则,它有所有这些奇怪的功能,像所有这些错误,像,它很恶心。所以,我要构建一个符合标准的 C 和 C++ 解析器。它将是美丽的,它将是惊人的,精心设计的,所有工程师想做的酷的事情。所以,我开始实现它,构建它,构建它,构建它,然后我得到了 include stdio.h,世界上所有的头文件都使用所有的 GCC 东西 (轻笑),好吗?

Lex: Yeah.

Chris: And so, again, come back away from theory back to reality, right? I was at a fork in the road. I could have built an amazingly beautiful academic thing that nobody would ever use, or I could say, “Well, it’s yucky in various ways. All these design mistakes, accidents of history, the legacy.” At that point, GCC was, like, over 20 years old, which, by the way…

Lex: Yeah.

Chris: …now LLVM’s over 20 years old. (laughs) Right? And so, it’s funny how…

Lex: Yep.

Chris: …time catches up to you, right? And so you say, okay, well, what is easier, right? I mean, as an engineer, it’s actually much easier for me to go implement long tail compatibility, weird features, even if they’re distasteful and just do the hard work and, like, figure it out, reverse engineer it, understand what it is, write a bunch of test cases, like, try to understand the behavior. It’s way easier to do all that work as an engineer than it is to go talk to all C programmers and argue with them and try to get them to rewrite their code, right?"

Lex: 是的。

Chris: 所以,再次,从理论回到现实,对吧?我站在一个岔路口。我可以构建一个惊人的美丽的学术性的东西,没有人会使用它,或者我可以说,好吧,它在很多方面都很恶心。所有这些设计错误,历史的意外,遗留问题。 在那个时候,GCC,像,已经超过 20 年了,顺便说一下……

Lex: 是的。

Chris: …现在 LLVM 已经超过 20 年了。(笑) 对吧?所以,有趣的是……

Lex: 是的。

Chris: …时间追上了你,对吧?所以,你说,好吧,什么更容易,对吧?我的意思是,作为一个工程师,对我来说,去实现长尾兼容性,奇怪的功能,即使它们令人厌恶,只是做艰苦的工作,而且,像,弄清楚它,逆向工程它,理解它是什么,写一堆测试用例,像,试图理解它的行为,实际上要容易得多,而不是去和所有的 C 程序员交谈,和他们争论,并试图让他们重写他们的代码,对吧?

Lex: Yeah.

Chris: And…

Lex: ‘Cause that breaks a lot more things.

Chris: Yeah. The reality is, like, nobody actually even understands how the code works ‘cause it was written by the person who quit 10 years ago (chuckles), right? And so, this software is kind of frustrating that way, but it’s, that’s how the world works, right?"

Lex: 是的。

Chris: 而且……

Lex: 因为它会破坏更多的东西。

Chris: 是的。现实是,就像,实际上没有人理解代码是如何工作的,因为它是由 10 年前辞职的人写的 (轻笑),对吧?所以,这个软件有点令人沮丧,但它,这就是世界的工作方式,对吧?

Lex: Yeah. Unfortunately, it can never be this perfect, beautiful thing.

Chris: Well, there are occasions in which you get to build, like, you know, you invent a new data structure or something like that, or there’s this beautiful algorithm that’s just like, makes you super happy, and I love that moment. But when you’re working with people…

Lex: Yeah.

Chris: …and you’re working with code and dusty deck code bases and things like this, right? It’s not about what’s theoretically beautiful, it’s about what’s practical, what’s real, what people will actually use. And I don’t meet a lot of people that say, “I wanna rewrite all my code just for the sake of it.” "

Lex: 是的。不幸的是,它永远不可能是完美的,美丽的东西。

Chris: 好吧,有些情况下,你可以构建,比如,你知道,你发明了一个新的数据结构,或者类似的东西,或者有这个美丽的算法,它就像,让你超级快乐,我喜欢那一刻。但当你与人合作的时候……

Lex: 是的。

Chris: …而且,你正在处理代码,以及 dusty deck 代码库,以及类似的东西,对吧?它不是关于理论上什么是美丽的,而是关于什么是实际的,什么是真实的,人们实际上会使用什么。我没有遇到很多人说,我想重写我的所有代码,只是为了它。

Lex: By the way, there could be interesting possibilities, and we’ll probably talk about it, where AI can help rewrite some code. That might be a farther-out feature, but it’s a really interesting one, how that could create more…

Chris: Yeah, yeah.

Lex: …be a tool in the battle against this monster of complexity that you mentioned."

Lex: 顺便说一下,可能会有一些有趣的可能性,我们可能会谈论它,人工智能可以帮助重写一些代码。那可能是一个更远的功能,但它是一个非常有趣的功能,它如何能够创造更多……

Chris: 是的,是的。

Lex: …成为你提到的对抗这个复杂性怪物的战斗中的一个工具。

Chris: Yeah.

Lex: You mentioned Guido, the benevolent dictator for life of Python. What does he think about Mojo? Have you talked to him much about it?"

Chris: 是的。

Lex: 你提到了 Guido,Python 的终身仁慈独裁者。他对 Mojo 有什么看法?你和他谈过很多吗?

Chris: I have talked with him about it. He found it very interesting. We actually talked with him before it launched, and so he was aware of it before it went public. I have a ton of respect for Guido for a bunch of different reasons. You talk about the walrus operator, and, like, Guido’s pretty amazing in terms of steering such a huge and diverse community and, like, driving it forward. And I think Python is what it is thanks to him, right? And so, to me, it was really important, starting to work on Mojo, to get his feedback and get his input and get his eyes on this, right? Now, a lot of what Guido was and is, I think, concerned about is how do we not fragment the community?"

Chris: 我和他谈过。他觉得它非常有趣。我们实际上在它发布之前就和他谈过了,所以他在它公开之前就知道了。我非常尊重 Guido,有很多不同的原因。你谈到了海象运算符,而且,像,Guido 在引导如此庞大和多样化的社区,而且,像,推动它前进方面,相当惊人。我认为 Python 之所以成为现在的 Python,要感谢他,对吧?所以,对我来说,从开始做 Mojo 的时候,就得到他的反馈,得到他的意见,并让他关注这个,真的很重要,对吧?现在,我认为,Guido 过去和现在都在担心的是,我们如何不分裂社区?

Lex: Yeah.

Chris: We don’t want a Python 2 to Python 3 thing. Like, that was really painful for everybody involved. And so, we spent quite a bit of time talking about that. And some of the tricks I learned from Swift, for example, so in the migration from Swift, we managed to, like, not just convert Objective-C into a slightly prettier Objective-C, which we did, we then converted, not entirely, but almost an entire community to a completely different language, right? And so, there’s a bunch of tricks that you learn along the way that are directly relevant to what we do. And so, this is where, for example, you leverage CPython while bringing up the new thing. Like, that approach is, I think, proven and comes from experience. And so, Guido’s very interested in, like, “Okay, cool. Like, I think that Python is really his legacy, it’s his baby. I have tons of respect for that. Incidentally, I see Mojo as a member of the Python family. I’m not trying to take Python from Guido and from the Python community. And so, to me, it’s really important that we’re a good member of that community. I think that, again, you would have to ask Guido this, but I think that he was very interested in this notion of, like, ‘Cool, Python gets beaten up for being slow. Maybe there’s a path out of that,’ right? And that, you know, if the future is Python,” right? I mean, look at the far outside case on this, right? And I’m not saying this is Guido’s perspective, but, you know, there’s this path of saying, like, “Okay, well, suddenly Python can suddenly go all the places it’s never been able to go before, right?” And that means that Python can go even further and can have even more impact on the world."

Lex: 是的。

Chris: 我们不想要 Python 2 到 Python 3 的事情。就像,那对所有参与其中的人来说都非常痛苦。所以,我们花了很多时间谈论这件事。例如,我从 Swift 中学到的一些技巧,所以在从 Swift 迁移的过程中,我们设法,比如,不仅仅是将 Objective-C 转换成一个稍微漂亮一点的 Objective-C,我们确实这样做了,然后我们转换了,不是全部,但几乎是整个社区,转换成一种完全不同的语言,对吧?所以,你在这个过程中学到了一堆技巧,它们与我们正在做的事情直接相关。所以,这就是,例如,你在引入新东西的同时利用 CPython 的地方。就像,我认为,这种方法已经被证明了,而且来自于经验。所以,Guido 非常感兴趣,比如,好吧,酷。就像,我认为 Python 确实是他的遗产,它是他的孩子。我非常尊重这一点。顺便说一下,我认为 Mojo 是 Python 家族的一员。我并没有试图从 Guido 和 Python 社区那里夺走 Python。所以,对我来说,成为那个社区的一个好成员真的很重要。我认为,再次,你必须问 Guido 这个问题,但我认为,他对这个概念非常感兴趣,比如,酷,Python 因为慢而被人诟病。也许有一条出路,对吧?而且,你知道,如果未来是 Python,对吧?我的意思是,看看这个最外面的情况,对吧?我不是说这是 Guido 的观点,但,你知道,有一条这样的说法,比如,好吧,突然,Python 突然可以去所有它以前从未去过的地方,对吧? 这意味着,Python 可以走得更远,可以对世界产生更大的影响。

Lex: So, in some sense, Mojo could be seen as Python 4.0.

Chris: I would not say that. I think that would drive a lot of people really crazy.

Lex: Because of the PTSD of the 3.0, 2.0.

Chris: I’m willing to annoy people about Emacs versus Vim or…

Lex: Not that one.

Chris: Versus spaces… I don’t know. That might be a little bit far, even for me. Like, my skin may not be that thick."

Lex: 所以,从某种意义上说,Mojo 可以被视为 Python 4.0。

Chris: 我不会这么说。我认为,那会让很多人发疯。

Lex: 因为 3.0,2.0 的 PTSD。

Chris: 我愿意惹恼那些关于 Emacs 和 Vim 的人,或者……

Lex: 不是那个。

Chris: 和空格……我不知道。即使对我来说,那也可能有点过分。就像,我的脸皮可能没有那么厚。

Lex: But the point is the step to being a superset and allowing all of these capabilities, I think, is the evolution of a language. It feels like an evolution of a language. So he’s interested by the ideas that you’re playing with but also concerned about the fragmentation. So what are the ideas you’ve learned? What are you thinking about? How do we avoid fragmenting the community where the Pythonistas and the, I don’t know what to call the Mojo people…

Chris: Mojicians.

Lex: …the Mojicians. I like it.

Chris: There you go.

Lex: …can coexist happily and share code and basically just have these big code bases that are using CPython and more and more moving towards Mojo?"

Lex: 但关键是,我认为,成为一个超集,并允许所有这些能力,是语言的进化。它感觉像是一种语言的进化。所以,他对你正在玩弄的想法很感兴趣,但也担心碎片化。所以,你学到了什么想法?你在想什么?我们如何避免分裂社区,在那里,Pythonistas 和,我不知道怎么称呼 Mojo 人……

Chris: Mojicians。

Lex: …Mojicians。我喜欢它。

Chris: 就是这样。

Lex: …可以快乐地共存,共享代码,基本上只是拥有这些正在使用 CPython 的大型代码库,并越来越多地转向 Mojo?

Chris: Yeah. Yeah. Well, so again, these are lessons I learned from Swift. And here, we face very similar problems, right? In Swift, you have Objective-C, super dynamic. They’re very different syntax. (chuckles) Right? But you’re talking to people who have large-scale code bases. I mean, Apple’s got the biggest, largest-scale code base of Objective-C code, right? And so, you know, none of the companies, none of the other iOS developers, none of the other developers, want to rewrite everything all at once. And so, you wanna be able to adopt things piece at a time. And so, a thing that I found that worked very well in the Swift community was saying, “Okay, cool,” and this is when Swift was very young, and you say, “Okay, you have a million lines of code, Objective-C app. Don’t rewrite it all, but when you implement a new feature, go implement that new class using Swift,” right? And so, now this turns out is a very wonderful thing for an app developer, but it’s a huge challenge for the compiler team and the systems people that are implementing this, right? And this comes back to what is this trade-off between doing the hard thing that enables scale versus doing the theoretically pure and ideal thing, right? And so, Swift had adopted and built a lot of different machinery to deeply integrate with the Objective-C runtime. And we’re doing the same thing with Python right now. What happened in the case of Swift is that Swift’s language got more and more and more mature over time, right? And incidentally, Mojo is a much simpler language than Swift in many ways. And so I think that Mojo will develop way faster than Swift for a variety of reasons, but as the language gets more mature, and parallel with that, you have new people starting new projects, right? And so, if, when the language is mature, and somebody’s starting a new project, that’s when they say, “Okay, cool, I’m not dealing with a million lines of code. I’ll just start and use the new thing for my whole stack.” Now the problem is, again, you come back to, we’re communities, and we’re people that work together. You build a new subsystem or a new feature or a new thing in Swift, or you build a new thing in Mojo, then you want it to be end up being used on the other side. (chuckles) Right? And so, then you need to work on integration back the other way. And so it’s not just Mojo talking to Python, it’s also Python talking to Mojo, right? And so, what I would love to see, I don’t wanna see this next month, right? But what I wanna see, over the course of time, is I would love to see people that are building these packages, like, you know, NumPy, or, you know, TensorFlow, or what, you know, these packages that are half Python, half C++. And if you say, “Okay, cool. I want to get out of this Python C++ world into a unified world. And so I can move to Mojo, but I can’t give up all my Python clients ‘cause they’re like, these libraries get used by everybody, and they’re not all gonna switch, all, you know, all at once, and maybe never, right?” Well, so the way we should do that is we should vend Python interfaces to the Mojo types. And that’s what we did in Swift, and it worked great. I mean, it was a huge implementation challenge for the compiler people, right? But there’s only a dozen of those compiler people, and there are millions of users. And so, it’s a very expensive, capital-intensive, like, skillset-intensive problem. But once you solve that problem, it really helps adoption, and it really helps the community progressively adopt technologies. And so I think that this approach will work quite well with the Python and the Mojo world."

Chris: 是的。是的。好吧,所以,再次,这些是我从 Swift 中学到的教训。在这里,我们面临着非常相似的问题,对吧?在 Swift 中,你有 Objective-C,超级动态。它们的语法非常不同。(轻笑) 对吧?但你是在和那些拥有大规模代码库的人交谈。我的意思是,苹果拥有最大,最大规模的 Objective-C 代码库,对吧?所以,你知道,没有哪家公司,没有其他的 iOS 开发人员,没有其他的开发人员,想一次性重写所有东西。所以,你希望能够一次采用一部分东西。所以,我发现一件在 Swift 社区中非常有效的事情是说,好吧,酷,这是 Swift 还很年轻的时候,你说,好吧,你有一百万行代码,Objective-C 应用程序。不要全部重写,但是,当你实现一个新功能的时候,去使用 Swift 实现那个新的类,对吧?所以,现在,事实证明,这对应用程序开发人员来说是一件非常棒的事情,但对实现它的编译器团队和系统人员来说,这是一个巨大的挑战,对吧?这又回到了,做支持规模的困难的事情和做理论上纯粹和理想的事情之间的权衡是什么,对吧?所以,Swift 采用并构建了很多不同的机制,与 Objective-C 运行时深度集成。我们现在正在对 Python 做同样的事情。在 Swift 的例子中,发生的事情是,Swift 的语言随着时间的推移变得越来越成熟,对吧?顺便说一下,在很多方面,Mojo 比 Swift 要简单得多。所以,我认为,Mojo 的发展速度会比 Swift 快得多,有很多原因,但随着语言变得越来越成熟,与之并行的是,你有新的人开始新的项目,对吧?所以,如果,当语言成熟的时候,有人开始一个新的项目,那就是他们说,好吧,酷,我不用处理一百万行代码。我只需要开始,并使用新的东西来完成我的整个栈。 现在,问题是,再次,你回到了,我们是社区,我们是共同工作的人。你在 Swift 中构建了一个新的子系统,或者一个新的功能,或者一个新的东西,或者你在 Mojo 中构建了一个新的东西,然后你希望它最终在另一边被使用。(轻笑) 对吧?所以,然后你需要在另一个方向上进行集成。所以,不仅仅是 Mojo 与 Python 对话,Python 也与 Mojo 对话,对吧?所以,我想要看到的是,我不想在下个月看到这个,对吧?但我想看到的是,随着时间的推移,我想看到那些正在构建这些包的人,比如,你知道,NumPy,或者,你知道,TensorFlow,或者什么,你知道,这些包,一半是 Python,一半是 C++。如果你说,好吧,酷。我想从这个 Python C++ 世界进入一个统一的世界。所以,我可以迁移到 Mojo,但我不能放弃我所有的 Python 客户端,因为他们就像,这些库被所有人使用,他们不会全部切换,所有,你知道,一次性,也许永远不会,对吧? 好吧,所以,我们应该这样做的方法是,我们应该向 Mojo 类型提供 Python 接口。这就是我们在 Swift 中所做的,它工作得很好。我的意思是,对编译器人员来说,这是一个巨大的实现挑战,对吧?但这些编译器人员只有一打,而用户有数百万。所以,这是一个非常昂贵的,资本密集型的,像,技能密集型的问题。但是,一旦你解决了这个问题,它真的有助于采用,它真的有助于社区逐步采用技术。所以,我认为,这种方法在 Python 和 Mojo 世界中会非常有效。

Lex: So for a package, port it to Mojo, and then create a Python interface.

Chris: Yep.

Lex: So when you’re on these packages, NumPy, PyTorch, TensorFlow…

Chris: Yeah.

Lex: …how do they play nicely together? So, is Mojo supposed to be… Let’s talk about the machine learning ones. Is Mojo kind of visioned to replace PyTorch, TensorFlow, to incorporate it? What’s the relationship in this?"

Lex: 所以,对于一个包,将它移植到 Mojo,然后创建一个 Python 接口。

Chris: 是的。

Lex: 所以,当你使用这些包的时候,NumPy,PyTorch,TensorFlow……

Chris: 是的。

Lex: …它们是如何很好地协同工作的?所以,Mojo 应该……让我们谈谈机器学习的那些。Mojo 是否被设想为取代 PyTorch,TensorFlow,将其纳入?它们之间的关系是什么?

Chris: All right. So take a step back. So I wear many hats. (chuckles) So you’re angling it on the Mojo side. Mojo’s a programming language.

Lex: Yes.

Chris: And so it can help solve the C, C++ Python feud that’s happening.

Lex: The fire emoji got me. I’m sorry. We should be talking Modular. Yes, yes.

Chris: Yes. Okay. So the fire emoji is amazing. I love it. It’s a big deal. The other side of this is the fire emoji is in service of solving some big AI problems, right?"

Chris: 好吧。所以,退一步说。我戴着很多帽子。(轻笑) 所以,你把它放在 Mojo 的一边。Mojo 是一种编程语言。

Lex: 是的。

Chris: 所以,它可以帮助解决正在发生的 C,C++,Python 之间的争斗。

Lex: 火 emoji 让我分心了。对不起。我们应该谈谈 Modular。是的,是的。

Chris: 是的。好的。所以,火 emoji 很棒。我喜欢它。它很重要。另一方面,火 emoji 是为了解决一些大的人工智能问题,对吧?

Lex: Yes.

Chris: And so the big AI problems are, again, this fragmentation, this hardware nightmare, this explosion of new potential, but it’s not getting felt by the industry, right? And so, when you look at, “How does the Modular engine help TensorFlow and PyTorch?” Right? It’s not replacing them, right? In fact, when I talk to people, again, they don’t like to rewrite all their code. You have people that are using a bunch of PyTorch, a bunch of TensorFlow. They have models that they’ve been building over the course of many years, right? And when I talk to them, there’s a few exceptions, but generally, they don’t wanna rewrite all their code, right? And so what we’re doing is we’re saying, “Okay, well, you don’t have to rewrite all your code.” What happens is the Modular engine goes in there and goes underneath TensorFlow and PyTorch. It’s fully compatible, and it just provides better performance, better predictability, better tooling. It’s a better experience that helps lift TensorFlow and PyTorch and make them even better. I love Python, I love TensorFlow, I love PyTorch, right? This is about making the world better because we need AI to go further."

Lex: 是的。

Chris: 所以,大的人工智能问题是,再次,这种碎片化,这种硬件噩梦,这种新潜力的爆炸,但它并没有被行业感受到,对吧?所以,当你看到,Modular 引擎是如何帮助 TensorFlow 和 PyTorch 的? 对吧?它并没有取代它们,对吧?实际上,当我与人们交谈时,再次,他们不喜欢重写所有的代码。有些人正在使用一堆 PyTorch,一堆 TensorFlow。他们有他们多年来一直在构建的模型,对吧?当我与他们交谈时,有一些例外,但通常,他们不想重写所有的代码,对吧?所以,我们正在做的是,我们说,好吧,你不用重写所有的代码。 发生的事情是,Modular 引擎进入那里,并进入 TensorFlow 和 PyTorch 的下面。它完全兼容,它只是提供更好的性能,更好的可预测性,更好的工具。这是一个更好的体验,它有助于提升 TensorFlow 和 PyTorch,使它们变得更好。我爱 Python,我爱 TensorFlow,我爱 PyTorch,对吧?这是关于让世界变得更好,因为我们需要人工智能走得更远。

Lex: But if I have a process that trains a model, and I have a process that performs inference on that model, and I have the model itself, what should I do with that in the long arc of history in terms of, if I use PyTorch to train it, should I rewrite stuff in Mojo if I care about performance?"

Lex: 但是,如果我有一个训练模型的过程,我有一个对该模型进行推理的过程,我拥有模型本身,从长远来看,我应该如何处理它,如果我使用 PyTorch 来训练它,如果我关心性能,我应该用 Mojo 重写东西吗?

Chris: Oh, so I mean, again, it depends. So if you care about performance, then writing it in Mojo is gonna be way better than writing in Python. But if you look at LLM companies, for example, so you look at OpenAI, rumored, and you look at many of the other folks that are working on many of these LLMs and other, like, innovative machine learning models, on the one hand, they’re innovating in the data collection and the model, billions of parameters, and the model architecture and the RLHF and the, like, all the cool things that people are talking about, but on the other hand, they’re spending a lot of time writing CUDA kernels, right? And so, you say, “Wait a second, how much faster could all this progress go if they were not having to hand write all these CUDA kernels,” right? And so, there are a few technologies that are out there, and people have been working on this problem for a while, and they’re trying to solve subsets of the problem, again, kinda fragmenting the space. And so, what Mojo provides for these kinds of companies is the ability to say, “Cool, I can have a unifying theory,” right? And again, the better together, the unifying theory, the two-world problem or the three-world problem, or the N-world problem, like, this is the thing that is slowing people down. And so, as we help solve this problem, I think it’ll be very helpful for making this whole cycle go faster."

Chris: 哦,所以,我的意思是,再次,这取决于。所以,如果你关心性能,那么用 Mojo 编写它会比用 Python 编写好得多。但如果你看看 LLM 公司,例如,所以你看看 OpenAI,传闻,你看看其他很多正在做这些 LLM 和其他,像,创新的机器学习模型的人,一方面,他们在数据收集和模型方面进行创新,数十亿的参数,以及模型架构和 RLHF,以及,像,所有人们正在谈论的酷的东西,但另一方面,他们花了很多时间编写 CUDA 内核,对吧?所以,你说,等一下,如果他们不用手工编写所有这些 CUDA 内核,所有这些进展会快多少,对吧?所以,有一些技术已经存在了,人们已经在这个问题上工作了一段时间,他们正在试图解决问题的子集,再次,有点碎片化空间。所以,Mojo 为这些类型的公司提供的是说,酷,我可以有一个统一的理论,的能力,对吧?再次,越好在一起,统一的理论,两个世界的问题,或者三个世界的问题,或者 N 世界的问题,像,这是正在拖慢人们速度的东西。所以,当我们帮助解决这个问题的时候,我认为它将非常有助于使整个周期更快。

Lex: So obviously we’ve talked about the transition from Objective-C to Swift. You’ve designed this programming language, and you’ve also talked quite a bit about the use of Swift for machine learning contexts. Why have you decided to move away from maybe an intense focus on Swift for the machine learning context versus sort of designing a new programming language that happens to be a superset?"

Lex: 所以,很明显,我们已经谈到了从 Objective-C 到 Swift 的过渡。你设计了这种编程语言,你也谈了很多关于在机器学习环境中使用 Swift 的事情。为什么你决定放弃对 Swift 在机器学习环境中的强烈关注,而转向设计一种恰好是超集的新编程语言?

Chris: You’re saying this is an irrational set of life choices I make or what? (chuckles) (Lex laughing)"

Chris: 你是说这是一组我不理性的生活选择吗?(轻笑) (Lex 笑)

Lex: Did you go to the desert, and did you meditate on it? Okay. All right. No, it was bold. It was bold and needed, and I think, I mean, it’s just bold, and sometimes to take those leaps, it’s a difficult leap to take.

Chris: Yeah. Well, so, okay. I mean, I think there’s a couple of different things. So actually, I left Apple back in 2017, like January 2017. So it’s been a number of years that I left Apple. And the reason I left Apple was to do AI, okay? So, and again, I won’t comment on Apple and AI, but at the time, right, I wanted to get into and understand the technology, understand the applications, the workloads, and so I was like, “Okay, I’m gonna go dive deep into applied and AI,” and then the technology underneath it, right? I found myself at Google.

Lex: And that was like when TPUs were waking up.

Chris: Yep, exactly.

Lex: And so I found myself at Google, and Jeff Dean, who’s a rockstar, as you know, right? And in 2017, TensorFlow’s, like, really taking off and doing incredible things. And I was attracted to Google to help them with the TPUs, right? And TPUs are an innovative hardware accelerator platform, have now, I mean, I think proven massive scale and, like, done incredible things, right? And so, one of the things that this led into is a bunch of different projects, which I’ll skip over, right, one of which was this Swift for TensorFlow project, right? And so that project was a research project. And so, the idea of that is to say, okay, well, let’s look at innovative new programming models where we can get a fast programming language, we can get automatic differentiation into the language, let’s push the boundaries of these things in a research setting, right? Now, that project I think lasted two, three years. There’s some really cool outcomes of that. So one of the things that’s really interesting is I published a talk at an LLVM conference in 2018, again, this seems like so long ago, about a graph program abstraction, which is basically the thing that’s in PyTorch 2. And so, PyTorch 2, with all this DynamoRIO thing, it’s all about this graph program abstraction thing from Python byte codes. And so, a lot of the research that was done ended up pursuing and going out through the industry and influencing things, and I think it’s super exciting and awesome to see that, but the Swift for TensorFlow project itself did not work out super well. And so, there’s a couple of different problems with that. One of which is that, you may have noticed, Swift is not Python. (chuckles) There’s a few people that write Python code."

Lex: 你去沙漠里冥想了吗?好吧。好吧。不,它很大胆。它很大胆,而且是必要的,而且我认为,我的意思是,它只是很大胆,而且,有时,要迈出这些飞跃,这是一个很难迈出的飞跃。

Chris: 是的。好吧,所以,好吧。我的意思是,我认为,有几件不同的事情。所以,实际上,我在 2017 年离开了苹果,就像 2017 年 1 月。所以,我已经离开苹果很多年了。我离开苹果的原因是为了做人工智能,好吗?所以,再次,我不会评论苹果和人工智能,但当时,对吧,我想进入并理解技术,理解应用程序,工作负载,所以,我就像,好吧,我要深入研究应用和人工智能,然后是它下面的技术,对吧?我发现自己在谷歌。

Lex: 那就像 TPU 觉醒的时候。

Chris: 是的,没错。

Lex: 所以,我发现自己在谷歌,Jeff Dean,他是摇滚明星,正如你所知,对吧?在 2017 年,TensorFlow,像,真的起飞了,并做了不可思议的事情。我被谷歌吸引是为了帮助他们使用 TPU,对吧?TPU 是一个创新的硬件加速器平台,现在已经,我的意思是,我认为已经证明了大规模,而且,像,做了不可思议的事情,对吧?所以,这导致的一件事是一堆不同的项目,我将跳过,对吧,其中之一是这个 Swift for TensorFlow 项目,对吧?所以,那个项目是一个研究项目。所以,它的想法是说,好吧,让我们看看创新的新的编程模型,在那里我们可以得到一种快速的编程语言,我们可以得到语言中的自动微分,让我们在研究环境中突破这些东西的界限,对吧?现在,我认为,那个项目持续了两,三年。有一些非常酷的结果。所以,其中一件真正有趣的事情是,我在 2018 年的 LLVM 会议上发表了一个演讲,再次,这感觉像是很久以前的事情了,关于图程序抽象,它基本上就是 PyTorch 2 中的东西。所以,PyTorch 2,以及所有这些 DynamoRIO 的东西,都是关于从 Python 字节码中提取这个图程序抽象的东西。所以,很多完成的研究最终都通过行业进行了追求和推广,并影响了事物,我认为,看到这一点非常令人兴奋和敬畏,但 Swift for TensorFlow 项目本身并没有取得很好的效果。所以,这有几个不同的问题。其中之一是,你可能已经注意到了,Swift 不是 Python。(轻笑) 有一些人写 Python 代码。

Lex: Yeah.

Chris: And so it turns out that all of ML is pretty happy with Python.

Lex: It’s actually a problem that other programming languages have as well, that they’re not Python. We’ll probably maybe briefly talk about Julia, was a very interesting, beautiful programming language, but it’s not Python."

Lex: 是的。

Chris: 所以,事实证明,所有的机器学习都对 Python 非常满意。

Lex: 实际上,其他编程语言也有这个问题,它们不是 Python。我们可能会简要地谈谈 Julia,它是一种非常有趣的,美丽的编程语言,但它不是 Python。

Chris: Exactly. And so, like, if you’re saying I’m gonna solve a machine learning problem where all the programmers are Python programmers…

Lex: Yeah.

Chris: …and you say the first thing you have to do is switch to a different language, well, your new thing may be good or bad or whatever, but if it’s a new thing, the adoption barrier is massively less…

Lex: It’s still possible."

Chris: 没错。所以,就像,如果你说我要解决一个机器学习问题,所有的程序员都是 Python 程序员……

Lex: 是的。

Chris: …而且,你说你必须做的第一件事是切换到不同的语言,好吧,你的新东西可能是好的,也可能是坏的,或者其他什么,但如果它是一个新的东西,采用障碍就会大大减少……

Lex: 它仍然是可能的。

Chris: …still possible, yeah, absolutely. The world changes and evolves, and there’s definitely room for new and good ideas, but it just makes it so much harder, right? And so, lesson learned, Swift is not Python, and people are not always in search of, like, learning a new thing for the sake of learning a new thing. And if you wanna be compatible with all the world’s code, turns out, meet the world where it is, right? The second thing is that, you know, a lesson learned is that Swift is a very fast and efficient language, kind of like Mojo, but a different take on it, still really worked well with eager mode. And so, eager mode is something that PyTorch does, and it proved out really well, and it enables really expressive and dynamic and easy to debug programming. TensorFlow at the time was not set up for that, let’s say. That was not…"

Chris: …仍然是可能的,是的,绝对的。世界在变化,在进化,肯定有新的,好的想法的空间,但它只是让它变得更难,对吧?所以,吸取的教训是,Swift 不是 Python,人们并不总是在寻找,像,为了学习新东西而学习新东西。如果你想与世界上所有的代码兼容,事实证明,在它所在的地方迎接世界,对吧?第二件事是,你知道,吸取的教训是,Swift 是一种非常快速和高效的语言,有点像 Mojo,但采取了不同的方式,仍然与 eager 模式很好地协同工作。所以,eager 模式是 PyTorch 做的事情,它被证明非常好,它使编程真正具有表现力,动态性,并且易于调试。当时,TensorFlow 并没有为此做好准备,让我们这么说。那不是……

Lex: The timing is also important in this world."

Lex: 时间在这个世界上也很重要。

Chris: Yeah, yeah. And TensorFlow is a good thing, and it has many, many strengths, but you could say Swift for TensorFlow is a good idea, except for the Swift and except for the TensorFlow part. (chuckles)"

Chris: 是的,是的。TensorFlow 是一件好事,它有很多,很多优点,但你可以说,Swift for TensorFlow 是一个好主意,除了 Swift 部分,除了 TensorFlow 部分。(轻笑)

Lex: Swift because it’s not Python, and TensorFlow because it…

Chris: It wasn’t set up for eager mode at the time, yeah.

Lex: It was 1.0.

Chris: Exactly. And so, one of the things about that is that in the context of it being a research project, I’m very happy with the fact that we built a lot of really cool technology. We learned a lot of things. I think the ideas went on to have influence in other systems, like PyTorch. A few people use it, I hear, right? And so I think that’s super cool, and for me, personally, I learned so much from it, right? And I think a lot of the engineers that worked on it also learned a tremendous amount, and so, you know, I think that that’s just really exciting to see. And, you know, I’m sorry that the project didn’t work out. I wish it did, of course, right, but, you know, it’s a research project. And so, you’re there to learn from it."

Lex: Swift 因为它不是 Python,TensorFlow 因为它……

Chris: 当时它还没有为 eager 模式做好准备,是的。

Lex: 它是 1.0。

Chris: 没错。所以,关于这一点的一件事是,在它是一个研究项目的背景下,我对我们构建了很多非常酷的技术这一事实感到非常高兴。我们学到了很多东西。我认为,这些想法继续影响着其他系统,比如 PyTorch。我听说,有一些人正在使用它,对吧?所以,我认为,那非常酷,对我个人来说,我从中学到了很多东西,对吧?我认为,很多参与其中的工程师也学到了很多东西,所以,你知道,我认为,看到这一点真的很令人兴奋。而且,你知道,我很抱歉,这个项目没有成功。我当然希望它成功,对吧,但是,你知道,这是一个研究项目。所以,你是在那里学习的。

Lex: Well, it’s interesting to think about the evolution of programming as we come up with these whole new sets of algorithms in machine learning, in artificial intelligence. And what’s going to win out, is it could be a new programming language? It could be…

Chris: Yeah.

Lex: …I mean, I just mentioned Julia. I think there’s a lot of ideas behind Julia that Mojo shares. What are your thoughts about Julia in general?"

Lex: 好吧,想想编程的进化很有趣,因为我们想出了这些全新的机器学习算法,人工智能。什么会胜出,它可能是一种新的编程语言?它可能是……

Chris: 是的。

Lex: …我的意思是,我刚刚提到了 Julia。我认为 Julia 背后有很多想法与 Mojo 相同。你对 Julia 的总体看法是什么?

Chris: So I will have to say that when we launched Mojo, one of the biggest things I didn’t predict was the response from the Julia community. And so I was not, I mean, I’ve, okay, lemme take a step back. I’ve known the Julia folks for a really long time. They’re an adopter of LLVM a long time ago. They’ve been pushing the state-of-the-art in a bunch of different ways. Julia’s a really cool system. I had always thought of Julia as being mostly a scientific computing-focused environment, right? And I thought that was its focus. I neglected to understand that one of their missions is to, like, help make Python work end-to-end (chuckles). And so, I think that was my error for not understanding that, and so I could have been maybe more sensitive to that, but there’s major differences between what Mojo’s doing and what Julia’s doing. So, as you say, Julia is not Python, right? And so one of the things that a lot of the Julia people came out and said is like, “Okay, well, if we put a ton more energy into, ton more money or engineering, or whatever, into Julia, maybe that would be better than starting Mojo, right?” Well, I mean, maybe that’s true, but it still wouldn’t make Julia into Python. (chuckles) So, if you worked backward from the goal of, “Let’s build something for Python programmers without requiring them to relearn syntax,” then Julia just isn’t there, right? I mean, that’s a different thing, right? And so if you anchor on, “I love Julia, and I want Julia to go further,” then you can look at it from a different lens, but the lens we were coming at was, “Hey, everybody is using Python. The syntax isn’t broken. Let’s take what’s great about Python and make it even better.” And so, it was just a different starting point. So I think Julia’s a great language. The community’s a lovely community. They’re doing really cool stuff, but it’s just a different, it’s a slightly different angle."

Chris: 所以,我不得不说,当我们发布 Mojo 的时候,我没有预料到的一件最大的事情是 Julia 社区的反应。所以,我不是,我的意思是,我已经,好吧,让我退一步说。我认识 Julia 的人已经很长时间了。他们很久以前就采用了 LLVM。他们一直在以各种不同的方式推动最先进的技术。Julia 是一个非常酷的系统。我一直认为 Julia 主要是一个专注于科学计算的环境,对吧?我认为,那是它的重点。我忽略了理解他们的任务之一是,比如,帮助使 Python 端到端地工作 (轻笑)。所以,我认为,那是我的错误,因为我没有理解这一点,所以,我可能应该对此更敏感一点,但 Mojo 正在做的事情和 Julia 正在做的事情有很大的区别。所以,正如你所说,Julia 不是 Python,对吧?所以,很多 Julia 人出来说的一件事是,比如,好吧,如果我们投入更多的精力,更多的资金或工程,或者其他什么,到 Julia 中,也许那会比开始做 Mojo 更好,对吧? 好吧,我的意思是,也许那是真的,但它仍然不会让 Julia 变成 Python。(轻笑) 所以,如果你从让我们为 Python 程序员构建一些东西,而不需要他们重新学习语法的目标反向工作,那么 Julia 就不会在那里,对吧?我的意思是,那是一件不同的事情,对吧?所以,如果你坚持,我爱 Julia,我希望 Julia 走得更远,那么你可以从不同的角度来看待它,但我们看待它的角度是,嘿,每个人都在使用 Python。语法没有问题。让我们利用 Python 的优点,并使它变得更好。 所以,这只是一个不同的起点。所以,我认为 Julia 是一种很棒的语言。社区是一个可爱的社区。他们正在做非常酷的事情,但它只是一个不同的,它是一个稍微不同的角度。

Lex: But it does seem that Python is quite sticky. Is there some philosophical, almost thing you could say about why Python, by many measures, seems to be the most popular programming language in the world?"

Lex: 但 Python 似乎确实很粘人。是否有一些哲学上的,几乎可以说,为什么 Python,在很多方面,似乎是世界上最流行的编程语言?

Chris: Well, I can tell you things I love about it. Maybe that’s one way to answer the question, right? So huge package ecosystem, super lightweight and easy to integrate. It has very low start-up time, right?"

Chris: 好吧,我可以告诉你我喜欢它的地方。也许,那是回答这个问题的一种方式,对吧?所以,巨大的软件包生态系统,超级轻量级,易于集成。它的启动时间非常短,对吧?

Lex: So what’s start-up time? You mean, like, learning curve, or what?"

Lex: 所以,什么是启动时间?你是说,像,学习曲线,还是什么?

Chris: Yeah. So if you look at certain other languages, you say, like, Go, and it just takes a, like Java, for example, it takes a long time to JIT compile all the things, and then the VM starts up, and the garbage collector kicks in, and then it revs its engines, and then it can plow through a lot of internet stuff, or whatever, right? Python is like scripting. Like, it just goes, right?"

Chris: 是的。所以,如果你看看其他一些语言,你说,比如,Go,它只需要一个,比如 Java,例如,它需要很长时间来 JIT 编译所有东西,然后虚拟机启动,垃圾收集器启动,然后它转动它的引擎,然后它就可以处理很多互联网的东西,或者其他什么,对吧?Python 就像脚本。就像,它只是运行,对吧?

Lex: Yeah.

Chris: Python has a very low compile time. Like, so you’re not sitting there waiting. Python integrates in notebooks in a very elegant way that makes exploration super interactive, and it’s awesome, right? Python is also, it’s like almost the glue of computing because it has such a simple object representation. A lot of things plug into it. That dynamic metaprogramming thing we were talking about also enables really expressive and beautiful APIs, right? So there’s lots of reasons that you can look at, technical things Python has done, and say like, “Okay, wow, this is actually a pretty amazing thing.” And any one of those you can neglect, people will all just talk about indentation (chuckles), and ignore like the fundamental things, but then you also look at the community side, right? So Python owns machine learning. Machine learning’s pretty big."

Lex: 是的。

Chris: Python 的编译时间非常短。就像,所以,你不会坐在那里等待。Python 以一种非常优雅的方式集成到笔记本中,这使得探索超级互动,而且,它很棒,对吧?Python 也是,它几乎就像计算的粘合剂,因为它有一个如此简单的对象表示。很多东西都插入到它里面。我们刚才谈论的动态元编程也使得 API 非常具有表现力和美观,对吧?所以,有很多理由,你可以看看 Python 所做的技术上的事情,并说,好吧,哇,这实际上是一件相当惊人的事情。 你可以忽略其中的任何一个,人们都会只谈论缩进 (轻笑),而忽略像基本的东西,但是,然后你也要看看社区方面,对吧?所以,Python 拥有机器学习。机器学习相当大。

Lex: Yeah, and it’s growing.

Chris: And it’s growing, right? And it’s growing in importance, right? And so…"

Lex: 是的,而且它正在增长。

Chris: 而且它正在增长,对吧?而且,它的重要性正在增长,对吧?所以……

Lex: And there’s a reputation of prestige to machine learning to where like if you’re a new programmer, you’re thinking about, like, “Which programming language do I use?” Well, I should probably care about machine learning, therefore let me try Python, and it kinda builds and builds and builds.

Chris: And even go back before that. Like, my kids learned Python, right? Not because I’m telling ’em to learn Python, but because…

Lex: Were they rebelling against you, or what?"

Lex: 而且,机器学习有一个声望,比如,如果你是个新程序员,你会想,我应该使用哪种编程语言? 好吧,我可能应该关心机器学习,因此,让我试试 Python,它有点像构建,构建,构建。

Chris: 甚至回到那之前。比如,我的孩子们学习 Python,对吧?不是因为我告诉他们学习 Python,而是因为……

Lex: 他们是在反抗你,还是什么?

Chris: Oh, no, no. Well, they, they also learn Scratch, right, and things like this too, but it’s because Python is taught everywhere, right? Because it’s easy to learn, right? And because it’s pervasive, right? And there’s…

Lex: Back in my day, we learned Java and C++.

Chris: Yeah, well.

Lex: Well, uphill both directions, but yes. I guess Python…

Chris: Yeah.

Lex: …is the main language of teaching software engineering schools now.

Chris: Yeah. Well, and if you look at this, there’s these growth cycles, right? If you look at what causes things to become popular and then gain in popularity, there’s reinforcing feedback loops, and things like this. And I think Python has done, again, the whole community has done a really good job of building those growth loops and help propel the ecosystem, and I think that, again, you look at what you can get done with just a few lines of code, it’s amazing."

Chris: 哦,不,不。好吧,他们,他们也学习 Scratch,对吧,以及类似的东西,但这是因为 Python 到处都在教,对吧?因为它很容易学习,对吧?因为它很普遍,对吧?而且,有……

Lex: 在我那个年代,我们学习 Java 和 C++。

Chris: 是的,好吧。

Lex: 好吧,两个方向都是上坡,但是,是的。我想 Python……

Chris: 是的。

Lex: …现在是软件工程学校教学的主要语言。

Chris: 是的。好吧,如果你看看这个,有这些增长周期,对吧?如果你看看是什么导致事物变得流行,然后越来越流行,就会有加强反馈循环,以及类似的东西。我认为,Python 已经做到了,再次,整个社区在构建这些增长循环方面做得很好,并帮助推动了生态系统,我认为,再次,你看看你只需几行代码就能完成的事情,这太神奇了。

Lex: So this kinda self-building loop is interesting to understand because when you look at Mojo, what it stands for, some of the features, it seems sort of clear that this is a good direction for programming languages to evolve in the machine learning community, but it’s still not obvious that it will because of this, whatever, the engine of popularity, of virality. Is there something you could speak to, like, how do you get people to switch?"

Lex: 所以,这种自我构建的循环很有趣,因为当你看看 Mojo 的时候,它代表了什么,一些功能,它似乎很清楚,这是机器学习社区中编程语言发展的一个好的方向,但它仍然不明显,因为它会,无论什么,流行的引擎,病毒式传播。你能不能谈谈,比如,你如何让人们切换?

Chris: Yeah. Well, I mean, I think that the viral growth loop is to switch people to Unicode.

Lex: Yes.

Chris: I think the Unicode file extensions are what I’m betting on. I think that’s gonna be the thing.

Lex: Yeah. (Chris chuckling) Tell the kids that you could use the fire emoji, and they’d be like, “What?”

Chris: Exactly, exactly. (Lex chuckling) Well, in all seriousness, like, I mean, I think there’s really, I’ll give you two opposite answers. One is, I hope if it’s useful, if it solves problems, and if people care about those problems being solved, they’ll adopt the tech, right? That’s kinda the simple answer. And when you’re looking to get tech adopted, the question is, is it solving an important problem people need solved? And is the adoption cost low enough that they’re willing to make the switch and cut over and do the pain upfront so that they can actually do it, right? And so, hopefully, Mojo will be that for a bunch of people. And, you know, people building these hybrid packages are suffering. It is really painful. And so I think that we have a good shot of helping people, but the other side is, like, it’s okay if people don’t use Mojo. Like, it’s not my job to say, like, “Everybody should do this.” Like, I’m not saying Python is bad. Like, I hope Python, CPython, like, all these implementations, ‘cause Python ecosystems, not just CPython, it’s also a bunch of different implementations with different trade-offs, and this ecosystem is really powerful and exciting, as are other programming languages. It’s not like TypeScript or something is gonna go away, right? And so, there’s not a winner-take-all thing. And so, I hope that Mojo’s exciting and useful to people, but if it’s not, that’s also fine."

Chris: 是的。好吧,我的意思是,我认为,病毒式增长的循环是让人们切换到 Unicode。

Lex: 是的。

Chris: 我认为,我押注的是 Unicode 文件扩展名。我认为,那将会是关键。

Lex: 是的。(Chris 轻笑) 告诉孩子们,他们可以使用火 emoji,他们会说,什么?

Chris: 没错,没错。(Lex 轻笑) 好吧,说真的,像,我的意思是,我认为,真的,我会给你两个相反的答案。一个是,我希望,如果它有用,如果它解决了问题,而且,如果人们关心那些正在被解决的问题,他们就会采用这项技术,对吧?那有点像简单的答案。当你希望技术被采用的时候,问题是,它是否解决了一个人们需要解决的重要问题?而且,采用成本是否足够低,以至于他们愿意做出改变,并切断,并预先承受痛苦,这样他们才能真正做到,对吧?所以,希望,Mojo 对很多人来说都是这样的。而且,你知道,那些构建这些混合包的人正在受苦。这真的很痛苦。所以,我认为,我们很有可能帮助人们,但另一方面,像,如果人们不使用 Mojo,也没关系。就像,这不是我的工作,说,每个人都应该这样做。 就像,我不是说 Python 不好。就像,我希望 Python,CPython,像,所有这些实现,因为 Python 生态系统,不仅仅是 CPython,它也是一堆不同的实现,有不同的权衡,这个生态系统真的很强大,令人兴奋,其他编程语言也是如此。这不像 TypeScript 或者其他什么东西会消失,对吧?所以,没有赢家通吃的说法。所以,我希望,Mojo 对人们来说是令人兴奋的,有用的,但如果它不是,那也很好。

Lex: But I also wonder what the use case for why you should try Mojo would be. So practically speaking…

Chris: Yeah.

Lex: …it seems like, so there’s entertainment. There’s the dopamine hit of saying, “Holy cow, this is 10 times faster. This little piece of code is 10 times faster in Mojo.”

Chris: Outta the box, before you get to 35,000."

Lex: 但我也想知道,你为什么要尝试 Mojo 的用例是什么。所以,实际上……

Chris: 是的。

Lex: …它看起来像,所以,有娱乐。有说,我的天啊,这快了 10 倍。这一小段代码在 Mojo 中快了 10 倍。 的多巴胺冲击。

Chris: 开箱即用,在你达到 35000 倍之前。

Lex: Exactly. I mean, just even that, I mean, that’s the dopamine hit that every programmer sorta dreams of is the optimization. It’s also the drug that can pull you in and have you waste way too much of your life optimizing and over-optimizing, right? But, so what do you see would be, like, common? It’s very hard to predict, of course, but, you know, if you look 10 years from now, and Mojo’s super successful…

Chris: Yeah.

Lex: …what do you think would be the thing where people, like, try and then use it regularly, and it kinda grows and grows and grows and grows?"

Lex: 没错。我的意思是,即使是这样,我的意思是,那是每个程序员都梦寐以求的多巴胺冲击,是优化。它也是一种毒品,它可以把你拉进去,让你浪费太多的生命来优化和过度优化,对吧?但是,所以,你认为,什么会是,像,常见的?当然,这很难预测,但是,你知道,如果你从现在开始看 10 年,Mojo 超级成功……

Chris: 是的。

Lex: …你认为,什么会是人们,像,尝试,然后定期使用它,而且,它有点增长,增长,增长,增长?

Chris: Well, so you talked about the dopamine hit, and so one, again, humans are not one thing. And some people love rewriting their code and learning new things and throwing themselves in the deep end and trying out a new thing. In my experience, most people, they’re too busy. They have other things going on. By number, most people don’t want, like, this “I wanna rewrite all my code” but (chuckles), even those people, the too-busy people, the people that don’t actually care about the language, that just care about getting stuff done, those people do like learning new things, right?"

Chris: 好吧,所以,你谈到了多巴胺冲击,所以,一个,再次,人类不是一回事。有些人喜欢重写他们的代码,学习新的东西,并把自己扔到深水区,尝试新的东西。根据我的经验,大多数人,他们太忙了。他们有其他的事情要做。从数量上看,大多数人不想,像,这个我想重写我的所有代码,但 (轻笑),即使是那些人,那些太忙的人,那些实际上不关心语言的人,那些只关心完成工作的人,那些人确实喜欢学习新的东西,对吧?

Lex: Yeah.

Chris: And so you talk about the dopamine rush of 10x faster, “Wow, that’s cool. I wanna do that again.” Well, it’s also like, here’s this thing I’ve heard about in a different domain, and I don’t have to rewrite all my code. I can learn a new trick, right? Well, that’s called growth (chuckles), you know? And so one thing that I think is cool about Mojo, and again, those will take a little bit of time, for example, the blog posts and the books and, like, all that kinda stuff to develop, and the language needs to get further along, but what we’re doing, you talk about types, like, you can say, look, you can start with the world you already know, and you can progressively learn new things and adopt them where it makes sense. And if you never do that, that’s cool. You’re not a bad person. (chuckles) If you get really excited about it and wanna go all the way in the deep end and rewrite everything, and like, whatever, that’s cool, right? But I think the middle path is actually the more likely one where it’s, you know, you come out with a new idea, and you discover, “Wow, that makes my code way simpler, way more beautiful, way faster,” whatever, and I think that’s what people like. Now, if you fast forward and you said, like, 10 years out, right? I can give you a very different answer on that, which is, I mean, if you go back and look at what computers looked like 20 years ago, every 18 months, they got faster for free, right? 2x faster every 18 months. It was like clockwork. It was free, right? You go back 10 years ago, and we entered into this world where suddenly we had multi-core CPUs, and we had, and if you squint and turn your head, what a GPU is, is just a many-core, very simple CPU thing, kind of, right? And 10 years ago, it was CPUs and GPUs and graphics. Today, we have CPUs, GPUs, graphics, and AI because it’s so important because the compute is so demanding because of the smart cameras and the watches and all the different places that AI needs to work in our lives, it’s caused this explosion of hardware. And so, part of my thesis, part of my belief of where computing goes, if you look out 10 years from now, is it’s not gonna get simpler. Physics isn’t going back to where we came from. It’s only gonna get weirder from here on out, right? And so to me, the exciting part about what we’re building is it’s about building that universal platform which the world can continue to get weird. ‘Cause again, I don’t think it’s avoidable, it’s physics, but we can help lift people, scale, do things with it, and they don’t have to rewrite their code every time a new device comes out. And I think that’s pretty cool. And so, if Mojo can help with that problem, then I think that it will be, hopefully, quite interesting and quite useful to a wide range of people because there’s so much potential. And like there’s so much, you know, maybe analog computers will become a thing or something, right? And we need to be able to get into a mode where we can move this programming model forward but do so in a way where we’re lifting people and growing them instead of forcing them to rewrite all their code and exploding them."

Lex: 是的。

Chris: 所以,你谈到了快 10 倍的多巴胺冲击,哇,那太酷了。我想再做一次。 好吧,这也像,这是我在另一个领域听说过的东西,而且,我不必重写我的所有代码。我可以学习一个新的技巧,对吧?好吧,那叫做成长 (轻笑),你知道吗?所以,我认为关于 Mojo 的一件很酷的事情是,再次,那些将需要一点时间,例如,博客文章和书籍,以及,像,所有这类东西的开发,语言需要更进一步,但我们正在做的事情,你谈论的是类型,像,你可以说,看,你可以从你已经知道的世界开始,你可以逐步学习新的东西,并在它有意义的地方采用它们。如果你从来没有这样做过,那很酷。你不是一个坏人。(轻笑) 如果你真的对此感到兴奋,并想一路走到深水区,重写所有东西,而且,像,无论什么,那很酷,对吧?但我认为,中间道路实际上是更有可能的一条,在那里,你知道,你想出了一个新的想法,你发现,哇,这使得我的代码更简单,更漂亮,更快,无论什么,我认为,这就是人们喜欢的。现在,如果你快进,你说,像,10 年后,对吧?我可以给你一个非常不同的答案,那就是,我的意思是,如果你回顾一下 20 年前的计算机是什么样子的,每 18 个月,它们就会免费地变得更快,对吧?每 18 个月快 2 倍。它就像时钟一样。它是免费的,对吧?你回到 10 年前,我们进入了这个世界,突然,我们有了多核 CPU,我们有了,如果你眯着眼睛,转过头,GPU 是什么,它只是一个多核的,非常简单的 CPU,有点像,对吧?10 年前,它是 CPU,GPU 和图形。今天,我们有 CPU,GPU,图形和人工智能,因为它非常重要,因为计算需求量很大,因为智能相机和手表,以及人工智能在我们生活中需要工作的各个不同的地方,它导致了硬件的爆炸式增长。所以,我的论文的一部分,我对计算发展方向的信念的一部分,如果你从现在开始展望 10 年,是它不会变得更简单。物理学不会回到我们来的地方。它只会从现在开始变得更加怪异,对吧?所以,对我来说,我们正在构建的东西的令人兴奋的部分是,它是关于构建那个通用的平台,世界可以在这个平台上继续变得怪异。因为,再次,我认为,这是不可避免的,这是物理学,但我们可以帮助提升人们,扩展,用它做事情,而且,他们不必每次新设备出来的时候都重写他们的代码。我认为,那很酷。所以,如果 Mojo 可以帮助解决这个问题,那么我认为,它将会,希望,对很多人来说都很有趣,很有用,因为它有很大的潜力。而且,像,有这么多,你知道,也许模拟计算机会成为一回事,或者其他什么,对吧?我们需要能够进入一种模式,在那里我们可以推动这个编程模型向前发展,但要以一种提升人们,让他们成长的方式,而不是强迫他们重写所有的代码,并让他们爆炸。

Lex: Do you think there’ll be a few major libraries that go Mojo first?"

Lex: 你认为,会有一些主要的库首先使用 Mojo 吗?

Chris: Well, so I mean, the Modular engine is on Mojo (chuckles). So, again, come back to, like, we’re not building Mojo because it’s fun. We’re building Mojo because we had to solve these accelerators…

Lex: That’s the origin story, but I mean, ones that are currently in Python."

Chris: 好吧,所以,我的意思是,Modular 引擎是在 Mojo 上的 (轻笑)。所以,再次,回到,像,我们不是因为好玩才构建 Mojo 的。我们构建 Mojo 是因为我们必须解决这些加速器……

Lex: 那是起源故事,但我的意思是,那些目前在 Python 中的。

Chris: Yeah. So I think that a number of these projects will. And so one of the things, and again, this is just my best guess. Like, each of the package maintainers also has… I’m sure plenty of other things going on. People really don’t like rewriting code just for the sake of rewriting code. But sometimes, like, people are excited about, like, adopting a new idea.

Lex: Yeah.

Chris: And turns out that while rewriting code is generally not people’s first thing, turns out that redesigning something while you rewrite it, and using a rewrite as an excuse to redesign, can lead to the 2.0 of your thing that’s way better than the 1.0, right? And so I have no idea, I can’t predict that, but there’s a lot of these places where, again, if you have a package that is half C and half Python, right? You just solve the pain, make it easier to move things faster, make it easier to debug and evolve your tech. Adopting Mojo kinda makes sense to start with, and then it gives you this opportunity to rethink these things."

Chris: 是的。所以,我认为,这些项目中的一些会这样做。所以,其中一件事,再次,这只是我的最佳猜测。就像,每个软件包维护者也有……我相信,还有很多其他的事情正在发生。人们真的不喜欢为了重写代码而重写代码。但有时,像,人们对,像,采用一个新的想法感到兴奋。

Lex: 是的。

Chris: 而且,事实证明,虽然重写代码通常不是人们的第一件事,但事实证明,在你重写一些东西的同时重新设计它,并使用重写作为重新设计的借口,可以导致你的东西的 2.0 版本比 1.0 版本好得多,对吧?所以,我不知道,我无法预测,但有很多这样的地方,再次,如果你有一个包,一半是 C,一半是 Python,对吧?你只是解决了痛苦,让事情更快地移动,让调试和发展你的技术变得更容易。采用 Mojo 从一开始就很有意义,然后它给了你重新思考这些东西的机会。

Lex: So the two big gains are that there’s a performance gain, and then there’s the portability to all kinds of different devices.

Chris: And there’s safety, right? So you talk about real types. I mean, not saying this is for everybody, but that’s actually a pretty big thing, right?"

Lex: 所以,两个最大的好处是,有性能的提升,然后是所有不同类型设备的可移植性。

Chris: 还有安全性,对吧?所以,你谈论的是真正的类型。我的意思是,不是说这对每个人来说都是如此,但那实际上是一件相当大的事情,对吧?

Lex: Yeah, types are…

Chris: And so, there’s a bunch of different aspects of what, you know, what value Mojo provides. And so, I mean, it’s funny for me, like, I’ve been working on these kinds of technologies and tools for too many years now, but you look at Swift, right? And we talked about Swift for TensorFlow, but Swift as a programming language, right? Swift’s now 13 years old from when I started it?"

Lex: 是的,类型是……

Chris: 所以,有很多不同的方面,你知道,Mojo 提供了什么价值。所以,我的意思是,这对我来说很有趣,像,我已经在这些类型的技术和工具上工作了太多年了,但你看看 Swift,对吧?我们谈论的是 Swift for TensorFlow,但 Swift 作为一种编程语言,对吧?Swift 从我开始做它的时候到现在已经 13 年了?

Lex: Yeah.

Chris: ‘Cause I started in 2010, if I remember. And so that project, and I was involved with it for 12 years, or something, right, that project has gone through its own really interesting story arc, right? And it’s a mature, successful, used-by-millions-of-people system, right? Certainly not dead yet, right? But also, going through that story arc, I learned a tremendous amount about building languages, about building compilers, about working with the community and things like this. And so that experience, like I’m helping channel and bring directly into Mojo, and, you know, other systems, same thing. Like, apparently I like building, and iterating, and evolving things. And so you look at this LLVM thing that I worked on 20 years ago, and you look at MLIR, right? And so a lot of the lessons learned in LLVM got fed into MLIR, and I think that MLIR is a way better system than LLVM was. And, you know, Swift is a really good system, and it’s amazing, but I hope that Mojo will take the next step forward in terms of design."

Lex: 是的。

Chris: 因为我是在 2010 年开始的,如果我没记错的话。所以,那个项目,我参与了 12 年,或者类似的,对吧,那个项目经历了自己的非常有趣的故事弧线,对吧?而且,它是一个成熟的,成功的,被数百万人使用的系统,对吧?当然还没有死,对吧?但是,也通过经历那个故事弧线,我学到了很多关于构建语言,关于构建编译器,关于与社区合作,以及类似的东西。所以,那种经验,就像我正在帮助引导,并直接带入 Mojo,而且,你知道,其他的系统,同样的事情。就像,显然我喜欢构建,迭代,和进化东西。所以,你看看这个 LLVM 的东西,我在 20 年前做的,你看看 MLIR,对吧?所以,LLVM 中学到的很多教训都被输入到了 MLIR 中,我认为,MLIR 是一个比 LLVM 好得多的系统。而且,你知道,Swift 是一个非常好的系统,它很神奇,但我希望 Mojo 在设计方面会向前迈出下一步。

Lex: In terms of running Mojo, and people can play with it, what’s Mojo Playground?

Chris: Yeah.

Lex: And from the interface perspective and from the hardware perspective, what’s this incredible thing running on?"

Lex: 就运行 Mojo 而言,人们可以玩弄它,什么是 Mojo Playground?

Chris: 是的。

Lex: 从接口的角度,以及从硬件的角度,这个不可思议的东西运行在什么上面?

Chris: Yeah. So right now, so here we are, two weeks after launch…

Lex: Yes.

Chris: …we decided that, okay, we have this incredible set of technology that we think might be good, but we have not given it to lots of people yet. And so we were very conservative and said, “Let’s put it in a workbook so that if it crashes, we can do something about it. We can monitor and track that, right?” And so, again, things are still super early, but we’re having, like, one person a minute sign up with over 70,000 people (chuckles), two weeks in, is kinda crazy.

Lex: And you can sign up for Mojo Playground, and you can use it in the cloud.

Chris: Yeah.

Lex: …in your browser.

Chris: Yeah. And so, what that’s running on, right?"

Chris: 是的。所以,现在,所以,我们在这里,发布两周后……

Lex: 是的。

Chris: …我们决定,好吧,我们有这套不可思议的技术,我们认为它可能很好,但我们还没有把它交给很多人。所以,我们非常保守,并说,让我们把它放在一个工作簿中,这样,如果它崩溃了,我们可以做一些事情。我们可以监控和跟踪它,对吧? 所以,再次,事情还处于超级早期阶段,但我们有,像,每分钟有一个人注册,超过 70000 人 (轻笑),两周内,这有点疯狂。

Lex: 你可以注册 Mojo Playground,你可以在云端使用它。

Chris: 是的。

Lex: …在你的浏览器中。

Chris: 是的。所以,它运行在什么上面,对吧?

Lex: Notebook.

Chris: Yeah. What that’s running on is that’s running on cloud VMs. And so you share a machine with a bunch of other people, but it turns out there’s a bunch of them now because there’s a lot of people, and so what you’re doing is you’re getting free compute, and you’re getting to play with this thing in kind of a limited, controlled way so that we can make sure that it doesn’t totally crash and be embarrassing, right?"

Lex: 笔记本。

Chris: 是的。它运行在什么上面,它运行在云虚拟机上。所以,你与一堆其他人共享一台机器,但事实证明,现在有很多机器,因为有很多人,所以,你正在做的是,你正在获得免费的计算,你正在以一种有限的,受控的方式玩弄这个东西,这样我们就可以确保它不会完全崩溃,并让人尴尬,对吧?

Lex: Yeah.

Chris: So now, a lot of the feedback we’ve gotten is people wanna download it and run it locally, so we’re working on that right now, and so…

Lex: So that’s the goal, to be able to download it locally to…

Chris: Yeah, that’s what everybody expects. And so, we’re working on that right now. And so we just wanna make sure that we do it right. I think this is one of the lessons I learned from Swift also, by the way, is when we launched Swift, gosh, it feels like forever ago. It was 2014, and we, I mean, it was super exciting. I, and we, the team had worked on Swift for a number of years in secrecy, okay? And (chuckles) four years into this development, roughly, of working on this thing, at that point, about 250 people at Apple knew about it.

Lex: Yeah.

Chris: Okay? So it was a secret. Apple’s good at secrecy, and it was a secret project. And so we launched this at WWDC, a bunch of hoopla and excitement, and said, “Developers are gonna be able to develop and submit apps in the App Store in three months,” okay? Well, several interesting things happened, right? So first of all, we learned that it had a lot of bugs. It was not actually production quality, and it was extremely stressful in terms of, like, trying to get it working for a bunch of people. And so what happened was, we went from zero to, you know, I don’t know how many developers Apple had at the time, but a lot of developers overnight. And they ran into a lot of bugs, and it was really embarrassing, and it was very stressful for everybody involved, right? It was also very exciting ‘cause everybody was excited about it. The other thing I learned is that when that happened, roughly every software engineer who did not know about the project at Apple, their head exploded when it was launched, ‘cause they didn’t know it was coming. And so, they’re like, “Wait, what is this? I signed up to work for Apple because I love Objective-C. Why is there a new thing?” Right?"

Lex: 是的。

Chris: 所以,现在,我们收到的很多反馈是,人们想下载它,并在本地运行它,所以,我们现在正在做这件事,所以……

Lex: 所以,这就是目标,能够在本地下载它到……

Chris: 是的,这就是每个人都期望的。所以,我们现在正在做这件事。所以,我们只是想确保我们做对了。我认为,这也是我从 Swift 中学到的教训之一,顺便说一下,是当我们发布 Swift 的时候,天哪,感觉像是很久以前的事情了。那是 2014 年,而且,我们,我的意思是,它超级令人兴奋。我,而且,我们,团队秘密地做了 Swift 好几年,好吗?而且,(轻笑) 大约四年后,在这个开发中,在那个时候,苹果公司大约有 250 人知道它。

Lex: 是的。

Chris: 好吗?所以,这是一个秘密。苹果公司擅长保密,而且,它是一个秘密项目。所以,我们在 WWDC 上发布了这个,一堆喧闹和兴奋,并说,开发人员将能够在三个月内在 App Store 中开发和提交应用程序,好吗?好吧,发生了几件有趣的事情,对吧?所以,首先,我们了解到,它有很多错误。它实际上不是生产质量,而且,就,像,试图让它为一堆人工作而言,它极其有压力。所以,发生的事情是,我们从零到,你知道,我不知道苹果公司当时有多少开发人员,但一夜之间就有了很多开发人员。他们遇到了很多错误,而且,这真的很尴尬,而且,对所有参与其中的人来说都非常有压力,对吧?这也非常令人兴奋,因为每个人都对此感到兴奋。我学到的另一件事是,当那件事发生的时候,几乎每一个在苹果公司不知道这个项目的软件工程师,当它发布的时候,他们的脑袋都爆炸了,因为他们不知道它要来了。所以,他们就像,等等,这是什么?我签约为苹果公司工作,是因为我爱 Objective-C。为什么会有一个新的东西? 对吧?

Lex: Yeah.

Chris: And so now, what that meant practically is that the push from launch, to first of all the fall, but then to 2.0, and 3.0 and, like, all the way forward was super painful for the engineering team and myself. It was very stressful. The developer community was very grumpy about it because they’re like, “Okay, well, wait a second. You’re changing and breaking my code, and like, we have to fix the bugs,” and it was just, like, a lot of tension and friction on all sides. There’s a lot of technical debt in the compiler because we have to run really fast, and you have to go implement the thing and unblock the use case and do the thing, and you know it’s not right, but you never have time to go back and do it right. And I’m very proud of the Swift team because they’ve come, I mean, we, but they came so far, and made so much progress over this time since launch. It’s pretty incredible. And Swift is a very, very good thing, but I just don’t wanna do that again, right? And so…"

Lex: 是的。

Chris: 所以,现在,这实际上意味着,从发布到,首先是秋季,但然后到 2.0,3.0,以及,像,一直向前推进,对工程团队和我来说都超级痛苦。这非常有压力。开发者社区对此非常不满,因为他们就像,好吧,等等。你正在改变和破坏我的代码,而且,像,我们必须修复错误,而且,它只是,像,各方面都有很多紧张和摩擦。编译器中有很多技术债务,因为我们必须运行得非常快,而且,你必须去实现这个东西,并解除用例的阻塞,并做这件事,而且,你知道它不对,但你从来没有时间回去把它做对。我为 Swift 团队感到非常自豪,因为他们已经走了,我的意思是,我们,但他们已经走了这么远,而且,自发布以来,在这段时间里取得了很大的进步。这相当不可思议。Swift 是一件非常,非常好的东西,但我只是不想再做一次,对吧?所以……

Lex: So iterate more through the development process.

Chris: And so what we’re doing is we’re not launching it when it’s hopefully 0.9, with no testers. We’re launching it and saying it’s 0.1, right? And so, we’re setting expectations of saying, like, “Okay, well, don’t use this for production, right?” If you’re interested in what we’re doing, we’ll do it in an open way, and we can do it together, but don’t use it in production yet. Like, we’ll get there, but let’s do it the right way. And I’m also saying we’re not in a race. The thing that I wanna do is build the world’s best thing.

Lex: Yeah.

Chris: Right? Because if you do it right, and it lifts the industry, it doesn’t matter if it takes an extra two months.

Lex: Yeah.

Chris: Like, two months is worth waiting. And so, doing it right and not being overwhelmed with technical debt and things like this is like, again, war wounds, lessons learned, whatever you wanna say, I think is absolutely the right thing to do, even though right now, people are very frustrated that, you know, you can’t download it, or that it doesn’t have feature X or something like this. And so…"

Lex: 所以,在开发过程中进行更多的迭代。

Chris: 所以,我们正在做的是,我们不会在它希望是 0.9 版本的时候发布它,没有测试人员。我们正在发布它,并说它是 0.1 版本,对吧?所以,我们正在设定期望,比如,好吧,不要在生产中使用它,对吧? 如果你对我们正在做的事情感兴趣,我们将以一种开放的方式进行,我们可以一起做,但现在不要在生产中使用它。就像,我们会到达那里,但让我们以正确的方式进行。我还说,我们没有参加比赛。我想做的是构建世界上最好的东西。

Lex: 是的。

Chris: 对吧?因为,如果你做对了,而且,它提升了整个行业,那么,即使它需要额外两个月的时间,也无关紧要。

Lex: 是的。

Chris: 就像,两个月值得等待。所以,正确地做,而不是被技术债务和类似的东西所淹没,就像,再次,战争的创伤,吸取的教训,无论你想说什么,我认为,绝对是正确的事情,即使现在,人们非常沮丧,你知道,你不能下载它,或者它没有功能 X,或者类似的东西。所以……

Lex: What have you learned in a little bit of time, since it’s been released into the wild, that people have been complaining about feature X or Y or Z? What have they been complaining about? Whether they have been excited about, like, almost like detailed things versus a big thing. I think everyone’s would be very excited about the big vision."

Lex: 自它发布到野外以来,在这一点点时间里,你学到了什么,人们一直在抱怨功能 X 或 Y 或 Z?他们在抱怨什么?他们是否对,像,几乎像细节的东西与大的东西感到兴奋。我认为,每个人都会对大的愿景感到非常兴奋。

Chris: Yeah, yeah. Well, so I mean, I’ve been very pleased. I mean, in fact, I mean, we’ve been massively overwhelmed with response, which is a good problem to have. It’s kinda like a success disaster, in a sense, right?

Lex: Yeah.

Chris: And so, I mean, if you go back in time when we started Modular, which is just not yet a year and a half ago, so it’s still a pretty new company, new team, small but very good team of people, like, we started with extreme conviction that there’s a set of problems that we need to solve. And if we solve it, then people will be interested in what we’re doing, right? But again, you’re building in basically secret, right? You’re trying to figure it out. The creation’s a messy process. You’re having to go through different paths and understand what you wanna do and how to explain it. Often, when you’re doing disruptive and new kinds of things, just knowing how to explain it is super difficult, right? And so, when we launched, we hoped people would be excited, but, you know, I’m an optimist, but I’m also, like, I don’t wanna get ahead of myself. And so when people found out about Mojo, I think their heads exploded a little bit, right? And, you know, here’s a, I think a pretty credible team that has built some languages and some tools before, and so they have some lessons learned and are tackling some of the deep problems in the Python ecosystem and giving it the love and attention that it should be getting, and I think people got very excited about that. And so if you look at that, I mean, I think people are excited about ownership and taking a step beyond Rust, right? And there’s people that are very excited about that, and there’s people that are excited about, you know, just like “I made Game of Life go 400 times faster”, right? And things like that, and that’s really cool. There are people that are really excited about the, okay, “I really hate writing stuff in C++, save me.” "

Chris: 是的,是的。好吧,所以,我的意思是,我一直很高兴。我的意思是,实际上,我的意思是,我们已经被大量的回应淹没了,这是一个好的问题。它有点像一个成功的灾难,在某种意义上,对吧?

Lex: 是的。

Chris: 所以,我的意思是,如果你回到我们开始做 Modular 的时候,那是在一年半前,所以,它仍然是一个相当新的公司,新的团队,小但非常好的团队,像,我们一开始就非常坚信,有一系列问题需要我们解决。如果我们解决了它,那么人们就会对我们正在做的事情感兴趣,对吧?但再次,你基本上是在秘密地构建,对吧?你正在试图弄清楚它。创造是一个混乱的过程。你不得不走不同的路,并理解你想做什么,以及如何解释它。通常,当你做颠覆性的,新的东西的时候,仅仅知道如何解释它就超级困难,对吧?所以,当我们发布的时候,我们希望人们会感到兴奋,但,你知道,我是一个乐观主义者,但我也,像,我不想超越自己。所以,当人们发现 Mojo 的时候,我认为,他们的脑袋爆炸了一点,对吧?而且,你知道,这里有一个,我认为是一个相当可信的团队,他们以前构建了一些语言和一些工具,所以,他们吸取了一些教训,并正在解决 Python 生态系统中的一些深层次问题,并给予它应有的爱和关注,我认为,人们对此感到非常兴奋。所以,如果你看看那个,我的意思是,我认为,人们对所有权感到兴奋,并正在迈出 Rust 的下一步,对吧?有些人对此感到非常兴奋,有些人对,你知道,就像我让生命游戏的速度提高了 400 倍,感到兴奋,对吧?以及类似的东西,那真的很酷。有些人对,好吧,我真的很讨厌用 C++ 写东西,救救我。 感到非常兴奋。

Lex: Like systems engineers. They’re, like, stepping up, like, “Oh, yes.”

Chris: And so, that’s me, by the way, also.

Lex: Yeah.

Chris: I really wanna stop writing C++, but the…"

Lex: 就像系统工程师。他们,就像,站出来,像,哦,是的。

Chris: 所以,那也是我,顺便说一下。

Lex: 是的。

Chris: 我真的很想停止用 C++ 写东西,但是……

Lex: I get third-person excitement when people tweet, “Here, I made this code, Game of Life, or whatever, faster.” And you’re like, “Yeah.”

Chris: Yeah. And also, like, well, I would also say that, let me cast blame out to people who deserve it."

Lex: 当人们在推特上说,看,我让这段代码,生命游戏,或者其他什么,更快了。 的时候,我会感到第三人称的兴奋。你就像,是的。

Chris: 是的。而且,也像,好吧,我也会说,让我把责任推给那些应该承担责任的人。

Lex: Sure.

Chris: These terrible people who convinced me to do some of this: Jeremy Howard, that guy.

Lex: Yes, yes. Well, he’s been pushing for this kinda thing. He’s been pushing…

Chris: He’s wanted this for years.

Lex: Yeah. He’s wanted this for a long, long time."

Lex: 当然。

Chris: 这些说服我做这些事情的可怕的人:Jeremy Howard,那个人。

Lex: 是的,是的。好吧,他一直在推动这类事情。他一直在推动……

Chris: 他已经想要这个很多年了。

Lex: 是的。他已经想要这个很长时间了。

Chris: He’s wanted this for years, and so…

Lex: For people who don’t know Jeremy Howard, he is, like, one of the most legit people in the machine learning community. He’s grassroots, he really teaches, he’s an incredible educator. He is an incredible teacher, but also legit in terms of a machine learning engineer himself.

Chris: Yes.

Lex: And he’s been running the fast.ai, and looking, I think, for exactly what you’ve done with Mojo."

Chris: 他已经想要这个很多年了,所以……

Lex: 对于那些不认识 Jeremy Howard 的人来说,他,像,是机器学习社区中最合法的人之一。他是草根阶层,他真的在教书,他是一个不可思议的教育家。他是一个不可思议的老师,但作为一个机器学习工程师,他本身也是合法的。

Chris: 是的。

Lex: 而且,他一直在运营 fast.ai,而且,我认为,他一直在寻找你用 Mojo 做的 exactement。

Chris: Exactly. And so, I mean, the first time, so I met Jeremy pretty early on, but the first time I sat up and I’m like, “This guy is ridiculous” is when I was at Google, and we were bringing up TPUs, and we had a whole team of people, and there was this competition called DAWNBench of, “Who can train ImageNet fastest”, right?"

Chris: 没错。所以,我的意思是,第一次,所以,我很早就认识 Jeremy 了,但第一次我坐起来,我就像,这个人太荒谬了,是我在谷歌的时候,我们正在启动 TPU,我们有一个完整的团队,而且,有一个叫做 DAWNBench 的比赛,是谁可以最快地训练 ImageNet,对吧?

Lex: Yeah, yes.

Chris: And Jeremy and one of his researchers crushed Google (chuckles) by, not through sheer force of the amazing amount of compute and the number of TPUs and stuff like that, but he just decided that progressive image sizing was the right way to train the model in. You were an epoch faster and make the whole thing go vroom, right?

Lex: Yep.

Chris: And I’m like, “This guy is incredible.” So you can say…

Lex: Right.

Chris: …anyway, come back to, you know, where’s Mojo coming from? Chris finally listened to Jeremy. (Lex laughing) It’s all his fault."

Lex: 是的,是的。

Chris: Jeremy 和他的一个研究人员通过,不是通过纯粹的力量,惊人的计算量和 TPU 的数量,以及类似的东西,而是他只是决定,渐进式图像大小调整是在中训练模型的正确方法,击败了谷歌 (轻笑)。你快了一个 epoch,并让整个事情变得非常快,对吧?

Lex: 是的。

Chris: 我就像,这个人太不可思议了。 所以,你可以说……

Lex: 对。

Chris: …无论如何,回到,你知道,Mojo 是从哪里来的?Chris 终于听从了 Jeremy 的建议。(Lex 笑) 这都是他的错。

Lex: Well, there’s a kinda very refreshing, pragmatic view that he has about machine learning that, I don’t know if it, it’s like this mix of a desire for efficiency, but ultimately grounded and desired to make machine learning more accessible to a lot of people. I don’t know what that is.

Chris: Yeah.

Lex: I guess that’s coupled with efficiency and performance, but it’s not just obsessed about performance.

Chris: Well, so a lot of AI, and AI research, ends up being that it has to go fast enough to get scale. So a lot of people don’t actually care about performance, particularly on the research side until it allows them to have more, a bigger dataset, right? And so, suddenly now you care about distributed compute and, like, all these exotic HPC, like, you don’t actually wanna know about that. You just want to be able to do more experiments faster and do so with bigger datasets, right? And so, Jeremy has been really pushing the limits, and one of the things I’ll say about Jeremy, and there’s many things I could say about Jeremy, ‘cause I’m a fanboy of his, but it fits in his head, and Jeremy actually takes the time, where many people don’t, to really dive deep into, “Why is the beta parameter of the Adam optimizer equal to this?” Right?"

Lex: 好吧,他有一种关于机器学习的非常令人耳目一新的,务实的观点,我不知道它,它就像是对效率的渴望的混合,但最终扎根于并渴望让机器学习对更多的人来说更容易获得。我不知道那是什么。

Chris: 是的。

Lex: 我想,那是与效率和性能相结合的,但它不仅仅是痴迷于性能。

Chris: 好吧,所以,很多人工智能,以及人工智能研究,最终都必须足够快才能获得规模。所以,很多人实际上并不关心性能,特别是在研究方面,直到它允许他们拥有更多,更大的数据集,对吧?所以,现在你突然关心分布式计算,以及,像,所有这些奇异的 HPC,像,你实际上不想知道。你只是希望能够更快地做更多的实验,并用更大的数据集来做,对吧?所以,Jeremy 一直在真正地挑战极限,而且,关于 Jeremy 的一件事,关于 Jeremy 的事情我可以说很多,因为我是他的粉丝,但它适合他的脑袋,而且,Jeremy 实际上花了时间,很多人都没有花时间,去真正深入研究,为什么 Adam 优化器的 beta 参数等于这个? 对吧?

Lex: Yeah.

Chris: And he’ll go survey and understand what are all the activation functions and the trade-offs and, “Why is it that everybody that does, you know, this model picks that thing?”

Lex: So the why. Not just trying different values. Like, “Really, what is going on here?”"

Lex: 是的。

Chris: 而且,他会去调查,并理解所有激活函数是什么,以及权衡,以及,为什么每个人都,你知道,这个模型选择了那个东西?

Lex: 所以,为什么。不仅仅是尝试不同的值。就像,这里到底发生了什么?

Chris: Right. And so, as a consequence of that, like, he’s always, he, again, he makes time, but he spends time to understand things at a depth that a lot of people don’t. And as you say, he then brings it and teaches people…

Lex: Teaches it.

Chris: …and his mission is to help lift, you know, his website says, “Making AI uncool again.” Like, it’s about, like, forget about the hype. It’s actually practical and useful. Let’s teach people how to do this, right? Now, the problem Jeremy struggled with is that he’s pushing the envelope, right? Research isn’t about doing the thing that is staying on the happy path, or the well-paved road, right? And so a lot of the systems today have been these really fragile, fragmented things that are special cased in this happy path. And if you fall off the happy path, you get eaten by an alligator. (chuckles)"

Chris: 对。所以,因此,像,他总是,他,再次,他腾出时间,但他花时间以很多人没有的深度来理解事物。正如你所说,他然后把它带来,并教人们……

Lex: 教它。

Chris: …而且,他的任务是帮助提升,你知道,他的网站上说,让 AI 再次变得不酷。 就像,它是关于,像,忘记炒作。它实际上是实用和有用的。让我们教人们如何做,对吧?现在,Jeremy 挣扎的问题是,他正在挑战极限,对吧?研究不是关于做那些停留在快乐的道路上,或者铺好的道路上的事情,对吧?所以,今天的很多系统都是这些真正脆弱的,支离破碎的东西,它们在这种快乐的道路上是特殊情况。如果你偏离了快乐的道路,你就会被鳄鱼吃掉。(轻笑)

Lex: (chuckles) So what about… So Python has this giant ecosystem of packages, and there’s a package repository. Do you have ideas of how to do that well for Mojo? How to do a repository of packages well?"

Lex: (轻笑) 那么,关于……所以,Python 有这个巨大的软件包生态系统,而且,有一个软件包仓库。你对如何为 Mojo 做好这件事有什么想法吗?如何做好软件包仓库?

Chris: So that’s another really interesting problem that I knew about but I didn’t understand how big of a problem it was: Python packaging. A lot of people have very big pain points, and a lot of scars, with Python packaging.

Lex: Oh, you mean, so there’s several things to say.

Chris: Building and distributing and managing dependencies…

Lex: Yes.

Chris: …and versioning and all this stuff.

Lex: So from the perspective of, if you want to create your own package, and then…

Chris: Yes, yeah.

Lex: …or you wanna build on top of a bunch of other people’s packages, and then they get updated and things like this. Now, I’m not an expert in this, so I don’t know the answer. I think this is one of the reasons why it’s great that we work as a team, and there’s other really good and smart people involved, but one of the things I’ve heard from smart people who’ve done a lot of this is that the packaging becomes a huge disaster when you get the Python and C together. And so, if you have this problem where you have code split between Python and C, now not only do you have to package the C code, you have to build the C code. C doesn’t have a package manager, right? C doesn’t have a dependency versioning management system, right? And so I’m not experiencing the state-of-the-art and all the different Python package managers, but my understanding is that’s a massive part of the problem, and I think Mojo solves that part of the problem directly, head-on. Now, one of the things I think we’ll do with the community, and this isn’t, again, we’re not solving all the world’s problems at once, we have to be kinda focused, to start with, is that I think that we will have an opportunity to re-evaluate packaging, right? And so, I think that we can come back and say, “Okay, well, given the new tools and technologies and the cool things we have that we’ve built up, because we have not just syntax, we have an entirely new compiler stack that works in a new way, maybe there’s other innovations we can bring together, and maybe we can help solve that problem.”

Chris: 所以,那是我知道的另一个真正有趣的问题,但我不知道它有多大:Python 打包。很多人对 Python 打包有很大的痛点,而且,有很多伤疤。

Lex: 哦,你是说,所以,有几件事要说。

Chris: 构建和分发以及管理依赖项……

Lex: 是的。

Chris: …以及版本控制,以及所有这些东西。

Lex: 所以,从这个角度来看,如果你想创建你自己的包,然后……

Chris: 是的,是的。

Lex: …或者你想在其他人的一堆包的基础上构建,然后他们更新了,以及类似的东西。现在,我不是这方面的专家,所以,我不知道答案。我认为,这就是为什么我们作为一个团队工作很棒的原因之一,而且,还有其他真正优秀和聪明的人参与其中,但其中一件事,我从那些做过很多这方面工作的人那里听到的是,当你把 Python 和 C 放在一起的时候,打包就会变成一个巨大的灾难。所以,如果你有这个问题,你的代码被分割成 Python 和 C,现在,你不仅要打包 C 代码,你还要构建 C 代码。C 没有包管理器,对吧?C 没有依赖项版本控制管理系统,对吧?所以,我没有体验过最先进的,以及所有不同的 Python 包管理器,但我的理解是,那是问题的一个很大一部分,而且,我认为,Mojo 直接,正面地解决了问题的这一部分。现在,我认为,我们将与社区一起做的一件事是,这不是,再次,我们不会一次性解决世界上所有的问题,我们必须有点专注,首先,我认为,我们将有机会重新评估打包,对吧?所以,我认为,我们可以回来,并说,好吧,考虑到新的工具和技术,以及我们已经构建的酷的东西,因为我们不仅仅有语法,我们有一个全新的编译器栈,它以一种新的方式工作,也许还有其他的创新我们可以整合在一起,也许我们可以帮助解决这个问题。

Lex: So almost a tangent to that question, from the user perspective of packages. It was always surprising to me that it was not easier to sort of explore and find packages, you know, with, with pip install. It’s an incredible ecosystem. It’s huge. It’s just interesting that it wasn’t made, it’s still, I think, not made easier to discover packages. To do, yeah, like search and discovery, as YouTube calls it.

Chris: Well, I mean, it is kinda funny because this is one of the challenges of these like intentionally decentralized communities, and so…

Lex: Yeah.

Chris: …I don’t know what the right answer is for Python. I mean, there are many people that, I don’t even know the right answer for Mojo. Like, so there are many people that would have much more informed opinions than I do, but it’s interesting if you look at this, right? Open source communities, you know, there’s Git. Git is a fully decentralized and anybody can do it any way they want, but then there’s GitHub, right? And GitHub centralized, commercial in that case, right? The thing really helped pull together and help solve some of the discovery problems and help build a more consistent community. And so, maybe there’s opportunities for…"

Lex: 所以,几乎是那个问题的一个题外话,从包的用户角度来看。我总是惊讶于,它没有更容易地去探索和发现包,你知道,用,用 pip install。这是一个不可思议的生态系统。它很大。只是有趣的是,它没有被制造出来,它仍然,我认为,没有更容易地发现包。做,是的,像搜索和发现,正如 YouTube 所称。

Chris: 好吧,我的意思是,这有点有趣,因为这是这些像故意去中心化的社区的挑战之一,所以……

Lex: 是的。

Chris: …我不知道 Python 的正确答案是什么。我的意思是,有很多的人,我甚至不知道 Mojo 的正确答案是什么。像,所以,有很多的人会有比我更明智的意见,但如果你看看这个,这很有趣,对吧?开源社区,你知道,有 Git。Git 是完全去中心化的,任何人都可以以他们想要的任何方式做,但后来有了 GitHub,对吧?GitHub 中心化了,在那种情况下,是商业化的,对吧?它真的帮助把所有东西拉到一起,并帮助解决了一些发现问题,并帮助建立了一个更一致的社区。所以,也许有机会……

Lex: There’s something like a GitHub for…

Chris: Yeah.

Lex: Although even GitHub, I might be wrong on this, but the search and discovery for GitHub is not that great. Like, I still use Google search.

Chris: Yeah, well, I mean, maybe that’s because GitHub doesn’t wanna replace Google search, right? I think there is room for specialized solutions to specific problems, but sure, I don’t know. I don’t know the right answer for GitHub either. They can go figure that out.

Lex: But the point is to have an interface that’s usable, that’s successful to people of all different skill levels, and…

Chris: So, well, and again, like, what are the benefit of standards, right? Standards allow you to build these next level-up ecosystems and next level-up infrastructure, and next level-up things. And so, again, come back to, “I hate complexity.” C plus Python is complicated. It makes everything more difficult to deal with. It makes it difficult to port, move code around, work with. All these things get more complicated, and so, I mean, I’m not an expert, but maybe Mojo can help a little bit by helping reduce the amount of C in this ecosystem and make it, therefore, scale better."

Lex: 有一个像 GitHub for……的东西

Chris: 是的。

Lex: 虽然,即使是 GitHub,我可能错了,但 GitHub 的搜索和发现并没有那么好。就像,我仍然使用谷歌搜索。

Chris: 是的,好吧,我的意思是,也许那是因为 GitHub 不想取代谷歌搜索,对吧?我认为,有专门针对特定问题的解决方案的空间,但当然,我不知道。我也不知道 GitHub 的正确答案是什么。他们可以去弄清楚。

Lex: 但关键是要有一个可用的接口,对所有不同技能水平的人来说都是成功的,而且……

Chris: 所以,好吧,再次,像,标准的好处是什么,对吧?标准允许你构建这些下一级的生态系统,下一级的基础设施,以及下一级的东西。所以,再次,回到,我讨厌复杂性。 C 加 Python 很复杂。它使所有事情都更难处理。它使移植,移动代码,以及与之合作变得困难。所有这些事情都变得更加复杂,所以,我的意思是,我不是专家,但也许 Mojo 可以通过帮助减少这个生态系统中的 C 的数量来提供一点帮助,并使它,因此,更好地扩展。

Lex: So any kind of packages that are hybrid in nature would be a natural fit to move to Mojo, which…

Chris: Which is a lot of them, by the way.

Lex: Yeah.

Chris: So a lot of them, especially that are doing some interesting stuff computation-wise.

Lex: Yeah, yeah. Let me ask you about some features.

Chris: Yeah.

Lex: So we talked about obviously indentation, that it’s a typed language, or optionally typed. Is that the right way to say it?"

Lex: 所以,任何类型的本质上是混合的包都将非常适合迁移到 Mojo,这……

Chris: 顺便说一下,其中有很多。

Lex: 是的。

Chris: 所以,其中很多,特别是那些在计算方面做一些有趣的事情的包。

Lex: 是的,是的。让我问你一些功能。

Chris: 是的。

Lex: 所以,我们谈论了显然是缩进,它是一种类型化语言,或者可选类型化。这是正确的说法吗?

Chris: It’s either optional, or progressively, or…

Lex: Progressively, okay.

Chris: I think the… So people have very strong opinions on the right word to use.

Lex: Yeah.

Chris: I don’t know.

Lex: I look forward to your letters. So there’s the var versus let, but let is for constants.

Chris: Yeah.

Lex: var is… optional.

Chris: Yeah, var makes it mutable, so you can reassign."

Chris: 它要么是可选的,要么是渐进式的,要么是……

Lex: 渐进式的,好的。

Chris: 我认为……所以,人们对使用哪个词有很强的意见。

Lex: 是的。

Chris: 我不知道。

Lex: 我期待着你的来信。所以,有 var 和 let,但 let 是用于常量的。

Chris: 是的。

Lex: var 是……可选的。

Chris: 是的,var 使它可变,所以,你可以重新赋值。

Lex: Okay. Then there’s function overloading.

Chris: Oh, okay, yeah.

Lex: I mean, there’s a lot of sources of happiness for me, but function overloading, that’s, I guess, is that for performance or is that… Why does Python not have function overloading?"

Lex: 好的。然后是函数重载。

Chris: 哦,好的,是的。

Lex: 我的意思是,对我来说,有很多快乐的来源,但函数重载,我想,那是为了性能,还是……为什么 Python 没有函数重载?

Chris: So I can speculate. So Python is a dynamic language. The way it works is that Python and Objective-C are actually very similar worlds if you ignore syntax. And so Objective-C is a straight-line derived from Smalltalk, a really venerable, interesting language that much of the world has forgotten about, but the people that remember it love it generally. And the way that Smalltalk works is that every object has a dictionary in it, and the dictionary maps from the name of a function or the name of a value within an object to its implementation. And so the way you call a method in Objective-C is you say, “Go look up, the way I call foo is I go look up foo. I get a pointer to the function back, and then I call it,” okay, that’s how Python works, right? And so now the problem with that is that the dictionary within a Python object, all the keys are strings, and it’s a dictionary.

Lex: Yeah.

Chris: So you can only have one entry per name. You think.

Lex: It’s as simple as that.

Chris: I think it’s as simple as that. And so now, why do they never fix this? Like, why do they not change it to not be a dictionary anymore, they not change, like, do other things?"

Chris: 所以,我可以推测。所以,Python 是一种动态语言。它的工作方式是,如果你忽略语法,Python 和 Objective-C 实际上是非常相似的世界。所以,Objective-C 是直接从 Smalltalk 派生出来的,Smalltalk 是一种真正值得尊敬的,有趣的语言,世界上很多人都忘记了它,但那些记得它的人通常都喜欢它。Smalltalk 的工作方式是,每个对象中都有一个字典,字典将对象中函数的名称或值的名称映射到它的实现。所以,你在 Objective-C 中调用方法的方式是,你说,去查找,我调用 foo 的方式是,我去查找 foo。我得到一个指向函数的指针,然后我调用它,好吧,这就是 Python 的工作方式,对吧?所以,现在,问题是,Python 对象中的字典,所有的键都是字符串,而且,它是一个字典。

Lex: 是的。

Chris: 所以,你每个名称只能有一个条目。你想。

Lex: 就这么简单。

Chris: 我认为,就这么简单。所以,现在,为什么他们从来没有修复这个问题?就像,为什么他们不把它改成不再是字典,他们不改变,像,做其他的事情?

Lex: Well, you don’t really have to in Python because it’s dynamic. And so you can say, “I get into the function now, if I got passed an integer, do some dynamic test for it. If it’s a string, go do another thing.

Chris: There’s another additional challenge, which is even if you did support overloading, you’re saying, okay, well, here’s a version of a function for integers and a function for strings. Well, even if you could put it in that dictionary, you’d have to have the caller do the dispatch. And so, every time you call the function, you’d have to say, like, “Is it an integer or is it a string?” And so, you’d have to figure out where to do that test. And so, in a dynamic language, overloading is something you general, you don’t have to have. But now you get into a typed language, and, you know, in Python, if you subscript with an integer, then you get typically one element out of a collection. If you subscript with a range, you get a different thing out, right? And so, often, in typed languages, you’ll wanna be able to express the fact that, cool, I have different behavior, depending on what I actually pass into this thing. And if you can model that, it can make it safer, and more predictable, and faster, and, like, all these things.”

Lex: 好吧,你实际上不必在 Python 中这样做,因为它是动态的。所以,你可以说,我现在进入函数,如果我被传递了一个整数,就对它进行一些动态测试。如果它是一个字符串,就去做另一件事。

Chris: 还有一个额外的挑战,那就是,即使你支持重载,你也在说,好吧,这里有一个用于整数的函数版本和一个用于字符串的函数版本。好吧,即使你可以把它放在那个字典中,你也必须让调用者进行分派。所以,每次你调用函数的时候,你都必须说,比如,它是一个整数还是一个字符串? 所以,你必须弄清楚在哪里做那个测试。所以,在动态语言中,重载是你通常,你不必拥有的东西。但现在你进入了一种类型化语言,而且,你知道,在 Python 中,如果你用一个整数下标,那么你通常会从一个集合中得到一个元素。如果你用一个范围下标,你会得到一个不同的东西,对吧?所以,通常,在类型化语言中,你会希望能够表达这样一个事实,酷,我根据我实际传递给它的东西,有不同的行为。如果你可以建模,它可以使它更安全,更可预测,更快,而且,像,所有这些东西。

Lex: It somehow feels safer, yes, but also feels empowering, like in terms of clarity. Like, you don’t have to design whole different functions.

Chris: Yeah. Well, and this is also one of the challenges with the existing Python typing systems is that in practice, like, you take subscript, like in practice, a lot of these functions, they don’t have one signature, right? They actually have different behavior in different cases, and so this is why it’s difficult to, like, retrofit this into existing Python code and make it play well with typing. You kinda have to design for that."

Lex: 不知何故,它感觉更安全,是的,但它也感觉更有力量,比如,就清晰度而言。就像,你不必设计完全不同的函数。

Chris: 是的。好吧,这也是现有 Python 类型系统面临的挑战之一,那就是,在实践中,像,你取下标,像,在实践中,很多这些函数,它们没有一个签名,对吧?它们实际上在不同的情况下有不同的行为,所以,这就是为什么很难,像,将它改装到现有的 Python 代码中,并使它与类型很好地配合。你有点必须为此而设计。

Lex: Okay. So there’s an interesting distinction that people that program Python might be interested in, is def versus fn. So it’s two different ways to define a function.

Chris: Yep.

Lex: And fn is a stricter version of def. What’s the coolness that comes from the strictness?"

Lex: 好的。所以,有一个有趣的区别,那些编程 Python 的人可能会感兴趣,那就是 def 和 fn。所以,这是定义函数的两种不同方式。

Chris: 是的。

Lex: 而且,fn 是 def 的一个更严格的版本。严格性带来的酷是什么?

Chris: So here you get into, what is the trade-off with the superset?

Lex: Yes.

Chris: Okay. So superset, you have to, or you really want to be compatible. Like, if you’re doing a superset, you’ve decided compatibility with existing code is the important thing, even if some of the decisions they made were maybe not what you’d choose.

Lex: Yeah, okay.

Chris: So that means you put a lot of time into compatibility, and it means that you get locked into decisions of the past, even if they may not have been a good thing, right? Now, systems programmers typically like to control things, right? And they wanna make sure that, you know, not all cases of course, and even systems programmers are not one thing, right? But often, you want predictability. And so, one of the things that Python has, for example, as you know, is that if you define a variable, you just say, x = 4, I have a variable named X. Now I say, some_long_method or some_long_name = 17. print(some_long_name), oops, but I typoed it, right? Well, the compiler, the Python compiler, doesn’t know in all cases what you’re defining and what you’re using and did you typo the use of it or the definition, right? And so, for people coming from typed languages, again, I’m not saying they’re right or wrong, but that drives them crazy because they want the compiler to tell them you typoed the name of this thing, right? And so, what fn does is it turns on, as you say, it’s a strict mode. And so it says, “Okay, well, you have to actually declare, intentionally declare your variables before you use them.” That gives you more predictability, more error checking, and things like this, but you don’t have to use it. And this is a way that Mojo is both compatible ‘cause defs work the same way that defs have always worked, but it provides a new alternative that gives you more control, and it allows certain kinds of people that have a different philosophy to be able to express that and get that."

Chris: 所以,在这里,你进入了,与超集的权衡是什么?

Lex: 是的。

Chris: 好的。所以,超集,你必须,或者你真的想兼容。就像,如果你正在做一个超集,你已经决定与现有代码的兼容性是重要的事情,即使他们做出的一些决定可能不是你选择的。

Lex: 是的,好的。

Chris: 所以,这意味着,你投入了很多时间来实现兼容性,而且,这意味着,你被锁定了过去的决定,即使它们可能不是一件好事,对吧?现在,系统程序员通常喜欢控制东西,对吧?他们想确保,你知道,当然,不是所有情况,即使是系统程序员也不是一回事,对吧?但通常,你想要可预测性。所以,Python 拥有的其中一件事,例如,正如你所知,是如果你定义了一个变量,你只是说,x = 4,我有一个名为 X 的变量。现在我说,some_long_method 或 some_long_name = 17。print(some_long_name),糟糕,但我打错了,对吧?好吧,编译器,Python 编译器,在所有情况下都不知道你正在定义什么,你正在使用什么,你是否打错了它的使用,或者定义,对吧?所以,对于那些来自类型化语言的人来说,再次,我不是说他们是对的还是错的,但这会让他们发疯,因为他们希望编译器告诉他们,你打错了这个东西的名字,对吧?所以,fn 所做的是,正如你所说,它打开了严格模式。所以,它说,好吧,你必须实际声明,有意声明你的变量,在你使用它们之前。 这给了你更多的可预测性,更多的错误检查,以及类似的东西,但你不必使用它。这就是 Mojo 既兼容的方式,因为 def 的工作方式与 def 一直以来的工作方式相同,但它提供了一个新的选择,它给了你更多的控制,而且,它允许某些有不同哲学的人能够表达这一点,并获得这一点。

Lex: But usually, if you’re writing Mojo code from scratch, you’ll be using fn.

Chris: It depends, again, it depends on your mentality, right? It’s not that def is Python and fn is Mojo. Mojo has both, and it loves both, right? It really depends on, that is just strict, yeah, exactly. Are you playing around and scripting something out? Is it a one-off throwaway script? Cool. Like, Python is great at that."

Lex: 但通常,如果你从头开始编写 Mojo 代码,你将使用 fn。

Chris: 这取决于,再次,这取决于你的心态,对吧?不是说 def 是 Python,fn 是 Mojo。Mojo 都有,它都喜欢,对吧?它真的取决于,那只是严格的,是的,没错。你是在玩耍,并编写一些东西吗?它是一个一次性的丢弃脚本吗?酷。就像,Python 非常擅长这一点。

Lex: I’ll still be using fn, but yeah.

Chris: Well, so I love strictness. Okay.

Lex: Well, so control, power. You also like suffering, right?

Chris: Yes, they go hand in hand.

Lex: How many pull-ups?

Chris: I’ve lost count at this, yeah, exactly, at this point.

Lex: So, and that’s cool. I love you for that. Yeah, and I love other people who like strict things, right, but I don’t wanna say that that’s the right thing because Python’s also very beautiful for hacking around and doing stuff in research, and these other cases where you may not want that."

Lex: 我仍然会使用 fn,但是,是的。

Chris: 好吧,所以,我喜欢严格性。好的。

Lex: 好吧,所以,控制,权力。你也喜欢痛苦,对吧?

Chris: 是的,它们是相辅相成的。

Lex: 多少个引体向上?

Chris: 我已经数不清了,是的,没错,在这一点上。

Lex: 所以,那很酷。我为此爱你。是的,而且,我也爱其他喜欢严格的东西的人,对吧,但我不想说那是正确的事情,因为 Python 对于破解和做研究也很美妙,而且,在其他一些情况下,你可能不想要那个。

Lex: You see, I just feel like, maybe I’m wrong in that, but it feels like strictness leads to faster debugging. So in terms of going from, even on a small project, from zero to completion, it just, I guess it depends on how many bugs you generate usually. Yeah.

Chris: Well, so I mean, if it’s, again, lessons learned in looking at the ecosystem, it’s really, I mean, I think it’s if you study some of these languages over time, like the Ruby community, for example. Now, Ruby is a pretty well-developed, pretty established community, but along their path, they really invested in unit testing. Like, so I think that the Ruby community is really pushed forward the state-of-the-art of testing because they didn’t have a type system that caught a lot of bugs at compile time, right? And so you can have the best of both worlds. You can have good testing and good types, right, and things like this. But I thought that it was really interesting to see how certain challenges get solved. And in Python, for example, the interactive notebook kind of experiences and stuff like this are really amazing. And if you typo something, it doesn’t matter, it just tells you it’s fine, right? And so, I think that the trades are very different if you’re building a, you know, large-scale production system versus you’re building and exploring a notebook."

Lex: 你看,我只是觉得,也许我错了,但感觉严格性会导致更快的调试。所以,就从,即使在一个小项目上,从零到完成,它只是,我想,这取决于你通常会产生多少错误。是的。

Chris: 好吧,所以,我的意思是,如果它,再次,从观察生态系统中吸取的教训,它真的是,我的意思是,我认为,如果你随着时间的推移研究其中的一些语言,比如 Ruby 社区,例如。现在,Ruby 是一个相当成熟的,相当成熟的社区,但沿着他们的道路,他们真的投资于单元测试。像,所以,我认为,Ruby 社区真的推动了测试的最先进水平,因为他们没有一个在编译时捕获很多错误的类型系统,对吧?所以,你可以拥有两全其美。你可以有好的测试和好的类型,对吧,以及类似的东西。但我认为,看到某些挑战是如何被解决的,真的很有趣。例如,在 Python 中,交互式笔记本类型的体验和类似的东西真的很棒。如果你打错了什么,没关系,它只是告诉你它很好,对吧?所以,我认为,如果你正在构建一个,你知道,大规模的生产系统,与你正在构建和探索一个笔记本,交易是非常不同的。

Lex: And speaking of control, the hilarious thing if you look at code I write just for myself, for fun, it’s like littered with asserts everywhere, okay?

Chris: It’s kinda, well, then…

Lex: Yeah. You would like the text.

Chris: It’s basically saying in a dictatorial way, “This should be true now, otherwise, everything stops.”

Lex: Well, and that is the sign, and I love you, man, but that is a sign of somebody who likes control. And so, yes.

Chris: Yeah."

Lex: 说到控制,如果你看看我为自己写的代码,为了好玩,它就像到处都是断言,好吗?这很有趣。

Chris: 它有点,好吧,然后……

Lex: 是的。你会喜欢文本的。

Chris: 它基本上是以一种独裁的方式说,现在这应该是真的,否则,一切都停止。

Lex: 好吧,那就是迹象,而且,我爱你,伙计,但那是喜欢控制的人的迹象。所以,是的。

Chris: 是的。

Lex: I think that you’ll like fn. This is turning into a, “I think I like Mojo…”

Chris: …therapy session. Yes. I definitely will.

Lex: Speaking of asserts, exceptions are called errors. Why is it called errors?"

Lex: 我认为,你会喜欢 fn。这正在变成一个,我认为我喜欢 Mojo……

Chris: …治疗环节。是的。我肯定会。

Lex: 说到断言,异常被称为错误。为什么它被称为错误?

Chris: So we, I mean, we use the same, we’re the same as Python, right? But we implement it a very different way, right? And so, if you look at other languages, like we’ll pick on C++, our favorite, right? C++ has a thing called zero-cost exception handling, okay? So, and this is, in my opinion, something to learn lessons from.

Lex: It’s a nice, polite way of saying it."

Chris: 所以,我们,我的意思是,我们使用相同的,我们和 Python 一样,对吧?但我们以一种非常不同的方式实现它,对吧?所以,如果你看看其他语言,比如,我们将选择 C++,我们最喜欢的,对吧?C++ 有一个叫做零成本异常处理的东西,好吗?所以,而且,在我看来,这是值得吸取教训的东西。

Lex: 这是一个很好的,礼貌的说法。

Chris: And so, zero-cost exception handling, the way it works is that it’s called zero-cost because if you don’t throw an exception, there’s supposed to be no overhead for the non-error code. And so, it takes the error path out of the common path. It does this by making throwing an error extremely expensive. And so, if you actually throw an error with a C++ compiler using exceptions, it has to go look up in tables on the side and do all this stuff, and so throwing an error can be, like, 10,000 times more expensive than returning from a function, right? Also, it’s called zero-cost exceptions, but it’s not zero-cost by any stretch of the imagination because it massively blows out your code, your binary, it also adds a whole bunch of different paths because it disrupts and other things like that that exist in C++, and it reduces the number of optimizations it has, like, all these effects. And so this thing that was called zero-cost exceptions, it really ain’t, okay. Now, if you fast forward to newer languages, and this includes Swift and Rust and Go, and now Mojo, well, and Python’s a little bit different because it’s interpreted, and so, like, it’s got a little bit of a different thing going on, but if you look at it, if you look at compiled languages, many newer languages say, “Okay, well, let’s not do that zero-cost exception handling thing. Let’s actually treat throwing an error the same as returning a variant, returning either the normal result or an error. Now, programmers generally don’t want to deal with all the typing machinery and, like, pushing around a variant, and so you use all the syntax that Python gives us, for example, try, and catch, and, you know, functions that raise and things like this. You can put a raises decorator on your functions, stuff like this, and if you wanna control that, and then the language can provide syntax for it. But under the hood, the way the computer executes it, throwing an error is basically as fast as returning something.” "

Chris: 所以,零成本异常处理,它的工作方式是,它被称为零成本,因为如果你不抛出异常,非错误代码应该没有开销。所以,它将错误路径从公共路径中移除。它通过使抛出错误变得极其昂贵来做到这一点。所以,如果你实际上用一个使用异常的 C++ 编译器抛出一个错误,它必须去旁边的表中查找,并做所有这些事情,所以,抛出一个错误可能是,像,比从函数返回贵 10000 倍,对吧?而且,它被称为零成本异常,但它绝不是零成本,因为它会极大地破坏你的代码,你的二进制文件,它还会添加一大堆不同的路径,因为它会破坏 C++ 中存在的其他东西,而且,它会减少它拥有的优化数量,像,所有这些影响。所以,这个被称为零成本异常的东西,它实际上不是,好吗?现在,如果你快进到更新的语言,这包括 Swift 和 Rust 和 Go,现在还有 Mojo,好吧,Python 有点不同,因为它是被解释的,所以,像,它有一点不同的事情正在发生,但如果你看看它,如果你看看编译语言,很多更新的语言说,好吧,让我们不要做那个零成本异常处理的事情。让我们实际上将抛出错误与返回一个变量,返回正常结果或错误,同等对待。现在,程序员通常不想处理所有的类型机制,以及,像,到处传递一个变量,所以,你使用 Python 给我们的所有语法,例如,try,和 catch,以及,你知道,抛出函数,以及类似的东西。你可以把一个 raises 装饰器放在你的函数上,类似这样的东西,如果你想控制它,然后语言可以为它提供语法。但在幕后,计算机执行它的方式,抛出一个错误基本上和返回一些东西一样快。

Lex: Oh, interesting. So it’s exactly the same way from a compiler perspective.

Chris: And so this is actually, I mean, it’s a fairly nerdy thing, right? Which is why I love it, but this has a huge impact on the way you design your APIs, right? So in C++, huge communities turn off exceptions because the cost is just so high, right? And so the zero-cost, the cost is so high, right? And so, that means you can’t actually use exceptions in many libraries, right?

Lex: Interesting. Yeah.

Chris: And even for the people that do use it, well, okay, how and when do you wanna pay the cost? If I try to open a file, should I throw an error? Well, what if I’m probing around, looking for something, right? And I’m looking it up in many different paths? Well, if it’s really slow to do that, maybe I’ll add another function that doesn’t throw an error or returns an error code instead. And now I have two different versions of the same thing, and so it causes you to fork your APIs. And so, you know, one of the things I learned from Apple, and I so love, is the art of API design is actually really profound. I think this is something that Python’s also done a pretty good job at in terms of building out this large-scale package ecosystem. It’s about having standards and things like this, and so, you know, we wouldn’t wanna enter a mode where, you know, there’s this theoretical feature that exists in language, but people don’t use it in practice. Now I’ll also say, one of the other really cool things about this implementation approach is that it can run on GPUs, and it can run on accelerators and things like this. And that standard zero-cost exception thing would never work on an accelerator. And so, this is also part of how Mojo can scale all the way down to, like, little embedded systems and to running on GPUs and things like that."

Lex: 哦,有趣。所以,从编译器的角度来看,它完全一样。

Chris: 所以,这实际上是,我的意思是,这是一件相当书呆子的事情,对吧?这就是我为什么喜欢它的原因,但这对你的 API 设计方式有很大的影响,对吧?所以在 C++ 中,巨大的社区关闭了异常,因为成本太高了,对吧?所以,零成本,成本太高了,对吧?所以,这意味着,你实际上不能在很多库中使用异常,对吧?

Lex: 有趣。是的。

Chris: 即使是那些确实使用它的人,好吧,你想如何以及何时支付成本?如果我试图打开一个文件,我应该抛出一个错误吗?好吧,如果我正在探测,寻找一些东西,对吧?而且,我正在很多不同的路径中查找它?好吧,如果这样做真的很慢,也许我会添加另一个不抛出错误或返回错误代码的函数。现在,我有两个不同版本的相同的东西,所以,它会导致你 fork 你的 API。所以,你知道,我从苹果学到的其中一件事,而且,我非常喜欢,是 API 设计的艺术实际上真的很深刻。我认为,这是 Python 在构建这个大规模的软件包生态系统方面也做得很好的一件事。它是关于拥有标准和类似的东西,所以,你知道,我们不想进入一种模式,在那里,你知道,语言中存在这种理论上的功能,但在实践中,人们并不使用它。现在,我还要说,这种实现方法的另一个真正酷的事情是,它可以在 GPU 上运行,而且,它可以在加速器和类似的东西上运行。而且,那个标准的零成本异常的东西永远不会在加速器上工作。所以,这也是 Mojo 如何能够一直扩展到,像,小的嵌入式系统,以及在 GPU 和类似的东西上运行的一部分。

Lex: Can you actually say about the… Maybe is there some high-level way to describe the challenge of exceptions and how they work in code during compilation? So it’s just this idea of percolating up a thing and error.

Chris: Yeah, yeah. So the way to think about it is, think about a function that doesn’t return anything, just as a simple case, right? And so, you have function one calls function two, calls function three, calls function four, along that call stack that are try blocks, right? And so, if you have function one calls function two, function two has a try block, and then within it, it calls function three, right? Well, what happens if function three throws? Well, actually, start simpler. What happens if it returns? Well, if it returns, it’s supposed to go back out and continue executing and then fall off the bottom of the try block and keep going, and it’s all good. If the function throws, you’re supposed to exit the current function and then get into the accept clause, right? And then do whatever codes there, and then keep falling on, and going on. And so, the way that a compiler like Mojo works is that the call to that function, which happens in the except block, calls the function, which happens in the except block, calls the function, and then instead of returning nothing, it actually returns, you know, a variant between nothing and an error. And so, if you return, normally fall off the bottom, or do return, you return nothing. And if you throw, throw an error, you return the variant. That is, “I’m an error,” right? So when you get to the call, you say, “Okay, cool, I called a function. Hey, I know locally I’m in a try block, right? And so I call the function, and then I check to see what it returns. Aha. Is that error thing? Jump to the except block.” "

Lex: 你能否实际谈谈……也许,是否有一些高级的方法来描述异常的挑战,以及它们在编译过程中如何在代码中工作?所以,这只是将一个东西和错误向上渗透的想法。

Chris: 是的,是的。所以,思考它的方式是,想想一个不返回任何东西的函数,只是一个简单的例子,对吧?所以,你有一个函数一调用函数二,调用函数三,调用函数四,沿着调用栈,有 try 块,对吧?所以,如果你有一个函数一调用函数二,函数二有一个 try 块,然后在它内部,它调用函数三,对吧?好吧,如果函数三抛出异常会发生什么?好吧,实际上,从更简单的开始。如果它返回会发生什么?好吧,如果它返回,它应该返回并继续执行,然后从 try 块的底部掉下来,并继续,而且,一切都很好。如果函数抛出异常,你应该退出当前函数,然后进入 accept 子句,对吧?然后,做那里的任何代码,然后继续向下,并继续。所以,像 Mojo 这样的编译器的工作方式是,在 except 块中发生的函数调用,调用函数,在 except 块中发生的,调用函数,然后,它不是返回空,它实际上返回,你知道,一个空和错误之间的变量。所以,如果你返回,通常从底部掉下来,或者确实返回,你返回空。如果你抛出,抛出一个错误,你返回变量。那就是,我是一个错误,对吧?所以,当你到达调用的时候,你说,好吧,酷,我调用了一个函数。嘿,我知道我本地在一个 try 块中,对吧?所以,我调用函数,然后我检查它返回什么。啊哈。那是错误的东西吗?跳转到 except 块。

Lex: And that’s all done for you behind the scenes.

Chris: Exactly. And so, the compiler does all this for you. And I mean, one of the things, if you dig into how this stuff works in Python, it gets a little bit more complicated because you have finally blocks, which you need to go into, do some stuff, and then those can also throw and return."

Lex: 所有这些都在幕后为你完成。

Chris: 没错。所以,编译器为你做了所有这些。而且,我的意思是,其中一件事,如果你深入研究这些东西在 Python 中是如何工作的,它会变得有点复杂,因为你最终会有块,你需要进入,做一些事情,然后那些也可以抛出和返回。

Lex: Wait, what? Nested?

Chris: Yeah, and like, the stuff matters for compatibility. Like, there’s really…

Lex: You can nest them.

Chris: …there’s with clauses, and so, with clauses are kinda like finally blocks with some special stuff going on. And so there’s nesting."

Lex: 等等,什么?嵌套的?

Chris: 是的,而且,像,这些东西对兼容性很重要。就像,真的有……

Lex: 你可以嵌套它们。

Chris: …有 with 子句,所以,with 子句有点像 finally 块,有一些特殊的东西正在发生。所以,有嵌套。

Lex: In general, nesting of anything, nesting of functions should be illegal. Well, it just feels like it adds a level of complexity.

Chris: Lex, I’m merely an implementer. And so this is, again, one last question. One of the trade-offs you get when you decide to build a superset is you get to implement a full-fidelity implementation of the thing that you decided is good. And so, yeah, I mean, we can complain about the reality of the world and shake our fist, but…"

Lex: 总的来说,任何东西的嵌套,函数的嵌套都应该是违法的。好吧,它只是感觉像它增加了一个复杂性级别。

Chris: Lex,我仅仅是一个实现者。所以,这又是,最后一个问题。当你决定构建一个超集时,你得到的权衡之一是,你必须实现你认为好的东西的完全忠实的实现。所以,是的,我的意思是,我们可以抱怨世界的现实,并挥舞着拳头,但是……

Lex: It always feels like you shouldn’t be allowed to do that. Like, to declare functions in certain functions inside functions, that seems…

Chris: Oh, wait, wait, wait. What happened to Lex, the Lisp guy?

Lex: No, I understand that, but Lisp is what I used to do in college.

Chris: So now you’ve grown up."

Lex: 它总是感觉像你不应该被允许这样做。就像,在函数内部的某些函数中声明函数,那似乎……

Chris: 哦,等等,等等,等等。Lisp 人 Lex 发生了什么事?

Lex: 不,我理解,但 Lisp 是我以前在大学里做的事情。

Chris: 所以,现在你长大了。

Lex: You know, we’ve all done things in college we’re not proud of. No, wait a sec, wait a sec. I love Lisp. I love Lisp.

Chris: Okay. Yeah. I was gonna say, you’re afraid of me irritating the whole internet.

Lex: Like, yeah. No, I love Lisp. It worked as a joke in my head and came out, right?"

Lex: 你知道,我们都在大学里做过一些我们不引以为豪的事情。不,等等,等等。我爱 Lisp。我爱 Lisp。

Chris: 好的。是的。我正要说,你害怕我惹恼整个互联网。

Lex: 像,是的。不,我爱 Lisp。它在我脑海里就像一个笑话,然后就出来了,对吧?

Chris: So, nested functions are, joking aside, actually really great for certain things, right? And so, these are also called closures. Closures are pretty cool, and you can pass callbacks. There’s a lot of good patterns, and so…"

Chris: 所以,嵌套函数,撇开玩笑不谈,实际上对某些事情真的很好,对吧?所以,这些也被称为闭包。闭包很酷,而且,你可以传递回调。有很多好的模式,所以……

Lex: So speaking of which, I don’t think you have nested functions implemented yet in Mojo.

Chris: We don’t have lambda syntax, but we do have nested…

Lex: …lambda syntax, nested functions.

Chris: …functions. Yeah.

Lex: There’s a few things on the roadmap that you have that it’d be cool to sort of just fly through, ‘cause it’s interesting to see, you know, how many features there are in a language, small and big.

Chris: Yep. They have to implement. Yeah."

Lex: 说到这里,我认为你还没有在 Mojo 中实现嵌套函数。

Chris: 我们没有 lambda 语法,但我们确实有嵌套……

Lex: …lambda 语法,嵌套函数。

Chris: …函数。是的。

Lex: 路线图上有一些东西,你有的,快速浏览一下会很酷,因为看到一种语言中有多少功能,无论大小,都很有趣。

Chris: 是的。他们必须实现。是的。

Lex: So first of all, there’s Tuple support, and that has to do with some specific aspect of it, like, the parentheses or not parentheses that… yeah.

Chris: This is just a totally syntactic thing."

Lex: 所以,首先,有 Tuple 支持,而且,那与它的一些特定方面有关,比如,括号或不括号,那……是的。

Chris: 这只是一个完全语法上的事情。

Lex: A syntactic thing, okay. There’s, but it is cool, it’s still so, keyword arguments and functions.

Chris: Yeah, so this is where, in Python, you can say, “Call function, x=4”, and x is the name…

Lex: Yeah.

Chris: …of the argument. That’s a nice sort of documenting, salt-documenting feature.

Lex: Yep.

Chris: Yeah, I mean, and again, this isn’t rocket science to implement this, just the laundry list.

Lex: It’s just on the list. The bigger features are things like traits. So traits are when you wanna define abstract… So when you get into typed languages, you need the ability to write generics, and so you wanna say, “I wanna write this function, and now I want it to work on all things that are arithmetic.” Like, well, what does arithmetic, like, mean? Well, arithmetic, like, is a categorization of a bunch of types. Again, you can define it many different ways, and I’m not gonna go into ring theory or something, but you, you know, you can say it’s arithmetic, like, if you can add, subtract, multiply, divide it, for example, right? And so, what you’re saying is you’re saying there’s a set of traits that apply to a broad variety of types, and so there are all these types arithmetic, like all these tensors and floating-point integers, and like, there’s this category of types, and then I can define, on an orthogonal axis, algorithms that then work against types that have those properties. It’s been implemented in Swift and Rust in many languages, so it’s not Haskell, which is where everybody learns their tricks from, but we need to implement that, and that’ll enable a new level of expressivity."

Lex: 语法上的事情,好的。有,但它很酷,它仍然是,关键字参数和函数。

Chris: 是的,所以,这就是,在 Python 中,你可以说,调用函数,x=4,x 是名称……

Lex: 是的。

Chris: …参数的名称。这是一个很好的文档化,自文档化功能。

Lex: 是的。

Chris: 是的,我的意思是,再次,实现这个不是火箭科学,只是洗衣清单。

Lex: 它只是在清单上。更大的功能是像 trait 这样的东西。所以,trait 是当你想要定义抽象……所以,当你进入类型化语言的时候,你需要编写泛型的能力,所以,你想说,我想编写这个函数,现在我想让它适用于所有算术的东西。 就像,好吧,算术,像,是什么意思?好吧,算术,像,是一堆类型的分类。再次,你可以用很多不同的方式来定义它,而且,我不会去讨论环论或者其他什么,但是,你,你知道,你可以说它是算术的,像,如果你可以加,减,乘,除它,例如,对吧?所以,你正在说的是,你正在说,有一组 trait 适用于各种各样的类型,所以,有所有这些类型的算术,像所有这些张量和浮点整数,而且,像,有这类的类型,然后我可以定义,在一个正交轴上,算法,然后针对具有这些属性的类型工作。它已经在 Swift 和 Rust 中以多种语言实现了,所以,它不是 Haskell,Haskell 是每个人学习技巧的地方,但我们需要实现它,而且,那将启用一个新的表现力水平。

Lex: So, classes.

Chris: Yeah. Classes are a big deal.

Lex: It’s a big deal still to be implemented. Like you said, lambda syntax, and there’s, like, detailed stuff, like, “Whole module import support for top-level code and file scope”, and then global variables also. So being able to have variables outside of a top level…"

Lex: 所以,类。

Chris: 是的。类是一件大事。

Lex: 它仍然是一件需要实现的大事。就像你说的,lambda 语法,而且,像,有详细的东西,像,对顶级代码和文件范围的整个模块导入支持,然后还有全局变量。所以,能够在顶级之外拥有变量……

Chris: Well, and so this comes back to where Mojo came from, and the fact that this is a 0.1, right? So Modular’s building an AI stack, right? And an AI stack has a bunch of problems working with hardware and writing high-performance kernels and doing this kernel fusion thing I was talking about and getting the most out of the hardware. And so, we’ve really prioritized and built Mojo to solve Modular’s problems. Right now, our North Star is to build it out to support all the things, and so we’re making incredible progress. By the way, Mojo’s only, like, seven months old. So that’s another interesting thing."

Chris: 好吧,所以,这又回到了 Mojo 的起源,以及它是一个 0.1 版本的事实,对吧?所以,Modular 正在构建一个 AI 栈,对吧?而且,一个 AI 栈有很多与硬件工作的问题,以及编写高性能内核,以及做我刚才谈论的这种内核融合的事情,以及从硬件中获得最大的收益。所以,我们真的优先考虑并构建了Mojo 来解决 Modular 的问题。现在,我们的北极星是构建它来支持所有东西,所以,我们正在取得令人难以置信的进展。顺便说一下,Mojo 只有,像,七个月大。所以,这是另一件有趣的事情。

Lex: Well, I mean, part of the reason I wanted to mention some of these things is like, there’s a lot to do, and it’s pretty cool how you just kinda, sometimes you take for granted how much there is in a programming language, how many cool features you kinda rely on, and this is kinda a nice reminder when you lay it as a to-do list."

Lex: 好吧,我的意思是,我想提到其中一些事情的部分原因是,像,有很多事情要做,而且,你只是有点,有时你认为理所当然,一种编程语言中有多少东西,有多少酷的功能你有点依赖,而且,当你把它作为一个待办事项清单列出来的时候,这是一个很好的提醒。

Chris: Yeah, and so, I mean, but also, you look into, it’s amazing how much is also there, and you take it for granted that a value, if you define it, it will get destroyed automatically. Like, that little feature itself is actually really complicated, given the way the ownership system has to work. And the way that works within Mojo is a huge step forward from what Rust and Swift have done.

Lex: Wait, can you say that again? When a value…

Chris: Yeah, when you define it, it gets destroyed automatically."

Chris: 是的,所以,我的意思是,但是,也,你深入研究,令人惊讶的是,那里也有多少东西,而且,你认为理所当然,一个值,如果你定义了它,它就会自动被销毁。像,那个小功能本身实际上真的很复杂,考虑到所有权系统必须工作的方式。而且,它在 Mojo 中的工作方式比 Rust 和 Swift 所做的向前迈进了一大步。

Lex: 等等,你能再说一遍吗?当一个值……

Chris: 是的,当你定义它的时候,它就会自动被销毁。

Lex: Yeah. So like, like say you have a string, right? So you define a string on the stack, okay, or on whatever that means, like, in your local function, right? And so you say, like, whether it be in a def, and so you just say, x = “Hello World!”, right? Well, if your string type requires you to allocate memory, then when it’s destroyed, you have to deallocate it. So, in Python and in Mojo, you define that with a del method, right? Where does that get run? Well, it gets run sometime between the last use of the value and the end of the program. Like in this, you now get into garbage collection. You get into, like, all these long-debated, you talk about religions and trade-offs and things like this. This is a hugely, hotly contested world. If you look at C++, the way this works is that if you define a variable, or a set of variables, within a function, they get destroyed in a last-in, first-out order. So it’s like nesting, okay. This has a huge problem because if you have a big scope, and you define a whole bunch of values at the top, and then you use them, and then you do a whole bunch of code that doesn’t use them, they don’t get destroyed until the very end of that scope, right? And so this also destroys tail calls. So good functional programming, right? This has a bunch of different impacts on, you know, you talk about reference counting optimizations and things like this, a bunch of very low-level things. And so, what Mojo does is it has a different approach on that from any language I’m familiar with, where it destroys them as soon as possible, and by doing that, you get better memory use, you get better predictability, you get tail calls that work, you get a bunch of other things, you get better ownership tracking. There’s a bunch of these very simple things that are very fundamental that are already built in there in Mojo today that are the things that nobody talks about generally, but when they don’t work right, you find out, and you have to complain about."

Lex: 是的。所以,像,比如,你有一个字符串,对吧?所以,你在栈上定义一个字符串,好吧,或者在任何这意味着,像,在你的本地函数中,对吧?所以,你说,像,无论它是在 def 中,所以,你只是说,x = Hello World!,对吧?好吧,如果你的字符串类型要求你分配内存,那么当它被销毁的时候,你必须释放它。所以,在 Python 和 Mojo 中,你用一个 del 方法来定义它,对吧?它在哪里运行?好吧,它在值的最后一次使用和程序结束之间的某个时间运行。就像在这个,你现在进入垃圾收集。你进入,像,所有这些长期争论的,你谈论的是宗教和权衡,以及类似的东西。这是一个巨大的,激烈争论的世界。如果你看看 C++,它的工作方式是,如果你在一个函数中定义一个变量,或者一组变量,它们会以后进先出的顺序被销毁。所以,它就像嵌套,好吧。这是一个巨大的问题,因为如果你有一个很大的作用域,而且,你在顶部定义了一大堆值,然后你使用它们,然后你做了一大堆不使用它们的代码,它们直到那个作用域的最末尾才会被销毁,对吧?所以,这也破坏了尾调用。所以,好的函数式编程,对吧?这对,你知道,你谈论的是引用计数优化,以及类似的东西,一堆非常底层的东西,有很大的影响。所以,Mojo 所做的是,它对此有一种与我熟悉的任何语言都不同的方法,它会尽快销毁它们,而且,通过这样做,你会获得更好的内存使用,你会获得更好的可预测性,你会获得可以工作的尾调用,你会获得一堆其他的东西,你会获得更好的所有权跟踪。今天,Mojo 中已经内置了很多这些非常简单的东西,它们是非常基础的,通常没有人谈论这些东西,但是,当它们不能正常工作的时候,你就会发现,你必须抱怨。

Lex: Is it trivial to know what’s the soonest possible to delete a thing that it’s not gonna be used again?"

Lex: 要知道什么东西最快可以删除,而且,它不会再被使用,是微不足道的吗?

Chris: Yeah. Well, I mean, it’s generally trivial. It’s after the last use of it. So if you just define x as a string, and then you have some use of x somewhere in your code…"

Chris: 是的。好吧,我的意思是,它通常是微不足道的。它是在它最后一次使用之后。所以,如果你只是将 x 定义为一个字符串,然后你在你的代码中的某个地方使用了 x……

Lex: Within that scope, you mean. Within the scope that is accessible?

Chris: It’s, yeah, exactly. So you can only use something within its scope.

Lex: Yeah.

Chris: And so then it doesn’t wait until the end of the scope to delete it, it destroys it after the last use.

Lex: So there’s kinda some very eager machine that’s just sitting there and deleting, yeah."

Lex: 你是说在那个作用域内。在可以访问的作用域内?

Chris: 是的,没错。所以,你只能在它的作用域内使用一些东西。

Lex: 是的。

Chris: 所以,然后它不会等到作用域结束才删除它,它会在最后一次使用之后销毁它。

Lex: 所以,有点像,有一些非常急切的机器,只是坐在那里,然后删除,是的。

Chris: And it’s all in the compiler, so it’s not at runtime, which is also cool. And so interesting, yeah, and this is actually non-trivial because you have control flow, right? And so, it gets complicated pretty quickly, and so, like, angst, right? Was not, not…

Lex: Well, so you have to insert delete, like, in a lot of places.

Chris: Potentially, yeah, exactly. So the compiler has to reason about this, and this is where, again, it’s experience building languages and not getting this right, so again, you get another chance to do it, and you get basic things like this, right? But it’s extremely powerful when you do that, right? And so, there’s a bunch of things like that that kinda combine together, and this comes back to the, you get a chance to do it the right way, do it the right way, and make sure that every brick you put down is really good so that when you put more bricks on top of it, they stack up to something that’s beautiful."

Chris: 而且,它都在编译器中,所以,它不在运行时,这也很酷。所以,有趣的是,是的,而且,这实际上不是微不足道的,因为你有控制流,对吧?所以,它变得非常快,所以,像,焦虑,对吧?不是,不是……

Lex: 好吧,所以,你必须插入删除,像,在很多地方。

Chris: 有可能,是的,没错。所以,编译器必须推理这件事,而且,这就是,再次,构建语言的经验,以及没有正确地做到这一点,所以,再次,你得到了另一个机会去做它,而且,你得到了像这样的基本的东西,对吧?但是,当你这样做的时候,它极其强大,对吧?所以,有很多像这样的东西,有点组合在一起,而且,这又回到了,你得到了一个机会以正确的方式去做它,以正确的方式去做它,并确保你放下的每一块砖都非常好,这样当你把更多的砖放在它上面的时候,它们就会堆积成一些美丽的东西。

Lex: Well, there’s also, like, how many design discussions do there have to be about particular details like implementation of particular small features? Because the features that seem small, I bet some of them might be like, really, require really big design decisions.

Chris: Yeah. Well, so I mean, lemme give you another example of this. Python has a feature called async/await, so it’s a new feature. I mean, in the long arc of Python history, it’s a relatively new feature, right, that allows way more expressive, asynchronous programming, okay? Again, this is, Python’s a beautiful thing, and they did things that are great for Mojo for completely different reasons. The reason that async/await got added to Python, as far as I know, is because Python doesn’t support threads, okay? And so, Python doesn’t support threads, but you wanna work with networking and other things, like, that can block. I mean, Python does support threads, it’s just not its strength. And so they added this feature called async/await. It’s also seen in other languages like Swift and JavaScript and many other places as well. Async/await in Mojo is amazing ‘cause we have a high-performance, heterogeneous compute runtime underneath the covers that then allows non-blocking I/O, so you get full use of your accelerator. That’s huge. Turns out it’s actually a really important part of fully utilizing the machine. You talk about design discussions. That took a lot of discussions, right? And it probably will require more iteration. And so my philosophy with Mojo is that, you know, we have a small team of really good people that are pushing forward, and they’re very good at the extremely deep knowing how the compiler and runtime and, like, all the low-level stuff works together, but they’re not perfect. It’s the same thing as the Swift team, right? And this is where, one of the reasons we released Mojo much earlier, is so we can get feedback, and we’ve already, like, renamed a keyword due to community feedback. Which one? We used an ampersand, now it’s named inout. We’re not renaming existing Python keywords ‘cause that breaks compatibility, right? We’re renaming things, we’re adding, and making sure that they are designed well. We get usage experience, we iterate and work with the community because, again, if you scale something really fast, and everybody writes all their code, and they start using it in production, then it’s impossible to change, and so you wanna learn from people, you wanna iterate and work on that early on, and this is where design discussions, it’s actually quite important to do."

Lex: 好吧,也像,有多少设计讨论必须是关于特定细节的,比如特定小功能的实现?因为那些看起来很小的功能,我敢打赌,其中一些可能像,真的,需要真正重大的设计决策。

Chris: 是的。好吧,所以,我的意思是,让我给你另一个例子。Python 有一个叫做 async/await 的功能,所以,它是一个新的功能。我的意思是,在 Python 历史的长河中,它是一个相对较新的功能,对吧,它允许更具表现力的,异步编程,好吗?再次,这是,Python 是一件美丽的东西,而且,他们做的事情对 Mojo 来说很棒,完全是出于不同的原因。据我所知,async/await 被添加到 Python 中的原因是,因为 Python 不支持线程,好吗?所以,Python 不支持线程,但你想与网络和其他东西一起工作,像,那些可以阻塞的东西。我的意思是,Python 确实支持线程,它只是不是它的强项。所以,他们添加了这个叫做 async/await 的功能。它也出现在其他语言中,比如 Swift 和 JavaScript,以及其他很多地方。Mojo 中的 Async/await 很棒,因为我们在幕后有一个高性能的,异构的计算运行时,它允许非阻塞 I/O,所以,你可以充分利用你的加速器。那太棒了。事实证明,它实际上是充分利用机器的一个非常重要的部分。你谈论的是设计讨论。那需要很多讨论,对吧?而且,它可能需要更多的迭代。所以,我对 Mojo 的理念是,你知道,我们有一个非常优秀的小团队,他们正在向前推进,而且,他们非常擅长极其深入地了解编译器和运行时,以及,像,所有底层的东西是如何协同工作的,但他们并不完美。这和 Swift 团队一样,对吧?这就是,我们之所以提前发布 Mojo 的原因之一,是为了我们可以得到反馈,而且,我们已经,像,由于社区反馈而重命名了一个关键字。哪一个?我们使用了一个 & 符号,现在它被命名为 inout。我们没有重命名现有的 Python 关键字,因为那会破坏兼容性,对吧?我们正在重命名东西,我们正在添加,并确保它们设计良好。我们获得使用经验,我们迭代,并与社区合作,因为,再次,如果你以非常快的速度扩展一些东西,而且,每个人都写了他们所有的代码,而且,他们开始在生产中使用它,那么就无法改变,所以,你想从人们那里学习,你想在早期进行迭代和工作,而且,这就是设计讨论,实际上非常重要的地方。

Lex: Could you incorporate an emoji, like, into the language, into the main language? Like a good… Like, do you have a favorite one?"

Lex: 你能将一个 emoji,像,纳入语言,纳入主要的语言吗?像一个好的……像,你有一个最喜欢的吗?

Chris: Well, I really, like, in terms of humor, like rofl, whatever, “rolling on the floor laughing”. So that could be, like, a, what would that be the use case for that? Like an, except, throw an exception of some sort? I don’t…

Lex: You should totally file a feature request.

Chris: …or maybe a heart one. It has to be a heart one.

Lex: People have told me that I’m insane. I’m liking this.

Chris: I’m gonna use the viral nature of the internet to get this passed."

Chris: 好吧,我真的,喜欢,就幽默而言,像 rofl,无论什么,在地上打滚大笑。所以,那可能是,像,一个,那会是什么用例?像一个,除了,抛出某种异常?我不……

Lex: 你应该完全提交一个功能请求。

Chris: …或者,也许是一个心形。它必须是一个心形。

Lex: 人们告诉我,我疯了。我喜欢这个。

Chris: 我要利用互联网的病毒性来通过这个。

Lex: I mean, it’s funny you come back to the flame emoji file extension, right? You know, we have the option to use the flame emoji, which, just even that concept, ‘cause, for example, the people at GitHub say, “Now I’ve seen everything,” you know, like…

Lex: Yeah, and there’s something, it kinda, it’s reinvigorating. It’s like, “Oh, that’s possible.” That’s really cool that, for some reason, that makes everything else, like, seem really exciting.

Chris: I think the world is ready for this stuff, right? And so, you know, when we have a package manager, we’ll clearly have to innovate by having the compiled package thing be the little box with the bow on it, right? I mean, it has to be done."

Lex: 我的意思是,你回到火焰 emoji 文件扩展名很有趣,对吧?你知道,我们可以选择使用火焰 emoji,这,即使是那个概念,因为,例如,GitHub 的人说,现在我什么都看到了,你知道,像……

Lex: 是的,而且,有一些东西,它有点,它令人振奋。它就像,哦,那是可能的。 那真的很酷,因为,出于某种原因,那让所有其他的东西,像,看起来真的很令人兴奋。

Chris: 我认为,世界已经为这些东西做好了准备,对吧?所以,你知道,当我们有一个包管理器的时候,我们显然必须通过让编译后的包成为那个带蝴蝶结的小盒子来进行创新,对吧?我的意思是,它必须被完成。

Lex: It has to be done. Is there some stuff on the roadmap that you’re particularly stressed about, or excited about, that you’re thinking about?"

Lex: 它必须被完成。路线图上有一些东西是你特别有压力,或者兴奋,你在思考的吗?

Chris: A lot. I mean, as of today’s snapshot, which will be obsolete tomorrow, the lifetime stuff is really exciting. And so, lifetimes give you safe references to memory without dangling pointers, and so this has been done in languages like Rust before, and so we have a new approach which is really cool. I’m very excited about that. That’ll be out to the community very soon. The traits feature is really a big deal, and so that’s blocking a lot of API design, and so, there’s that. I think that’s really exciting. A lot of it is these kinda table stakes features. One of the things that is, again, also lessons learned with Swift, is that programmers, in general, like to add syntactic sugar. And so it’s like, “Oh, well, this annoying thing, like in Python, you have to spell add. Why can’t I just use plus, def plus? Come on. Why can’t I just do that?” Right? And so, a trivial bit of syntactic sugar. It makes sense, it’s beautiful, it’s obvious. We’re trying not to do that, and so for two different reasons, one of which is that, again, lesson learned with Swift. Swift has a lot of syntactic sugar, which maybe a good thing, maybe not, I don’t know, but because it’s such an easy and addictive thing to do, sugar, like, make sure blood gets crazy, right? Like, the community will really dig into that and wanna do a lot of that. And I think it’s very distracting from building the core abstractions. The second is we wanna be a good member of the Python community, right? And so we wanna work with the broader Python community, and yeah, we’re pushing forward a bunch of systems programming features, and we need to build them out to understand them. But once we get a long ways forward, I wanna make sure that we go back to the Python community and say, “Okay, let’s do some design reviews. Let’s actually talk about this stuff. Let’s figure out how we want this stuff all to work together.” And syntactic sugar just makes all that more complicated. So…"

Chris: 很多。我的意思是,就今天的快照而言,它明天就会过时,生命周期的东西真的很令人兴奋。所以,生命周期给了你对内存的安全引用,没有悬空指针,所以,这在 Rust 这样的语言中已经做过了,所以,我们有一个新的方法,真的很酷。我对此感到非常兴奋。它很快就会发布到社区。trait 功能真的很重要,所以,那阻塞了很多 API 设计,所以,有那个。我认为,那真的很令人兴奋。很多都是这些类型的赌注功能。其中一件事是,再次,也是从 Swift 中吸取的教训,是程序员,总的来说,喜欢添加语法糖。所以,它就像,哦,好吧,这个烦人的东西,像在 Python 中,你必须拼写 add。为什么我不能只使用加号,def 加号?拜托。为什么我不能这样做? 对吧?所以,一点微不足道的语法糖。它有意义,它很漂亮,它很明显。我们正在试图不做那件事,所以,有两个不同的原因,其中一个是,再次,从 Swift 中吸取的教训。Swift 有很多语法糖,这可能是一件好事,也可能不是,我不知道,但因为它是一件如此容易和上瘾的事情,糖,像,确保血液变得疯狂,对吧?像,社区会真的深入研究它,并想做很多。我认为,它非常分散构建核心抽象的注意力。第二个是,我们想成为 Python 社区的一个好成员,对吧?所以,我们想与更广泛的 Python 社区合作,而且,是的,我们正在推动一堆系统编程功能,而且,我们需要构建它们来理解它们。但一旦我们取得了很大的进展,我想确保我们回到 Python 社区,并说,好吧,让我们做一些设计评审。让我们实际谈谈这些东西。让我们弄清楚我们希望所有这些东西如何协同工作。 而且,语法糖只是使所有这些变得更加复杂。所以……

Lex: And, yeah, list comprehension. Is that yet to be implemented?

Chris: Yeah.

Lex: And my favorite, I mean, dictionaries.

Chris: Yeah, there’s some basic… 0.1.

Lex: 0.1, yeah.

Chris: …but nonetheless, it’s actually still quite interesting and useful."

Lex: 而且,是的,列表推导式。那还没有实现吗?

Chris: 是的。

Lex: 还有我最喜欢的,我的意思是,字典。

Chris: 是的,有一些基本的……0.1。

Lex: 0.1,是的。

Chris: …但尽管如此,它实际上仍然相当有趣和有用。

Lex: As you’ve mentioned, Modular is very new. Mojo is very new. It’s a relatively small team… yeah, building up this…

Chris: Yeah, we’re just, gigantic stack, yeah, this incredible stack that’s going to perhaps define the future of development of our AI overlords."

Lex: 正如你提到的,Modular 非常新。Mojo 非常新。这是一个相对较小的团队……是的,正在构建这个……

Chris: 是的,我们只是,巨大的栈,是的,这个不可思议的栈,它可能会定义我们的人工智能霸主的未来的发展。

Lex: We just hope it will be useful.

Chris: As do all of us. So what have you learned from this process of building up a team? Maybe one question is, how do you hire…

Lex: Yeah.

Chris: …great programmers, great people that operate in this compiler, hardware, machine learning, software interface design space? And maybe are… yeah…"

Lex: 我们只是希望它会有用。

Chris: 我们所有人也是如此。所以,你从这个团队建设过程中学到了什么?也许,一个问题是,你如何雇佣……

Lex: 是的。

Chris: …优秀的程序员,在这个编译器,硬件,机器学习,软件接口设计空间中工作的优秀人才?而且,也许是……是的……

Lex: …a little bit fluid in what they can do?

Chris: So, okay, so language design too.

Lex: Yeah.

Chris: So building a company is just as interesting in different ways as building a language, like, different skillsets, different things, but super interesting. And I’ve built a lot of teams, a lot of different places. If you zoom in from the big problem into recruiting, well, so here’s our problem, okay. I’ll be very straightforward about this. We started Modular with a lot of conviction about, “We understand the problems. We understand the customer pain points. We need to work backward from the suffering in the industry, and if we solve those problems, we think it’ll be useful for people.” But the problem is that the people we need to hire, as you say, are all these super specialized people that have jobs at big tech, big tech worlds, right? And, you know, I don’t think we have product-market fit in the way that a normal start-up does, or we don’t have product-market fit challenges because right now, everybody’s using AI, and so many of them are suffering, and they want help. And so, again, we started with strong conviction. Now again, you have to hire and recruit the best, and the best all have jobs. And so, what we’ve done is we’ve said, “Okay, well, let’s build an amazing culture. Start with that.” That’s usually not something a company starts with. Usually, you hire a bunch of people, and then people start fighting, and it turns into a gigantic mess, and then you try to figure out how to improve your culture later. My co-founder, Tim, in particular, is super passionate about making sure that that’s right. And we’ve spent a lot of time, early on, to make sure that we can scale."

Lex: …他们能做的事情有点流动性?

Chris: 所以,好的,所以,还有语言设计。

Lex: 是的。

Chris: 所以,创办一家公司和构建一种语言一样有趣,只是方式不同,像,不同的技能,不同的东西,但超级有趣。而且,我建立了很多团队,很多不同的地方。如果你从大问题放大到招聘,好吧,所以,这是我们的问题,好吗?我将非常直率地说这件事。我们创办 Modular 的时候,非常坚信,我们了解问题。我们了解客户的痛点。我们需要从行业的痛苦中反向工作,而且,如果我们解决了那些问题,我们认为它对人们会有用。 但问题是,正如你所说,我们需要雇佣的人,都是那些在大型科技公司,大型科技世界工作的超级专业化的人,对吧?而且,你知道,我不认为我们有像普通初创公司那样的产品市场契合度,或者我们没有产品市场契合度挑战,因为现在,每个人都在使用人工智能,而且,他们中的很多人都在受苦,他们想要帮助。所以,再次,我们一开始就非常坚信。现在,再次,你必须雇佣和招募最好的人才,而且,最好的人才都有工作。所以,我们所做的是,我们说,好吧,让我们建立一个惊人的文化。从那开始。 那通常不是一家公司开始做的事情。通常,你雇佣了一堆人,然后人们开始争斗,而且,它变成了一个巨大的混乱,然后你试图在以后弄清楚如何改善你的文化。我的联合创始人,Tim,特别热衷于确保那是正确的。而且,我们花了很多时间,在早期,来确保我们可以扩展。

Lex: Can you comment… Sorry, before we get to the second, what makes for a good culture?"

Lex: 你能评论一下……对不起,在我们谈到第二个之前,什么造就了一个好的文化?

Chris: Yeah. So, I mean, there’s many different cultures, and I have learned many things from many different people, several very unique, almost famously unique cultures, and some of them I learned what to do, and some of them I learned what not to do.

Lex: Yep.

Chris: Okay. And so, we want an inclusive culture. I believe in, like, amazing people working together, and so I’ve seen cultures where you have amazing people, and they’re fighting each other. I see amazing people and they’re told what to do, like, “Don’t shout. Line up and do what I say, it doesn’t matter if it’s the right thing, do it!” Right? And neither of these is the… and I’ve seen people that have no direction. They’re just kinda floating in different places, and they wanna be amazing, they just don’t know how. And so, a lot of it starts with, “Have a clear vision,” right? And so, we have a clear vision of what we’re doing, and so I kind of grew up at Apple in my engineering life, right? And so a lot of the Apple DNA rubbed off on me. My co-founder, Tim, also is, like, a strong product guy. And so, what we learned is, you know, I saw at Apple that you don’t work from building cool technology. You don’t work from, like, “Come up with a cool product and think about the features you’ll have in the big checkboxes and stuff like this,” ‘cause if you go talk to customers, they don’t actually care about your product. They don’t care about your technology. What they care about is their problems, right? And if your product can help solve their problems, well, hey, they might be interested in that, right? And so, if you speak to them about their problems, if you understand, you have compassion, you understand what people are working with, then you can work backward to building an amazing product."

Chris: 是的。所以,我的意思是,有很多不同的文化,而且,我从很多不同的人那里学到了很多东西,几种非常独特的,几乎是出名的独特的文化,而且,其中一些我学到了该做什么,其中一些我学到了不该做什么。

Lex: 是的。

Chris: 好的。所以,我们想要一种包容的文化。我相信,像,优秀的人一起工作,所以,我见过这样的文化,你有优秀的人,而且,他们互相争斗。我见过优秀的人,他们被告知该做什么,像,不要喊。排好队,做我说的,这是否正确并不重要,做就是了! 对吧?而且,这些都不是……而且,我见过没有方向的人。他们只是有点像漂浮在不同的地方,而且,他们想变得很棒,他们只是不知道如何去做。所以,很多都始于,有一个清晰的愿景,对吧?所以,我们对我们正在做的事情有一个清晰的愿景,所以,我有点像在我的工程生涯中在苹果长大,对吧?所以,很多苹果的 DNA 都影响了我。我的联合创始人,Tim,也像,是一个强悍的产品人。所以,我们学到的是,你知道,我在苹果看到的是,你不能从构建酷的技术开始工作。你不能从,像,想出一个酷的产品,并考虑你将在大的复选框中拥有的功能,以及类似的东西,开始工作,因为如果你去和客户交谈,他们实际上并不关心你的产品。他们不关心你的技术。他们关心的是他们的问题,对吧?如果你的产品可以帮助解决他们的问题,好吧,嘿,他们可能会对此感兴趣,对吧?所以,如果你和他们谈论他们的问题,如果你理解,你有同情心,你理解人们正在处理什么,那么你可以反向工作,构建一个惊人的产品。

Lex: So the vision’s done by defining the problem.

Chris: And then you can work backward and solving technology."

Lex: 所以,愿景是通过定义问题来完成的。

Chris: 然后你可以反向工作,并解决技术。

Lex: Got it. And at Apple, like, it’s, I think pretty famously said that, you know, for every, you know, there’s a hundred nos for every yes. I would refine that to say that there’s a hundred “not yets” for every yes. Yeah. But famously, if you go back to the iPhone, for example, right? iPhone 1, every, I mean, many people laughed at it because it didn’t have 3G. It didn’t have copy and paste, right? And then a year later, “Okay, finally, it has 3G, but it still doesn’t have copy and paste, it’s a joke. Nobody will ever use this product,” blah, blah, blah, blah, blah, blah, blah, right? Well, year three, had copy and paste, and people stopped talking about it, right? And so being laser-focused and having conviction and understanding what the core problems are and giving the team the space to be able to build the right tech is really important. Also, I mean, you come back to recruiting, you have to pay well, right? So we have to pay industry-leading salaries and have good benefits and things like this. That’s a big piece. We’re a remote-first company, and so we have to… So remote-first has a very strong set of pros and cons. On the one hand, you can hire people from wherever they are, and you can attract amazing talent, even if they live in strange places or unusual places. On the other hand, you have time zones. On the other hand, you have, like, everybody on the internet will fight if they don’t understand each other, and so we’ve had to learn how to, like, have a system where we actually fly people in, and we get the whole company together periodically, and then we get work groups together, and we plan and execute together."

Lex: 明白了。而且,在苹果,像,我认为,很有名的一句话是,你知道,对于每一个,你知道,对于每一个 yes,都有一百个 no。我会改进一下,说对于每一个 yes,都有一百个还没有。是的。但很有名的是,如果你回到 iPhone,例如,对吧?iPhone 1,每一个,我的意思是,很多人都嘲笑它,因为它没有 3G。它没有复制和粘贴,对吧?然后,一年后,好吧,终于,它有 3G 了,但它仍然没有复制和粘贴,这是一个笑话。没有人会使用这个产品,等等,等等,等等,等等,等等,对吧?好吧,第三年,有了复制和粘贴,而且,人们不再谈论它了,对吧?所以,专注于激光,并拥有信念,并理解核心问题是什么,并给团队空间,让他们能够构建正确的技术,真的很重要。而且,我的意思是,你回到招聘,你必须支付高薪,对吧?所以,我们必须支付行业领先的工资,并有良好的福利,以及类似的东西。那是一个很大的部分。我们是一家远程优先的公司,所以,我们必须……所以,远程优先有很多优点和缺点。一方面,你可以从任何地方雇佣人员,而且,你可以吸引惊人的人才,即使他们住在奇怪的地方,或者不寻常的地方。另一方面,你有时区。另一方面,你有,像,互联网上的每个人都会争吵,如果他们不理解彼此,所以,我们不得不学习如何,像,拥有一个系统,我们实际上让人们飞进来,而且,我们会定期让整个公司聚在一起,然后我们会让工作小组聚在一起,我们一起计划和执行。

Lex: And there’s, like, an intimacy to the in-person brainstorming. Yeah, I guess you lose, but maybe you don’t. Maybe if you get to know each other well, and you trust each other, maybe you can do that.

Chris: Yeah.

Lex: Yeah.

Chris: Well, so when the pandemic first hit, I mean, I’m curious about your experience too, the first thing I missed was having whiteboards, right?

Lex: Yeah.

Chris: Those design discussions where you’re like, “I can high, high-intensity work through things, get things done, work through the problem of the day, understand where you’re on, figure out and solve the problem and move forward.” But we’ve figured out ways…

Lex: Yeah.

Chris: …to work around that now with, you know, all these screen-sharing and other things like that that we do. The thing I miss now is sitting down at a lunch table with the team.

Lex: Yeah.

Chris: The spontaneous things, like the coffee bar things and the bumping into each other and getting to know people outside of the transactional, “Solve a problem over Zoom.” "

Lex: 而且,像,有一种亲密的面对面头脑风暴。是的,我想你失去了,但也许你没有失去。也许,如果你彼此非常了解,而且,你彼此信任,也许你可以做到。

Chris: 是的。

Lex: 是的。

Chris:好吧,所以,当疫情第一次爆发的时候,我的意思是,我也很好奇你的经历,我首先怀念的是白板,对吧?

Lex: 是的。

Chris: 那些设计讨论,你就像,我可以高强度地完成事情,把事情做完,解决当天的问题,了解你的进展,弄清楚并解决问题,并向前推进。 但我们已经找到了方法……

Lex: 是的。

Chris: …现在用,你知道,所有这些屏幕共享和其他类似的东西来解决这个问题。我现在怀念的是和团队坐在午餐桌上。

Lex: 是的。

Chris: 那些自发的事情,比如咖啡吧的事情,以及互相碰撞,以及在交易之外了解人们,通过 Zoom 解决问题。

Lex: And I think there’s just a lot of stuff that I’m not an expert at. This, I don’t know who is, hopefully, there’s some people, but there’s stuff that somehow is missing on Zoom, even with the whiteboard. If you look at that, if you have a room with one person at the whiteboard, and then there’s, like, three other people at a table, there’s a, first of all, there’s a social aspect to that, where you’re just shooting the, a little bit, almost like…

Lex: Yeah. As people are just kinda coming in and… yeah.

Chris: That, but also while the, like, it’s a breakout discussion that happens for like seconds at a time, maybe an inside joke or like this interesting dynamic that happens, that’s Zoom…

Lex: And you’re bonding.

Chris: Yeah.

Lex: Yeah.

Chris: You’re bonding. You’re bonding. But through that bonding, you get the excitement. There’s certain ideas where, like, complete. And you’ll see that in the faces of others that you won’t see necessarily on Zoom and, like, something, it feels like that should be possible to do without being in person.

Lex: Well, I mean, being in person is a very different thing.

Chris: Yeah.

Lex: It’s worth it, but you can’t always do it. And so again, we’re still learning."

Lex: 而且,我认为,有很多东西我不是专家。这个,我不知道谁是,希望,有一些人,但有一些东西不知何故在 Zoom 上缺失了,即使有白板。如果你看看那个,如果你有一个房间,有一个人在白板上,然后有,像,另外三个人在桌子上,有一个,首先,有一个社交方面,在那里你只是射击,一点点,几乎像……

Lex: 是的。当人们只是有点进来,然后……是的。

Chris: 那个,但也是,像,这是一个一次发生几秒钟的分组讨论,也许是一个内部笑话,或者像这个发生的有趣的动态,那是 Zoom……

Lex: 而且,你们正在建立联系。

Chris: 是的。

Lex: 是的。

Chris: 你们正在建立联系。你们正在建立联系。但通过这种联系,你会得到兴奋。有一些想法,像,完整的。而且,你会在别人的脸上看到这一点,你不一定会在 Zoom 上看到,而且,像,一些东西,感觉像应该可以在没有面对面的情况下做到。

Lex: 好吧,我的意思是,面对面是一件非常不同的事情。

Chris: 是的。

Lex: 这是值得的,但你不能总是这样做。所以,再次,我们仍在学习。

Chris: Yeah.

Lex: And we’re also learning as, like, humanity with this new reality, right? But what we found is that getting people together, whether it be a team, or the whole company or whatever, is worth the expense because people work together and are happier after that. Like, it just, like, there’s a massive period of time where you’re, like, go out, and things start getting frayed. Pull people together, and then, yeah, you realize that we’re all working together, we see things the same way. We work through the disagreement or the misunderstanding, we’re talking across each other, and then you work much better together. And so, things like that I think are really quite important.

Lex: What about people that are kinda specialized in very different aspects of the stack working together? What are some interesting challenges there?"

Chris: 是的。

Lex: 而且,我们也正在学习,像,人类,以及这个新的现实,对吧?但我们发现的是,让人们聚在一起,无论是一个团队,还是整个公司,或者其他什么,都是值得的,因为人们在一起工作,而且,在那之后更快乐。就像,它只是,像,有一段很长的时间,你,像,出去,而且,事情开始变得磨损。把人们拉到一起,然后,是的,你意识到,我们都在一起工作,我们以相同的方式看待事物。我们克服了分歧,或者误解,我们互相交谈,然后,你们一起工作得更好。所以,我认为,像这样的事情真的很重要。

Lex: 那么,那些有点专业化,在栈中非常不同的方面一起工作的人呢?那里有一些有趣的挑战吗?

Chris: Yeah. Well, so I mean, I mean, there’s lots of interesting people, as you can tell, I’m, you know, hard to deal with too, but…

Lex: You’re one of the most lovable people.

Chris: So there’s different philosophies in building teams for me. And so, some people say, “Hire 10x programmers,” and that’s the only thing, whatever that means, right? What I believe in is building well-balanced teams, teams that have people that are different in them. Like, if you have all generals and no troops or all troops and no generals, or you have all people that think in one way, and not the other way, what you get is you get a very biased and skewed and weird situation where people end up being unhappy. And so, what I like to do is I like to build teams of people where they’re not all the same. You know, we do have teams, and they’re focused on, like, runtime, or compiler, GPU, or accelerator, or whatever the specialty is, but people bring a different take and have a different perspective, and I look for people that complement each other. And particularly, if you look at leadership teams and things like this, you don’t want everybody thinking the same way. You want people bringing different perspectives and experiences, and so I think that’s really important.

Lex: That’s the team. But what about building a company as ambitious as Modular? So what are some interesting questions there?"

Chris: 是的。好吧,所以,我的意思是,我的意思是,有很多有趣的人,正如你所知,我,你知道,也很难相处,但是……

Lex: 你是最可爱的人之一。

Chris: 所以,对我来说,建立团队有不同的哲学。所以,有些人说,雇佣 10 倍的程序员,而且,那是唯一的事情,无论那意味着什么,对吧?我相信的是建立平衡的团队,团队中的人是不同的。像,如果你只有将军,没有士兵,或者只有士兵,没有将军,或者你只有以一种方式思考的人,而不是以另一种方式思考的人,你得到的是,你得到一个非常有偏见,扭曲,和奇怪的情况,人们最终会不快乐。所以,我喜欢做的是,我喜欢建立团队,团队中的人并不都一样。你知道,我们确实有团队,而且,他们专注于,像,运行时,或者编译器,GPU,或者加速器,或者其他任何专业,但人们带来了不同的看法,并有不同的观点,而且,我寻找那些互补的人。而且,特别是,如果你看看领导团队和类似的东西,你不想让每个人都以相同的方式思考。你想要人们带来不同的观点和经验,所以,我认为,那真的很重要。

Lex: 那是团队。但建立一家像 Modular 一样雄心勃勃的公司呢?所以,那里有一些有趣的问题吗?

Chris: Oh, I mean, so many. Like, so one of the things I love about… Okay, so Modular’s the first company I built from scratch. One of the first things that was profound was I’m not cleaning up somebody else’s mess, right? And so, if you look at… and…

Lex: That’s liberating to some degree."

Chris: 哦,我的意思是,太多了。像,所以,其中一件事我喜欢的是……好吧,所以,Modular 是我从头开始建立的第一家公司。其中一件深刻的事情是,我没有清理别人的烂摊子,对吧?所以,如果你看看……而且……

Lex: 这在某种程度上是解放的。

Chris: It’s super liberating. And also, many of the projects I’ve built in the past have not been core to the project of the company. Swift is not Apple’s product, right? MLIR is not Google’s revenue machine or whatever, right? It’s important, but it’s like working on the accounting software for, you know, the retail giant or something, right? It’s like enabling infrastructure and technology, and so at Modular, the tech we’re building is here to solve people’s problems. Like, it is directly the thing that we’re giving to people, and so this is a really big difference. And what it means for me, as a leader, but also for many of our engineers, is they’re working on the thing that matters, and that’s actually pretty, I mean, again, for compiler people and things like that, that’s usually not the case, right? And so, that’s also pretty exciting and quite nice. But one of the ways that this manifests is it makes it easier to make decisions. And so, one of the challenges I’ve had in other worlds is it’s like, okay, well, community matters somehow for the goodness of the world, or open source matters theoretically, but I don’t wanna pay for a T-shirt."

Chris: 它超级解放。而且,我过去构建的很多项目都不是公司的核心项目。Swift 不是苹果的产品,对吧?MLIR 不是谷歌的收入机器,或者其他什么,对吧?它很重要,但它就像为,你知道,零售巨头或者其他什么东西做会计软件,对吧?它就像支持基础设施和技术,所以,在 Modular,我们正在构建的技术是为了解决人们的问题。像,它直接是我们提供给人们的东西,所以,这是一个非常大的区别。而且,这对我来说,作为一个领导者,但对我们很多工程师来说,意味着他们正在做重要的事情,而且,那实际上相当,我的意思是,再次,对于编译器人员和类似的东西,那通常不是这样,对吧?所以,那也相当令人兴奋和美好。但其中一种表现方式是,它使做决定更容易。所以,我在其他世界遇到的挑战之一是,它就像,好吧,社区不知何故对世界有益,或者开源理论上很重要,但我不想为一件 T 恤衫付费。

Lex: Yeah.

Chris: …right, or some swag. Like, well, T-shirts cost 10 bucks each. You can have 100 T-shirts for $1,000. To a megacorp, but $1,000 is unaccountably, they can’t count that low."

Lex: 是的。

Chris: …对吧,或者一些赠品。像,好吧,T 恤衫每件 10 美元。你可以用 1000 美元买到 100 件 T 恤衫。对一个巨型公司来说,但 1000 美元是不可计算的,他们不能计算那么低的数字。

Lex: Yes.

Chris: Right? But justifying it and getting a T-shirt… By the way, if you’d like a T-shirt, I can give you a T-shirt.

Lex: Well, I would 100% like a T-shirt. Are you joking?

Chris: You can have a fire emoji T-shirt. Is that…"

Lex: 是的。

Chris: 对吧?但证明它的合理性,并得到一件 T 恤衫……顺便说一下,如果你想要一件 T 恤衫,我可以给你一件。

Lex: 好吧,我 100% 想要一件 T 恤衫。你在开玩笑吗?

Chris: 你可以拥有一件火 emoji T 恤衫。那是……

Lex: I will treasure this. Is that a good thing? I will pass it down to my grandchildren.

Chris: And so, you know, it’s very liberating to be able to decide, “I think that Lex should have a T-shirt,” right? And it becomes very simple because I like Lex."

Lex: 我会珍惜这个。这是一件好事吗?我会把它传给我的孙子孙女。

Chris: 所以,你知道,能够决定,我认为 Lex 应该拥有一件 T 恤衫,真的很解放,对吧?而且,它变得非常简单,因为我喜欢 Lex。

Lex: This is awesome. So I have to ask you about one of the interesting developments with large language models is that they’re able to generate code recently.

Chris: Really?"

Lex: 这太棒了。所以,我必须问你一个关于大型语言模型的有趣发展,那就是它们最近能够生成代码。

Chris: 真的吗?

Lex: Well, yes, to a degree that, maybe I don’t know if you understand, but I struggle to understand because it forces me to ask questions about the nature of programming, of the nature of thought because the language models are able to predict the kinda code I was about to write so well.

Chris: Yep.

Lex: That it makes me wonder, like, how unique my brain is, and where the valuable ideas actually come from. Like, how much do I contribute in terms of ingenuity, innovation, to code I write or design and that kinda stuff. When you stand on the shoulders of giants, are you really doing anything? And what LLMs are helping you do is they help you stand on the shoulders of giants in your programming. There’s mistakes. They’re interesting that you learn from, but I just, it would love to get your opinion first, high level…

Chris: Yeah.

Lex: …of what you think about this impact of large language models when they do program synthesis, when they generate code."

Lex: 好吧,是的,在某种程度上,也许我不知道你是否理解,但我很难理解,因为它迫使我提出关于编程的本质,关于思想的本质的问题,因为语言模型能够如此好地预测我即将编写的代码类型。

Chris: 是的。

Lex: 这让我想知道,像,我的大脑有多独特,以及有价值的想法实际上来自哪里。像,我在我编写或设计的代码中贡献了多少独创性,创新性,以及类似的东西。当你站在巨人的肩膀上时,你真的在做任何事情吗?而且,LLM 正在帮助你做的是,它们帮助你站在你编程中的巨人的肩膀上。有错误。它们很有趣,你可以从中学习,但我只是,我很想先听听你的意见,高层次的……

Chris: 是的。

Lex: …你对大型语言模型在进行程序合成,在生成代码时的这种影响的看法。

Chris: Yeah. Well, so I don’t know where it all goes.

Lex: Yeah.

Chris: I’m an optimist, and I’m a human optimist, right? I think that things I’ve seen are that a lot of the LLMs are really good at crushing LeetCode projects, and they can reverse the linked list like crazy. Well, it turns out there’s a lot of instances of that on the internet, and it’s a pretty stock thing, and so if you want to see standard questions answered, LLMs can memorize all the answers, then that can be amazing. And also, they do generalize out from that, and so there’s good work on that, but I think that if you, in my experience, building things, building something like you talk about Mojo, where you talk about these things, where you talk about building an applied solution to a problem, it’s also about working with people, right? It’s about understanding the problem. What is the product that you wanna build? What are the use cases? What are the customers? You can’t just go survey all the customers because they’ll tell you that they want a faster horse. Maybe they need a car, right? And so a lot of it comes into, you know, I don’t feel like we have to compete with LLMs. I think they’ll help automate a ton of the mechanical stuff out of the way. And just like, you know, I think we all try to scale through delegation and things like this. Delegating rote things to an LLM, I think is an extremely valuable approach that will help us all scale and be more productive."

Chris: 是的。好吧,所以,我不知道这一切会走向何方。

Lex: 是的。

Chris: 我是一个乐观主义者,而且,我是一个人类乐观主义者,对吧?我认为,我看到的东西是,很多 LLM 非常擅长粉碎 LeetCode 项目,而且,它们可以疯狂地反转链表。好吧,事实证明,互联网上有很多这样的例子,而且,它是一件相当普通的东西,所以,如果你想看到标准问题的答案,LLM 可以记住所有的答案,那么,那可能会很神奇。而且,它们确实从那里面概括出来,所以,在这方面有很好的工作,但我认为,如果你,根据我的经验,构建东西,构建你谈论的 Mojo 这样的东西,在那里你谈论这些东西,在那里你谈论构建一个问题的应用解决方案,它也是关于与人合作,对吧?它是关于理解问题。你想构建的产品是什么?用例是什么?客户是什么?你不能只是去调查所有的客户,因为他们会告诉你,他们想要一匹更快的马。也许,他们需要一辆汽车,对吧?所以,很多都进入了,你知道,我不觉得我们必须与 LLM 竞争。我认为,它们会帮助我们自动化很多机械的东西。而且,就像,你知道,我认为,我们都试图通过委托和类似的东西来扩展。我认为,将死记硬背的东西委托给 LLM 是一种非常有价值的方法,它将帮助我们所有人扩展并提高效率。

Lex: But I think it’s a fascinating companion, but…

Chris: I’d say I don’t think that that means that we’re gonna be done with coding."

Lex: 但我认为,它是一个迷人的伴侣,但是……

Chris: 我会说,我不认为,这意味着,我们将完成编码。

Lex: Sure. But there’s power in it as a companion, and…

Chris: Yeah, absolutely.

Lex: So from there, I would love to zoom in onto Mojo a little bit. Do you think about that? Do you think about LLMs generating Mojo code and helping sort of like, yeah. When you design a new programming language, it almost seems like, “Man, it would be nice to,” this sort of almost as a way to learn how I’m supposed to use this thing, for them to be trained on some of the Mojo code."

Lex: 当然。但它作为伴侣的力量,而且……

Chris: 是的,绝对的。

Lex: 所以,从那里,我很想放大一点 Mojo。你考虑过吗?你考虑过 LLM 生成 Mojo 代码,并帮助,像,是的。当你设计一种新的编程语言时,它几乎看起来像,伙计,如果,这几乎就像一种学习我应该如何使用这个东西的方式,让他们在一些 Mojo 代码上进行训练。

Chris: Yeah. So I do lead an AI company, so maybe there’ll be a Mojo LLM at some point, but if your question is, like, “How do we make a language to be suitable for LLMs?”

Lex: Yeah.

Chris: I think the cool thing about LLMs is you don’t have to, right? And so if you look at what is English, or any of these other terrible languages that we, as humans, deal with on a continuous basis, they’re never designed for machines, and yet they’re the intermediate representation. They’re the exchange format that we humans use to get stuff done, right? And so, these programming languages, they’re an intermediate representation between the human and the computer or the human and the compiler, roughly, right? And so I think the LLMs will have no problem learning whatever keyword we pick."

Chris: 是的。所以,我确实领导着一家 AI 公司,所以,也许在某个时候会有一个 Mojo LLM,但如果你的问题是,像,我们如何使一种语言适合 LLM?

Lex: 是的。

Chris: 我认为,LLM 的酷之处在于,你不必这样做,对吧?所以,如果你看看什么是英语,或者我们人类一直在处理的任何其他糟糕的语言,它们从来没有为机器设计过,但它们是中间表示。它们是我们人类用来完成工作的交换格式,对吧?所以,这些编程语言,它们是人与计算机之间,或者人与编译器之间的中间表示,大致来说,对吧?所以,我认为,LLM 学习我们选择的任何关键字都不会有问题。

Lex: Maybe the fire emoji is gonna, oh.

Chris: Maybe that’s gonna break it. It doesn’t tokenize.

Lex: No, the reverse of that. It will actually enable it because one of the issues I could see with being a superset of Python is there will be confusion about the gray area, so it’ll be mixing stuff, but…

Chris: Well, I’m a human optimist. I’m also an LLM optimist. I think that we’ll solve that problem. But you look at that, and you say, “Okay, well, reducing the rote thing,” right? Turns out compilers are very particular, and they really want the indentation to be right. They really want the colon to be there on your elses, or else it’ll complain, right? I mean, compilers can do better at this, but LLMs can totally help solve that problem. And so, I’m very happy about the new predictive coding and co-pilot type features and things like this because I think it’ll all just make us more productive."

Lex: 也许,火 emoji 会,哦。

Chris: 也许,那会破坏它。它没有标记化。

Lex: 不,反过来。它实际上会启用它,因为我可以看到,成为 Python 的超集的一个问题是,灰色区域会造成混淆,所以,它会混合东西,但是……

Chris: 好吧,我是一个人类乐观主义者。我也是一个 LLM 乐观主义者。我认为,我们会解决那个问题。但你看看那个,你说,好吧,减少死记硬背的东西,对吧?事实证明,编译器非常挑剔,而且,它们真的希望缩进是正确的。它们真的希望你的 else 上有冒号,否则它会抱怨,对吧?我的意思是,编译器可以在这方面做得更好,但 LLM 可以完全帮助解决这个问题。所以,我对新的预测编码和副驾驶类型功能和类似的东西感到非常高兴,因为我认为,所有这些都会使我们更有效率。

Lex: It’s still messy and fuzzy and uncertain. Unpredictable. So, but is there a future you see, given how big of a leap GPT-4 was, where you start to see something like LLMs inside a compiler? Or no?

Chris: I mean, you could do that. Yeah, absolutely. I mean, I think that would be interesting.

Lex: Is that wise?"

Lex: 它仍然是混乱的,模糊的,不确定的。不可预测的。所以,但是,考虑到 GPT-4 的飞跃有多大,你是否看到了一个未来,在那里你开始看到像编译器内部的 LLM 这样的东西?还是没有?

Chris: 我的意思是,你可以做到。是的,绝对的。我的意思是,我认为,那会很有趣。

Lex: 那是明智的吗?

Chris: Well, well, I mean, it would be very expensive, so compilers run fast, and they’re very efficient, and LLMs are currently very expensive. There’s on-device LLMs, and there’s other things going on, and so, maybe there’s an answer there. I think that one of the things that I haven’t seen enough of is that, so LLMs, to me, are amazing when you tap into the creative potential of the hallucinations, right? And so, if you’re doing creative brainstorming, or creative writing, or things like that, the hallucinations work in your favor. If you’re writing code that has to be correct ‘cause you’re gonna ship it in production, then maybe that’s not actually a feature. And so, I think that there has been research, and there has been work on building algebraic reasoning systems and kind of like figuring out more things that feel like proofs. And so, I think that there could be interesting work in terms of building more reliable at-scale systems, and that could be interesting, but if you chased that rabbit hole down, the question then becomes, how do you express your intent to the machine? And so, maybe you want the LLM to provide the spec, but you have a different kind of net that then actually implements the code, right? So it’s to use the documentation and inspiration versus the actual implementation.

Lex: Yeah.

Chris: Potentially."

Chris: 好吧,好吧,我的意思是,它会非常昂贵,所以,编译器运行得很快,而且,它们非常高效,而且,LLM 目前非常昂贵。有设备上的 LLM,而且,还有其他的事情正在发生,所以,也许那里有一个答案。我认为,其中一件事,我还没有看到足够多的是,所以,LLM,对我来说,当你挖掘幻觉的创造潜力时,它们是惊人的,对吧?所以,如果你正在进行创造性的头脑风暴,或者创造性的写作,或者类似的事情,幻觉对你有利。如果你正在编写必须正确的代码,因为你要在生产中发布它,那么,也许那实际上不是一个功能。所以,我认为,已经有一些研究,而且,已经有一些关于构建代数推理系统的工作,有点像弄清楚更多感觉像证明的东西。所以,我认为,在构建更可靠的大规模系统方面,可能会有有趣的工作,而且,那可能会很有趣,但如果你追逐那个兔子洞,问题就变成了,你如何向机器表达你的意图?所以,也许你希望 LLM 提供规范,但你有一种不同的网络,然后实际上实现代码,对吧?所以,它是使用文档和灵感,而不是实际的实现。

Lex: 是的。

Chris: 有可能。

Lex: Since if successful, Modular will be the thing that runs, I say so jokingly, our AI overlords, but AI systems that are used across, I know it’s a cliche term, but the internet of things. So across…

Chris: So I’ll joke and say, like, “AGI should be written in Mojo.”

Lex: Yeah. AGI should be written in Mojo. You’re joking, but it’s also possible that it’s not a joke, that a lot of the ideas behind Mojo seems like the natural set of ideas that would enable at-scale training and inferences of AI systems. So it’s just, I have to ask you about the big philosophical question about human civilization. So folks like Eliezer Yudkowsky are really concerned about the threat of AI.

Chris: Yeah.

Lex: Do you think about the good and the bad that can happen at scale deployment of AI systems?"

Lex: 因为,如果成功,Modular 将是运行的东西,我开玩笑地说,我们的人工智能霸主,但人工智能系统被用于,我知道这是一个陈词滥调,但物联网。所以,跨越……

Chris: 所以,我会开玩笑地说,像,AGI 应该用 Mojo 编写。

Lex: 是的。AGI 应该用 Mojo 编写。你在开玩笑,但也有可能,这不是一个笑话,Mojo 背后的很多想法似乎是能够实现人工智能系统的大规模训练和推理的自然的想法集。所以,只是,我必须问你一个关于人类文明的大的哲学问题。所以,像 Eliezer Yudkowsky 这样的人真的很担心人工智能的威胁。

Chris: 是的。

Lex: 你有没有想过,人工智能系统的大规模部署可能带来的好处和坏处?

Chris: Well, so I’ve thought a lot about it, and there’s a lot of different parts to this problem, everything from job displacement to Skynet, things like this.

Lex: Yeah.

Chris: And so, you can zoom into subparts of this problem. I’m not super optimistic about AGI being solved next year. I don’t think that’s gonna happen personally."

Chris: 好吧,所以,我考虑过很多,而且,这个问题有很多不同的部分,从工作岗位流失到天网,类似这样的事情。

Lex: 是的。

Chris: 所以,你可以放大这个问题的子部分。我对 AGI 在明年被解决并不超级乐观。我个人认为,那不会发生。

Lex: So you have a kinda zen-like calm about… There’s a nervousness because the leap of GPT-4 seems so big.

Chris: Sure, it’s huge."

Lex: 所以,你有一种类似禅宗的平静……有一种紧张,因为 GPT-4 的飞跃似乎很大。

Chris: 当然,它很大。

Lex: It’s like there’s some kinda transitionary period. You’re thinking…

Chris: Well, so I mean, there’s a couple of things going on there. One is I’m sure GPT-5 and 7 and 19 will be also huge leaps. They’re also getting much more expensive to run, and so there may be a limiting function in terms of just expense. On the one hand, to train, like, that could be a limiter that slows things down, but I think the bigger limiter, outside of, like, “Skynet takes over,” and I don’t spend any time thinking about that because if Skynet takes over and kills us all, then I’ll be dead, so I don’t worry about that. So, you know, I mean, that’s just, okay, other things to worry about, I’ll just focus on. I’ll focus and not worry about that one. But I think that the other thing I’d say is that AI moves quickly, but humans move slowly, and we adapt slowly. And so what I expect to happen is, just like any technology diffusion, like, the promise and then the application takes time to roll out. And so, I think that I’m not even too worried about autonomous cars defining away all the taxi drivers. Remember, autonomy was supposed to be solved by 2020.

Lex: Boy, do I remember.

Chris: And so like, I think that, on the one hand, we can see amazing progress, but on the other hand, we can see that, you know, the reality is a little bit more complicated, and it may take longer to roll out than you might expect."

Lex: 就像有一些过渡时期。你在想……

Chris: 好吧,所以,我的意思是,那里有几件不同的事情正在发生。一个是,我相信,GPT-5,7,和 19 也将是巨大的飞跃。它们的运行成本也越来越高,所以,就成本而言,可能会有一个限制函数。一方面,为了训练,像,那可能是一个限制器,它会减缓事情的进展,但我认为,更大的限制器,除了,像,天网接管,而且,我没有花任何时间去想那个,因为如果天网接管并杀死了我们所有人,那么我就会死,所以,我不担心那个。所以,你知道,我的意思是,那只是,好吧,其他需要担心的事情,我只会专注于。我会专注于,并不用担心那个。但我认为,我要说的另一件事是,人工智能发展得很快,但人类发展得慢,而且,我们适应得慢。所以,我预计会发生的是,就像任何技术的传播一样,像,承诺,然后应用需要时间来推出。所以,我认为,我甚至不太担心自动驾驶汽车会取代所有的出租车司机。记住,自动驾驶本来应该在 2020 年得到解决。

Lex: 老兄,我记得。

Chris: 所以,像,我认为,一方面,我们可以看到惊人的进步,但另一方面,我们可以看到,你知道,现实有点复杂,而且,它可能需要更长的时间才能推出,比你预期的要长。

Lex: Well, that’s in the physical space. I do think in the digital spaces, the stuff that’s built on top of LLMs that runs, you know, the millions of apps that could be built on top of them, and that could be run on millions of devices, millions of types of devices.

Chris: Yeah.

Lex: …I just think that the rapid effect it has on human civilization could be truly transformative.

Lex: We don’t even know.

Chris: Well, and so the predict… well, and there I think it depends on, are you an optimist or a pessimist? Or a masochist?"

Lex: 好吧,那是在物理空间。我确实认为,在数字空间,构建在 LLM 之上的东西,你知道,数以百万计的应用程序可以构建在它们之上,而且,可以运行在数以百万计的设备上,数以百万计的设备类型上。

Chris: 是的。

Lex: …我只是认为,它对人类文明的快速影响可能是真正 transformative。

Lex: 我们甚至不知道。

Chris: 好吧,所以,预测……好吧,我认为,那里取决于,你是一个乐观主义者,还是一个悲观主义者?还是一个受虐狂?

Lex: Yeah.

Chris: Just to clarify, optimistic about human civilization."

Lex: 是的。

Chris: 只是为了澄清,对人类文明持乐观态度。

Lex: Me too. And so, I look at that as saying, “Okay, cool, well, AI do, right?” And so, some people say, “Oh my God! Is it gonna destroy us all? How do we prevent that?” I kinda look at it from a, “Is it gonna unlock us all?” Right? You talk about coding. “Is it gonna make it so I don’t have to do all the repetitive stuff?” Well, suddenly, that’s a very optimistic way to look at it. And you look at what a lot of these technologies have done to improve our lives, and I want that to go faster.

Lex: So what do you think the future of programming looks like in the next 10, 20, 30, 50 years? That LLMs, LLMs, and with Mojo, with Modular, like your vision for devices, the hardware, to compilers, to this, to the different stacks of software?"

Lex: 我也是。所以,我把它看作是说,好吧,酷,好吧,人工智能做,对吧? 所以,有些人说,我的天啊!它会毁灭我们所有人吗?我们如何阻止它? 我有点像从,它会解放我们所有人吗? 的角度来看待它。对吧?你谈论的是编码。它会让它,这样我就不用做所有重复的事情了吗? 好吧,突然,那是一种非常乐观的方式来看待它。而且,你看看很多这些技术为改善我们的生活所做的事情,而且,我希望它能更快地发展。

Lex: 那么,你认为未来 10 年,20 年,30 年,50 年的编程会是什么样子?LLM,LLM,以及 Mojo,Modular,像你对设备,硬件,到编译器,到这个,到不同的软件栈的愿景?

Chris: Yeah, yeah. Well, so what I want, I mean, coming back to my arch-nemesis, right, is complexity, right? So again, me being the optimist, if we drive down complexity, we can make these tools, these technologies, these cool hardware widgets, accessible to way more people, right? And so what I’d love to see is more personalized experiences, more things, the research getting into production instead of being lost in academia, right? And so, and like these things that impact people’s lives by entering products, and so one of the things that I’m a little bit concerned about is, right now, the big companies are investing huge amounts of money, and are driving the top line of AI capability forward really quickly, but if it means that you have to have $100 million to train a model, or more, $100 billion, right, well, that’s gonna make it very concentrated with very few people in the world that can actually do this stuff. I would much rather see lots of people across the industry be able to participate and use this, right? And you look at this, you know, I mean, a lot of great research has been done in the health world and looking at like detecting pathologies and doing radiology with AI, and, like, doing all these things. Well, the problem today is that to deploy and build these systems, you have to be an expert in radiology and an expert in AI. And if we can break down the barriers so that more people can use AI techniques, and it’s more like programming Python, which roughly everybody can do if they want to, right, then I think that we’ll get a lot more practical application of these techniques, and a lot more niche-y, cool, but narrower demands, and I think that’s gonna be really cool."

Chris: 是的,是的。好吧,所以,我想要的是,我的意思是,回到我的死敌,对吧,是复杂性,对吧?所以,再次,我是一个乐观主义者,如果我们降低复杂性,我们可以让这些工具,这些技术,这些酷的硬件小部件,更容易被更多的人使用,对吧?所以,我想要看到的是更个性化的体验,更多的东西,研究进入生产,而不是迷失在学术界,对吧?所以,像这些通过进入产品影响人们生活的东西,所以,其中一件事,我有点担心的是,现在,大公司正在投入大量的资金,而且,正在以非常快的速度推动人工智能能力的顶线向前发展,但如果这意味着,你必须有 1 亿美元来训练一个模型,或者更多,1000 亿美元,对吧,好吧,那将使它非常集中,世界上只有很少的人能够真正做这些事情。我更希望看到整个行业的很多人都能够参与并使用它,对吧?而且,你看看这个,你知道,我的意思是,在健康领域已经做了很多很棒的研究,而且,看看像用人工智能检测病理,做放射学,以及,像,做所有这些事情。好吧,今天的问题是,要部署和构建这些系统,你必须是放射学专家,并且是人工智能专家。如果我们可以打破障碍,让更多的人可以使用人工智能技术,而且,它更像编程 Python,如果他们愿意,几乎每个人都可以做到,对吧,那么我认为,我们将获得更多这些技术的实际应用,以及更多利基的,酷的,但更窄的需求,而且,我认为,那将会非常酷。

Lex: Do you think we’ll have more or less programmers in the world than now?"

Lex: 你认为,世界上的程序员会比现在更多还是更少?

Chris: Well, so I think we’ll have more programmers, but they may not consider themselves to be programmers.

Lex: That’d be a different name for it, right? I mean, do you consider somebody that uses, you know, I think that arguably the most popular programming language is Excel."

Chris: 好吧,所以,我认为,我们将有更多的程序员,但他们可能不认为自己是程序员。

Lex: 那将是一个不同的名字,对吧?我的意思是,你认为,使用,你知道,我认为,可以说最流行的编程语言是 Excel 的人。

Chris: Yeah.

Lex: Right?

Chris: Yep.

Lex: And so, do they consider themselves to be programmers? Maybe not. I mean, some of them make crazy macros and stuff like that, but what you mentioned, Steve Jobs, it’s the bicycle for the mind that allows you to go faster, right? And so I think that as we look forward, right, what is AI? I look at it as, hopefully, a new programming paradigm. It’s like object-oriented programming, right? If you wanna write a cat detector, you don’t use for loops. Turns out that’s not the right tool for the job, right? And so, right now, unfortunately, because, I mean, it’s not unfortunate, but it’s just kinda where things are, AI is this weird, different thing that’s not integrated into programming languages and normal toolchains, and all the technology is really weird, and doesn’t work, right? And you have to babysit it, and every time you switch hardware, it’s different. It shouldn’t be that way. When you change that, when you fix that, suddenly, again, the tools and technologies can be way easier to use. You can start using them for many more things, and so that’s what I would be excited about."

Chris: 是的。

Lex: 对吧?

Chris: 是的。

Lex: 所以,他们认为自己是程序员吗?也许不是。我的意思是,他们中的一些人制作了疯狂的宏和类似的东西,但你提到的,史蒂夫·乔布斯,它是心灵的自行车,它让你走得更快,对吧?所以,我认为,当我们展望未来的时候,对吧,什么是人工智能?我希望,它是一种新的编程范式。它就像面向对象编程,对吧?如果你想写一个猫探测器,你不会使用 for 循环。事实证明,那不是正确的工作工具,对吧?所以,现在,不幸的是,因为,我的意思是,这不是不幸的,但它只是有点像事情的现状,人工智能是这种奇怪的,不同的东西,它没有集成到编程语言和正常的工具链中,而且,所有的技术都真的很奇怪,而且,不能工作,对吧?而且,你必须照看它,而且,每次你切换硬件的时候,它都不一样。它不应该那样。当你改变它的时候,当你修复它的时候,突然,再次,工具和技术就可以更容易地使用。你可以开始将它们用于更多的事情,所以,这就是我感到兴奋的地方。

Lex: What kinda advice could you give to somebody in high school right now, or maybe early college, who’s curious about programming, and feeling like the world is changing really quickly here?

Chris: Yeah.

Lex: Well, what kinda stuff to learn, what kinda stuff to work on? Should they finish college? Should they go work at a company? Should they build a thing? What do you think?"

Lex: 你对现在高中,或者也许是大学早期的人有什么建议,他们对编程很好奇,而且,感觉世界在这里变化得很快?

Chris: 是的。

Lex: 好吧,应该学习什么样的东西,应该做什么样的工作?他们应该完成大学学业吗?他们应该去公司工作吗?他们应该构建一个东西吗?你怎么看?

Chris: Yeah. Well, so I mean, one of the things I’d say is that you’ll be most successful if you work on something you’re excited by. And so, don’t get the book and read the book cover to cover and study and memorize and recite and flashcard, and… go build something! Like, go solve a problem. Go build the thing that you wanted to exist. Go build an app. Go build, train a model. Like, go build something, and actually use it, and set a goal for yourself, and if you do that, then you’ll, you know, there’s a success, there’s the adrenaline rush, there’s the achievement. There’s the unlock that, I think, is where, you know, if you keep setting goals, and you keep doing things, and building things, learning by building is really powerful. In terms of career advice, I mean, everybody’s different. It’s very hard to give generalized advice. I’ll speak as, you know, a compiler nerd. If everybody’s going left, sometimes it’s pretty cool to go right."

Chris: 是的。好吧,所以,我的意思是,其中一件事,我会说的是,如果你做一些你感到兴奋的事情,你将是最成功的。所以,不要拿书,从头到尾地读,并学习,记忆,背诵,和抽认卡,而且……去构建一些东西!像,去解决一个问题。去构建你想要存在的东西。去构建一个应用程序。去构建,训练一个模型。像,去构建一些东西,而且,实际使用它,并为自己设定一个目标,而且,如果你这样做,那么你将,你知道,有一个成功,有一个肾上腺素激增,有一个成就。有一种解锁,我认为,是,你知道,如果你不断设定目标,而且,你不断做事,并构建东西,通过构建来学习是非常强大的。就职业建议而言,我的意思是,每个人都不一样。给出概括性的建议非常困难。我将作为一个,你知道,编译器书呆子来说话。如果每个人都向左走,有时向右走会很酷。

Lex: Yeah.

Chris: And so, just because everybody’s doing a thing, it doesn’t mean you have to do the same thing and follow the herd. In fact, I think that sometimes the most exciting paths through life lead to being curious about things that nobody else actually focuses on, right? And it turns out that understanding deeply parts of the problem that people want to take for granted makes you extremely valuable and specialized in ways that the herd is not. And so, again, I mean, there’s lots of rooms for specialization, lots of room for generalists. There’s lots of room for different kinds and parts of the problem, but I think that it’s, you know, just because everything, everybody’s doing one thing doesn’t mean you should necessarily do it."

Lex: 是的。

Chris: 所以,仅仅因为每个人都在做一件事,并不意味着你必须做同样的事情,并随大流。实际上,我认为,有时,人生中最令人兴奋的道路是,对那些实际上没有其他人关注的东西感到好奇,对吧?而且,事实证明,深入理解人们认为理所当然的问题的部分,会使你变得极其有价值,并以群体所没有的方式进行专业化。所以,再次,我的意思是,有很多专业化的空间,有很多通才的空间。有很多不同类型和部分问题的空间,但我认为,你知道,仅仅因为所有东西,每个人都在做一件事,并不意味着你必须做它。

Lex: And now, the herd is using Python. So if you wanna be a rebel, go check out Mojo, and help Chris and the rest of the world fight the arch-nemesis of complexity, ‘cause simple is beautiful.

Chris: There we go. Yeah."

Lex: 现在,人群正在使用 Python。所以,如果你想成为一个反叛者,去看看 Mojo,并帮助 Chris 和世界上的其他人对抗复杂性的死敌,因为简单就是美。

Chris: 我们走吧。是的。

Lex: Chris, you’re an incredible person. You’ve been so kind to me ever since we met. You’ve been extremely supportive. I’m forever grateful for that. Thank you for being who you are, for being legit, for being kind, for fighting this really interesting problem of how to make AI accessible to a huge number of people, a huge number of devices.

Chris: Yeah, well, so Lex, you’re a pretty special person too, right? And so, I think that, you know, one of the funny things about you is that besides being curious, and pretty damn smart, you’re actually willing to push on things, and you’re, I think that you’ve got an agenda to, like, make the world think, which I think is a pretty good agenda. It’s a pretty good one.

Lex: Thank you so much for talking to me, Chris.

Chris: Yeah, thanks Lex.

Lex: Thanks for listening to this conversation with Chris Lattner. To support this podcast, please check out our sponsors in the description. And now let me leave you some words from Isaac Asimov: “I do not fear computers. I fear the lack of them.” Thank you for listening]"

Lex: Chris,你是一个不可思议的人。自从我们相遇以来,你一直对我很好。你一直非常支持我。我永远感激你。谢谢你做你自己,谢谢你合法,谢谢你善良,谢谢你为这个真正有趣的问题而战,那就是如何让人工智能更容易被大量的人,大量的设备使用。

Chris: 是的,好吧,所以,Lex,你也是一个相当特别的人,对吧?所以,我认为,你知道,关于你的一件有趣的事情是,除了好奇,而且,非常聪明,你实际上愿意推动事情,而且,你,我认为,你有一个议程,像,让世界思考,我认为,那是一个相当好的议程。那是一个相当好的议程。

Lex: 非常感谢你和我谈话,Chris。

Chris: 是的,谢谢,Lex。

Lex: 感谢收听与 Chris Lattner 的对话。为了支持这个播客,请查看我们描述中的赞助商。现在,让我给你留下 Isaac Asimov 的一些话:我不害怕计算机。我害怕没有它们。 感谢收听

备注

此翻译由youtube字幕下载器下载英文字幕,由Gemini 1.5 Pro整理翻译,仅供参考


Tags: YouTube

author

Jesse Lau

網名遁去的一,簡稱遁一。2012年定居新西蘭至今,自由職業者。
本文采用知識共享署名 4.0 國際許可協議進行許可。簡而言之,可隨意轉發轉載,轉載請注明出處。


留点评论吧: