在不使用任何框架的情况下使用Ruby完成Web应用程序的难度如何?陷阱? [英] Complete web apps in Ruby without using any frameworks - how difficult? Pitfalls?

查看:78
本文介绍了在不使用任何框架的情况下使用Ruby完成Web应用程序的难度如何?陷阱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Ruby菜鸟.这个社区中有没有人编写没有任何框架的Ruby应用程序? (我的目标是自己写一个.)告诉我们您的经历.有多难?您使用的最低抽象是多少?有什么陷阱?谢谢.

I am a Ruby noob. Has any one in this community written a Ruby app without any frameworks? (edit:My goal is to write one on my own.)Tell us about your experience. How difficult is it? Whats the lowest abstractions you used? What are the pitfalls? Thanks.

推荐答案

这是一个非常非常广泛的问题.您是要编写自己的框架还是编写简单的类似于CGI的应用程序(可以很容易地使用ERB做到这一点).

This ia a very, very broad question. Are you looking to write your own framework, or just a simple CGI-like application (you can do that with ERB quite easily).

我看到不使用框架(包括您编写的框架)的最大陷阱是,其他人很难弄清您的代码在做什么以及为什么.此外,您将失去所有自动测试,数据绑定,打包,文档生成以及框架捆绑在一起的其他优点.

The biggest pitfall I can see to not using a framework (including one that you've written) is that it will be much, much harder for other people to figure out what your code is doing, and why. Plus, you lose all the automated testing, data binding, packaging, document generation, and other goodies that frameworks tie together.

当然,如果您自己进行所有绑定,那么您已经编写了一个框架. :)

Of course, if you do all the tying-together yourself, you've just written a framework. :)

如果没有,则说明您编写了可怕的意大利面条代码.

If not, you've written a horrible mess of spaghetti code.

由于您是一名初学者,因此我想做的是阅读Rails(或Sinatra)源代码,并尝试弄清楚它的作用.并不是因为它一定是一个很好的例子,而是因为您对Web框架的理解将通过深入了解而变得更加完整.这是非常非常有价值的.

What I'd do, since you're a beginning Rubyist, is read the Rails (or Sinatra) source, and try and figure out what it does. Not because it's necessarily a great example, but because your understanding of web frameworks will be a lot more complete by diving into a couple. And this is very, very valuable.

我查看了您的其他几篇文章,看起来您是一名学生,所以我要告诫您不要编写自己的框架,不是因为这本身不是一个好主意,而是因为软件框架代表-即,使用X语言的多年经验的总和.

I looked at a few of your other posts, and it looks like you're a student, so I'm going to caution you against writing your own framework, not because it's a bad idea per se, but because of what a software framework represents -- namely, the sum total of years of experience in working with language X.

程序员就像海狸一样-我们要构建.我们希望自己构建一切,并且始终以解决现有工具的缺点为目的.尽管这是一件非常崇高的事情,但它往往会引导人们走上很少完成工作的道路,因为他们不愿意使用别人编写的工具,而这些工具通常归结为次要的,修饰性的原因.年轻的编码员对此特别内gui,我也没什么不同–我浪费了数年的时间来编写Web服务器和数据库抽象层,而不是编写本来可以赚钱的软件.

Programmers are like beavers -- we want to build. We want to to build everything ourselves, always with the idea of fixing the shortcomings of the existing tools. While this is a very noble thing, it tends to lead people down the path of getting very little done, because they aren't willing to use tools that other people have written, often for what boil down to minor, cosmetic reasons. Younger coders are especially guilty of this, and I was no different -- I wasted literally years screwing around with writing webservers and database abstraction layers, instead of writing software that I could have made money with.

如果我可以回头去做不同的事情,那我将开始为已经存在的框架做出贡献,而不仅仅是尝试从头开始正确地做".

If I could go back and do things differently, I would have started contributing to the frameworks that already existed, rather than just trying to "do it right" from scratch.

现在,首先使用其他人的工作"规则是个例外,那就是当您有了使用工具的经验,知道何时该构建新的东西时. DHH(创建Rails的人)在决定编写Rails之前是一个很长的Ruby编码器.

Now, there is an exception to that rule of "use other peoples' work first", and that is when you've got the experience with the tools to know when it's time to build something new. DHH (the guy who started Rails) was a very long-time Ruby coder before he decided to write Rails.

作为Ruby新手,您可能会更好地阅读其他人的熟知识,并进行修补/改进,而不仅仅是自己开始.您将学到更多有关该语言的知识,为社区做出宝贵的贡献,并为自己提供一些不错的简历.

As a Ruby newbie, you're probably better-served at reading what other people have cooked up, and patching/improving that, rather than just starting on your own. You'll learn more about the language, make a valuable contribution to the community, and give yourself some good resume fodder.

这篇关于在不使用任何框架的情况下使用Ruby完成Web应用程序的难度如何?陷阱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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