Default JavaScript library

Hi there, sorry to bring this topic up yet again, but I feel that some time has passed, and that the landscape has changed.

Currently, Prototype is the default option in Rails. While switching to jQuery is pretty easy, it's not as easy as not having to switch at all, and this being Rails and all, our expectations in the area of rock-solid defaults are high. I'd like to bring up some arguments in favor of switching the default to jQuery.

1. It is my feeling that the vast majority of the Rails community use jQuery exclusively. 2. jQuery has a vast community of its own, and a multitude of plugins. 2. Yehuda Katz.

In all honesty, it's probably the first argument that carries the most weight: if the vast majority of developers use jQuery, Rails should embrace it as the new default, seeing as it's the *preferred* one now. Now, I may be wrong about the number of jQuery vs. Prototype users, but I'd be surprised if I was.

I hope I'll get at least a few responses. I can entirely understand if you've got personal reasons to prefer Prototype and all, its long history side by side with Rails and all, but Rails 3.1 may be a good time reflect on whether it's still the best choice.

Best regards, Daniel Schierbeck

Hi there, sorry to bring this topic up yet again, but I feel that some time has passed, and that the landscape has changed.

Currently, Prototype is the default option in Rails. While switching to jQuery is pretty easy, it's not as easy as not having to switch at all, and this being Rails and all, our expectations in the area of rock-solid defaults are high. I'd like to bring up some arguments in favor of switching the default to jQuery.

1. It is my feeling that the vast majority of the Rails community use jQuery exclusively.

Mine too.

2. jQuery has a vast community of its own, and a multitude of plugins. 2. Yehuda Katz.

I agree, and think that Rails 3 is a good opportunity to offer new default values for a lot of things, including the default javascript library.

Jeff

It probably makes any difference, but +1 anyway...

Rodrigo

Death to prototype! Long live jQuery!

Ryan Bigg / Radar

+1 jQuery

I suppose once 3.0 is released and it's just as easy to use jQuery with Rails as Prototype, it should be easy to determine which one people are using more often and then make that the default for 3.1. I'm also pretty convinced jQuery will come out far ahead.

Just to be clear, I don’t think there’s any doubt that jQuery has far more users, both in the Rails space and in the general space. So I don’t think that determining that jQuery is used more by Rails 3 users will result in changing the defaults.

I’d like to hear from other Rails core team members about this topic.

Yehuda Katz Architect | Engine Yard (ph) 718.877.1325

I don't particularly care which is the default, but I think it should be easy to pick either. Maybe a flag on the rails command like -d for the database. You could do something like:

rails myapp -j=jquery

Allen Madsen

+1

I think ideally, there should be -o and -t options for picking your orm and test framework at creation time as well

-/+1

yes - it should be easy to select, but one has to differentiate between first time users and heavy users.

first time users might not be able to choose between various types of orm, jslib, testlib ... and so they will choose the default.

i think well thought defaults are important as they will lay the foundation of first projects and will bind first time users to at least a few months to the libs.

I think that picking a single default that works for the majority, while retaining the possibility of opting out is the way to go. Having a command line switch that toggles different implementations may be nice, but it also incurs a much bigger maintenance work, as the sheer number of combinations between different components becomes vast.

Unless this is something someone wants to maintain, I suggest removing the non-default bindings from the Rails repo and putting it in a plugin.

Cheers, Daniel Schierbeck

+1 for jQuery.

It's tough to get people to switch, so I think you should have a choice. Ship with both perhaps.

But I think the syntax and philosophy of jQuery is more similar to Ruby than Protoype is similar to Ruby. I think it would be easier for new people to pick up jQuery than Prototype, but both are very easy to get started with.

Karl

Prototype looks more like Ruby, but I like jQuery better.

It is a very good idea! I'm a beginner, and still have some problems with setting up Rails with a workable database... so it won't be fun, if a beginner has to pay attention also for choosing the better JS library - while maybe he doesn't have any idea about Js at all! Anyway: jQuery is much better, and also very good for beinners; for example I made half that much basic mistakes than with Prottype! :wink: Of course I'm not the only beginner - so it is just an opinion.

üdv, Zoli

This report from RailsLab says jRails is used by about 16% of RPM users:

http://railslab.newrelic.com/2010/05/25/state-of-the-stack-a-ruby-on-rails-benchmarking-report-25-may-2010?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+RailsLab+(RailsLab)&utm_content=Google+Feedfetcher

It could be the case that some switch to jQuery without jRails, but I wouldn't expect that to be a significant percent. In any case, a 16% in that particular sample does not seem to support that perception.

-- fxn

PS: I you match gems and plugins, numbers say Mislav is the king :).

Projects using jQuery dont necessarily use jRails so I dont think that 16% is a real indicator of the usage of jQuery in Rails projects.

At least to me it seems like the problem of having Prototype as default affects mostly to new people. Advanced users will just install jRails and use jQuery. New people might find themselves thinking they nave to use Prototype to work with Rails, or other harmful situations. I believe that if the default lib is the most used everywhere these negative situations will happen less often.

Hope it helps.

At every talk I give at a conference, I ask whether people use jQuery in their Rails apps. In every case, close to 100% of the room raises their hands. jRails is a replacement for the Rails helpers only; I personally know a huge number of people who use jQuery with jRails.

In short jRails usage != jQuery usage

Projects using jQuery dont necessarily use jRails so I dont think that 16% is a real indicator of the usage of jQuery in Rails projects.

As I said, I don't expect that to be a significant percent.

At least to me it seems like the problem of having Prototype as default affects mostly to new people. Advanced users will just install jRails and use jQuery. New people might find themselves thinking they nave to use Prototype to work with Rails, or other harmful situations. I believe that if the default lib is the most used everywhere these negative situations will happen less often.

That's a different story. What the 16% tells in my view is that you can't include (1) among the reasons for advocating a switch in the default.

In all fairness, I think that's a bit misleading question. I raised my hand when you asked it in Frozen Rails, but I would also have raised my hand if you'd had asked the same question about Prototype.

//jarkko

The idea that 16% of Rails users use jQuery is divorced from reality. I can devise some experiments to prove that, but I have seen no evidence in my travels of a huge amount of people using anything else. I freely agree that people use Protoype, MooTools and Dojo. The number of people who do so, in my estimation, is quite small.

Also, to be clear, people who don't write JavaScript at all but just use the Rails helpers would be unaffected by a change in defaults. I would consider them N/As rather than "prototype users"