Dart (programming language): Difference between revisions

Content deleted Content added
Reverted 1 edit by RajatSharmaWiki (talk): Promotion of GeeksforGeeks website
Updates for Dart 3.4.
Line 45:
Dart 2.6 introduced a new extension, <code>dart2native</code>. This extended native compilation to the Linux, macOS, and Windows desktop platforms.<ref>{{Cite web |title=Dart language evolution |url=https://dart.dev/guides/language/evolution |access-date=2023-06-20 |website=dart.dev |language=en}}</ref> Earlier developers could create new tools using only Android or iOS devices. With this extension, developers could deploy a program into self-contained executables. The Dart SDK doesn't need to be installed to run these self-contained executables.<ref>{{Cite web |title=Dart overview |url=https://dart.dev/overview.html |access-date=2023-05-12 |website=dart.dev |language=en }}{{Dead link|date=March 2024 |bot=InternetArchiveBot |fix-attempted=yes }}</ref> The [[Flutter (software)|Flutter]] toolkit integrates Dart, so it can compile on small services like backend support.<ref>{{Cite web|url=https://www.infoworld.com/article/3454623/dart-26-brings-native-compilation-to-the-desktop.html|title=Dart 2.5 brings native compilation to the desktop|website=Infoworld|date=20 November 2019|access-date=2019-11-28}}</ref><ref>{{Cite web|url=https://sdtimes.com/goog/dart-2-6-released-with-dart2native/|title=Dart 2.6 released with dart2native|website=SDtimes|date=7 November 2019|access-date=2019-11-28}}</ref>
 
Dart 3.0 was released in May 2023<ref>{{Cite web |title=Dart language evolution |url=https://dart.dev/guides/language/evolution |access-date=2024-01-09 |website=dart.dev |language=en}}</ref> with changes to the type system to require sound null safety. This release included new features like records, patterns,<ref>{{Cite web |title=Patterns |url=https://dart.dev/language/patterns.html |access-date=2023-05-12 |website=dart.dev |language=en }}{{Dead link|date=March 2024 |bot=InternetArchiveBot |fix-attempted=yes }}</ref> and class modifiers.<ref>{{Cite web |title=Class modifiers |url=https://dart.dev/language/class-modifiers}}</ref>

Dart 3can alsocompile previewedto supportWebAssembly foras [[WebAssembly|Webof Assembly]]Dart 3.22.<ref name=":3">{{Cite web |last=Thomsen |first=Michael |date=20232024-05-1014 |title=AnnouncingLanding Flutter 3.22 and Dart 3.4 at Google I/O 2024 |url=https://medium.com/dartlangflutter/announcingio24-dart-3-53f065a106355e211f708a37 |access-date=20232024-05-1217 |website=DartFlutter |language=en}}</ref>
 
== Specification ==
Line 56 ⟶ 58:
 
Developers can deploy Dart apps in six ways:
{| class="wikitable sortable"
|+Dart deployment methods
!Deployment type
Line 72 ⟶ 74:
|Fast
|-
|WebAssembly<ref (preview)name=":3" /><ref name=":2">{{Cite web |last=Thomsen |first=Michael |date=2023-05-10 |title=Announcing Dart 3 |url=https://medium.com/dartlang/announcing-dart-3-53f065a10635 |access-date=2023-05-13 |website=Dart |language=en}}</ref>
|Browser
|No
Line 109 ⟶ 111:
 
=== Deploying to the web ===
Dart 3 can deploy apps to the web as either JavaScript or WebAssembly apps. WebAssemblyDart supportsupports iscompiling offeredto as a preview onlyWebAssembly {{as of|2024|May 2023|lc=y}}.
 
==== JavaScript ====
: To run in mainstream [[web browser]]s, Dart relies on a [[source-to-source compiler]] to [[JavaScript]]. This makes Dart apps compatible with all major browsers. Dart optimizes the compiled JavaScript output to avoid expensive checks and operations. This results in JavaScript code that can run faster than equivalent code handwritten in pure JavaScript.<ref name="dartlang.org">{{cite web |url=http://www.dartlang.org/slides/2012/10/jsconfeu/javascript-as-compilation-target-florian-loitsch.pdf |title=JavaScript as a compilation target: Making it fast |publisher=Dartlang.org |access-date=2013-08-18 |archive-url=https://web.archive.org/web/20160702204820/http://www.dartlang.org/slides/2012/10/jsconfeu/javascript-as-compilation-target-florian-loitsch.pdf |archive-date=2016-07-02}}</ref>
: The first Dart-to-JavaScript compiler was <code>dartc</code>. It was deprecated in Dart 2.0.
:The second Dart-to-JavaScript compiler was frog.<ref>{{Cite web |title=Towards a single Dart to JavaScript compiler |date=10 September 2019 |url=https://news.dartlang.org/2012/02/towards-single-dart-to-javascript.html |access-date=2023-05-13 |language=en}}</ref> Written in Dart, it was introduced in 2013 and deprecated in 2020. This should not be confused with Dart Frog,<ref>{{Cite web |title=Dart Frog |url=https://dartfrog.vgv.dev/ |access-date=2023-05-13 |website=dartfrog.vgv.dev |language=en}}</ref> an open-source Dart framework for building backend systems from [[Very Good Ventures]].
:The third Dart-to-JavaScript compiler is <code>dart2js</code>. Introduced in Dart 2.0,<ref>{{Cite web |last=Moore |first=Kevin |date=2018-08-08 |title=Announcing Dart 2 Stable and the Dart Web Platform |url=https://medium.com/dartlang/dart-2-stable-and-the-dart-web-platform-3775d5f8eac7 |access-date=2023-05-13 |website=Dart |language=en}}</ref> the Dart-based <code>dart2js</code> evolved from earlier compilers. It intended to implement the full Dart language specification and semantics. Developers use this compiler for production builds. It compiles to [[Minification (programming)|minified JavaScript]].
Line 129 ⟶ 132:
 
==== WebAssembly ====
:With the Dart 3.22 release, Google announced preview support for compiling Dart code to [[WebAssembly]].<ref name=":23" /> Full support for [[WebAssembly|Wasm]] will requirerequires adoption of the WasmGC<ref>{{Citation |title=GC Proposal for WebAssembly |date=2023-05-12 |url=https://github.com/WebAssembly/gc/blob/5431d631547c8af09a6377e29fee5126219f33c5/proposals/gc/Overview.md |access-date=2023-05-13 |publisher=WebAssembly}}</ref> feature into the Wasm standard. Chrome, 119<ref>{{Cite web |title=WebAssembly Garbage Collection (WasmGC) now enabled by default in Chrome Platform{{!}} StatusBlog |url=https://chromestatusdeveloper.chrome.com/featureblog/6062715726462976wasmgc |access-date=20232024-05-1317 |website=chromestatus.comChrome for Developers |language=en}}</ref> supports WasmGC. [[Firefox]],<ref>{{Cite web |date=2023-02-16 |title=SpiderMonkey Newsletter (Firefox 110-111) |url=https://spidermonkey.dev/blog/2023/02/16/newsletter-firefox-110-111.html |access-date=2023-05-13 |website=SpiderMonkey JavaScript/WebAssembly Engine |language=en-US}}</ref> 120 and later could support WasmGC, but a current bug is blocking compatibility<ref>{{Cite web |title=1788206 - OffscreenCanvas.transferToImageBitmap incurs a copy |url=https://bugzilla.mozilla.org/show_bug.cgi?id=1788206 |access-date=2024-05-17 |website=bugzilla.mozilla.org |language=en}}</ref>. [[Safari (web browser)|Safari]]<ref>{{Cite web |title=Safari Technology Preview 167 Release Notes |url=https://docs.developer.apple.com/documentation/safari-technology-preview-release-notes/stp-release-167 |access-date=2023-05-13 |website=Apple Developer Documentation |language=en}}</ref> and [[Microsoft Edge]] are integrating WasmGC support.
 
=== Deploying to native platforms ===
Line 168 ⟶ 171:
 
== Null safety ==
Starting with Dart 2.12, Dart introduced sound [[Void safety|null safety]].<ref>{{Cite web |last=Hracek |first=Filip |date=2020-06-10 |title=Announcing sound null safety |url=https://medium.com/dartlang/announcing-sound-null-safety-defd2216a6f3 |access-date=2023-05-12 |website=Dart |language=en}}</ref> This serves as a guarantee that variables cannot return a null value unless it has explicit permission. Null safety prevents the developer from introducing null-pointer exceptions, a common, but difficult to debug, error. With Dart&nbsp; 3.0, all code must follow sound null safety.
 
==Data storage==