Live data from Hacker News

Regarding JavaScript trailing commas

dontkry.com

11–20 of 48 posts

Re: Regarding JavaScript trailing commas

#11
post #4

I'm a Python programmer. In Python, trailing comma are idiomatic, so I welcome this. Perhaps I'm just a lazy bastard, but it makes cut & paste a lot easier.

Ditto, from the Perl side of things. I'm a JS coder for the last few years, and I find I really hate a lot of the style conventions - they seem much more oriented towards "because I said so" than "because it's actually better".

Re: Regarding JavaScript trailing commas

#13

Controversies like the "trailing comma" strike me as evidence that JavaScript has superfluous syntax. The reason it even uses commas the way it does is that it started life as a lisp with (manager-mandated) Java-like syntax. I happen to agree with the position that syntax that can be made implicit should be. CoffeeScript has done a good job of this. LiveScript has done an even better one. What are the arguments again…

> CoffeeScript has done a good job of this

And that language shouldn't be used by beginners in 2016 due to its uncertain fate in the long run as its creator kind of abandoned the project. Furhtermore ES2015 adds many CS features to the language.

Don't know about LiveScript, but frankly that whole transpilation thing is a mess. People don't use Transpilers for Python or Ruby. They work with the language quirks.

Re: Regarding JavaScript trailing commas

#14

Earlier quoted context omitted.

> Is there a good reason not to use a syntactically cleaner language ... I find Coffeescript hard to read. Especially when dealing with nested callbacks (e.x.: when you have to nest, such as with Jasmine `describe` and `it` blocks for testing). Here's an interesting thread on the "cons" of using Coffeescript: https://news.ycombinator.com/item?id=6527316

Fair enough. Maybe CoffeeScript specifically isn't the answer. But the general idea of compiling neater languages into JavaScript strikes me as a better long-term solution than settling for its current syntactical warts, which are entirely historical accidents. I do like ES6!

I think ES6 is the solution. Evolve JS and remove the "warts" instead of introducing new variants.

I'm a big JS fan. I can't stand Coffeescript - it doesn't seem to add anything except changing the syntax to make it easier for Rubyists to understand. Which is fine, I guess, but feels like a personal preference. More like a text editor setting than something anyone should publish their code in.

Same for Typescript, to a certain extent, though I understand the heartfelt desire to have the compiler pick up some of the more common errors.

We run the risk of fragmenting the community by promoting CS and TS - better to evolve JS itself, which is what is happening and it's great.

TL;DR: kill Coffeescript and Typescript, evolve Javascript for the win!

Re: Regarding JavaScript trailing commas

#17
I've actually come to like a weird style popular in the Haskell world, leading commas:

    { one   = 1
    , two   = 2
    , three = 3
    }
It's weird, but it's actually pretty convenient. I think it has all the same properties the article argues for, but I don't want to figure it out for sure at the moment.

Re: Regarding JavaScript trailing commas

#18

Trailing commas were tough to get used to because my primary communication language is English, After a while I got used to them and I like the copy-paste-ability the enable... I'm also hoping they put an end to leading-comma style,

There is so much in programming that isn't necessarily directly in line with English, why are trailing commas any different?

Re: Regarding JavaScript trailing commas

#20
post #18

Trailing commas were tough to get used to because my primary communication language is English, After a while I got used to them and I like the copy-paste-ability the enable... I'm also hoping they put an end to leading-comma style,

There is so much in programming that isn't necessarily directly in line with English, why are trailing commas any different?

This was just my opinion, and it was not based on logic: I battled through and now I'm a happy trailing comma-er. But if I think about your question, I'd say the answer was because commas are the only part of coding that has a strong resemblance to written english in that you commonly use them to separate items a list.
Post reply on HN