6 ms·
Interesting note about code comments in V8: https://www.openhub.net/p/v8-js/factoids#FactoidCommentsVeryLow https://www.openhub.net/p/v8-js/factoids#FactoidComm
by Scarbutt 8y ago
Interesting note about code comments in V8:
https://www.openhub.net/p/v8-js/factoids#FactoidCommentsVeryLow https://www.openhub.net/p/v8-js/factoids#FactoidCommentsVery...
Spidermonkey is one third of the size(LoC) of V8 and has three times more comments.
- folkrav 8y ago> A high number of comments might indicate that the code is well-documented and organized, and could be a sign of a helpful and disciplined development team. Watch out for the "self documenting" comments coming up. Disclaimer : I don't agree that code is inherently self-documenting, especially in terms of intent and implementation choice.
- frou_dh 8y agoWhat's interesting about it? Not surprising that projects show some variance in how much documentation there is and where it lives.
- microcolonel 8y agoFor what it's worth, a lot of the documentation for the structure of V8 is in textbooks and decades of precedent set by the Smalltalk VM (which is the ancestor of V8). I suspect that people who worked on HotSpot will tend to understand V8 at some level.
- forgotpwd16 8y ago>Smalltalk VM (which is the ancestor of V8) In that both utilize JIT compilation or in other ways too?
- Leszek 8y agoIn that V8 makes heavy use of inline caches
- pawelmurias 8y agoIt has some code from strongtalk. V8 has (some) developer who worked on smalltalk vms
- pjmlp 8y agoLars Bak
- hayd 8y agoAre there plans to rewrite/port Spidermonkey to rust as part of the Servo project?
- cpeterso 8y agoNot at this time. The SpiderMonkey code is evolving quickly and Rust's safety guarantees won't help much when executing the JIT-generated code. Servo uses SpiderMonkey. The SpiderMonkey team has prototyped some JITs using Rust. The "Holy JIT" (a pun on Oracle's Graal VM name) is a meta-compiler for JITs: https://blog.mozilla.org/javascript/2017/10/20/holyjit-a-new-hope/ https://blog.mozilla.org/javascript/2017/10/20/holyjit-a-new... https://medium.com/@jponge/the-graalvm-frenzy-f54257f5932c https://medium.com/@jponge/the-graalvm-frenzy-f54257f5932c
- Thaxll 8y agoYet spidermonkey is slower.
- zbraniecki 8y agoSource?
- magicalist 8y ago> Spidermonkey is one third of the size(LoC) of V8 and has three times more comments Is that based on https://www.openhub.net/p/spidermonkey https://www.openhub.net/p/spidermonkey? It says last analyzed two years ago, but the last commit it includes looks like it was in April 2011. LoC is a silly measure for complexity anyways :) Does it include tests and test runners? Generated files? v8 is in its own repo while spidermonkey is in the main mozilla repo, so it's going to be difficult to compare well.
- asdfasgasdgasdg 8y agoI also think in many cases comments serve as a stand-in for poor design. These days, when I catch myself writing a comment, I try to think of whether I could choose a better name for a variable or method instead, or if I could add an assertion to clarify that an invariant holds in a particular location. Comment rot also makes ordinary code rot look like a walk in the park. Since comments aren't tested, they rot incredibly quickly without meticulous double-checking every time you modify the code. In a heavily-commented, older codebase this become super annoying, since every other line is a comment that, ten percent of the time, doesn't hold any more.
- deleted 8y ago[deleted]
- skybrian 8y agoI think the problem of stuff going out of date can be avoided by giving background (why it was originally written) rather than making a commitment you can't keep about keeping it up to date. Knowing why code was originally written can be more important than knowing what it currently does.
- lostctown 8y agoThis is fantastic advice.
- asdfasgasdgasdg 8y agoGreat advice, and it does resonate. FWIW I'm certainly not a "no comments" guy. I just like to check myself to see if there is a better way to accomplish what I was going to do with a comment.