用于大型项目的 NodeJS 与 Play 框架

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7639742/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 14:39:01  来源:igfitidea点击:

NodeJS vs Play Framework for large project

mongodbnode.jsplayframeworkcoffeescriptanorm

提问by Jason Miesionczek

I am really torn between two different stacks with which to build a large application. One the one hand there is this option:

我真的在构建大型应用程序的两个不同堆栈之间左右为难。一方面有这个选项:

  • Node.js
    • express
    • coffee script
    • coffeekup
    • mongoose/mongodb or
    • presistencejs/mysql
  • 节点.js
    • 表达
    • 咖啡脚本
    • 咖啡杯
    • 猫鼬/mongodb 或
    • presistencejs/mysql



  • Play Framework w/ Scala
    • Anorm w/ mysql
    • or mongodb
  • 使用 Scala 播放框架
    • 带 mysql 的异常
    • 或 mongodb

The node.js path is appealing to me because i can write all of the server side code, views and client side code in coffeescript, which i already know. If i go down this road i am still not 100% sure which db path i would take. mongoose makes storing data quick and easy, but the lack of true relationships might be more difficult to work with given the data model i have in mind (very SQLish).

node.js 路径对我很有吸引力,因为我可以用我已经知道的 coffeescript 编写所有服务器端代码、视图和客户端代码。如果我沿着这条路走下去,我仍然不能 100% 确定我会选择哪条 db 路径。mongoose 使存储数据变得快速而简单,但鉴于我想到的数据模型(非常 SQL),缺乏真正的关系可能更难处理。

The Play Framework path is also appealing because i know the framework well when using Java, but i don't know much about Scala, so there would be a hit to productivity as i work through learning that language. The Anorm database access layer is appealing because i can write the SQL by hand which i would prefer, and have the results mapped to objects automatically, which saves a lot of effort.

Play Framework 路径也很吸引人,因为我在使用 Java 时非常了解该框架,但我对 Scala 了解不多,因此在我学习该语言时工作效率会受到影响。Anorm 数据库访问层很有吸引力,因为我可以手动编写我喜欢的 SQL,并将结果自动映射到对象,这节省了很多精力。

I keep leaning towards node.js, but i'm not sold on the best db access layer to use. Anyone have any experience with any of this and can share some insight?

我一直倾向于 node.js,但我并没有在最好的数据库访问层上出售。任何人都对此有任何经验并且可以分享一些见解?

采纳答案by Mike

The stack you choose should depend upon the needs of your application. Let's look at Play vs. Node for their strengths:

您选择的堆栈应取决于您的应用程序的需要。让我们看看 Play vs. Node 的优势:

Node

节点

  • Real-time applications (chat, feeds)
  • Event-driven architecture
  • Can perform client-server duties (e.g. serve files), but not well-suited for this
  • Database management, testing tools, etc, available as additional packages
  • 实时应用程序(聊天、提要)
  • 事件驱动架构
  • 可以执行客户端 - 服务器的职责(例如提供文件),但不适合于此
  • 数据库管理、测试工具等,作为附加包提供

Play!

玩!

  • Client-server applications (website, services)
  • Share-nothing architecture
  • Can perform real-time duties (e.g. Websockets), but not well-suited for this
  • Database management (including migrations!), testing tools, etc, built into core
  • 客户端-服务器应用程序(网站、服务)
  • 无共享架构
  • 可以执行实时任务(例如 Websockets),但不太适合于此
  • 数据库管理(包括迁移!)、测试工具等,内置于核心

If your application more closely matches a traditional web-based model, Play is probably your best choice. If you need immediate feedback and real-time dynamic messaging, Node is the better choice.

如果您的应用程序更接近于传统的基于 Web 的模型,Play 可能是您的最佳选择。如果您需要即时反馈和实时动态消息,Node 是更好的选择。

For large traditional applications, seriously consider the Play! Framework because of the built-in unit and functional testing along with database migrations. If incorporated into the development process, these go a long waytoward an end product that works as expected and is stable and error-free.

对于大型传统应用程序,请认真考虑 Play!由于内置单元和功能测试以及数据库迁移的框架。如果纳入开发过程中,走了很长的路向最终产品,作为预期,是稳定的,无差错。

回答by Yevgeniy Brikman

There are 10 major categories you should consider when comparing web frameworks:

在比较 Web 框架时,您应该考虑 10 个主要类别:

  1. Learn: getting started, ramp up, overall learning curve.
  2. Develop: routing, templates, i18n, forms, json, xml, data store access, real time web.
  3. Test: unit tests, functional tests, integration tests, test coverage.
  4. Secure: CSRF, XSS, code injection, headers, authentication, security advisories.
  5. Build: compile, run tests, preprocess static content (sass/less/CoffeScript), package.
  6. Deploy: hosting, monitoring, configuration.
  7. Debug: step by step debugger, profilers, logging,
  8. Scale: throughput, latency, concurrency.
  9. Maintain: code reuse, stability, maturity, type safety, IDEs.
  10. Share: open source activity, mailing lists, popularity, plugins, commercial support, jobs.
  1. 学习:入门、提升、整体学习曲线。
  2. 开发:路由、模板、i18n、表单、json、xml、数据存储访问、实时网络。
  3. 测试:单元测试、功能测试、集成测试、测试覆盖率。
  4. 安全:CSRF、XSS、代码注入、标头、身份验证、安全建议。
  5. 构建:编译、运行测试、预处理静态内容(sass/less/CoffeScript)、打包。
  6. 部署:托管、监控、配置。
  7. 调试:逐步调试器、分析器、日志记录、
  8. 规模:吞吐量、延迟、并发。
  9. 维护:代码重用、稳定性、成熟度、类型安全、IDE。
  10. 分享:开源活动、邮件列表、流行度、插件、商业支持、工作。

Check out my talk Node.js vs Play Frameworkfor a detailed breakdown of how these two frameworks compare across these 10 dimensions.

查看我的演讲Node.js vs Play Framework,详细了解这两个框架在这 10 个维度上的比较。