I am experimenting with Ruby and Rails. I like Ruby, but not Rails. I have Java/PHP background, I have used some frameworks, but never totally liked any of them.
Anybody using Ruby to build web apps, but not any of the frameworks? (rails, merb etc). If yes, can you point me to some resources to learn it?
It might be wise to at least leverage Rack, and maybe Sinatra gets enough out of your way for you to feel comfortable. Sinatra isn't much more than a very small, simple wrapper around the rack handler afaik.
Doing Web apps in Ruby without using a framework is like cooking without heat. I question the sense of trying this.
That said, you could probably hook up Apache to call a Ruby program as a CGI. I suspect it would be dog slow, though.
Edit: Apparently you're not the only one crazy enough to attempt this, though: I found a tutorial on Simple Ruby CGI. The author claims as his rationale that "he has nothing better to do."
Your question looks quite similar to Ruby off the rails, so you probably should read the answers of that one.
I'm using ruby instead of bash and python on my ubuntu server for sysadmin tasks.
I've found Ruby a particularly clean and powerful replacement for the places I'd have previously used bash and python in sysadmin.
I personally found one thing for myself. When I prepare some interview or I am gonna build something from scratch, in most cases I need some basic features included in Rails. That usually happens when you build something not complex, but still non trivial. In 99% of cases I need ActiveRecord, ActiveSupport etc. It is easy to get those things in your Gemfile and play with them. One thing you will always repeat is basic application structure, easy console access with preloaded libs, rakes... I created minimal gem for myself to organise this process though.. :) If you read sources you'll see what I constantly do to start something new. It is not a big deal not to use any framework at all.
https://github.com/einzige/framework
Related
I've worked through some of the Sinatra and Rails samples, but I'm having a hard time figuring out which features belong to which technology.
What specifically do I gain by using Sinatra/Rails? Is it just ActionPack/ActionView? Correct me if I'm wrong, but I COULD just use Webrick/Mongrel and serve up my .erb files right? And I could use ActiveRecord technology in those files and still access post variables, session state and querystring variables right?
So, what I'm asking you guys is, if I start with the PHP-like scenario above; Webrick + ERB + ActiveRecord, what do I gain by using Sinatra? And what do I further gain by using Rails?
For Sinatra, it's really almost like a wrapper around Rack. So you first need to ask what the point of Rack is. Rack is basically a specification for how a framework should return a result, it can use what's returned with any web server that Rack supports. So it's really a compatibility layer that allows you to choose your framework/server combination at will, without worrying about whether they'll work together. If your framework is Rack-compliant, you should be able to deploy on practically any server via Rack.
Now, the thing is Rack is very low level. Frameworks such as Sinatra give you things like nice routing, helpers, before/after filters, and a lot more. You just need to look to the docs to see what you can get. Rails is much more featureful, and in many ways "magical". That is, you might write a single line in Rails that ends up doing quite a lot, which for some is a good thing, and for some too magical. I personally prefer Sinatra for this reason, at least before getting a decent understanding of Rails internals.
The gain by Rails is ActionView/ActionPack. But you can just replace by Mongrel/Erb. It's something different.
It's all herlper you have in your view like name_route or error management in your form. It's all resources management and all plugin like InheritedResources. The advantage of Rails.
There are some tool like the Padrino environment to help you to have all of this helper. But It's really speeder after all plugin activate ? I don't think so.
With Rails 3, Rails is a complete Rack application with a lot of RackMiddleware. You can just drop off some middleware to increase your response.
This question is still relevant until today. And with rails' features are increasing over the time, I want to add a new answer.
There are so many gems right now, so what you can achieve in Rails, most likely you can achieve it too in Sinatra. If we want to compare between Rails and Sinatra (or any other frameworks), we just need to compare the performance and the ease of use.
One of Rails doctrine is convention over configuration. When you create a project in Rails, automatically you get many gems included in your Gemfile. Not only gems, when you look at config directory, you'll see many things included. This doctrine is the reason why the magic can happen in the first place. Once you break the convention, you have to modify -or even create- your configuration.
When we want to have more flexibility but still not reinvent the wheel, we can use framework like Sinatra, where only not so many features is enabled when we first create the project. Even so, I've created mini rails from Sinatra: I just adopting rails' way, with libs/gems that I really need. Because I need to develop my own configuration, the development time was longer than using rails.
If you see this web frameworks benchmark, you'll see that Rails is so slow while other ruby framework, like Sinatra, can be found much higher than Rails.
So, when the best to use Rails?
You need fast development time. Just follow the convention;
The future features of your apps are still unknown.
When the best to use Sinatra?
You don't need fast development time;
Sinatra can be fast if you only work in mini project;
You know that you won't add many features in the future.
What do you gain from Rails? Development speed.
What do you gain from Sinatra? Flexibility.
I been intersted in ruby and rails lately but what I always encounter in blog/ podcast / book is they will always teach how to use ruby or rails plugin/ ruby instead of writing one. Did we really always need to use plugin, even thing like authorization? Authenticate? Is it really waste time Or hard to write from start? Then if it hard and waste time why rails say make web development less painful?
Or I was wrong in term of concept? Goal ? Or anything else? Of rails? Anyone can guide me ?
It can be a good learning experience to write your own tagging system, or authentication system, or what have you. That's one argument for "rolling your own".
The argument for using libraries is the "standing on the shoulders of giants" concept. By using popular, actively-developed libraries, you can be reasonably sure that they're well-tested in multiple production environments and are extremely stable. And it gives you more time to focus on your actual application.
As an example, I would be very wary of writing my own system to process credit card payments when there are already full-featured, well-tested alternatives.
I think it really has to do with edge cases. With something you build yourself, you can think of many of the edge cases up front, but there are just as many that you will not be able to think of until you come to them. That's where the time savings comes in.
That being said, if you don't understand how to write an authentication system, then you should probably write your own. Conceptually you should fully understand how the parts of your app work, and if you don't, writing from scratch is a good way to learn. But with things that you already understand, I recommend using a gem.
I've put some of my free time on reading/learning about cakephp but now I'm wondering if will not be better to switch completely to ruby on rails.
Can you give me the good and the bad of those tools, when is about web-development?
many thx
Why switch? Since you've got a head start on CakePHP, take a little break.
Learn some Ruby on Rails for a while, then switch back to CakePHP when the mood strikes you.
That way, in the end, you'll end up knowing two languages/frameworks rather than just one. It's always better to get as much exposure as possible. Each has its benefits and downsides, but why not learn enough to make the decision yourself?
Neither is better than the other. While one may be more suited to particular applications than the other, they are certainly both good frameworks.
PHP is said to be faster, Ruby is objectively a better designed language. These probably make more of a difference than the framework itself - you can always modify the libraries or write your own classes to make the framework do what you want it to.
My advice is to stick with what you know if you are happy with it - learning a new framework is a long process. If you have issues with Cake or you're keen to try something different, Rails is definitely worthwhile.
I recently read a good article from a developer with a CakePHP base who just completed a large Ruby on Rails project.
http://www.jimmycuadra.com/blog/10-from-cake-to-rails
He details where Rails is stronger than Cake but also the other way around. Another blog here compares Ruby and PHP.
http://developingwithstyle.com/articles/2009/06/09/10-reasons-why-ruby-is-better-than-php-reason-5.html
personally i would choose cakephp at this moment. php and mysql are very common on most web hosting packages, even free ones. it is based on php and there is a huge amount of resources to learn and get help from. you can reuse many already written classes.
regarding the speed of cakephp, there are ways how to speed up cakephp in the production environment through the ways you code and caching.
I would choose ruby on rails because
ruby is fun to write
there is a great community
there are more high quality resources like www.railscasts.com and teachmetocode.com
Duplicate: Django or Ruby-On-Rails?
I have been reading on Ruby on Rails, and it seems like on some threads, some users like Django a lot too?
Can someone who have used both give some insight about using them, such as
ease of use
productivity
fun factor
deployment issues
or any other framework you'd highly recommend?
Both are excellent frameworks. Though, I've found Rails to be more suited for the agile developer. For the most part, you'll run some generators to get the files you need as placeholders for your code. Things will work right away, and you just build up from these conventions. It's really flexible and has a large community, lots of innovation and interesting practices are being put into Rails. It's development cycle seems faster paced than Django.
After only touching the surface with Django, it has some interesting differences. As far as I know, you don't get the schema migrations like Rails has out of the box. But you get an extremely simple CRUD mechanism for your models with the extensible admin interface, which is great for testing/managing content. The entire project is documented really well, from the Django Book to the vast amount of information on docs.djangoproject.com.
I personally prefer the Rails way of doing things. But honestly, you need to try them both to see what works for you, and since we're talking about two very good, yet totally different frameworks, it's a tough decision to make either way. So, if you already know Ruby or Python well enough, start with what you know and just go from there. Once you understand how one works, you'll be able to evaluate the smaller differences yourself. Hope that helps.
I would like to use a lighter framework than Rails (Sinatra/Ramaze/Camping) but am concerned that by doing so I will not be able to use a lot of shared libraries that have been tailored to Rails in the form of plugins. Is this a major concern or are most of these plugins usable across different Ruby frameworks?
Are there any other potential disadvantages in using a Ruby framework other than Rails?
You can still use gems in all of the frameworks you mentioned, so a ton of stuff is reusable. Want to swap in a new ORM, no problems. Want a fancy shmacy syntax highlighting, no problems. Rails has been making a huge push to move away from the old plugin model to use gems exclusively.
If one of the other frameworks fits your needs better use it. Keep in mind that when it comes to documentation and samples rails has more.
If I was learning Ruby and wanted to try out a web framework I would probably go with Rails not because its better, but because its got much better tooling and documentation.
Most Ruby modules used by Rails (even ActiveRecord) can be used without Rails. But then you lose the extra benefit of integration provided by Rails. You may have to work extra hard to glue Ruby modules to the framework of your choice. Please also note that most of the documentation about Ruby modules used by Rails tells you only how to use that module with Rails.
Network effects play a bit of a role.
One issue that comes up when you use other frameworks like sinatra, camping, etc is that rails gives you a proven structure for your files in the your application. Smaller frameworks are quite open and free.
This can be a downside when you are working with multiple developers as you need to have conversations about creating conventions rather then simply following them.
If you've been using Ruby for less than a year, stick to Rails, unless you have a very clear need that is better handled by one of the other frameworks.
The lighter frameworks, most notably Sinatra, tend to be popular with people who know exactly what they will need and can't afford to have any additional overhead from unused code. Essentially, you pick your toolchain, instead of generally being stuck with what Rails gives you. (Yes, in Rails, you can replace ActiveRecord, et al. with other libraries, but it's not exactly easy.) So the lighter frameworks give you significantly more freedom, but you also have quite a bit more work to do in many cases.
I think no rails plugin is going to work out of the box with any of the alternative frameworks, except for ActiveRecord plugins (such as acts_as_nested_set etc.) which are still going to need some plumbing work (setting $LOAD_PATH and requiring right files). I'd recommend DataMapper for ORM, not only it's way faster than ActiveRecord, but it's also very modularly built and plugins are actual gems that you can easily install. In difference, ActiveRecord plugins are mostly monkey-patches that tend to break with every new version.
Sinatra doesn't come with any "goodies", no Rakefiles, no skeletons, no script/generate, but actually that's what it's been written for. You can gradually "plumb in" all the extra stuff. There are also skeletons for sinatra apps that come with some basic layout and defaults, you may find these useful.