简体   繁体   English

服务器和客户端框架

[英]Server and client side frameworks

I know this a fairly common question but after reading a lot I still can't understand this concept. 我知道这是一个相当普遍的问题,但是在阅读了很多书后,我仍然无法理解这个概念。

What I understand so far is that the main difference about a server side and a client side language is that the first one needs to be interpreted by the server to be sent to browser and the second one doesn´t. 到目前为止,我了解的是服务器端和客户端语言的主要区别在于,第一个需要由服务器解释才能发送到浏览器,而第二个则不需要。

I've worked with Vaadin and I know that is a server side framework because the java code needs to be interpreted to HTML and Javascript to be sent to browser. 我已经与Vaadin一起工作,并且我知道这是一个服务器端框架,因为Java代码需要解释为HTML和Javascript才能发送到浏览器。 But then I've read that GWT is a client side and I can't understand why because we design all the page elements with Java widgets and they need to be interpreted to HTML and Javacript right? 但是后来我读到GWT是客户端,我不明白为什么会这样,因为我们使用Java小部件设计了所有页面元素,并且需要将它们解释为HTML和Javacript吗? So, shouldn't GWT be a server side framework? 那么,GWT不应该是服务器端框架吗?

And what about JSF? 那JSF呢? I'm working with Primefaces and I develop xhtml files that uses beans to get server information. 我正在使用Primefaces,并开发了使用Bean获取服务器信息的xhtml文件。 That means that the xhml files are client side and the Java beans are server side right? 这意味着xhml文件是客户端,而Java Bean是服务器端,对吗?

Thanks! 谢谢!

It's not about the language the code is written, it's about where it runs. 这与代码编写的语言无关,而与代码的运行位置有关。

GWT is a client-side technology just like TypeScript or CoffeeScript: they first have to be compiled or transpiled (a true compilation in the case of GWT) to JavaScript. 就像TypeScript或CoffeeScript一样,GWT是一种客户端技术:首先必须将它们编译或转译为JavaScript(对于GWT而言是真正的编译)。 The compilation has to be done at build time, before you deploy the app to your server. 在将应用程序部署到服务器之前,必须在构建时完成编译。 Once compiled to JavaScript, you don't need a server: the scripts can be packaged into browser extensions, mobile apps, or just run out of the filesystem (or be deployed to a Node.js server to run as server-side code !). 一旦编译为JavaScript,就不需要服务器:这些脚本可以打包到浏览器扩展,移动应用中,或者只用完文件系统即可(或部署到Node.js服务器以作为服务器端代码运行! )。
You can draw a parallel with Dart: dart2js converts Dart code to JavaScript so it can run in the browser, and/or you can run Dart code in a DartVM on the server side. 您可以与Dart进行比较:dart2js将Dart代码转换为JavaScript,使其可以在浏览器中运行,和/或可以在服务器端的DartVM中运行Dart代码。

JSF is a server-side technology: things run in the server and generate code (HTML, JavaScript, CSS) to be interpreted by the browser (client). JSF是服务器端技术:事物在服务器中运行,并生成要由浏览器(客户端)解释的代码(HTML,JavaScript,CSS)。

I can't really tell for Vaadin as I don't know its architecture. 我不知道Vaadin是什么,因为我不知道它的体系结构。 If GWT Widgets have to be compiled upfront, then it'd be a server-side technology, generating highly dynamic web pages (so they could even run offline). 如果必须预先编译GWT窗口小部件,那么它将是一种服务器端技术,可以生成高度动态的网页(因此它们甚至可以脱机运行)。 If it compiles GWT widgets on-the-fly, then it'd be a bit in between; 如果它能即时编译GWT小部件,则介于两者之间。 but it's primarily a server-side technology. 但这主要是服务器端技术。

Vaadin use GWT to keep client-side code base in Java. Vaadin使用GWT在Java中保留客户端代码库。 GWT compiles Java code into browser dependent JavaScript. GWT将Java代码编译为依赖于浏览器的JavaScript。 Without GWT all code should be written in JS. 没有GWT,所有代码都应使用JS编写。 Vaadin is RIA application framework, so managing complex widgets code (look into Table source code) with pure JavaScript would be painful and not easy. Vaadin是RIA应用程序框架,因此使用纯JavaScript管理复杂的窗口小部件代码(查看Table源代码)将很痛苦且不容易。 You can write some logic in client side and also you can use pure JavaScript in Vaadin7. 您可以在客户端编写一些逻辑,也可以在Vaadin7中使用纯JavaScript。 It's easy to extend and gives solid foundations to write good and rich UI with minimal use of the JavaScript. 它易于扩展,并为使用最少的JavaScript编写良好而丰富的UI提供了坚实的基础。

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

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