javascript可以避免Dart和火药吗

JavaScript has been the leading choice for single-page applications for a long period of time, and every JavaScript lover hopes that it will remain on top in the future as well. But recent developments in Blazor by Microsoft and Dart by Google seem to be threatening JavaScript’s kingdom. These frameworks were first introduced around 2017 and 2011, respectively, but they hadn't made a real impact in the developing world until recently.

很长一段时间以来,JavaScript一直是单页应用程序的首选,每个JavaScript爱好者都希望它将来也能保持领先地位。 但是,Microsoft的Blazor和Google的Dart的最新发展似乎正在威胁JavaScript的王国。 这些框架分别于2017年和2011年首次引入,但直到最近才对发展中国家产生真正的影响。

So, the main purpose of this article is to investigate the hype behind Blazor and Dart and compare them with JavaScript to see whether they can dethrone JavaScript.

因此,本文的主要目的是研究Blazor和Dart背后的炒作,并将它们与JavaScript进行比较,以了解它们是否可以取代JavaScript。

什么是Dart? (What Is Dart?)

Dart was first introduced by Google as its internal web, mobile, and server development language around 2011, and language was pretty much limited to Google itself. But just after the introduction of Flutter at Google I/O 2018, Dart started to climb up the ranks rapidly.

Dart是Google于2011年左右首次引入的,它是其内部Web,移动和服务器开发语言,其语言在很大程度上仅限于Google本身。 但是就在Google I / O 2018上介绍Flutter之后,Dart开始Swift攀升。

Dart is a client-optimized language that compiles the source codes in a similar way to many other programming languages like C. The significant difference is that Dart contains its own package manager called pub while also having a standalone SDK shipped with Dart VM.

Dart是一种客户端优化的语言,它以类似于C之类的许多其他编程语言的方式来编译源代码。最大的区别是Dart包含自己的名为pu​​b的软件包管理器,同时还具有Dart VM随附的独立SDK。

为什么Dart很流行? (Why Is Dart Becoming Popular?)

As I see it, Flutter is the main reason behind the hype of Dart. Ever since Google introduced Flutter for cross-platform mobile development, mobile developers have become very keen to try out Flutter — and they had to start working with Dart. Although Dart is fairly new compared to JavaScript, developers with good OOP and Java knowledge were able to catch the basic concepts and syntax quickly and the Dart community started to grow rapidly.

如我所见,Flutter是大肆宣传Dart的主要原因。 自从Google将Flutter引入跨平台移动开发以来,移动开发人员就非常热衷于尝试Flutter —并且他们必须开始与Dart合作。 尽管与JavaScript相比,Dart还是很新的,但是具有良好OOP和Java知识的开发人员能够Swift掌握基本概念和语法,并且Dart社区开始Swift发展。

Also, Dart has the ability to compile the code in both Ahead of Time and Just in Time, which means your code is simultaneously compiling and executing in the background while you develop.

此外,Dart能够在“提前”和“及时”中编译代码,这意味着您的代码在开发时会在后台同时编译和执行。

Other than that, Dart provides many interesting features that we can point out as its advantages and strengths:

除此之外,Dart还提供了许多有趣的功能,我们可以指出其优势和优势:

  • Dart supports object-oriented development.

    Dart支持面向对象的开发。
  • Well-written documentation makes it easy to learn.

    精心编写的文档易于学习。
  • Dart doesn't have any hardware or architectural requirements to run.

    Dart没有任何硬件或体系结构要求可运行。
  • It can be used on mobile apps, web apps, a desktop app, scripting tasks, and server-side/client-side work.

    它可以用于移动应用程序,Web应用程序,桌面应用程序,脚本任务以及服务器端/客户端工作。
  • Single-threaded programming language.

    单线程编程语言。
  • No compile time in development.

    在开发中没有编译时间。
  • Dart has a rich ecosystem with a large variety of supporting tools like pub, analyzer, test, dev_compiler, server-side VM, etc.

    Dart具有丰富的生态系统,具有多种支持工具,例如pub,分析器,测试,dev_compiler,服务器端VM等。
  • Cross-platform support.

    跨平台支持。

You can find more details on Dart in the documentation as well.

您也可以在文档中找到有关Dart的更多详细信息。

Dart与JavaScript (Dart vs. JavaScript)

Comparing Dart with JavaScript is much easier than comparing JavaScript with Blazor since Dart has established itself by now.

将Dart与JavaScript进行比较比将JavaScript与Blazor进行比较要容易得多,因为Dart已经建立了自己。

