News for hackers. Stuff that matters.
Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by underbluewaters on Tuesday January 19, 2016 @12:48PM (#10932373)
I don't understand what the goal is here. Honest question, not a criticism. Can someone please explain. Is the intention to have node work on multiple Javascript engines like spidermonkey? I can see why Chakra developers could want this but as a developer using node I don't see how I would benefit.
Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by dsp1234 on Tuesday January 19, 2016 @12:58PM (#10932447)
Competition in the space leads to better engines.

I put a link in another comment to last week's discussion on the topic. But my main concern is developers writing code that tries to bend around then V8 implementation, even if it's not required by the language.

One great example from that thread was about try/catch:

"For example, a try/catch in V8 triggers deoptimization for the entire function it's in, while it might not in other engines. So this leads to many developers avoiding try/catch in performance critical code. This ends up with them avoiding it in general usage, which means that now "avoiding try/catch" is considered a general purpose performance tip in javascript, even though it might only apply to one engine (and the v8 team has expressed interest in trying to stop that deopt)"[0]

"It is a good example actually. Chakra does fully optimize functions with try/catch. Caveat: we don't optimize try/finally yet... Disclaimer: I work for MSFT on Chakra."[1]

"try/catch has pretty much no runtime overhead in SpiderMonkey unless an actual exception is thrown."[2]

[0] - https://news.ycombinator.com/item?id=10896729

[1] - https://news.ycombinator.com/item?id=10896971

[2] - https://news.ycombinator.com/item?id=10897851

Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by Klathmon on Tuesday January 19, 2016 @01:03PM (#10932492)
And that was just the first thing off the top of my head, there are tons of other little performance things that many people consider a "JavaScript thing" instead of a "V8 thing"
Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by Touche on Tuesday January 19, 2016 @02:45PM (#10933390)
Does it matter? If V8 deoptimizes code with try/catch, then I as a developer need to account for that.
Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by Klathmon on Tuesday January 19, 2016 @03:21PM (#10933671)
It does!

V8 has expressed interest in fixing the try/catch deopt, but it keeps falling behind on their list because not many people are using it.

Most people aren't using it because V8 (and in some minds, mine included until 5 days ago, all of Javascript) doesn't optimize it.

It's a bit of a catch 22, and having alternate engines where that deopt doesn't happen can be the way out.

Basically having an alternate engine makes sure that stuff like this doesn't become permanent. You'll probably avoid try/catch in performance code for the near future (and i'll most likely do it as well), but the hope is that multiple implementations will force V8 to fix that issue (if it can be called that) at some point and eventually this little bit of optimization will no longer be necessary.

Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by STRML on Tuesday January 19, 2016 @08:09PM (#10935359)
> it keeps falling behind on their list because not many people are using it.

How can that be true? try/catch is as common a JS idiom as a for loop.

This causes significant trouble all over React and many other libraries, as many hot areas of code are covered in try/catches to ensure developer error doesn't blow the whole render. Optimizing it could lead to pretty serious performance gains.

Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by chrisseaton on Tuesday January 19, 2016 @03:45PM (#10933863)
I don't think V8 deoptimises on a try-catch - I think it doesn't optimise in the first place. It's a bailout rather than an uncommon trap I believe.
Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by lttlrck on Tuesday January 19, 2016 @06:56PM (#10935053)
We already have alternate engines in web browsers.
Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by Sanddancer on Tuesday January 19, 2016 @08:11PM (#10935362)
Yes, you need to account for that, and potentially make the decision that you should investigate targeting a different engine as the one you develop against. Your infrastructure should absolutely not be set in stone, and this includes looking at different compilers, different javascript engines, and different operating systems. If the most straightforward way of writing your code involves lots of try/catch blocks, then it sounds reasonable that you should target an engine that provides better speed for try/catch blocks.
Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by dsp1234 on Tuesday January 19, 2016 @03:36PM (#10933796)
then I as a developer need to account for that

Why? Switch out V8 for ChakraCore. Having multiple engines means you, as a developer, get to pick the right tool for the job. That's not always V8.

Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by kuschku on Tuesday January 19, 2016 @02:58PM (#10933491)
Why? Most users aren’t on V8.
Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by Touche on Tuesday January 19, 2016 @03:03PM (#10933532)
Because a lot of them do, and nearly 100% of servers do.
Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by kuschku on Tuesday January 19, 2016 @05:40PM (#10934671)
More of a reason to stop supporting their bugs, and force users and servers to migrate to a more standard-compliant solution.

You are just turning V8 into the new IE6 by adapting to it.

(Although, in reality, you probably won’t be able to do this, and will end up having to support the non-standard behaviour of V8.)

Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by magicalist on Tuesday January 19, 2016 @10:34PM (#10935901)
I think you're confused. It's not a bug, try/catch executes just fine.

try/catch just isn't supported by V8's Crankshaft so some people avoid putting it in potentially hot code.

Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by kuschku on Wednesday January 20, 2016 @07:00AM (#10937475)
Why do they avoid using it?

That's like not using CSS3 because IE6 doesn't support it.

Sure, some users of an antiquated browser will not get the full performance, but I have no sympathy for them.

If something doesn't work on Firefox, it's always "just switch to Chrome, our site only works on Chrome". If it doesn't work on Chrome, all hell breaks loose.

Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by inglor on Tuesday January 19, 2016 @12:55PM (#10932427)
I think the goal is to have Node applications in the windows store. Having a v8 dependency there would be a big problem with embedded devices.

Microsoft is trying to get into the whole IoT hype. This would help them a lot.

It also means they can write servers on Azure that don't need to be able to run V8.

Mostly windows store apps though.

Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by pori on Tuesday January 19, 2016 @01:34PM (#10932770)
This will certainly help with the development of .NET development. My team has been burned a few times by Windows specific compilation errors.

Hopefully this will reduce the necessity to have a non-Windows machine around. That aspect has made things tedious for us.

Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by rom1504 on Tuesday January 19, 2016 @12:53PM (#10932408)
For example the chakra engine has a better coverage of es6 than v8. see edge score there https://kangax.github.io/compat-table/es6/
Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by s3th on Tuesday January 19, 2016 @01:36PM (#10932790)
We're working on updating Kangax, but V8 now has 92% ES6 coverage in Chrome Canary (on track for shipping in Chrome M49)!

Disclaimer: I work on V8

Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by sonnyp on Wednesday January 20, 2016 @03:02AM (#10936617)
How so? I just loaded es6 kangax table in Canary "Version 49.0.2566.0 canary (64-bit)" and it reports 62% for current browser.

EDIT: 92% reported for "Version 50.0.2626.0 canary (64-bit)"

nice job!

Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by johannes1234321 on Tuesday January 19, 2016 @12:55PM (#10932424)
As long as they stay compatible to each other it might create competition between engines, leading to innovation and improvement in both.
Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by cybice on Tuesday January 19, 2016 @01:07PM (#10932527)
Node v8 memory limit is the big problem for me http://stackoverflow.com/questions/7193959/memory-limit-in-n... Sometimes I need to move data outside heap memory - Buffers etc. Looks like chakra have no such problem.
Re:Enable Node.js to Run with Microsoft's ChakraCore Engine by krisdol on Tuesday January 19, 2016 @01:19PM (#10932638)
Isn't it just --max-old-space-size=whateveryouwant? The default of 512mb seems pretty reasonable.