is about line comments. C gets credit for the // comments, starting in 1972, but that's not really accurate. BCPL -- which begat B which begat C -- had // comments but they were not included in C until C99. C++ (which isn't included in their top 30 languages) brought back // comments from BCPL sometime between 1979 and 1985 (the first public release of cfront). Many C compilers included // comments as an extension prior to C99 but those were inspired by C++.
This brought back a vivid memory. Sometime in the late 1980s there was a C standards committee meeting in the San Jose area, leading up to the C89 standard.
I was acquainted with one of the committee members and called him to ask if // comments would be included in the standard.
He told me there was no plan for this, but if it was something I felt strongly about, I would be welcome to visit the committee meeting and lobby for it.
I thought about doing this, but didn't bother since all the C compilers I was using already supported // comments.
I also wasn't sure how I would lobby for it.
In hindsight, it would have been a lot of fun to just show up wearing a "sandwich board" with a big // printed on front and back.
Memory is a funny thing. I don't remember the committee member's name or exactly when I called him, but I could tell you exactly where I was sitting and which direction I was facing when we talked. I also think it was before I got married, so that would put the call perhaps sometime in 1987.
Any old-timers here happen to know when that meeting was?
(For anyone wondering what we're talking about, Lua is written in a very portable subset of C including pre-C99, so no // comments.)
I got curious and downloaded the Lua 5.4.4 source and ran this:
$ cat * | grep -c ' */'
6386
(If there is a better or more correct way to do this, anyone feel free to correct me, as my grep-fu is muy pobre.)
So this is 6386 * 3 = 19,158 characters wasted in this version of the Lua source.
And that's just one Lua version.
Let's assume there are ten million copies of various versions of the Lua source on developer machines and repos around the world. That would make this something on the order of 200 gigabytes. We'd better multiply that by 5 to account for backups and datacenter redundancy.
So my selfish and lazy decision to go to the beach instead of the committee meeting that day has cost the world a terabyte of storage, maybe much more.
And that's the least of it. I didn't account for the extra typing that /* comment */ takes, and how it's just not fun to type all that. So I have annoyed every developer who's had to do this for compatibility reasons. Including myself.
If there is a better or more correct way to do this, anyone feel free to correct me, as my grep-fu is muy pobre.
$ cat * | grep -c ' */'
6386
Doesn't that * in your regular expression mean "greedily match as many of the preceding SPACE character as possible including zero, followed by the /" ?
So, what you've done is counted all the slashes in the code. Let's imagine that there are not many divide /, and there are not that many pathname /, so you're double counting the comments and should at least divide your 6386 in half
you want
$ cat * | grep -c ' \*/'
the backslash is protected by the single quotes, so it will get passed to grep where it will mean "literally *" rather than the regular expression operator * (now I'm thinking my \ is going to get swallowed up by HN so I'd better double them? ed: nope, didn't have to double, but I did have to backslash escape the asterisk after literally)
https://pldb.com/posts/does-every-programming-language-suppo...
is about line comments. C gets credit for the // comments, starting in 1972, but that's not really accurate. BCPL -- which begat B which begat C -- had // comments but they were not included in C until C99. C++ (which isn't included in their top 30 languages) brought back // comments from BCPL sometime between 1979 and 1985 (the first public release of cfront). Many C compilers included // comments as an extension prior to C99 but those were inspired by C++.