Live data from Hacker News

Replace CoffeeScript with ES6

robots.thoughtbot.com

111–120 of 178 posts

Re: Replace CoffeeScript with ES6

#111

The reason that I like CoffeeScript is that it removes, what I consider, the unnecessary boilerplate of JavaScript and replaces it with a shorthand equivalent and good conventions. I feel that CoffeeScript is better at representing the intent of JS than JS. I can visually sift through CoffeeScript and understand the code much quicker than normal JavaScript, which in my opinion leads to more maintainable code. I'm not…

I totally agree, but have you read the ES6 changes (i.e. what the article talks about)? To me, ES6 provides 90% of the good parts of CS, but without some of the tendency to let people write some of the headscratchers CS allows for.

Re: Replace CoffeeScript with ES6

#112

Earlier quoted context omitted.

Semicolons are already optional in JS. Automatic semi colon insertion (ASI) has a clear set of rules that are pretty easy to remember. http://mattdesl.svbtle.com/to-semicolon-or-not

But ASI is controversial, because of the bugs that can be caused by it. (See "JavaScript, the Good Parts"). I make our devs (myself include) use semicolons with jshint, because I believe it's too easy to screw up.

jshint warns about these bugs regardless of whether you have ASI flag turned on.

Writing semicolon-free code is easy. Just put a preceding semicolon before any lines beginning with: ( [ + -

Re: Replace CoffeeScript with ES6

#113

it solves a lot of the problems that CoffeeScript is trying to solve without drastic syntax changes. I cannot speak to authorial intent, but for me the majority of the problems CoffeeScript(and moreso LiveScript) solves are syntax ones.

ES6 solves many of those same problems that required overly verbose or awkward ES5 syntax. Things like basic this-preserving closures, collection extraction, and so forth. Same problems, similar but less radical solution in ES6 vs. CS

Re: Replace CoffeeScript with ES6

#114

CoffeeScript compiles down to ES3, which means it's compatible with Old IE. The ES6 compilers can only compile down to ES5.

That's not necessarily true. Many of the features can be made ES3 compatible. Of course knowing which ones are exactly isn't always straightforward.

Re: Replace CoffeeScript with ES6

#115
post #110
post #92

Earlier quoted context omitted.

Ex-Coffeescript ,now Javascript with lot's of Python experience guy here. The "I understand CS code much quicker" argument is a valid one theoretically, but In my opinion, it does not hold up practically that well. CS got one thing wrong that Python got right: There are many ways to do things. When writing CS, I understood MY CS just fine... but it always took me longer to understand the CS of other people. Sometimes…

As an example that I deal with daily, writing React components in CoffeeScript v.s. Javascript really highlights the elegance of CoffeeScript. Of course you can reduce the JS verbosity with JSX instead... which again is introducing a pre-processor to the mix (one I personally am not a fan of, but w/e). ES6 adds some sweet stuff for sure, but IMO it doesn't make JS a pleasure to work with yet (which seems to be the ar…

"it doesn't make JS a pleasure to work with yet (which seems to be the argument?)"

My interpretation of what Retozi is saying is that CS just means that in addition to understanding JS, including ES6, you need to be familiar with all the different ways things can be done in CS.

I tend to agree, especially as JS is becoming an improving with each release.

What I'd like to see going forward is JS continuing to add selective sugar as is in CS, but also add functionality that makes going into a new fresh JS codebase and making sense of it easier. That side of things is less about CS, and more about the sorts of ideas you see in Dart and TypeScript.

Re: Replace CoffeeScript with ES6

#116

The reason that I like CoffeeScript is that it removes, what I consider, the unnecessary boilerplate of JavaScript and replaces it with a shorthand equivalent and good conventions. I feel that CoffeeScript is better at representing the intent of JS than JS. I can visually sift through CoffeeScript and understand the code much quicker than normal JavaScript, which in my opinion leads to more maintainable code. I'm not…

If you've got any sort of programming skill your js will only be concatenated on test and production builds, not on development. Your last paragraph makes little sense as you should never, ever be debugging a problem on live and I think minification has caused me a problem like twice in the 8 years since it's been popular. And it was pretty obvious when it did as the is wasn't even compiling.

>If you've got any sort of programming skill your js will only be concatenated on test and production builds, not on development.

Development builds should use concatenated and minified .js code. That verifies that the development build performs exactly like the production build.

You can use source maps to help with debugging.

Re: Replace CoffeeScript with ES6

#117
post #37

Earlier quoted context omitted.

Some reasons why I will stick with CS: * Optional braces and parenthesis. Results in visually cleaner and more compact code, especially when dealing with large objects. * Requiring backticks to do string interpolation seems like an ugly hack. * CS uses dots to slice and splice ranges: host?.split(".")[-1..][0] == "dns" BTW, notice in the example above two additional CS features that don't exist in ES6: * The existent…

I looked at 6to5 and started re-writing a few files of CoffeeScript in ES6. First impression was not great. I'd forgotten how many curly braces are required in JS. ES6's fat arrow is just not as nice as CoffeeScript's (required parentheses, no option for thin arrow). I'll no doubt try it out again soon, but I'm not a convert yet.

ES6 fat arrow syntax doesn't require parentheses if there is only one function parameter. If there are more, parentheses make the code more readable in my opinion.

Re: Replace CoffeeScript with ES6

#118
post #89
post #56

Earlier quoted context omitted.

And the beauty of using ES6 is when the browsers you need to support handle, you just remove the transpiling step.

How much of this beauty will be fixed in ES6? http://wtfjs.com

Some of those problems are with the DOM and browsers, not JavaScript.

Re: Replace CoffeeScript with ES6

#119

Earlier quoted context omitted.

Significant indentation is a good thing. Haskell and Python do it too. It's much easier to read indentation than it is to match up pairs of brackets in your head. In other languages, if the indentation doesn't match the brackets, you'll naturally read the indentation first and get the wrong impression of what the code does. In those languages, the indentation is supposed to match the brackets anyway. Why be redundant…

I like the indentation + braces redundancy because indentations are for humans, brackets are for the interpreter. Logic blocks are more explicit with brackets I encountered a non-obvious Python bug that was caused by mixed spaces-and-tabs: to my human eyes, the indentation looked fine - the same as previous line, but the interpreter saw a different level of indentation.

True, agreed. Python has the -tt flag but, UI mistake, it should have been on by default. Or at least -t.

Re: Replace CoffeeScript with ES6

#120
post #50

The reason that I like CoffeeScript is that it removes, what I consider, the unnecessary boilerplate of JavaScript and replaces it with a shorthand equivalent and good conventions. I feel that CoffeeScript is better at representing the intent of JS than JS. I can visually sift through CoffeeScript and understand the code much quicker than normal JavaScript, which in my opinion leads to more maintainable code. I'm not…

My biggest problem is definitely the source maps. It took me forever to get them to "work" and while the stack traces are mostly correct, they're often off by a line number or two. This makes debugging ridiculously hard when the line numbers are just "close". I know this might not sound like a big deal in the grand scheme of things, but I also don't think CoffeeScript really improves on js all that much, so the annoy…

I'm surprised. I use Browserify (and Coffeeify), which spits out a source map inline at the end of the file, which has not once given me problems.
Post reply on HN