News for hackers. Stuff that matters.
Re:Ten years of V8 by Scarbutt on Tuesday September 11, 2018 @03:42PM (#17962664)
Interesting note about code comments in V8: 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.

Re:Ten years of V8 by magicalist on Tuesday September 11, 2018 @07:07PM (#17964219)
> 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?

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.

Re:Ten years of V8 by asdfasgasdgasdg on Tuesday September 11, 2018 @07:24PM (#17964312)
I 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.
Re:Ten years of V8 by ridiculous_fish on Wednesday September 12, 2018 @01:09AM (#17965703)
JS is full of fun facts, like that ++ is different than +=1, or that ToInteger may return negative zero.

Better naming can't justify these head-scratchers. As an implementor all you can do is write a loud! comment! referencing the spec, and add a test or two or a million.

Anything that implements a spec needs copious comments to justify the implementation. clang for example is chock-full of references to the C99 standard.

Re:Ten years of V8 by skybrian on Tuesday September 11, 2018 @09:25PM (#17964889)
I 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.

Re:Ten years of V8 by asdfasgasdgasdg on Wednesday September 12, 2018 @06:22PM (#17974008)
Great 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.
Re:Ten years of V8 by lostctown on Tuesday September 11, 2018 @11:06PM (#17965307)
This is fantastic advice.
Re:Ten years of V8 by hayd on Tuesday September 11, 2018 @04:16PM (#17962951)
Are there plans to rewrite/port Spidermonkey to rust as part of the Servo project?
Re:Ten years of V8 by cpeterso on Tuesday September 11, 2018 @05:08PM (#17963382)
Not 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...

https://medium.com/@jponge/the-graalvm-frenzy-f54257f5932c

Re:Ten years of V8 by Thaxll on Tuesday September 11, 2018 @04:35PM (#17963124)
Yet spidermonkey is slower.
Re:Ten years of V8 by zbraniecki on Tuesday September 11, 2018 @04:41PM (#17963169)
Source?
Re:Ten years of V8 by microcolonel on Tuesday September 11, 2018 @04:00PM (#17962804)
For 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.
Re:Ten years of V8 by forgotpwd16 on Tuesday September 11, 2018 @04:37PM (#17963136)
>Smalltalk VM (which is the ancestor of V8)

In that both utilize JIT compilation or in other ways too?

Re:Ten years of V8 by pawelmurias on Tuesday September 11, 2018 @05:25PM (#17963516)
It has some code from strongtalk. V8 has (some) developer who worked on smalltalk vms
Re:Ten years of V8 by pjmlp on Wednesday September 12, 2018 @03:48AM (#17966331)
Lars Bak
Re:Ten years of V8 by Leszek on Tuesday September 11, 2018 @04:53PM (#17963265)
In that V8 makes heavy use of inline caches
Re:Ten years of V8 by frou_dh on Tuesday September 11, 2018 @03:58PM (#17962784)
What's interesting about it? Not surprising that projects show some variance in how much documentation there is and where it lives.