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!
CoffeeScript is no longer recommended by the Rails community.
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.
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.
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.
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.
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.
I arrived here from googling the same thing. Here's what I learned in the last 30 min:
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:
There's a pull request opened to change the information: https://github.com/rails/rails/pull/37529
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With