Default JavaScript library

This is that api I propose. If it is agreed upon by core team then a patch can easily be created.

# create a demo app with prototype javascript # in this way current behavior is not changed

rails init demo

# create a demo app with latest stable jquery # GitHub - rails/jquery-ujs: Ruby on Rails unobtrusive scripting adapter for jQuery should have a jquery-versions.txt file which lists all the stable releases of jquery. That file will be referred # on runtime and the latest stable version will be found which would be 1.4.2 as of this writing

rails init demo -j=jquery

# create a demo app with jquery version 1.4.1

rails init demo -j=jquery:1.4.1

# create a demo app with mootools version 1.2.4

rails init demo -j=mootools:1.2.4

Once this kind of api is in place then I don't care what is the default JavaScript library that ships with rails.

Thoughts?

But you are talking perceptions, and the sample talks numbers.

Of course 16% has to be taken with some margins, but you can't deny it makes difficult to claim that the vast majority of Rails developers use jQuery exclusively, which was the claim in (1). That is a strong claim! (1 was originally stated as a feeling not a fact, that's fine).

If the percent had been 84% then there would be no doubt about it, right? But < 20%... dubious.

But it turns out the 84% seems to support that the vast majority are using Prototype, no matter which is our termometer.

Hey, I am not saying people can't advocate jQuery because of a series of reasons. I am only raising a flag about this claim about the perceived user base.

I think in reality, most rails developers end up using both; prototype because it's the default, and jquery because of the large library of plugins. I do think that supports a move to using jquery as default, despite preferring prototype myself.

Of course 16% has to be taken with some margins, but you can't deny it makes difficult to claim that the vast majority of Rails developers use jQuery exclusively, which was the claim in (1). That is a strong claim! (1 was originally stated as a feeling not a fact, that's fine).

If the percent had been 84% then there would be no doubt about it, right? But < 20%... dubious.

But it turns out the 84% seems to support that the vast majority are using Prototype, no matter which is our termometer.

I completely disagree, just because people don't use jrails, doesn't mean they're a prototype user. I generally bring in jQuery manually and delete all the prototype cruft from my projects, but I then write my own jQuery code to do specifically what I want, ignoring Rails helpers.

You can't assume that 16% jRails = 16% jQuery - it would be true if that was the only way of using jQuery with Rails, but it so blatantly isn't.

Cheers,

Andy

This is why I stated that once Rails 3 comes out, it should be easier to get some "real" numbers on this, since presumably it will be just as easy for developers to use jQuery as it currently is to use Prototype, and those users who actively program in Javascript rather than just using the helpers will consciously decide to use one or the other.

I would suggest it's a bit late to change the default option at this time, and if the decision is left for 3.1 it can easily be based at least in part on real-world numbers that nobody disputes.

Taking a sampling of libraries from the home pages of the six example sites listed on http://rubyonrails.org/ (Who is already on Rails?)

jQuery: Twitter, Shopify, Yellow Pages, Github

Prototype: Basecamp, Lighthouseapp

I only looked at the source of the home pages, and may have missed a jQuery also using Prototype and vice versa.

  • Adam

I know!

The problem is to gauge which percent does that represent. Do you claim that there's a 50% of people using jQuery exclusively without jRails to be able to sum up say 70%?

My hypothesis is that that percent is small, and this is of course speculation. But speculation based on the fact that generally speaking one prefers to keep the helpers if the cost is as cheap as installing jRails.

I am not claiming 16% is the exact figure, this is a sample, there's that other variable. What I say is that the numbers do not seem to **support**, to bring some evidence in favor of (1), on the contrary.

Xavier, I for one never use jRails -- in fact, neither do most of the rails devs i know. We do, however, use jQuery.

The JavaScript helpers in Rails 2.3 were rather ugly, from a jQuery point of view, which probably explains why not that many people felt like using jRails.

Daniel

Seconded. We use jQuery for almost all of our projects around here, but don't bother with jRails because of the ugly factor.

I would not go changing this in a minor release. Major or bust.

Ryan Bigg / Radar

I personally disagree. With a limit backwards compatibility, current Prototype users could have a simple command line switch to regain their old default. Furthermore, I feel that the default JS library is the least coupled piece of Rails 3 -- changing it is rather unobtrusive, as long as bindings are available for the major frameworks.

Cheers, Daniel

Why? SQLite3 was made the default database in 2.0.2 and the world didn't stop. It's a change that affects people creating new Rails applications - not ones that have already been created.

I'm a big fan of jQuery too but maybe at this point it would be nice to take an issue off the core team's table. At the end of the day Rails 3 is still going to work great no matter what the default is.

I agree. Let’s get 3.0 out and table this until then.

Deal?

Yehuda Katz Architect | Engine Yard (ph) 718.877.1325

Why? SQLite3 was made the default database in 2.0.2 and the world

didn’t stop. It’s a change that affects people creating new Rails

applications - not ones that have already been created.

There’s a big difference between changing the default database system and changing the default javascript engine. For a very basic example: Model.create will work the same on whatever database system you’re using where $(‘blog_1’) will behave differently depending on the javascript engine.

I see your point.

I’m a big fan of jQuery too but maybe at this point it would be nice

to take an issue off the core team’s table. At the end of the day

Rails 3 is still going to work great no matter what the default is.

Indeed and I’ll agree with Yehuda here. 3.0’s gotta be out soon, right?

I'd like to see vbscript as the default, but I guess we can wait until Rails 3 ships first.

I think Rails 3.1 would be the appropriate target.

Daniel

We discussed in this thread usage stats. Usage stats seem to favor Prototype, though of course it has been the default since the beginning and that matters.

On the other hand, stats about what people prefer *now* suggest that's clearly jQuery:

    http://survey.hamptoncatlin.com/survey/stats

I think this number is worth taking into account.