Live data from Hacker News

Regarding JavaScript trailing commas

dontkry.com

21–30 of 48 posts

Re: Regarding JavaScript trailing commas

#21
I don't actually know the history of JavaScript style, but I feel like this assertion is likely trivializing something more complex:

>The reason you were once told trailing commas are bad is because they are invalid in EcmaScript 3.

I can imagine plenty of reasons people would have for avoiding trailing commas even after they became valid syntax.

The whole "consistency" section also feels like unnecessary snark.

Re: Regarding JavaScript trailing commas

#22
post #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.

No way. What you if had to cut and paste the first item?

Re: Regarding JavaScript trailing commas

#23
post #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.

For the love of god though don't suddenly start using this style in a project that doesn't (I've had to deal with it)

Re: Regarding JavaScript trailing commas

#24
post #22
post #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.

No way. What you if had to cut and paste the first item?

I think the argument would be that this is rarer

Re: Regarding JavaScript trailing commas

#25

Earlier quoted context omitted.

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 agree. Language features such as async/await (ES7) are exciting.

I am excited by async/await but it makes code non-trivially harder to debug. The tools are far from there

Re: Regarding JavaScript trailing commas

#26
post #21

I don't actually know the history of JavaScript style, but I feel like this assertion is likely trivializing something more complex: >The reason you were once told trailing commas are bad is because they are invalid in EcmaScript 3. I can imagine plenty of reasons people would have for avoiding trailing commas even after they became valid syntax. The whole "consistency" section also feels like unnecessary snark.

> I can imagine plenty of reasons people would have for avoiding trailing commas even after they became valid syntax.

Could you list a few?

Re: Regarding JavaScript trailing commas

#27
post #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.

It's worth mentioning that Elm uses this style: http://elm-lang.org/docs/style-guide#types

I was initially surprised by this but now knowing that the creator comes from a Haskell background, it makes sense that he would prefer it.

Re: Regarding JavaScript trailing commas

#29
post #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.

I've always found this style a lot better and can't figure out why people don't use it.

Adding items to the end of a list, tuples to a dictionary, arguments to a function etc... is more common then adding them to the start.

Re: Regarding JavaScript trailing commas

#30

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.

Some of the features of ES6 are pretty neat. Some of them are just crap piled on crap, which bloat out the language for marginal benefits at best.

Unfortunately, many of the ES6 features inspired by CoffeeScript features are completely unoptimized and an order of magnitude slower in cutting-edge browsers than the CoffeeScript versions. Even more unfortunately, they don’t work at all in lots of browser versions people are still using today. Which means that they can’t really be adopted by most projects yet.

Finally, even if ES6 were implemented perfectly everywhere, it’s still much less pleasant (from a syntax clarity perspective) to read and write ES6 code than CoffeeScript code, at least for me.

At the point when the vast majority of browsers support ES6 features, it will perhaps be reasonable to change CoffeeScript to use them in its generated output. In the mean time, CS is fantastic as-is, and its generated code works efficiently in every browser.

But hey, use whatever language you like (ClojureScript, Elm, Dart, Haxe, ES6, whatever..). It’s your code, so the only people who should care are you and your close collaborators.

Post reply on HN