3 ms·
Don't complain about a tool built for Javascript when you try to shoehorn Coffeescript into it. Coffee script being a hack built into a new beast of a language
by warfangle 13y ago
Don't complain about a tool built for Javascript when you try to shoehorn Coffeescript into it.
Coffee script being a hack built into a new beast of a language, I have yet to read docs that drift from "JS is better! ... No, CS is better!"
Use the right tools for the job, and don't complain that your pentagonal screwdriver doesn't always work on phillips head screws.
- ricardobeat 13y agoI see your point, but really, what he said about CoffeeScript doesn't make any sense. It doesn't have any 'default behaviour of including a module' because it's just syntax sugar, you use the same require() and libraries.
- nahname 13y agoThe default behavior for coffeescript is to hide the code in a JS module (the pattern). This is to prevent turning variables into globals. This behavior can be disabled, but I see it as one of the many benefits of coffeescript.
- grncdr 13y agoCould you provide an example scenario in which this would cause a problem? This has never had any noticeable effects in the 2 years I've been using Node and CoffeeScript together.
- ricardobeat 13y agoA closure. That's true, but it doesn't change the behavior inside a node module at all, they already have their own contained scope, you have access to the same globals `module/exports/global/require/etc`, and `this` is preserved.
- reissbaker 13y ago"JS modules" (what you're actually referring to are called IIFEs, which stands for "immediately-invoked function expressions" — JS modules are something else, and CoffeeScript doesn't support them) don't have anything to do with importing/exporting code. In browser-CoffeeScript the only way to "import" and "export" code is to make global whatever you intend to export. IIFEs are also pretty orthogonal to Node's module system — they work perfectly fine together, and don't have much to do with each other at all. Not sure why you'd feel the need to disable IIFEs in the CoffeeScript compiler except out of desire for cleanliness since they're an ugly hack in the first place.
- warfangle 13y agoPlease don't confuse JS modules and closures, they are completely different things.