Hacker News new | comments | show | ask | jobs | submit login

> SO MANY BRACKETS.

                                })
                              })
                            })
                          })
                        })
                      })
                    },
                  })
                })
              })
            })
          })
        })
      },
Whatever do you mean?



Promises returning promises (or async/await which is just sugar-coating for promises) solves this very cleanly in my experience


I 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.


the 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


It is still confusing. Look at how clear python files are for example.


My 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.


CoffeeScript 2 will compile classes to ES6 classes, among other changes. So the output should be more readable than it was previously.


Exactly, which sort of mutes the effectiveness of this tool. Coffeesctipt 2 is already a coffee to es6 transpiler


Python would be even worse in this situation, IMO. At least brackets are visible; having to line up a bunch of indentation for that kind of nesting depth is the sort of thing that gives me nightmares at night.


Didn't ES6 promise ;) to solve this?


I'm awaiting ES7 :D for the true solution to this problem. It'll eliminate the boilerplate of .then(function() {})` entirely. Less brackets, less ceremony.


ES7 was finalized a year ago. Everything except IE 11 supports all of it.

You meant ES2017.

HTH


And all current browsers save IE11 support ES2017 async functions.


Isn't ES6 `.then(()=>{})` ?


Or even without curly braces:

`.then(x => doSomethingWith(x));`


This 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.


> 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?


Who writes JS like this?


This 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.


You 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.


People who have not yet discovered named functions.


It 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


Only if you're editing text with a potatoe.


Assuming 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.


So 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?


If you're using ES6, you're already likely doing a compilation step anyway. So I'm not too sure there's much loss.


True, 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.




Applications are open for YC Winter 2018

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: