什麼東西在Go裡用著開心而在其他語言裡卻很難?
谷歌的首席技術宣講師麥克•瓊斯Michael Jones如是回覆Go論壇上的一個提問:什麼東西在Go裡用著開心而在其他語言裡卻很難?。此文得到了Go的核心開發者之一的Russ Cox的推薦。我也認為它是對Go的特性的一個熱情但不失客觀地總結,特翻譯如下,以資參考。
“你是你能力所及”的物件模型使很多事情變簡單了,雖然最初未必能夠體會到。
介面的機制很了不起,同時也很微妙。我認為還沒有人充分利用到它絕大部分的能力。
併發模型和執行體使很多事情變簡單了、變高效了,雖然最初未必能夠體會到。
“頭等函式”的定位使很多事情簡單了、高效了,雖然最初未必能夠體會到,至少對非LISP/Scheme/T等等的開發者仍是如此。
將語言用作巨集語言的設施,對一種非LISP/J/Forth的語言是很強的。這一方面歸於語言本身,一方面得益於標準庫,但遊刃於兩者使一些事情簡單得很自然,例如解析原始碼,得出標準又美觀的版本但仍保持註釋不變,重寫現有程式碼以跟上語言和庫設計的變化(大多是指1.0版前,但其能力仍存於go vet),查遍整個現有程式碼,以便引入新的或者改動舊介面,等等。
和Web相關的庫設施,使其成為應用層級的語言,能簡單地架構複雜的面對客戶端的服務。
“實業觀”而不是“學業觀”的哲學定位,用在諸如建造管理、設計針對測試、測試融於開發上,這些對大型軟體團隊很普通,但卻通常是新語言所缺失的。
一貫地簡潔使編碼、測試、除錯、(和將來時態的)長期維護變容易了,雖然人們最初未必能夠體會。例如,事情就是它們看起來的樣子,做著看樣子它們在做的事情。像這樣的工具(C,Go,錘子,砧板,螺絲起子等等),是人們很容易喜歡上的。
開發、編譯和執行是三倍的速度,這相當地獨特,也恰當地揭示了它的前途:成品程式碼用在龐大的系統上、勝任出奇豐富的業務,並且能快樂程式設計、輕鬆理解、和迅速執行。要記得效能自身也是一種賦能的科技。
它看著還“小”,仍能輕易地適合一個人的心智模式,正如‘C’。這是優點。
Map作為頭等原語有些意思。人們總能把關聯儲存做成個附加,但頭等對待並加以整合可以降低使用門檻。這有助於輕鬆達致更好的O(n)方式,並巧妙地將開發者帶向高效能的設計,並在問題面擴大後仍能維持快捷。
對一個新語言而言,它的庫是不尋常地精密。閱讀API文件可以看出上述的元素(特別是介面),是如何美妙地用一種新穎的方式重組服務。直到庫的設計對你而言是自然而然之前(“啊,對呀。我也會這樣做),你還不能算個地道的Go者。它有些“相當”雅緻的元素,會一直保持典雅,就在這時代大部分的語言都褪色的時候。
Michael Jones
Aug 9, 11:58 am
Re: [go-nuts] Fun things in Go that are hard in other languages?
The "you are what you can do" object model makes many things simple, in ways perhaps not appreciated at first. The Interface mechanism is simultaneously extraordinary and subtle. For the most part I think none of us yet fully realize its power.
The concurrency model and runtime make many things simple and efficient, in ways perhaps not appreciated at first.
The "first-class functions" orientation makes many things simple and efficient, in ways perhaps not appreciated still, at least by non-Lisp/Scheme/T/etc. developers.
The language-as-metalanguage facilities are strong for non-Lisp/non-J/non-Forth languages. This is partially the language, and partially the standard libraries, but between them they make it easy and natural to do such things as parse source and emit standardized pretty-printed versions with comments intact, rewrite code bases to match evolving language features and library designs (mostly pre-1.0 but the power remains in go vet), check the entirety of the codebase for possible introduction of new or change of old interfaces, etc.
The web-related library facilities makes it an application-level language for simple construction of sophisticated client-facing services.
A philosophical orientation from the "industrial view" rather then the "academic view" on issues like build management, design for test, test in development, and so on that is maybe common in large software teams but heretofore absent in new-language efforts.
The consistent simplicity makes coding, testing, debugging, (and future tense) long-term maintenance easy in ways perhaps not appreciated at first. For example, things mean what they seem to mean and do what they seem to do. Tools like this (C, Go, the hammer, the anvil, the screwdriver, etc.) are easy to love.
The speed of development, compilation, and execution are as a triple, rather unique and a good suggestion of what may lie ahead: production code on very large systems capable of marvelously rich services that is fun to write, easy to undersand, and speedy in execution performance. Remember that performance itself is an enabling technology.
It still seems "small" and can fit in one's mental model easily, just as C. This is goodness.
Integration of Maps as a first-class primitive is interesting. One could always build associative storage systems as an add-on, but being first class and integrated lowers the usage barrier. This can help make the "easy way" the better O(n) way and subtly lead developers to performant designs that stay fast as problem size scales up.
The library is unusually sophisticated for a new language. Read the API documentation to see how wonderfully the elements above (Interfaces especially) are used to factor services in new and novel ways. Until the design of the library is natural to you ("oh, of course, that's how I would have done it too") then you're not yet a Go native. There are VERY elegant elements in there that will still be elegant when most contemporary languages are gone.
Some thoughts, Michael
-- Michael T. Jones | Chief Technology Advocate | m...@google.com | +1 650-335-5765
相關文章
- go與其他語言有什麼區別?學習go語言怎麼樣Go
- 在遊戲裡“翻盤”為什麼那麼難?遊戲
- input 框裡面的東西刪不掉怎麼辦?
- go語言開發培訓班哪裡好Go
- HTML5.1 裡的新東西HTML
- 在阿里工作的日子裡,我都學到了哪些東西?阿里
- 什麼是Go語言?Go語言有什麼特點?Go
- [譯]JS裡我才知道的東西JS
- JavaScript 6 裡都有啥新鮮東西?JavaScript
- 為什麼很多公司都轉型go語言開發?Go語言能做什麼Go
- 開心檔之Go 語言常量Go
- go語言教程哪裡有?go 語言優秀開源專案彙總Go
- 聽說node.js很火?那麼這skr什麼鬼東西?Node.js
- go語言能做什麼Go
- python語言與其他語言有什麼不同?Python
- Python會在什麼時候被其他語言取代Python
- 在我眼裡的幾種語言
- git裡最有用最經常使用的東西Git
- 為什麼在遊戲裡做一扇好用的“門”這麼難?遊戲
- 我在阿里工作的這段時間裡,都學到了哪些東西阿里
- 框架是個什麼東西?框架
- 這是什麼東西呢?
- ftp是什麼,ftp是什麼東西?FTP
- Go語言適合做什麼 ?Go
- Go語言GOPATH是什麼Go
- 為什麼那麼多人要學習go語言?go語言有什麼特點?Go
- 三種東西永遠不要放到資料庫裡資料庫
- mock在vue裡怎麼用MockVue
- Java JVM:垃圾回收(GC 在什麼時候,對什麼東西,做了什麼事情)JavaJVMGC
- SQL:我為什麼慢你心裡沒數嗎?SQL
- 開心檔之Go 語言環境安裝Go
- 為什麼寫爬蟲用Python語言?原因很簡單!爬蟲Python
- Vue 3 的 setup語法糖到底是什麼東西?Vue
- 在python裡int是什麼意思Python
- 做出一款成功遊戲後,為什麼第二款卻很難做成?遊戲
- “Go語言”有什麼用途?有什麼優勢?Go
- 在windows下開發go 用什麼工具WindowsGo
- 什麼是布隆過濾器?在php裡你怎麼用?過濾器PHP