If we consider the popularity of these two, we can clearly say that JavaScript is more popular since it has been there for a long time and developers use JavaScript for almost everything. But on the other hand, Dart is gaining momentum and attracting developers towards it at an increasing rate.

如果我们考虑这两者的流行性,可以清楚地说JavaScript更加流行,因为它已经存在了很长时间,并且开发人员几乎将JavaScript都用于其中。 但另一方面,Dart正在获得发展势头,并以越来越高的速度吸引了开发者。

If we consider the Stack Overflow survey in 2019, we can see that both JavaScript and Dart are on the same level when it comes to the most loved language.

如果我们考虑2019年Stack Overflow调查,就最受欢迎的语言而言,我们可以看到JavaScript和Dart处于同一水平。

Image for post
Stack Overflow 堆栈溢出

Also, we can’t see a much difference between these two when it comes to the learning curve and ease of use. Both JavaScript and Dart may be a little confusing at the beginning, but using them becomes a walk in the park once you get settled.

此外,在学习曲线和易用性方面,我们看不出两者之间有太大差异。 JavaScript和Dart在一开始可能会有些混乱,但是一旦您安顿下来,就可以在公园里散步。

Likewise, we can compare many aspects of these two regarding their speed, commercial use, platform support, editor support, etc. But we can't see much difference between these two. There might be slight advantages to each. For instance, JavaScript can be used on both the front end and back end, while Dart doesn't support back-end development. Dart, for its part, is backed by Google.

同样,我们可以在速度,商业用途,平台支持,编辑器支持等方面对这两个方面进行比较。但是,我们看不出这两者之间有多少区别。 每个可能都有一点优势。 例如,JavaScript可以同时在前端和后端使用,而Dart不支持后端开发。 就Dart而言,它得到了Google的支持。

Overall, what I can say is that we can’t talk in favor of a single technology since both of them contain their own set of values that can’t be overrun by others. JavaScript has been on the top for a long period of time, and it will remain there in the future as well. However, Dart will also gain its position as time goes on. As developers, it is our duty to choose what is best for our solution.

总体而言,我只能说我们不能赞成一种技术,因为它们两者都包含自己的一套价值,这些价值不能被其他人超越。 JavaScript长期以来一直位居榜首,并且将来也将保持这种地位。 但是,随着时间的流逝,Dart也将获得其位置。 作为开发人员,我们有责任选择最适合我们解决方案的产品。

什么是Blazor? (What Is Blazor?)

Blazor (Browser+Razor) is a new web development framework introduced by Microsoft that allows you to develop browser-based applications using C# and Razor syntax alongside HTML and CSS.

Blazor(Browser + Razor)是Microsoft引入的新的Web开发框架,使您可以使用C#和Razor语法以及HTML和CSS开发基于浏览器的应用程序。

If you have worked with Razor views before, you should be familiar with the process you had to follow to present the HTML view to the browser. We had to run Razor views on the server side to present them in the browser. But with the introduction of Blazor, Razor views can now be executed on the client side as well. Blazor doesn't require any additional plug-ins or libraries to be installed on the client-side browser. WebAssembly takes care of all these things, and as developers, we can just start developing both the client and server sides using C# to make our lives easier using Blazor.

如果您以前使用过Razor视图,则应该熟悉将HTML视图呈现给浏览器所必须遵循的过程。 我们必须在服务器端运行Razor视图,以将其显示在浏览器中。 但是,随着Blazor的引入,Razor视图现在也可以在客户端执行。 Blazor不需要在客户端浏览器上安装任何其他插件或库。 WebAssembly负责所有这些事情,作为开发人员,我们可以开始使用C#开发客户端和服务器端,从而使用Blazor简化生活。

为什么Blazor变得流行? (Why Is Blazor Becoming Popular?)

Although it has been some time since Blazor was first introduced, it remained off the radar for a significant period of time. But with the introduction of WebAssembly, Blazor came up in the rankings significantly and discussions comparing it with JS and other major frameworks made an even bigger buzz within the development world.

自Blazor首次推出以来已经有一段时间了,但是它在相当长的一段时间内一直不在人们的视野中。 但是随着WebAssembly的引入,Blazor的排名显着上升,并且将其与JS和其他主要框架进行比较的讨论在开发界引起了更大的关注。

As the topic of this article implies, JavsScript has been at the top of front-end development for a long period of time. For .NET developers, it was a real headache since they needed to learn JavaScript or TypeScript from scratch to develop front ends.

