跳至內容

Mojo

本頁使用了標題或全文手工轉換
維基百科,自由的百科全書
Mojo
編程範型多範式指令式(為主),函數式泛型
語言家族Python
設計者克里斯·拉特納
實作者Modular公司
面市時間2023年,​11個月前​(2023
目前版本
  • 24.5.0(2024年9月13日;穩定版本)[1]
編輯維基數據鏈結
型態系統
作業系統跨平臺
許可證專有
副檔名.🔥(火焰emoji/U+1F525)、.mojo
網站www.modular.com/mojo
啟發語言
PythonCythonCC++RustSwiftZig

Mojo是由Modular公司開發的一種基於MLIR編譯框架英語MLIR (software)程式語言,旨在為人工智慧等領域的軟體開發提供統一的編程框架。[2][3][4][5][6][3][7][8]

Mojo語言為Python語言超集[7][9],故也被稱為Python++ 。同時,它還具有C++的速度與Rust的安全性。[10][5][11][12][13][2][14]

Mojo語言於2023年5月推出,最初僅能在瀏覽器的Jupyter筆記本中使用[3][15],2023年9月起開始提供Linux本地版本。[16]Modular公司團隊還開發了支援Mojo語言的Visual Studio Code擴充。[17]

原始設計與開發

[編輯]

2022年,Swift語言創始人克里斯·拉特納Google機器學習產品經理蒂姆·戴維斯(Tim Davis)共同創立了Modular公司。[18]2022年9月,Modular公司在內部發布了Mojo的初始版本[19],支援MLIR編譯器框架提供的進階編譯功能。[3][20]

Mojo語言的型別系統是同時包含靜態型別和動態型別的混合系統,開發者可以為其編寫的函式自由選擇是否使用高效能靜態型別。

與Python的對比

[編輯]

Mojo語言旨在與Jupyter生態系統完全相容。目前,其尚未做到完全與Python 3.x原始碼相容英語Source-code compatibility,而僅支援Python語法的子集。在此基礎上,Mojo還支援Python沒有的高效能低階程式語言的功能,如能使用「fn」關鍵字建立類型化可編譯函式,或使用「struct」關鍵字建立可最佳化主記憶體使用的[15]Mojo還能通過CPython來呼叫現有的Python 3.x代碼。此外,Mojo借鑑Rust引入了Python所沒有的借用檢查器。

實例

[編輯]

使用Mojo語言編寫的Hello world程式與Python相同:

print('Hello, World!')

參考文獻

[編輯]
  1. ^ Release 24.5.0. 2024年9月13日 [2024年9月27日]. 
  2. ^ 2.0 2.1 Mojo🔥 programming manual. docs.modular.com. Modular. 2023 [2023-09-26]. (原始內容存檔於2023-10-22). Mojo is a programming language that is as easy to use as Python but with the performance of C++ and Rust. Furthermore, Mojo provides the ability to leverage the entire Python library ecosystem. 
  3. ^ 3.0 3.1 3.2 3.3 Krill, Paul. Mojo language marries Python and MLIR for AI development. InfoWorld. 4 May 2023 [2023-09-27]. (原始內容存檔於2023-05-05) (英語). 
  4. ^ Mojo 🔥 — the programming language for all AI developers. www.modular.com. Modular. 2023 [2023-09-26]. (原始內容存檔於2023-11-10). Mojo leverages MLIR, which enables Mojo developers to take advantage of vectors, threads, and AI hardware units. 
  5. ^ 5.0 5.1 Hahn, Silke. Jenseits von Python: Mojo baut Brücke zwischen Python und C für Machine Learning. www.heise.de. Heise Medien GmbH & Co. KG. 2023-05-09 [2023-09-26]. (原始內容存檔於2023-09-26) (德語). Eine neue Programmiersprache für Machine Learning, eine Art Python++? 
  6. ^ Why Mojo🔥 - A language for next-generation compiler technology. docs.modular.com. Modular. 2023 [2023-09-26]. (原始內容存檔於2023-05-05). While many other projects now use MLIR, Mojo is the first major language designed expressly for MLIR, which makes Mojo uniquely powerful when writing systems-level code for AI workloads. 
  7. ^ 7.0 7.1 Claburn, Thomas. Modular reveals Mojo, Python superset with C-level speed. The Register. 5 May 2023 [2023-09-27]. (原始內容存檔於2023-09-02) (英語). 
  8. ^ Pandey, Mohit. This New Programming Language is Likely to Replace Python. Analytics India Magazine. 3 May 2023 [2023-09-27]. (原始內容存檔於2023-05-30). 
  9. ^ Welcome to Mojo 🔥. github.com. Modular. 2023 [2023-09-26]. (原始內容存檔於2023-10-25). Mojo is still young, but it is designed to become a superset of Python over time. 
  10. ^ Ramarao, Pramod. Mojo🔥 - It’s finally here!. www.modular.com. Modular. 2023-09-07 [2023-09-26]. (原始內容存檔於2023-11-12). Mojo: a high performance 'Python++' language for compute 
  11. ^ Howard, Jeremy. Mojo may be the biggest programming language advance in decades. www.fast.ai. fast.ai. 2023-05-04 [2023-09-26]. (原始內容存檔於2023-10-17). Maybe it’s better to say Mojo is Python++ 
  12. ^ May, Eira. Like Python++ for AI developers. stackoverflow.blog. Stack Exchange, Inc. 2023-09-25 [2023-09-26]. (原始內容存檔於2023-10-04). 
  13. ^ Saplin, Maxim. Mojo🔥SDK has been released for Linux. dev.to. DEV Community. 2023-09-07 [2023-09-26]. (原始內容存檔於2023-10-22). From the creators of LLVM, Clang, and Swift. A better Python, Python++ 
  14. ^ May, Eira. Mojo: The usability of Python with the performance of C. stackoverflow.blog. Stack Exchange, Inc. 2023-09-22 [2023-09-26]. (原始內容存檔於2023-10-08). 
  15. ^ 15.0 15.1 Yegulalp, Serdar. A first look at the Mojo language. InfoWorld. 7 June 2023 [2023-09-27]. (原始內容存檔於2023-08-18) (英語). 
  16. ^ Deutscher, Maria. Modular makes its AI-optimized Mojo programming language generally available. Silicon Angle. 7 September 2023 [2023-09-11]. (原始內容存檔於2023-10-23) (英語). 
  17. ^ Mojo for Visual Studio Code. marketplace.visualstudio.com. Microsoft. [2023-09-26]. (原始內容存檔於2023-10-14). 
  18. ^ Claburn, Thomas. Modular finds its Mojo, a Python superset with C-level speed. The Register. 2023-05-05 [2023-08-08]. (原始內容存檔於2023-09-02). 
  19. ^ Mojo🔥 changelog. [2023-09-27]. (原始內容存檔於2023-11-01). 
  20. ^ Lattner, Chris; Amini, Mehdi; Bondhugula, Uday; Cohen, Albert; Davis, Andy; Pienaar, Jacques; Riddle, River; Shpeisman, Tatiana; Vasilache, Nicolas; Zinenko, Oleksandr. MLIR: A Compiler Infrastructure for the End of Moore's Law. 2020-02-29. arXiv:2002.11054可免費查閱 [cs.PL]. 

外部連結

[編輯]