Framework for non-web Ruby project

后端 未结 3 1606
情书的邮戳
情书的邮戳 2021-02-02 17:51

I\'m looking for a simple Ruby framework for a non-web project. I\'m very familiar with Rails, so when I write pure Ruby I miss:

  • The different env
3条回答
  •  执念已碎
    2021-02-02 18:47

    First of all, Rails goal as a web framework is to let you mostly forget about the low-level details of a web based application (interacting with a web server, a database, etc.) and provide you with high-level abstractions which allow you to concentrate yourself on the actual job: Getting your application done.

    There is such a huge diversity of non-web applications, that it is simply impossible to have a framework that "makes them all".

    It is useful to understand what a framework is, and why and when you should use it.

    Let's say you would have to build a dog house. You would buy some wood, nails and a hammer to build it the way you want from scratch, or you could go to Walmart and buy a DIY doghouse kit. You will get a manual with detailed instructions on how to build your dog's "dream doghouse", and you will get it faster done than when making it from scratch, but you will be limited to the wood that comes with it and may be forced to use their nails or screws, and in some cases you would also need to buy a special screw driver.

    The DIY kit is your framework. Some smart guys already provided you with the basic tools of making your doghouse, you only had to figure out (or not, if you had a manual) how to do it given their "framework".

    Now, let's say you would build a skyscraper. The materials, tools and conventions (the framework) used would probably not be the same as they would when building a doghouse, and it would be over-kill to use a "skyscraper framework" to build a doghouse.

    You wouldn't write Twitter client with the same set of tools and conventions as you would when writing a banking application with a billion concurrent users.

    Rails is just one framework which provides you with a set of many, many good (and useful) conventions to write a web application, but that doesn't necessarily mean that it's the ultimate way to go. You can choose another framework, and maybe you will like the conventions for writing your application even more than the ones provided by Rails; or you could write all from scratch which would not limit you to what is provided by a specific framework and maybe make it even better.

    To answer your question: Think of what you want to write and don't let yourself be narrowed down by the set of tools and conventions provided by a framework, as they will surely be if you choose this path.

    Buy yourself some books about Design Patterns and read some great software, and then you may understand why the authors did not choose an application framework. Indeed, they've developed their own conventions and defined the behavior of what it should do; and once again, the "Rails way" isn't the only way, which doesn't make it the bad way. :)

    I would appreciate constructive criticism as I really tried to provide a good answer.

提交回复
热议问题