就像本文的主题所暗示的那样,JavsScript长期以来一直处于前端开发的顶端。 对于.NET开发人员来说,这是一个真正的头痛,因为他们需要从头学习JavaScript或TypeScript来开发前端。

But with the introduction of Blazor, C# can be used to develop both the server side and client side of the application, and that has been the main selling point of Blazor. So, if you are a .NET developer, you don't need to worry about learning JavaScript for client-side development anymore.

但是,随着Blazor的引入,C#可用于开发应用程序的服务器端和客户端,这已成为Blazor的主要卖点。 因此,如果您是.NET开发人员,则无需担心学习JavaScript进行客户端开发。

Apart from that, there are many features/advantages of Blazor:

除此之外,Blazor还有许多功能/优点:

  • Blazer doesn’t require browser plug-ins.

    Blazer不需要浏览器插件。
  • Enables full .NET debugging.

    启用完整的.NET调试。
  • It uses the latest web browser capabilities.

    它使用最新的Web浏览器功能。
  • Model for building composable UI.

    用于构建可组合UI的模型。
  • Browser compatibility (even for older versions).

    浏览器兼容性(即使是较旧的版本)。
  • Dependency injection is available.

    依赖注入是可用的。
  • Can share code between client and server.

    可以在客户端和服务器之间共享代码。
  • Blazor applications can work offline.

    Blazor应用程序可以脱机工作。
  • Blazor is pre-compiled into an intermediary language.

    Blazor已预先编译为中间语言。
  • Works well with performance-demanding applications.

    与性能要求很高的应用程序一起很好地工作。

Blazor与JavaScript (Blazor vs. JavaScript)

Comparing Blazor and JavaScript at this stage will not seem fair, but this comparison is something everyone is looking for. So I decided to compare Blazor’s features with some of the leading JavaScript frameworks like Angular, React, and Vue.

在这个阶段比较Blazor和JavaScript似乎并不公平,但是这种比较是每个人都在寻找的东西。 因此,我决定将Blazor的功能与一些领先JavaScript框架(例如Angular,React和Vue)进行比较。

Many JavaScript frameworks, including the aforementioned ones, have been there for a long period of time and have gained the trust of the people to be used in a large number of applications. If we consider React, Angular, or Vue, there are huge communities behind them and those frameworks have proven themselves.

许多JavaScript框架(包括上述框架)已经存在了很长一段时间,并且赢得了人们的信任,可以在大量应用程序中使用。 如果我们考虑使用React,Angular或Vue,它们背后便是巨大的社区,这些框架已经证明了自己。

On the other hand, Blazor is still new to the game and hasn't gained the trust of developers. But we can't say it is completely new since Blazor is almost similar to .NET development with features like Razor views and C# as the language. Also, being new hasn't stopped Blazor from providing some advanced features such as built-in support for routing, validations, and form handling, sharing components between the client side and server side, using NuGet packages, deploying as static files, etc.

另一方面,Blazor仍然是游戏的新手,尚未获得开发人员的信任。 但是我们不能说它是全新的,因为Blazor几乎与.NET开发类似,具有Razor视图和C#等语言功能。 同样,新手并没有阻止Blazor提供某些高级功能,例如对路由,验证和表单处理的内置支持,在客户端和服务器端之间共享组件,使用NuGet软件包,作为静态文件进行部署等。

But with the prevailing situation and features of Blazor, I don't think it contains any significant features to drag JavaScript developers towards it. But if you are a .Net developer or good with C#, Blazor is definitely a good option for you.

但是,鉴于Blazor的普遍情况和功能,我认为它没有任何重要功能会拖累JavaScript开发人员。 但是,如果您是.Net开发人员或使用C#很好,Blazor绝对是您的理想选择。

结论 (Conclusion)

The simple answer to the topic is that JavaScript will be fine. JavaScript will stay on top for a significant period of time. But both Dart and Blazor have great potential to be premium competitors for JavaScript while providing their own features that can be used in different solutions as suites.

该主题的简单答案是JavaScript会很好。 JavaScript将在相当长的一段时间内保持领先地位。 但是Dart和Blazor都具有成为JavaScript优质竞争对手的巨大潜力,同时提供了可以在不同解决方案中作为套件使用的自己的功能。

Also, I believe that this topic cannot be limited to what I have summarized in this article. I invite all of you to share your thoughts in the comments section. Thank you for reading.

另外,我认为该主题不能局限于我在本文中概述的主题。 我邀请大家在评论部分分享您的想法。 感谢您的阅读。

翻译自: https://medium.com/better-programming/can-javascript-keep-away-dart-and-blazor-e39b52834349

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值