如何看待dart2側重client-side開發?
https://medium.com/dartlang/announcing-dart-2-80ba01f43b6
嗯,關於Google選擇dart作為flutter開發語言的原因,知乎上似乎有一個版本,說是dart組離flutter組近……也許這是一個原因,但是這麼簡單粗暴的理由要用來做這種決策,有些太過於草率了
今天隨手翻了翻flutter的faq,這個問題的答案就在faq裡面,我直接拷貝了:
Why did Flutter choose to use Dart?
Flutter used four primary dimensions for evaluation, and considered the needs of framework authors, developers, and end users. We found some languages met some requirements, but Dart scored highly on all of our evaluation dimensions and met all our requirements and criteria.
Dart runtimes and compilers support the combination of two critical features for Flutter: a JIT-based fast development cycle that allows for shape changing and stateful hot reloads in a language with types, plus an Ahead-of-Time compiler that emits efficient ARM code for fast startup and predictable performance of production deployments.
In addition, we have the opportunity to work closely with the Dart community, which is actively investing resources in improving Dart for use in Flutter. For example, when we adopted Dart, the language did not have an ahead-of-time toolchain for producing native binaries, which is instrumental in achieving predictable, high performance, but now the language does because the Dart team built it for Flutter. Similarly, the Dart VM has previously been optimized for throughput but the team is now optimizing the VM for latency, which is more important for Flutter』s workload.
Dart scores highly for us on the following primary criteria:
- Developer productivity. One of Flutter』s main value propositions is that it saves engineering resources by letting developers create apps for both iOS and Android with the same codebase. Using a highly productive language accelerates developers further and makes Flutter more attractive. This was very important to both our framework team as well as our developers. The majority of Flutter is built in the same language we give to our users, so we need to stay productive at 100k』s lines of code, without sacrificing approachability or readability of the framework and widgets for our developers.
- Object-orientation. For Flutter, we want a language that』s suited to Flutter』s problem domain: creating visual user experiences. The industry has multiple decades of experience building user interface frameworks in object-oriented languages. While we could use a non-object-oriented language, this would mean reinventing the wheel to solve several hard problems. Plus, the vast majority of developers have experience with object-oriented development, making it easier to learn how to develop with Flutter.
- Predictable, high performance. With Flutter, we want to empower developers to create fast, fluid user experiences. In order to achieve that, we need to be able to run a significant amount of end-developer code during every animation frame. That means we need a language that both delivers high performance and delivers predictable performance, without periodic pauses that would cause dropped frames.
- Fast allocation. The Flutter framework uses a functional-style flow that depends heavily on the underlying memory allocator efficiently handling small, short-lived allocations. This style was developed in languages with this property and does not work efficiently in languages that lack this facility.
來源:FAQ - Flutter
這麼一大段寫得很清楚,我覺得理由也足夠充分,就這麼說,dart就是客戶端java,可以看到很多java世界裡面我們曾經見過的專業術語全部出現,比如不要重複造輪子,面向對象, 跨平台等
Plus, the vast majority of developers have experience with object-oriented development, making it easier to learn how to develop with Flutter.
像這種話,我相信正常人都能猜出來它在說啥,然後dart faq裡面有一段關於dart和java的關係:
Q. Isn』t Dart a lot like Java?
Dart has some similarities with Java. See the Intro to Dart for Java Developers codelab for examples of some of the differences between Dart and Java.
其實多翻番,很多問題人家都回答了,比如這個
Q. Why isn』t Dart more like Haskell / Smalltalk / Python / Scala / other language?
Various reasons, depending on the language being asked about.
For languages that are quite different from JavaScript: it』s important for Dart to compile to efficient JavaScript. Our experience in GWT is that if the source language is too different from JavaScript, it creates some cases where complex output code is needed to emulate the source language』s behavior. This can cause performance to vary in ways that are not transparent to the programmer.
For languages that are less mainstream: we expect that modeling Dart on these would, on the whole, hurt our adoption. Our team includes fans of these languages, and if we thought Dart could take up our favorite cool language features and push them to widespread adoption we might be tempted, but really we think we』ve got our hands full introducing a new language at all.
For languages that are 「more dynamic」 than Dart: Dart deliberately trades off some of this arbitrary runtime modification for the goal of better performance and tools.
來源:Frequently Asked Questions (FAQ)
再想想最近oracle跟google的官司,判決安卓上用java api怎麼滴不行
dart就是google版的java,只是換了個名字而已,實際上google和sun,java和dart之間都有千絲萬縷的聯繫,比如google和sun都是斯坦福大學出廠的,google在最初起步的時候,得到了sun的支援,java的hotspot jvm和dart,都有一個共同的作者,那個人叫做lars bak等等,這種軼事聯繫進去,dart跟java相似應該是很正常的事
然後google針對java無法在客戶端使用,也列舉了不少原因,比如常見的慢,這個就是latency方面的優化,一個是gc pause降低,目前沒有找到關於dart gc部分的benchmark,不好說,但是肯定會做類似優化,google在這個領域有足夠多的經驗,其次過於aot,可以啟動速度變快等等,怎麼看都像是一個java的客戶端版本,用上了java的語法,針對客戶端的需求做優化
google是一家腳踏實地用技術解決問題的公司,這才是一家技術公司應該有的樣子,做的很多事都在解決實實在在的問題,比如會java的人多,但是java在客戶端的性能暫時還不行,怎麼辦?解決它,flutter就是google解決該問題的產物,而不是只懂得說,java慢啊,所以不要用java了,因噎廢食,java慢就想辦法解決它,技術的進步就是在解決一個又一個實際問題中的產物
在我看來,這意味著用java/dart這種語法來搞遊戲的曙光,我們決定把握該機會,投身其中
vive la dart
推薦閱讀:
※程序員得痔瘡算工傷嗎?
※拉比克偷取他人技能,在代碼程序層面時如何實現的?
※計算機程序如何識別音色?
※【譯】注釋的藝術
※根本就沒有代碼是你的,只有Bug 是你的