5 ms·
> SO MANY BRACKETS. }) }) }) })
by s_kilk 9y ago
> SO MANY BRACKETS.
})
})
})
})
})
})
},
})
})
})
})
})
})
},
Whatever do you mean?
- chx 9y agoDidn't ES6 promise ;) to solve this?
- matthewmacleod 9y agoThis is true only insofar as libraries use promises, and your code uses promises. They're still pretty annoying in my experience. There are still some other cases where the mess of brackets is overkill, other than callback hell.
- udp 9y ago> This is true only insofar as libraries use promises, and your code uses promises. They're still pretty annoying in my experience. Promisify, or (as I prefer to) just "return new Promise((resolve, reject) => { nonPromisedStuff(...) })"? > There are still some other cases where the mess of brackets is overkill, other than callback hell. Like bad coding style?
- roblabla 9y agoI'm awaiting ES7 :D for the true solution to this problem. It'll eliminate the boilerplate of .then(function() {})` entirely. Less brackets, less ceremony.
- jholman 9y agoES7 was finalized a year ago. Everything except IE 11 supports all of it. You meant ES2017. HTH
- masklinn 9y agoAnd all current browsers save IE11 support ES2017 async functions.
- zajd 9y agoIsn't ES6 `.then(()=>{})` ?
- deleted 9y ago[deleted]
- ravenstine 9y agoOr even without curly braces: `.then(x => doSomethingWith(x));`
- ulucs 9y agoPromises returning promises (or async/await which is just sugar-coating for promises) solves this very cleanly in my experience
- deleted 9y ago[deleted]
- horsawlarway 9y agoI agree. Promises have solved most our team's nesting issues. It's incredibly clear, allows clean and concise error handling, and is easy to use.
- teknologist 9y agoIt takes time to get those brackets right; time that adds up. That's one of the many ways CoffeeScript contributed to my own productivity over the years
- icholy 9y agoOnly if you're editing text with a potatoe.
- dmix 9y agoAssuming you have an editor which auto wraps pararenthesis then with Coffeescript you are basically exchanging brackets for spacing with zero productivity gain, besides some features such as list comprehension and easier handling of that = this. Additionally every JS file has to be preprocessed making debugging slightly harder and set up more involved. Every person contributing to the project has to become familiar with CS. Plus mixing both CS and non-CS files always ends up happening in my experience. As a former CS fan, I really don't see the utility of using CS like I used to.
- matthewmacleod 9y agoIf you're using ES6, you're already likely doing a compilation step anyway. So I'm not too sure there's much loss.
- dmix 9y agoTrue, I've been using Babel for ES6 when not working on chrome extensions or sites limited to early adopters which I look forward to not having to depend on. For Node you don't need Babel to use ES6 besides support for import instead of require. I still find having to use Babel annoying.
- teknologist 9y agoSo we're assuming that everyone only ever writes new code in a situation where auto insertion of parentheses would kick in and contribute. Don't you people have to edit existing code? Callback hell anyone?
- ojr 9y agothe text editors/ides I use today have bracket matching and with eslint it's been easier to track missing/extra bracket bugs, the example you have is heavily exaggerated, nesting like that is bad code with or without brackets
- baby 9y agoIt is still confusing. Look at how clear python files are for example.
- dmix 9y agoMy editor's colorscheme makes brackets dark gray and I don't use semicolons in JS because it's optional. It's really not that ugly. I What IS ugly is inspecting machine generated Coffeescript source code in Chrome dev tools and debugging it. So is having to set up preprocessors whenever you want to use Coffeescript. Which is easy in Rails but a challenge in many other scenarios such as simple static sites. Not to mention the number of projects I've joined which has a random mix of both .js and .coffee files. I'd prefer spacing over bracket if it was natively supported in the language as it is in my favourite languages Erlang, Elixir, and Haskell. But that's not the case here.
- deleted 9y ago[deleted]
- yellowapple 9y ago
- buchanaf 9y agoWho writes JS like this?
- scaryclam 9y agoThis is something I'm left wondering. I've written a lot of JS, some of it in complex applications. I've never had this issue of mass nesting that would cause all of these brackets people here seem to be complaining about. I'd suggest that coffeescript isn't solving issues with javascript syntax, but instead is allowing the kind of code that should be refactored out to stay around for longer as it doesn't look so ugly. That's not really a good thing. Perhaps it's a good thing if the community lets it die.
- maxscam 9y agoYou might not feel like you wrote too many brackets, but good luck convincing someone who uses none (except for hashes) that they should start. Coffeescript code is not sloppier, its more terse.
- z3t4 9y agoPeople who have not yet discovered named functions.