Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I dunno. I think that a lot of that is just a matter of developer maturity and code discipline. If you can't recognize a code smell when you're writing code, the problem is probably that you aren't mature enough as a developer, not that the language is bad for allowing it. I don't think that most seasoned developers would look at that 160-column list comprehension, say "okay, that works!" and move on to the next task. They'd say "okay, that works, but holy crap it's ugly. Quick, to the refactormobile!" I've seen 160+ column nested ternary operations in pure Javascript that make the aforementioned comprehension look positively poetic.

I've seen some genuinely horrible Javascript. Like, stuff that so terribly abuses the language without any comprehension whatsoever of closures or context binding and only works because the author got stupidly lucky and/or abused globals so badly that the code was effectively one giant function. In both cases, bad developers writing bad code are going to produce unmaintainable messes. Doesn't mean that the language should be avoided. Garbage in, garbage out.



I've seen terrible JS, but I've seen much worse CS. Most programmers have relatively no sense of organization, and when unleashed with CS create things far more nasty than their JS counterparts.

nasty: https://github.com/jashkenas/coffee-script/blob/master/src/r...

nasty: https://github.com/jashkenas/coffee-script/blob/master/src/o...

nasty: https://github.com/jashkenas/coffee-script/blob/master/src/c...

sexy: https://github.com/jashkenas/coffee-script/blob/master/src/g...


I've seen terrible assembly but I've seen much worse C. Most programmers have relatively no sense of organization, and when unleashed with C create things far more nasty than their assembly counterparts.

nasty: https://github.com/mirrors/gcc/blob/master/gcc/c-family/c-co...

nasty: https://github.com/mirrors/gcc/blob/master/gcc/c-family/c-le...

But you get the idea. I'm merely pointing out that compilers are tricky and complicated beasts. And especially in the rewriter CS has to jump through hoops to disambiguate.


I dont know if I would call CS complicated, but yeah you'll get that all the way down. Noobs will write their js, bigger noobs write CS, smarter people off writing C, and even smarter people writing ASM. Most will still write nasty code regardless but the ambiguity in CS makes this far more painful to consume


Unfortunately, in this particular case, the code was equally nasty even when all of those methods were written in Ruby, and has grown nastier over time through pull requests. I think it tells you far more about the author than the language ;)


The code smells are on the demo page for CoffeeScript.


Which bits do you consider to be code smells, out of curiosity? Things like postfix conditionals and list comprehensions generally aren't considered to be smells by the majority of people that use them. I don't see any 160-column list comprehensions or implicit bracketless object returns there, which are genuine smells.


once you turn a comprehension into a multi-line block of code it looks just like JavaScript, so ... :\




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: