简体   繁体   English

在HTML5 Canvas中使用GWT是个好主意吗?

[英]Is it a good idea to use GWT with HTML5 Canvas?

I am new to GWT. 我是GWT的新手。 I started using it three days ago with HTML5 Canvas for drawing some basic shapes with basic animation (nothing fancy, just straight lines moving up and down). 我三天前开始在HTML5 Canvas中使用它,用基本动画绘制了一些基本形状(花哨的东西,只是直线上下移动)。 Before moving to GWT, I wrote some javascript code to do the same thing. 在转到GWT之前,我写了一些JavaScript代码来做同样的事情。

And I noticed that javascript is a lot faster in rendering the shapes than GWT. 而且我注意到javascript在呈现形状方面比GWT快得多。 Considering that GWT is also javascript, is there something that I do not know that is slowing GWT down? 考虑到GWT也是javascript,是否有我不知道的事情在拖慢GWT? I also want to know if it is a good idea to use GWT for canvas at all, or is it a better idea to stick to javascript for drawing on cavas? 我也想知道在画布上使用GWT是否是一个好主意,还是坚持使用javascript在cavas上绘制是一个更好的主意?

How do you run your GWT application? 您如何运行GWT应用程序? In development mode? 在开发模式下? In development mode the code runs much slower than in production. 在开发模式下,代码运行速度比生产环境慢得多。 If you compile your application and deploy it to an application server it should be as fast as native javascript (because then it is actually native javascript! :)) 如果编译应用程序并将其部署到应用程序服务器,则它应与本地javascript一样快(因为它实际上是本地javascript!:))

Honestly, I would suggest taking a strong look at dart. 老实说,我建议您认真看一下飞镖。 It compiles down to faster javascript than GWT and is looking to have greater support by google in general. 它可以编译为比GWT更快的javascript,并且希望获得google的更大支持。

GWT produces javascript that is generally around 1.5->2.0 slower than native javascript. GWT生成的javascript通常比本地javascript慢1.5-> 2.0。 For a business app, that usually isn't a big deal. 对于商务应用程序来说,这通常没什么大不了的。 GWT makes a lot of sense when you are looking for backwards compatibility and strong support for java and java like features. 当您正在寻找向后兼容性以及对Java和类似Java功能的强大支持时,GWT非常有意义。

Where you are using HTML5, the compatibility benefit of GWT becomes moot. 在使用HTML5的地方,GWT的兼容性优势变得毫无意义。 At that point, you are targeting the browsers which dart supports. 届时,您的目标是dart支持的浏览器。

(The "why" gwt is slower has to do with java. GWT has to do a lot of work to ensure that java constraints and behavior is maintained. Dart was designed with an eye towards javascript compilation) (“为什么” gwt与Java的关系较慢。GWT必须做大量工作以确保维持Java约束和行为。Dart的设计着眼于javascript编译)

the Only advantage i can seen in using GWTCanvas is browser compatibility. 使用GWTCanvas的唯一优势是浏览器兼容性。 Its mainly focused on the browser support. 它主要集中在浏览器支持上。 It doesn't have all the features implemented in HTML5 Canvas element. 它没有HTML5 Canvas元素中实现的所有功能。 If you are looking for all the canvas features then better to move along with javascript. 如果您正在寻找所有画布功能,那么最好与javascript一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM