词条 | Dart (programming language) |
释义 |
| name = | title = Dart | logo = Dart programming language logo.svg | logo caption = | screenshot = | screenshot caption = | paradigm = Multi-paradigm: scripting, object-oriented (class-based), imperative, reflective, functional, garbage-collected[1] | family = | released = {{Start date and age|2011|10|10}}[2] | designer = Lars Bak and Kasper Lund | developer = Google | latest release version = 2.2.0 | latest release date = {{Start date and age|2019|02|26}}[3] | latest preview version = 2.2.0-dev.2.0 | latest preview date = {{Start date and age|2019|02|14}}[4] | typing = 1.x: Optional, | scope = | implementations = Dart VM, dart2js, DDC, Flutter | dialects = | influenced by = C#, Erlang, JavaScript, Smalltalk, Strongtalk[6] | influenced = | programming language = | platform = Cross-platform | operating system = Cross-platform | license = BSD | website = {{URL|www.dartlang.org}} | file ext = .dart | fileformat = }}Dart is a general-purpose programming language originally developed by Google and later approved as a standard by Ecma (ECMA-408).[7] It is used to build web, server, desktop, and mobile applications.[8] Dart is an object-oriented, class defined, garbage-collected language[9] using a C-style syntax that transcompiles optionally into JavaScript. It supports interfaces, mixins, abstract classes, reified generics, static typing, and a sound type system.[10] HistoryDart was unveiled at the GOTO conference in Aarhus, Denmark, October 10–12, 2011.[11] The project was founded by Lars Bak and Kasper Lund.[12] Dart 1.0 was released on November 14th, 2013.[13] In August 2018, Dart 2.0 was released, with language changes including a sound type system.[14]
Ecma International has formed technical committee TC52[15] to work on standardizing Dart, and inasmuch as Dart can be compiled to standard JavaScript, it works effectively in any modern browser. Ecma International approved the Dart language specification first edition in July 2014, at its 107th General Assembly,[16] and a second edition in December 2014.[17] The latest specification is available at https://www.dartlang.org/guides/language/spec. UsageThere are three main ways to run Dart code:
IsolatesTo achieve concurrency, Dart uses isolates, which are independent workers that do not share memory, but instead use message passing. This is similar to Erlang actors. Every Dart program uses at least one isolate, which is the main isolate. Since Dart 2 the Dart web platform no longer supports isolates, and suggests developers use Web Workers instead.[22] SnapshotsSnapshots are a core part of the Dart VM. Snapshots are files which store objects and other runtime data.
Dart programs can be compiled into snapshot files. These files contain all of the program code and dependencies preparsed and ready to execute. This allows fast startups.
The Dart core libraries can be compiled into a snapshot file which allows fast loading of the libraries. Most standard distributions of the main Dart VM have a prebuilt snapshot for the core libraries which is loaded at runtime.
Dart is a very asynchronous language. With this, it uses isolates for concurrency. Since these are workers which pass messages, it needs a way to serialize a message. This is done using a snapshot, which is generated from a given object, and then this is transferred to another isolate for deserializing. Native mobile appsGoogle has introduced Flutter for native mobile app development on both Android and iOS.[23] Flutter is a mobile app SDK, complete with framework, widgets, and tools, that gives developers a way to build and deploy mobile apps, written in Dart. Flutter works with Firebase and other mobile app SDKs, and is open source. Compiling to JavaScriptThe Dart SDK contains two Dart-to-JavaScript compilers. During development, [https://webdev.dartlang.org/tools/dartdevc dartdevc] supports quick refresh cycles. For the final version of an app, [https://webdev.dartlang.org/tools/dart2js dart2js] produces deployable JavaScript.[24] The first compiler to generate JavaScript from Dart code was dartc, but it was deprecated. The second Dart-to-JavaScript compiler was Frog. It was written in Dart, but never implemented the full semantics of the language. The third Dart-to-JavaScript compiler was dart2js. An evolution of earlier compilers, dart2js is written in Dart and intended to implement the full Dart language specification and semantics. On March 28, 2013, the Dart team posted an update on their blog addressing Dart code compiled to JavaScript with the dart2js compiler,[25] stating that it now runs faster than handwritten JavaScript on Chrome's V8 JavaScript engine for the DeltaBlue benchmark.[26] EditorsOn November 18, 2011, Google released Dart Editor, an open-source program based on Eclipse components, for Mac OS X, Windows, and Linux-based operating systems.[27] The editor supports syntax highlighting, code completion, JavaScript compiling, running web and server Dart applications, and debugging. On August 13, 2012, Google announced the release of an Eclipse plugin for Dart development.[28] On April 18, 2015, Google announced that the Dart Editor would be retired in favor of the JetBrains integrated development environment (IDE),[29] which is now the recommended IDE for the language. The Dart plugin[30] is available for IntelliJ IDEA, PyCharm, PhpStorm and WebStorm. This plugin supports many features such as syntax highlighting, code completion, analysis, refactoring, debugging, and more. Other plugins are available for editors like Sublime Text, Atom, Emacs, Vim and Visual Studio Code.[31] Chrome Dev EditorIn 2013, the Chromium team began work on an open source, Chrome App-based development environment with a reusable library of GUI widgets, codenamed Spark.[32] The project was later renamed as Chrome Dev Editor.[33] It was built in Dart, and contained Spark which is powered by Polymer.[34] In June 2015, Google transferred the CDE project to GitHub as a free software project and ceased active investment in CDE.[35] DartPadThe Dart team created DartPad at the start of 2015, to provide an easier way to start using Dart. It is a fully online editor from which users can experiment with Dart application programming interfaces (APIs), and run Dart code. It provides syntax highlighting, code analysis, code completion, documentation, and HTML and CSS editing.[36] SIMDIn 2013, John McCutchan announced[37] that he had created a performant interface to single instruction, multiple data (SIMD) instruction sets for Dart. The interface consists of two types:
Instances of these types are immutable and in optimized code are mapped directly to SIMD registers. Operations expressed in Dart typically are compiled into one instruction with no overhead. This is similar to C and C++ intrinsics. Benchmarks for 4×4 matrix multiplication, 3D vertex transformation, and Mandelbrot set visualization show near 400% speedup compared to scalar code written in Dart. ExampleA Hello World example: main() { } A function to calculate the nth Fibonacci number: int fib(int n) => (n > 2) ? (fib(n - 1) + fib(n - 2)) : 1; // this is a fibonacci function implementation with a ternary operator in Dart // this code shall be read as: // If int n > 2, return fib(n - 1) + fib(n - 2); // otherwise, return int 1 as result void main() { } A simple class: // Import the math library to get access to the sqrt function. import 'dart:math' as math; // Create a class for Point. class Point { // Final variables cannot be changed once they are assigned. // Create two instance variables. final num x, y; // A constructor, with syntactic sugar for setting instance variables. // The constructor has two mandatory parameters Point(this.x, this.y); // A named constructor with an initializer list. Point.origin() : x = 0, y = 0; // A method. num distanceTo(Point other) { var dx = x - other.x; var dy = y - other.y; return math.sqrt(dx * dx + dy * dy); } // Example of Operator Overloading Point operator +(Point other) => Point(x + other.x, y + other.y); // When you Instantiating a class such as Point, in Dart 2+, new is // an optional word } // All Dart programs start with main(). void main() { // Instantiate point objects. var p1 = Point(10, 10); var p2 = Point.origin(); var distance = p1.distanceTo(p2); print(distance); } Influences from other languagesDart is a descendant of the ALGOL language family,[38] alongside C, Java, C#, JavaScript, and others. The method cascade syntax, which provides a syntactic shortcut for invoking several methods one after another on the same object, is adopted from Smalltalk. Dart's mixins were influenced by Strongtalk{{Citation needed|reason=Just seeing a citation implies it is true, the paper on Smalltalk/Strongtalk predates Dart so does not say for sure. Maybe someone know it is based on Strongtalk mixins. Strongtalk wasn't first to introduce mixins. No expert on mixins – are there different variants and for sure Strongtalk the first to use this variant? Even then would someone have to say that it is based on that language?|date=March 2014}}[39] and Ruby. Dart makes use of isolates as a concurrency and security unit when structuring applications.[40] The Isolate concept builds upon the Actor model, which is most famously implemented in Erlang. The Mirror API for performing controlled and secure reflection was first proposed in a paper[41] by Gilad Bracha (who is a member of the Dart team) and David Ungar and originally implemented in Self. CriticismDart initially had a mixed reception and the Dart initiative has been criticized by some for fragmenting the web, due to the original plans to include a Dart VM in Chrome. Those plans were dropped to focus instead on compiling Dart to JavaScript.[42] See also{{Portal|Computer programming|Free and open-source software}}
References1. ^{{cite book|last1=Kopec|first1=David|title=Dart for Absolute Beginners|isbn=9781430264828|page=56|url=https://books.google.cz/books?id=EcvjAwAAQBAJ&lpg=PA56&dq=dart%20multi-paradigm&pg=PA56#v=onepage&q=dart%20multi-paradigm&f=false|accessdate=24 November 2015}} 2. ^{{cite web|last1=Bak|first1=Lars|title=Dart: a language for structured web programming|url=http://googlecode.blogspot.com/2011/10/dart-language-for-structured-web.html|website=Google Code Blog|publisher=Google|accessdate=31 January 2016}} 3. ^https://github.com/dart-lang/sdk/releases 4. ^https://github.com/dart-lang/sdk/releases 5. ^https://www.dartlang.org/faq#q-is-dart-a-statically-typed-language 6. ^{{cite web|title=Web Languages and VMs: Fast Code is Always in Fashion. (V8, Dart) - Google I/O 2013|url=https://www.youtube.com/watch?v=huawCRlo9H4&t=30m10s|publisher=Google|accessdate=22 December 2013}} 7. ^https://www.dartlang.org/ 8. ^https://flutter.io 9. ^{{Cite web|url=https://www.dartlang.org/guides/language/language-tour#important-concepts|title=A Tour of the Dart Language|website=www.dartlang.org|access-date=2018-08-09}} 10. ^https://www.dartlang.org/guides/language/sound-dart 11. ^{{Citation | contribution-url= http://gotocon.com/aarhus-2011/presentation/Opening%20Keynote:%20Dart,%20a%20new%20programming%20language%20for%20structured%20web%20programming | format= presentation | type= opening keynote | contribution= Dart, a new programming language for structured web programming | title= GOTO conference | url= http://gotocon.com/aarhus-2011/ | place= Århus conference | date= 2011-10-10}} 12. ^{{cite web|url= http://radar.oreilly.com/2012/03/what-is-dart.html|title= What is Dart |date= |accessdate= August 16, 2014 |website= What is Dart? |publisher= O'Reilly |last= Ladd|first= Seth}} 13. ^{{Cite web|url=https://news.dartlang.org/2013/11/dart-10-stable-sdk-for-structured-web.html|title=Dart 1.0: A stable SDK for structured web apps|website=news.dartlang.org|access-date=2018-08-08}} 14. ^{{Cite web|url=https://medium.com/dartlang/dart-2-stable-and-the-dart-web-platform-3775d5f8eac7|title=Announcing Dart 2 Stable and the Dart Web Platform|last=Moore|first=Kevin|date=2018-08-07|website=Dart|access-date=2018-08-08}} 15. ^{{cite web|url=http://www.ecma-international.org/memento/TC52.htm | title =TC52 - Dart | accessdate =2013-12-16}} 16. ^{{cite web|url=http://news.dartlang.org/2014/07/ecma-approves-1st-edition-of-dart.html|title=Dart News & Updates|author=Anders Thorhauge Sandholm|work=dartlang.org}} 17. ^{{cite web|url=http://news.dartlang.org/2014/12/enums-and-async-primitives-in-dart.html|title=Dart News & Updates|author=Anders Thorhauge Sandholm|work=dartlang.org}} 18. ^{{Citation | url= http://www.dartlang.org/support/faq.html#why-dart | contribution= Why? | title= Dart lang | type= FAQ | quote= We designed Dart to be easy to write development tools for, well-suited to modern app development, and capable of high-performance implementations.}} 19. ^{{cite web |url= http://www.dartlang.org/slides/2012/10/jsconfeu/javascript-as-compilation-target-florian-loitsch.pdf |format= PDF |title= JavaScript as a compilation target: Making it fast |publisher= Dartlang.org |accessdate=2013-08-18 |archiveurl= https://web.archive.org/web/20160702204820/http://www.dartlang.org/slides/2012/10/jsconfeu/javascript-as-compilation-target-florian-loitsch.pdf |archivedate= 2016-07-02}} 20. ^{{cite web |url=http://www.dartlang.org/articles/io/ |title=An Introduction to the dart:io Library |website= Dartlang.org|accessdate=2013-07-21}} 21. ^{{cite web|url=https://flutter.io/faq/#how-does-flutter-run-my-code-on-ios|title=Flutter FAQ|at=How does Flutter run my code on iOS?|work=flutter.io|accessdate=2016-10-02}} 22. ^{{Cite web|url=https://groups.google.com/a/dartlang.org/d/msg/misc/djfFMNCWmkE/F7WE8a0JAwAJ|title=Dart2 Breaking Change: Removing web support for dart:mirrors and dart:isolate|last=Moore|first=Kevin|date=February 23, 2018|website=Google Groups|archive-url=|archive-date=|dead-url=|access-date=}} 23. ^Flutter 24. ^https://webdev.dartlang.org/angular/guide/deployment 25. ^{{cite web |last=Ladd |first=Seth |date=2013-03-28 |url=http://news.dartlang.org/2013/03/why-dart2js-produces-faster-javascript.html |title=Dart News & Updates: Why dart2js produces faster JavaScript code from Dart |website=News.dartlang.org. |accessdate=2013-07-21}} 26. ^{{cite web |url=http://www.dartlang.org/performance/ |title=Dart Performance | website= Dartlang.org. |accessdate= 2013-07-21}} 27. ^{{cite web |url=http://dartr.com/google-releases-dart-editor/ |title=Google Releases Dart Editor for Windows, Mac OS X, and Linux}} 28. ^{{cite web |url=http://news.dartlang.org/2012/08/dart-plugin-for-eclipse-is-ready-for.html |title=Google Release Dart Eclipse Plugin}} 29. ^{{Cite web|url= http://news.dartlang.org/2015/04/the-present-and-future-of-editors-and.html|title= The present and future of editors and IDEs for Dart|date= 2015-04-30|accessdate= 2015-05-18|website= Dart News & Updates|publisher= Google|last= Ladd|first= Seth}} 30. ^{{cite web |url=http://plugins.intellij.net/plugin/?idea&id=6351 |title=JetBrains Plugin Repository : Dart |website=Plugins.intellij.net |accessdate=2013-07-21}} 31. ^{{Cite web|url=https://www.dartlang.org/tools|title=Dart Tools|website=www.dartlang.org|access-date=2016-11-15}} 32. ^{{cite web |url=https://plus.google.com/+FrancoisBeaufort/posts/giSLiGvA4ye |first=François |last=Beaufort |title=The chromium team is currently actively working}} 33. ^{{cite web |url=https://github.com/dart-lang/spark |title = A Chrome app based development environment}} 34. ^{{cite web |url=http://www.chromestory.com/2013/11/spark-chrome-app-google-ide-chromebook/ |title=Chrome Story: Spark, A Chrome App from Google is an IDE for Your Chromebook}} 35. ^{{cite web |url=https://plus.google.com/+SriSaroop/posts/6EwgknKpesS |first=Sri |last=Saroop |title=Chrome Dev Editor: Announcements}} 36. ^{{Cite web|url= http://news.dartlang.org/2015/05/announcing-dartpad-friction-free-way-to.html|title= Announcing DartPad: A friction-free way to explore Dart code|date= 2015-05-06|accessdate= 2015-05-18|website= Dart News & Updates|publisher= Google|last= Ladd|first= Seth}} 37. ^{{cite web |url=https://www.dartlang.org/slides/2013/02/Bringing-SIMD-to-the-Web-via-Dart.pdf|title=Bringing SIMD to the web via Dart}} 38. ^{{cite web|url=http://c2.com/cgi/wiki?AlgolFamily|title=Algol Family|work=c2.com}} 39. ^{{cite journal| last = Bracha| first = Gilad| last2 = Griswold| first2 = David| date = September 1996| title = Extending the Smalltalk Language with Mixins| url = http://ftp.linux62.org/~glibersat/publis/p331-bracha.pdf| journal = OOPSLA Workshop| publisher = OOPSLA| volume =| issue =| pages =| doi =| accessdate =}} 40. ^{{cite web|url=http://www.infoq.com/articles/google-dart/|title=The Essence of Google Dart: Building Applications, Snapshots, Isolates|work=InfoQ}} 41. ^{{cite journal| last = Bracha| first = Gilad| last2 = Ungar| first2 = David| year = 2004| title = Mirrors: design principles for meta-level facilities of object-oriented programming languages| url = http://ftp.linux62.org/~glibersat/publis/p331-bracha.pdf| journal = ACM SIGPLAN Notices| publisher = ACM| volume = 39| issue = 10| pages = 331–344| doi = 10.1145/1035292.1029004| accessdate = 15 February 2014}} 42. ^{{cite web|url=http://news.dartlang.org/2015/03/dart-for-entire-web.html|title=Dart News & Updates|author=Seth Ladd|work=dartlang.org}} Bibliography{{refbegin}}
| first1 = Kathy | last1 = Walrath | first2 = Seth | last2 = Ladd | date = March 7, 2012 | title = What is Dart? | publisher = O'Reilly Media | edition = 1st | page = 20 | isbn = 978-14493-32327 | url = http://shop.oreilly.com/product/0636920025887.do }}
| first1 = Kathy | last1 = Walrath | first2 = Seth | last2 = Ladd | date = November 7, 2012 | title = Dart: Up and Running | publisher = O'Reilly Media | edition = 1st | page = 144 | isbn = 978-1449330897 | url = http://shop.oreilly.com/product/0636920025719.do }}
| first = Chris | last = Buckett | date = December 28, 2012 | title = Dart in Action | publisher = Manning Publications | edition = 1st | page = 475 | isbn = 978-1617290862 | url = }}{{refend}} External links
13 : Articles with example code|C programming language family|Concurrent programming languages|Dynamically typed programming languages|Google software|JavaScript programming language family|Object-oriented programming languages|Programming languages created in 2011|Scripting languages|Software using the BSD license|Web programming|Free software projects|2011 software |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。