如果JavaScript在客户端完全执行网络界面, 与 WinForms/ Native UI 的区别将微不足道。
然而,在多数情况下,网络界面会触发网络服务器的某些网络请求,然后它必须经过以下步骤才能达到与WinForms/Native application相同的效果:
- Send a HTTP request (GET/POST/...) to the Web server
- The Web server is an executable (in the format of an external app or a service) listening to one or multiple ports. When it receives the request, parses it, and finds the Web application.
- Web server executes backend (server-side) logic within application.
Web application such as ASP.NET is pre-compiled. Time complexity of this step could be very close to a Windows app.
- Web server renders the result into markup and sends it back to the client
- Client (Browser) parses the result and updates the UI if necessary.
Controls/images/other resources in a Web page normally take a little longer to render within a browser than a Windows app renders its display.
即使网络服务器是本地的,也不能忽视数据解析/格式化/传输产生的成本。
On the other hand, an application with WinForms/Native UI typically maintains a message loop, which is active and hosted in machine code. A UI request normally just triggers a lookup in the message table and then execute the backend logic (Step 2 in the above)
When it returns result and updates UI, it can be simply binary data structure (doesn t need to be in markup), and doesn t reply another application(browser) to render to the screen.
最后,WinForms/Natima 应用程序通常拥有全部控制权,可以维持多个线索,以逐步更新UI,而网络应用程序对这种类型的服务器侧资源没有直接控制权。
UPDATE :
当我们比较网站应用程序和Windows/WPF(或原生)应用程序时,它们使用相同的网络服务来部分更新它们的 UI
""https://i.sstatic.net/939c1.png" alt="此处的内置图像描述"/"
The two UIs should respond and refresh with ignorable speed difference. The implementation difference between binary & scripting execution to respond and refresh UI is almost nothing.
Neither of the UIs needs to reconstruct the control tree and refresh entire appearance. Given same conditions, they could have same CPU priority, memory/virtual memory caching, and same/close number of kernel object & GDI handles at process/thread level.
In this case, as you described, there should be almost no visual difference.
UPDATE 2:
Actually event handling mechanisms in Web and Windows apps are similar. DOM has event bubbling. Similarly, MFC has command routing; Winforms has its event flow; WPF has event bubbling and tunnelling, and so on. The idea is a UI event might not strictly belong to one control and a control has some way to claim an event has been "handled". For standard controls, focus changing, text changing, dropdown, scrolling events should have similar client-side response time for both Web and Windows apps.
从性能上看, 图像是最大的差异。 网络应用程序对“ 设备上下文” 的控制有限, 因为一个网页是由外部应用程序 — — 网络浏览器 — — 托管的。 Windows 应用程序可以使用像 WPF 这样的 GPU 资源来实施动画效果, 并通过部分刷新“ 设备上下文” 来加速生成。 这就是为什么 HTML5 画布让网络开发者在 Windows 游戏开发者使用 OpenGL/ DirectX 超过 10 年的时间里很兴奋 。
UPDATE 3:
Each Web browser engine (http://en.wikipedia.org/wiki/Layout_engine) has its own implementation of rendering DOM, CSS; and implementation of (CSS) selectors. Moving and resizing elements within a Web page is changing DOM, CSS (tree) setup. The selector and rendering performance highly depends on the Web browser engine.
- UI operations could make selectors go through unnecessary steps to update UI.
- A Web page doesn t have control to inform the browser to do partial rendering.
使高档 JavaScript 控制( 一些jQuery UI、 dojo、Ext JS) 无法实时快速, 通常比 Flash 控制慢 。