Live data from Hacker News

Of parser-fetishists and semi-colons

christianheilmann.com

51–60 of 125 posts

Re: Of parser-fetishists and semi-colons

#51
post #13

Anyone else think this is by far the most boring technical debate ever to hit HN?

Yep. Sayre's law has kicked in with a vengeance here.

"In any dispute the intensity of feeling is inversely proportional to the value of the issues at stake."

http://en.wikipedia.org/wiki/Sayre%27s_law

Re: Of parser-fetishists and semi-colons

#52
post #13

Anyone else think this is by far the most boring technical debate ever to hit HN?

Actually, my understanding that there is nothing technical about this debate: the debate is about writing maintainable, supportable, and portable code versus "cool" code. But I also agree this is "by far the most boring debate ever to hit HN" (without technical :).

Re: Of parser-fetishists and semi-colons

#53
post #20

Haven't yet seen anyone point out what unpleasantly quirky code this was in the first place: !isActive && $parent.toggleClass('open') It should have been written like this: if (!isActive) { $parent.toggleClass('open'); } What if somebody needs to add a second bit of code to be executed if isActive is false? In the first case, they'd have to refactor the code into an if statement before adding it. It should have been…

You can always continue with

  !isActive && ($parent.toggleClass('open') || do_something_else())
but this is write-only code.

This actually reminds me of some cool hacks with structure pointers and functions in the Linux kernel.

Re: Of parser-fetishists and semi-colons

#54

All the people arguing that the code as was presented should is good and right, I present this: Everyone knows that debugging is twice as hard as writing a program in the first place. So if you are as clever as you can be when you write it, how will you ever debug it? ~Brian Kernighan I couldn't tell that the second line in the code in question was an if statement at first without actually thinking about it. How is t…

I imagine you would get used to viewing that statement as a conditional. Hell, I think most people involved with this debate would recognize it now.

Re: Of parser-fetishists and semi-colons

#55
post #13

Anyone else think this is by far the most boring technical debate ever to hit HN?

I think this piece is a great place to end it, as it builds a solid pragmatic case.

It was interesting for me to learn about the possibility of using that kind of '!' notation in JS, even if it's impenetrable to most other developers. Maybe I'll be able to parse some other hipster's code thanks to this.

Re: Of parser-fetishists and semi-colons

#56
post #50

Earlier quoted context omitted.

Disagree. This is so much worse than that. At least with Hungarian notation (which thankfully died a well-deserved death), its advocates were arguing for a relatively well thought-out system of readability and tying member names to their types for quickly-identifiable scope and type referencing. But, to suggest that simply removing semicolons constitutes some grand gesture towards readability, simplicity, or somethin…

But you're... you're doing it. Look at yourself. You have a strong opinion about using semicolons.

Oh Good God, it's true.

"We have met the enemy, and he is us."

http://ow.ly/ajyBJ

Re: Of parser-fetishists and semi-colons

#57

I come from a Python background. However, thanks to work and school, I now program mostly in JavaScript, PHP, and Java (though I still use Python when I get a chance). Now, I could use underscore_names in Java and JavaScript, but I don't. Even though I personally prefer underscore_names to camelCaseNames, I also realize that those languages are designed with camelCaseNames in mind, that the community conventions are…

I think your camelCase example really nails it. Code should be written in a way that is both non-ambiguous and idiomatic to the existing codebase.

If you're in a position where you can define that idiom, then by all means do so. But stay consistent so that when others join a project, or you leave a project, the intent of your codebase is well understood without needing to wade through pages of documentation.

So, IMO, while semicolons are important, they're relatively trivial and an easy "bug" to fix. If I'm looking for an authority, I typically check out the Google Style Guides.

A similar, though more pressing issue that I've faced recently is the proper parenthization of conditions for if. It's generally nice when you don't have to spend a minute or two remembering/looking up the nuances of C++ operator precedence. Know all of the intricacies and tricks for a language doesn't mean every member of your team knows them that well either.

Re: Of parser-fetishists and semi-colons

#58
I think the real issue in the whole debate is that 95%+ of people programming do not understand how programming languages are implemented and haven't been exposed to basic theoretical stuff e. g. to the fact that languages can be ambiguous, that there are cases where it might be impossible to interpret a part of the code, that handling syntax errors is actually hard etc. This post is a good example, it completely misses the point, as the only reason semicolons are present in some languages is to make parsing possible. I think many people would not argue about this if they had a clue why programming languages syntax is the way it is.

Re: Of parser-fetishists and semi-colons

#59

I come from a Python background. However, thanks to work and school, I now program mostly in JavaScript, PHP, and Java (though I still use Python when I get a chance). Now, I could use underscore_names in Java and JavaScript, but I don't. Even though I personally prefer underscore_names to camelCaseNames, I also realize that those languages are designed with camelCaseNames in mind, that the community conventions are…

Your comment makes me wonder if this is localized issue, or a more general anti-pattern in polyglot programming. The pattern being: "push my favorite language into the other ones I use". It may or may not be covered by "you can write FORTRAN in any language", or some sort of corollary to Greenspun's 10th law.

Re: Of parser-fetishists and semi-colons

#60
post #13

Anyone else think this is by far the most boring technical debate ever to hit HN?

I think it's so boring because it's a one-sided debate.

One side chooses a style that they find aesthetically-pleasing even if it causes issues for some small subset of potential users.

The other side is flabbergasted that someone would be so reckless and argues for the sensible, safe option, which requires simply terminating your lines of code with an extra character, making those few issues for a small subset of potential users vanish instantly.

Post reply on HN