3 ms·
And thus, Lua's source code gained a kilobyte worth of */
by scythe 4y ago
And thus, Lua's source code gained a kilobyte worth of */
- Stratoscope 4y agoIt's even worse than that! (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. I humbly apologize, and hang my head in shame.
- fsckboy 4y agoIf 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)
- djbusby 4y agoBeach day is more important than 1TB and some chars that are auto-completed by the IDE.