使用 Sinatra 开发完整的网站有什么问题吗?
我正在开发一个新网站。该网站的复杂程度与 Yelp.com 相当。我对 Ruby 还很陌生,但我决定使用它来开发后端。在这个过程中我偶然发现了西纳特拉。我真的很喜欢 Sinatra 中路由的简单性,并决定将其用作我的开发的起点。似乎大多数地方都说 Sinatra 非常适合快速开发和“小型网络应用程序”。 Sinatra 是否存在固有的扩展问题,或者这些评论是否源于您基本上必须从头开始构建一切的事实?如果您对使用 Sinatra 作为大型 Web 应用程序的基础有任何意见,我们将不胜感激。
我不确定 stackoverflow 是否是提出此类意见问题的正确位置,但它是我目前拥有的唯一资源,可以真正获得有关此类问题的反馈。
I am in the process of developing a new website. The level of complexity of the site would be somewhere on the order of Yelp.com. I am pretty new to Ruby but decided I want to develop the backend using it. In the process I stumbled across Sinatra. I really love the simplicity of the routing in Sinatra and decided to use it as the starting point for my development. It seems most places say Sinatra is great for quick development and for "small web apps." Is there an inherent scaling problem with Sinatra or are the comments stemming from the fact that you basically have to build everything up from scratch? Any comments regarding your opinion about using Sinatra as the basis for a large scale web app would be appreciated.
I'm not sure if stackoverflow is the correct place to ask an opinion question such as this, but it's the only resource I currently have at my disposal to actually get some feedback about something like this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用 Sinatra 构建了最近两个相当复杂的项目,并且很享受这个过程。我喜欢的是,它鼓励您预先考虑正在构建的 Web 应用程序的 API,而不是事后才考虑。
我现在倾向于做的是让 API 工作并进行测试,然后使用 jQuery 构建面向浏览器的前端。前端和后端之间的所有交互都是通过API完成的。
通过将辅助方法分解为单独的库并利用 ActiveRecord 等 Ruby on Rails 库,我发现该代码并不比我编写的任何其他代码更难维护,而且它当然很容易测试。
我编写了一些简单的通用路由,这些路由允许我使用与 Nesta 项目类似的想法来集群页面级内容(以 markdown、textile 或 haml 编写),这意味着我的 99% 的路由是 API 调用而不是页面显示来电。我还为基于规则的导航构建添加了一些简洁的助手,这也确实很有帮助。
简而言之,答案是否定的,使用 Sinatra 构建大型网站没有任何问题,而且事实上我相信它可以带来更好设计的 Web 应用程序。
I've built my last two fairly complex projects using Sinatra and have enjoyed the process. What I like is that it encourages you to consider the API of the web application you are building up-front rather than as an afterthought.
What I tend to do now is get the API working and tested and then build the browser-facing front-end using jQuery. All interaction between the front end and the back is done via the API.
By breaking out helper methods into separate libraries and taking advantage of Ruby on Rails libs like ActiveRecord etc I find the code is no harder to maintain than any other code I have written, and it's certainly easy to test.
I've written some simple generic routes that allow me to cluster page level content (either written in markdown, textile, or haml) using similar ideas to the Nesta project which means that 99% of my routes are API calls rather than page-display calls. I've added some neat helpers for rule based navigation construction too that really help too.
So in short the answer is no, there is nothing wrong with building large websites with Sinatra, and in fact I believe it can lead to better designed web applications.
使用 Sinatra 构建大型站点不会给您带来扩展问题,但肯定会给您带来维护代码的困难。虽然我喜欢 Sinatra,但 Rails 中的约定优于配置毫无疑问胜出。另请注意,在大型网站上使用 Sinatra 并不是错误/不好/不可能,只是很难正确执行,而且您不希望自己以后后悔。如果你仍然顽固地使用 Sinatra,你可以尝试 Padrino 它基本上是 Sinatra 的包装(我从未使用过)它不能帮助你)
Building a Big site with Sinatra will not face you with scaling problems, but will definitely give u a very hard time maintaining code. Although i love Sinatra, convention over configuration in rails wins hands down. Also note that it isnt wrong/bad/impossible to use Sinatra for a huge site, just that it is hard doing it right and you would not want yourself regretting later. If you still are stubborn in using Sinatra you can try Padrino which is basically a wrapper over Sinatra(I have never used it so cant help you about that)