7

I have found some articles saying that FF's JavaScript engine partially adopted Chrome's V8 features, or even that some of its source code is from V8!

If so, can I say that replacing the JavaScript engine in Firefox with Chrome's V8 is easy as pie?

If not, what's the difference?

ggorlen
  • 44,755
  • 7
  • 76
  • 106
Spry Mickael
  • 71
  • 1
  • 1
  • 4

2 Answers2

9

The only V8 source code that Firefox uses is things that were factored out into separate libraries (e.g. some of the numeric conversion code), as far as I know.

The reasons to not adopt V8 wholesale are that it has certain bugs that SpiderMonkey (the JS engine in Firefox) doesn't have, is missing some features that SpiderMonkey has, and Firefox would not be able to introduce new features for JS until the V8 folks got around to it.

Boris Zbarsky
  • 34,758
  • 5
  • 52
  • 55
  • But there is a folder named V8 in the js/src folder of the FF source code,so I guess FF must have borrowed some code from chrome,and that is where I am confused.and can you tell me what do you mean by saying "Firefox would not be able to introduce new features for JS until the V8 folks got around to it"?3x. – Spry Mickael Apr 05 '12 at 08:41
  • 1
    @SpryMickael That's the V8 benchmark (yay Google reusing the same name for multiple somewhat unrelated things), as you can tell by just looking in the folder. As for what I mean... if Firefox were just using V8, it wouldn't be able to introduce new features until they were accepted into V8. Unless they forked it, of course, which seems even worse. – Boris Zbarsky Apr 05 '12 at 14:21
0

Chrome engine is faster (that Google claims).

Sytax is the same.

Nevermind: I haven't seen question description. Why they won't replace entire Javascript engine with V8? Because that it's Google and they don't want to have more than 1% of Google code in their code. They want to be 'independent'.

djmati11
  • 597
  • 5
  • 18
  • Actually, the syntax is not the same. SpiderMonkey supports various features (like `let`) that V8 doesn't support. – Boris Zbarsky Apr 02 '12 at 02:35
  • You _can_ if you try hard enough. But it's quite possible to write JS that works only in one or the other, because they don't implement the same set of features. – Boris Zbarsky Apr 04 '12 at 18:56
  • You mean that I can replace FF's SpiderMonkey with V8 in chrome if I abandoned these features in FF? – Spry Mickael Apr 05 '12 at 08:37
  • 1
    Tracking performance of popular JavaScript engines [Are we Fast Yet?](http://arewefastyet.com) – Ihab Shoully Jul 04 '14 at 10:36