Live data from Hacker News

Block Comments Are a Bad Idea

futhark-lang.org

1–10 of 84 posts

Re: Block Comments Are a Bad Idea

#2
How would one do inline comments without block comments?

I don't know if Python's triple-quote can be used inline, but otherwise that seems like a good solution. I am not entirely familiar with Python comments, does any of his arguments apply to triple-quotes?

Re: Block Comments Are a Bad Idea

#4
post #2

How would one do inline comments without block comments? I don't know if Python's triple-quote can be used inline, but otherwise that seems like a good solution. I am not entirely familiar with Python comments, does any of his arguments apply to triple-quotes?

Triple-quotes are string literals, not comments. It's just that a string literal at the start of a function, file, or class is a docstring.

Re: Block Comments Are a Bad Idea

#7
This is my personal preference, but from experience I prefer languages that don't shun concepts because they're bad programming practice. I can understand if something is difficult to implement or prevents other features from being added, but if a feature is possible, I say add it---it might come in handy sometimes. There's a reason languages like C, C++, Ruby, and Javascript are immensely popular. It's because programmers can use and abuse any nook and cranny of it when needed, because they let you mess with pointers, use goto, redefine language keywords through macros, patch standard libary functions/classes, etc. If programmers want to write bad code, let them write bad code. You can't magically make a bad programmer write good code because of restrictions of the language. I've seen some horribly written Haskell for example, despite how "perfect" the language is designed.

For blocks comments in a functional language though, it might work because many people would come from LISP/Scheme, where block comments were never a thing (I think.)

Re: Block Comments Are a Bad Idea

#8
post #7

This is my personal preference, but from experience I prefer languages that don't shun concepts because they're bad programming practice. I can understand if something is difficult to implement or prevents other features from being added, but if a feature is possible, I say add it---it might come in handy sometimes. There's a reason languages like C, C++, Ruby, and Javascript are immensely popular. It's because progr…

See also GOTO which is a wart 99.9% of the time but really useful for writing e.g. parsers.

Re: Block Comments Are a Bad Idea

#9
The D Programming language has a neat trick to block commenting out code for debugging purposes. Wrapping code in a version(none) {} block will exclude the block from compilation. The code inside the block must still be syntactically valid so it avoids the problem mentioned in the linked post.

The D Programming Language - Conditional Compilation: https://dlang.org/spec/version.html

Re: Block Comments Are a Bad Idea

#10
You don't have to solve all edge cases for a feature to be useful. At least not all the time.

I, am not too unhappy with the behaviour of C/C++/Java/... - That the block comment will end at the first occurence of " * / ".

If I accidentally close a comment too early (because there already was another block comment inside the code I want to comment), then...

* The syntax highlighting of my IDE will tell me.

* The compiler will tell me.

* I can take it as an opportunity to consider whether this file is too large - That problem should not have happened at all.

Post reply on HN