Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is / why is Rails 6 still using / recommending CoffeeScript?

I am new to the Rails word. Using Rails 6 and following the guides / tutorials. On the official Rails guides, there are CoffeeScript examples and it's even recommended to use CoffeeScript, see: https://guides.rubyonrails.org/working_with_javascript_in_rails.html#an-introduction-to-ajax (even in the edge guides: https://edgeguides.rubyonrails.org/working_with_javascript_in_rails.html#an-introduction-to-ajax).

As an experienced JavaScript developer, I have never seen for the past three years any company choosing CoffeeScript as their JavaScript tool. Thanks to the innovations from CoffeeScript JavaScript has evolved and the need for CoffeeScript disappeared.

Now why would Rails still recommend it? I feel like it will most probably confuse newcomers to Rails because for most of the new developers, CoffeeScript is not even a thing anymore. It's a good history lesson if you read it about JavaScript but that's it.

Thanks!

like image 602
vvo Avatar asked Nov 18 '19 08:11

vvo


People also ask

Does rails still use CoffeeScript?

CoffeeScript is no longer recommended by the Rails community.

What is Rails CoffeeScript?

CoffeeScript is a language that compiles into JavaScript. It has been included in Rails 3.1 so a lot of Rails developers are going to be taking a look at it for the first time soon. In this episode we're going to convert some existing JavaScript code into CoffeeScript as this is a great way to learn it.

Should I upgrade to rails 6 now or wait?

One important note to make: Rails 6 will be using Webpacker by default for Javascript, so it will probably be getting rid of coffeescript as well. You might want to just make the upgrade now if you can so you'll have an easier time upgrading to Rails 6.

Is it possible to use JavaScript and jQuery in Ruby on rails?

We know, Ruby on Rails provides us by default .coffee files when we create any controller. In my view folder, I have defined a test.html.erb file, I have a button and if I define the script for this button by using javascript or jquery in the same page i.e. test.html.erb it works.

What do I need to run a CoffeeScript compiler?

Lastly, you’ll need a JavaScript interpreter to run the CoffeeScript compiler. If you’re on OSX the Ruby wrapper (shipped in the coffee-script gem) will use the built in system interpreter but if you’re on another platform, you’ll want to check the ExecJS README which goes over the options available.

Can CoffeeScript be used in a web browser?

Because it compiles down to JavaScript (versus assembly or some other bytecode like many languages), CoffeeScript is already useable in browsers that support JavaScript and on platforms like node.js.


2 Answers

I arrived here from googling the same thing. Here's what I learned in the last 30 min:

  • There was a lot of discussion about updating the rails guides to remove coffeescript
    • That took place, and recent versions of rails guides do not reference coffeescript any more
  • Anecdotal, but some very experienced rails devs I asked about this do not use coffeescript any more.

Now JS is a quite decent language, so there’s no reason to use CoffeeScript anymore. Also, I don’t think that there’s anyone maintaining

Based on this info:

  • I will use up to date rails guides (that don't use coffeescript)
  • I won't use or learn coffeescript
like image 123
stevec Avatar answered Oct 19 '22 08:10

stevec


There's a pull request opened to change the information: https://github.com/rails/rails/pull/37529

like image 2
vvo Avatar answered Oct 19 '22 08:10

vvo