GWT vs打字稿 [英] GWT vs typescript

查看:98
本文介绍了GWT vs打字稿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GWT vs javascript上有很多帖子,但是我无法在GWT vs typescript上找到任何信息。

我在Java中有大约20,000行代码,我需要移到浏览器客户端。但是,如果我走这条路线,那不仅仅是在GWT中重新编译。我需要删除的代码中引用了一堆对象(现有的代码是一个更大的程序的一部分)。



另外,一些底层类正在被广泛使用的正在改变。这不是一个很大的改变,但是这些课程在很多地方都有使用。所以这是真正的重写。如果我得到GWT,重写会更平滑一些,但仍然是重写。



这段代码也没有GUI或I / O组件。它在客户端被javascript调用,仅用于处理JavaScript代码创建和使用的JavaScript对象。



这导致我的问题。 GWT vs typescript有哪些优缺点?

解决方案

如果我正确理解你,你想运行 Java 以前在没有GUI的浏览器中的Server / Java Applet上运行的代码。



我没有使用 Typescript ,所以我会强调 GWT (可能其中一些也适用于 Typescript ):



最大的优点是可以测试大部分代码在普通Java中。只有那些需要仿真的类必须在浏览器中进行测试。您可以使用 SuperDevMode SourceMaps 直接在浏览器中进行调试。



最近举行的 GWT.create 会议也突出显示对 GWT 的一些有趣的未来改进。
有计划优化编译器,以便它生成为javascript引擎优化的javascript代码(对象布局等)。

还有一些想法可以使用键入数组,这会使性能受益,特别是对于计算密集型任务。



可能 GWT 可以指定 asm.js ,它可以为你提供原生的表演。


There are a number of posts on GWT vs javascript but I couldn't find any on GWT vs typescript.

I have about 20,000 lines of code in Java I need to move over to the browser client. However, it's not just recompile in GWT if I go that route. There's a bunch of objects referenced in that code that I need to remove (the existing code is part of a much larger program).

In addition, some low-level classes that are widely used are changing. It's not a big change but these classes are used in a lot of places. So it's really a rewrite either way. A bit smoother rewrite if I got to GWT, but a rewrite nonetheless.

This code also has no GUI or I/O component. It's called by javascript on the client and is used solely to process the javascript objects created and used by the javascript code.

Which leads to my question. What are the advantages and disadvantages of GWT vs typescript?

解决方案

Well if I correctly understand you, you want to run Java code that was previously run on the Server/Java Applet in the browser without GUI.

I haven't used Typescript so I will highlight the advantages of GWT (maybe some of them also apply to Typescript):

  • You having existing Java code, so GWT is a naturally fit (with Typescript you have to rewrite everything).
  • You can use super-source to override classes and packages that won't work in the Browser. This is huge because you will end up with more or less one code base that's capable of running on Browsers, Servers, Java Apps, etc. For example the new google drive spreadsheet (web-app, Android app, etc) is built using this technique.
  • GWT supports tree-shaking and thus the cost you play is only for what you really use
  • Advantages (refactoring, type checks) due to static types

The biggest advantage is that most of your code, can be tested in "plain Java". Only those classes that need emulation have to be tested in the browser. You can use SuperDevMode and SourceMaps to debug them directly in the browser.

The recently held GWT.create conference highlighted also some interesting future improvements to GWT. There are plans to optimize the compiler so that it produces javascript code that is optimized for the javascript engines (object layout, etc).
There are also some ideas to use typed arrays which would benefit performance, especially for computational intense tasks.

Possibly GWT could target asm.js which could give you native like performance.

这篇关于GWT vs打字稿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