Live data from Hacker News

Replace CoffeeScript with ES6

robots.thoughtbot.com

81–90 of 178 posts

Re: Replace CoffeeScript with ES6

#81

Mmmm without drastic syntax changes ? Classes: There is no semicolon after the function name The function keyword is omitted There are no commas after each definition Interpolation: `${1 + 1}` Multi line strings: ` Now we have a 3rd string delimiter` Fat arrow: $("button").on("click", () => { // really? hanging parens? no function keyword? }); Destructuring: var [first, , last] = [1, 2, 3] // thats a var to assign va…

I don't like the class syntax in either ES6 or CoffeeScript.

In my opinion Ceylon nailed it:

    class Person(variable String firstName, variable String lastName) {

        shared String name => firstName + " " + lastName;
    
        assign name {
            value names = name.split().sequence();
            firstName = names[0] else "";
            lastName = names[1] else "";
        }
    }

Classes are effectively just closures with subtyping that export their shared members/functions.

Unrelated: A simple class like that shouldn't be mutable.

Re: Replace CoffeeScript with ES6

#82

I wonder if ES6+ is going to become the new HTML5 - all these great features but no hope of proper browser support for years. I had no idea ES7 was also in development, so it seems like browsers are always going to be playing catchup. The comments on an article here the other day said people aren't upgrading tablets as often as phones. I can see a lot of tablets being stuck on ES5, that people don't want to upgrade,…

Most of the JavaScript community is already using this, thanks to tools like https://6to5.org/ . Developers are excited about new language features not because of browser support, but because it standardizes patterns they were already using (fat arrow functions, Promises, modules, classes, etc.) through CoffeeScript and third-party code.

I think your "most" is rather optimistic.

(6to5 didn't even exist six months ago.)

Re: Replace CoffeeScript with ES6

#83

Earlier quoted context omitted.

The things I hate most about CoffeeScript are the dash rockets and white-space significance. These are just opinions though. There are things I like about CS as well, like destructuring assignment and splats. Sometimes when I'm writing JS, I miss is, unless, etc... That said, I'd put my money on ES6 in the long run, though it doesn't really matter. People should use whatever makes them (and their team) happy and prod…

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.

Re: Replace CoffeeScript with ES6

#84

Earlier quoted context omitted.

The things I hate most about CoffeeScript are the dash rockets and white-space significance. These are just opinions though. There are things I like about CS as well, like destructuring assignment and splats. Sometimes when I'm writing JS, I miss is, unless, etc... That said, I'd put my money on ES6 in the long run, though it doesn't really matter. People should use whatever makes them (and their team) happy and prod…

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…

It's not just significant indentation. CS parses "f + g" differently from "f +g" (the former is an addition, the latter is a function call with "+g" as the first argument).

Re: Replace CoffeeScript with ES6

#85

Earlier quoted context omitted.

The things I hate most about CoffeeScript are the dash rockets and white-space significance. These are just opinions though. There are things I like about CS as well, like destructuring assignment and splats. Sometimes when I'm writing JS, I miss is, unless, etc... That said, I'd put my money on ES6 in the long run, though it doesn't really matter. People should use whatever makes them (and their team) happy and prod…

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'm sure this has been argued to death but the counter argument is invisible formatting changing behavior is a bad thing. Sure if you get your entire team to use spaces or the same tabs great but passing open source code around to lots of programmers some of which use tabs and some of which use spaces ends up leading to wasted debugging time when someone used a tab where they should have used a space or visa versa.

On top of that I find it invaluable to be able to space out debugging code. Example

    void SomeFunc() {
       int x = doSomething1(1, 2, 3, 4);
       int y = doSomething1(4, 5, 6, 8);
       int z = doSomething1(5, 6, 7, 9);
       printf("xyz=%d,%d,%d", x, y, z);
       int a = doSomething1(0, 2, 3, 4);
       int b = doSomething1(1, 5, 6, 8);
       int c = doSomething1(2, 6, 7, 9);
       printf("abc=%d,%d,%d", a, b, c);
       int d = doSomething1(6, 2, 3, 4);
       int e = doSomething1(5, 5, 6, 8);
       int f = doSomething1(7, 6, 7, 9);
       printf("def=%d,%d,%d", d, e, f);
       return x * y * z + a * b * c + d * e * f;
    }
vs

    void SomeFunc() {
       int x = doSomething1(1, 2, 3, 4);
       int y = doSomething1(4, 5, 6, 8);
       int z = doSomething1(5, 6, 7, 9);
    printf("xyz=%d,%d,%d", x, y, z);
       int a = doSomething1(0, 2, 3, 4);
       int b = doSomething1(1, 5, 6, 8);
       int c = doSomething1(2, 6, 7, 9);
    printf("abc=%d,%d,%d", a, b, c);
       int d = doSomething1(6, 2, 3, 4);
       int e = doSomething1(5, 5, 6, 8);
       int f = doSomething1(7, 6, 7, 9);
    printf("def=%d,%d,%d", d, e, f);
       return x * y * z + a * b * c + d * e * f;
    }
On a long functions I find it much easier to see/find/delete the debug print lines by indenting them separate from the real logic but I can't do that on any language that enforces code blocks by indentation.

Commenting out also because an issue

    void SomeFunc(int v) {
       bool doit = v > 5;
       if (doit) 
       {
         DoSomething();
         DoSomethingElse();
         DoSomethingOther();
       }
    }
For testing I often want to comment out the if

    void SomeFunc(int v) {
       bool doit = v > 5;
       //if (doit) 
       {
         DoSomething();
         DoSomethingElse();
         DoSomethingOther();
       }
    }
If I was in python I can't do that

    def SomeFunc(v):
       doit = v > 5
       #if doit 
         DoSomething()
         DoSomethingElse()
         DoSomethingOther()
       
Error! I have to format the whole function just to comment out a line for testing. Yes in this case I could put `if true` (then requiring two changes instead of one) but there are plenty of other cases where code blocks by indent make it really annoying to work with my code.

So no, significant indentation is not a good thing.

Re: Replace CoffeeScript with ES6

#86

Coffeescript is pretty damn ugly. For god sakes can people please use parenthesis when calling functions with arguments?

Why add unnecessary clutter?

It is not unnecessary, it helps the reader building a mental model about what is a function and what is not. I would concede It can be useful to create some DSL or to access an object lazily but the is a price to pay: a more opaque code base

Re: Replace CoffeeScript with ES6

#88

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'm sure this has been argued to death but the counter argument is invisible formatting changing behavior is a bad thing. Sure if you get your entire team to use spaces or the same tabs great but passing open source code around to lots of programmers some of which use tabs and some of which use spaces ends up leading to wasted debugging time when someone used a tab where they should have used a space or visa versa. O…

Python 3 does not allow you to mix spaces and tabs. I don't know if Coffeescript is similarly strict.

I guess you've developed a habit where you're completely OK with having incorrect indentation a lot of the time, whereas I can't stand it. Just because it's easier to read for you doesn't make it easier for everyone, especially beginners.

Re: Replace CoffeeScript with ES6

#89
post #56

I wonder if ES6+ is going to become the new HTML5 - all these great features but no hope of proper browser support for years. I had no idea ES7 was also in development, so it seems like browsers are always going to be playing catchup. The comments on an article here the other day said people aren't upgrading tablets as often as phones. I can see a lot of tablets being stuck on ES5, that people don't want to upgrade,…

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

Re: Replace CoffeeScript with ES6

#90

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.

> I encountered a non-obvious Python bug that was caused by mixed spaces-and-tabs

This is why PEP8 exists and people are supposed to follow it. Additionally, mixed spaces-and-tabs is a bug that causes poor readability - there's plenty of people who have their editors set to have tabstops as 2 or 3 spaces rather than 4, and your code will look wrong in their editors.

If you think there's any issues with mixed tabs and spaces in your codebase, Python provides a tool to find out - tabnanny. Additionally, any context-aware code editor will display a warning. (If you're using Sublime Text, the plugin to use is SublimeLinter - I assume there's similar tools for vim and emacs.) You can even set spaces and tabs to display differently in many editors!

Post reply on HN