Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the comparison between JavaScript vs Dart and the two

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Today, I would like to talk to you about the comparison between the two JavaScript vs Dart is like this, many people may not understand, in order to let you better understand, the editor summed up the following content for you, I hope you can gain something according to this article.

What is JavaScript?

JavaScript is often referred to as a browser scripting language, but it has also been extended to many server-side and mobile application development environments. JS has been around for nearly 20 years, and it is certain that it is indeed a mature and stable programming language. After Facebook released the React and React Native frameworks, JS became more and more popular.

JavaScript has its own package manager, such as NPM and Yarn. Although JavaScript is now the first choice and popular, there are still some different comments in the programming community. However, it is safe to say that there is no doubt about the popularity of JavaScript, as it contains nearly 2 million issues marked on StackOverFlow.

What is Dart?

Dart is a language designed by Google for client-side optimization for fast applications on a variety of platforms. Google originally used it as an internal programming language to build Web, servers, and mobile applications. Although Dart has been around since 2011, it became popular after Google announced that Flutter would develop cross-platform mobile applications. The only reason is that Flutter is based entirely on Dart. Therefore, mobile developers must learn Dart before they can start using Flutter.

Dart compiles the source code, similar to other programming languages such as C #. But it also has its own virtual machine (VM) for running native applications called Dart VM. Dart also has its own package manager, called Pub.

Sample application using Dart and JavaScript

The screenshot above is a Hello World program written in Dart and JavaScript.

Comparison between JavaScript and Dart

1. Epidemic degree

JavaScript is virtually ubiquitous, and there are few devices that don't run JavaScript. Currently, JavaScript is used to write Web, mobile and server-side code. JavaScript marked nearly 2 million questions on StackOverflow.

Because of its popularity, the JS ecosystem is huge, and now, with the emergence of cloud component centers, it even dominates the "market" of reusable components.

On the other hand, Dart is becoming more and more popular, but it is still a long way from JavaScript. Before Google announced Flutter, Dart was nowhere to be found. Dart attracts developers who do not support JavaScript. Currently, Dart has marked nearly 30, 000 questions on StackOverFlow.

two。 Learning curve

As we all know, JavaScript is quite tricky for beginners, especially when they don't have background knowledge of programming concepts. But JavaScript is one of the main languages taught in universities and training camps because it is one of the core of Web development. In fact, HTML,CSS and JavaScript are called the three Musketeers of Web development. There are many courses and tutorials online to help you learn JavaScript.

However, with Dart, the situation is very different. Learning Dart can be very scary for beginners because it is not as well known as JavaScript and has relatively few learning materials. But Google does its best to help developers of other OOP languages seamlessly transition to Dart.

3. Type safety

This is one of the main differences between JavaScript and Dart. As an interpretive language, JavaScript supports dynamic types and duck types. The duck type is a type that determines whether an object is suitable for a particular purpose based on the existence of specific methods and properties rather than the type of the object itself. Javascript allows any code to be typed, making it a non-type-safe language, causing errors to be found only at run time.

In contrast, Dart supports loose and powerful prototyping. As a compiled language, Dart can find most errors during compilation, which makes it more type-safe than JavaScript.

4. Enterprise use

JavaScript has been used commercially, even in large projects, to build Web and cross-platform applications. The Web and cross-platform frameworks React and React Native introduced by Facebook use JavaScript, which are used within Facebook. Other companies, such as Airbnb,Slack,eBay, also use JavaScript.

Dart was born in Google, so it was widely used internally at first. Then, after the introduction of Flutter, large companies such as Alibaba adopted Flutter and Dart to develop their cross-platform applications.

Compile Dart to JavaScript

Dart has two different JS compilers, and the Webdev tool chooses the best compiler based on the use case. When developing an application, webdev chooses dartdevc, which supports incremental compilation, so you can quickly view the editing results. However, when building the application to be deployed, webdev chooses dart2js, which uses techniques such as shaking trees to generate optimized code.

The Dart team is trying to make dart2js-compiled code run faster than handwritten JS. Although this may not be the case in all cases, we can expect some fierce competition in the near future.

Comparison of advantages and disadvantages

1. JavaScript

Advantages:

JavaScript can be used for Web and mobile applications.

It can be used for both the front end and the back end, so JavaScript can run on each device.

JavaScript has a large community and an excellent framework provided online.

Light and flexible.

A large number of learning materials can be found.

Disadvantages:

Although JS has a large number of libraries, many libraries are of poor quality and maintainability.

Errors are found only at run time.

2. Dart

Advantages:

Open source.

It is supported by Google, a large company.

Type safe and compiled using JIT and AOT.

The backbone of Flutter.

It's relatively faster in some cases.

Disadvantages:

Relatively new to programmers.

Compared with JavaScript, the learning materials are not extensive.

Conclusion

Both Dart and JavaScript are ideal for developing a variety of applications. As they are used in Flutter and React,React Native, I can see the bright future of both languages. In a poll conducted by Jaxenter, Dart was chosen as your first language on your 2019 list with 223 votes. In addition, in a survey conducted by Stack Overflow, Dart (66.3%) was the most popular programming language in 2019, second only to JavaScript (66.8%). Dart also ranks first in the fastest-growing language category of "Github State of the Octoverse".

Github State of the Octoverse: https://octoverse.github.com/

StackOverflow

Jaxenter

Credits: GitHub

As a novice developer, I suggest you start with JavaScript and first master the basics of it. You don't necessarily need to be a JS professional, but you need to know the basics. When you're done, you can turn to Dart and explore its waters. In this way, you can get to know the two giants out and out.

After reading the above, do you have any further understanding of the comparison between JavaScript vs Dart and the two? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report