Earlier quoted context omitted.
Yup, see @pauljz's comment above - https://news.ycombinator.com/item?id=10375297
I still don't understand that. Function.prototype.toString() wouldn't break because the parser stripped the comments, it would just output the source without comments? Does any code anywhere depend on the comments being preserved?
Node.js: Some quick optimization advice
71–75 of 75 posts
Re: Node.js: Some quick optimization advice
#72Earlier quoted context omitted.
I wonder what performance gains/losses you would experience if you had the comment outside the function block, before the function declaration.
Exactly, if the comment were outside the function, there would be no issue.
Re: Node.js: Some quick optimization advice
#73So, is this is a point in favor of not commenting your Javascript code or using inline docs? Historically, I preferred to use inline JsDoc style comments as the source of documentation for my public APIs. Recently though, I decided that I didn't like them and that I wanted something better. I was hoping to find some tool that parses my JS to AST, figures out what was being exported (e.g. what was public) and writes a…
As others have said, you can always strip comments in production builds. But I agree that this is utterly silly - I'd like to see a movement to deprecate including comments in parsing at all. Anything that makes use of such a feature is hacky weirdness from the start.
I think all the dissenters missed that part (about it being "one point" in favor/not in favor). I thought programmers were supposed to be good with subtle details, but it seems like the majority of them lose that ability when talking about religious topics.
Re: Node.js: Some quick optimization advice
#74Earlier quoted context omitted.
I still don't understand that. Function.prototype.toString() wouldn't break because the parser stripped the comments, it would just output the source without comments? Does any code anywhere depend on the comments being preserved?
People literally toString functions and parse them to implement features. Those features depend on there being comment text in the function that they parse. Pretty much a terrible hack but it is true that you can't remove the comments without breaking current code.
Surely this must be undocumented features of the language spec?
Re: Node.js: Some quick optimization advice
#75Earlier quoted context omitted.
it's incredible that that project has 11,000 commits, a huge amount of effort has gone into it but the code is really unpleasant to read. I feel like I must be missing something about FOAM - who is using it and why?
Let's stop trashing on people's work. The success of an endeavor is proportional to the number of shitty hacks that have come before it. Sometimes this it true in a literal sense -- sometimes a project consists of shitty hacks. But the astute reader will notice that a hack is only known to be shitty because someone did it , and had the courage to make their example public. Do we reward their courage? No. We act like…
I shouldn't have said that the code was unpleasant, which is obviously subjective, but I should have said "the code style is quite unusual for JS", which it is. It was certainly not my intention to "trash their work".