I have not used Underscore/Lodash in production, but I use jQuery a lot with CoffeeScript. CoffeeScript does not replace jQuery, although it can make your jQuery a lot nicer.
As far as other libraries, there really are no restrictions; CoffeeScript compiles transparently to JavaScript. The only thing holding it back would be poor support in the specific ecosystem you are working with, such as a lack of plugins that automate the build process. In that case, you may need to compile manually or set up your own build script. But other than that, you can use CoffeeScript in place of JS pretty much anywhere.
Does CoffeeScript just convert the modules methods/functions accordingly when needing to be called?
Just curious how that works.
Since so much of JavaScript development, especially nowadays, ties into a lot of frameworks/libraries (modules? I'm not always sure what we want to call it), I just didn't see a reference (maybe I missed it) on their page in regards to what it actually looks like to invoke module/framework/library specific things.
capitalStringsWithX = _.chain array
.map (item) -> item.toUpperCase()
.filter (item) -> item.includes "X"
.value()
as opposed to: var capitalStringsWithX = _.chain(array)
.map(function(item) { return item.toUpperCase(); })
.filter(function(item) { return item.includes("X"); })
.value();Your jQuery example would simply be written:
$ -> _..code here.._
However, the codebase I was working in had no clear style guidelines about when it was acceptable to drop braces/parens and so it left me wanting for Python's "there's one way to do it" aesthetic.
It is even more frustrating in .js repositories today. People use various ESXX flavours and syntaxes that might not compatible with each other.
Just look at this list: https://babeljs.io/docs/plugins/ My favorite is: babel-plugin-transform-decorators-legacy (A plugin for Babel 6 that (mostly) replicates the old decorator behavior from Babel 5)
Talk about code reuse
- Only use {}-free object literals in assignment
- Always add () to nested single-line function calls, and calls with expressions.
def foo(bar):
a = bar + 1
vs
foo = (bar) ->
a = bar + 1So invoking jquery and everything is totally 100% supported. In fact that is how I used coffeescript a few years ago.
My other question is: how nice does coffee script play with other libraries? We (unfortunately) use jQuery a lot. I have also been using underscore and lodash as well. Are those two even needed when writing coffee script? I'm kind of assuming not, since they're both largely just adding methods/functions.