<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>pieroxy.net - node.js vs Java nashorn</title>
    <link>https://pieroxy.net/blog/2015/06/29/1435607520000.html</link>
    <description>Why did I test it?  In my current Java project, I make some use of JavaScript. Performances were quite horrendous with Rhino in java 6 and 7, but in Java 8 there is a brand new JavaScript runtime: Nashorn.  Its principal feature is that it's much faster ...</description>
    <language>en</language>
    <copyright>pieroxy</copyright>
    <pubDate>Mon, 10 Sep 2018 13:17:15 GMT</pubDate>
    <managingEditor>pieroxy</managingEditor>
    <dc:date>2018-09-10T13:17:15Z</dc:date>
    <dc:language>en</dc:language>
    <dc:rights>pieroxy</dc:rights>
    <image>
      <title>pieroxy.net</title>
      <url>https://pieroxy.net/blog/</url>
    </image>
    <item>
      <title>Re: node.js vs Java nashorn</title>
      <link>https://pieroxy.net/blog/2015/06/29/1435607520000.html#comment1536585435650</link>
      <content:encoded>Both are brilliant Javascript Engines for Java. Unfortunately you can't easily use Node.js packages with Nashorn so you're quite limited. If you are looking for &lt;a href="https://www.classboat.com/tech/java-classes-mumbai"&gt;Java Classes in Mumbai&lt;/a&gt; then you can Visit Classboat.</content:encoded>
      <pubDate>Mon, 10 Sep 2018 13:17:15 GMT</pubDate>
      <guid isPermaLink="false">tag:pieroxy.net,2015-06-29:pieroxy.net/c/1435607520000/1536585435650</guid>
      <dc:date>2018-09-10T13:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: node.js vs Java nashorn</title>
      <link>https://pieroxy.net/blog/2015/06/29/1435607520000.html#comment1525438951153</link>
      <content:encoded>19 ScriptEngines is probably overkill, but having a pool of 5 ScriptEngines might be enough. The point is to reuse them. At most, one per physical core of your server should do the trick. Note that there is most likely a memory footprint for each ScriptEngine so don't create and hold too many of them.

As far as optimistic typing is concerned, I'd suggest for you to do a small benchmark to assess the added value of that feature.</content:encoded>
      <pubDate>Fri, 04 May 2018 13:02:31 GMT</pubDate>
      <guid isPermaLink="false">tag:pieroxy.net,2015-06-29:pieroxy.net/c/1435607520000/1525438951153</guid>
      <dc:date>2018-05-04T13:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: node.js vs Java nashorn</title>
      <link>https://pieroxy.net/blog/2015/06/29/1435607520000.html#comment1525433912899</link>
      <content:encoded>Hi.. thanks for the great article.. We have application which is executing a payload against 19 JS files and each time we are creating the ScriptEngine. Shall we think about going for caching of all 19 JS with 19 ScriptEngine objects? Also I researched on NET but wasnt convinced whether we shall use Optimistic Typing.. We are execute two methods on JavaScript and one is returning Boolean and another String.</content:encoded>
      <pubDate>Fri, 04 May 2018 11:38:32 GMT</pubDate>
      <guid isPermaLink="false">tag:pieroxy.net,2015-06-29:pieroxy.net/c/1435607520000/1525433912899</guid>
      <dc:date>2018-05-04T11:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: node.js vs Java nashorn</title>
      <link>https://pieroxy.net/blog/2015/06/29/1435607520000.html#comment1514351841025</link>
      <content:encoded>Node.js and Java couldn't be much more different in the types of programmers/clients that each attracts.Thanks for sharing.</content:encoded>
      <pubDate>Wed, 27 Dec 2017 05:17:21 GMT</pubDate>
      <guid isPermaLink="false">tag:pieroxy.net,2015-06-29:pieroxy.net/c/1435607520000/1514351841025</guid>
      <dc:date>2017-12-27T05:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: node.js vs Java nashorn</title>
      <link>https://pieroxy.net/blog/2015/06/29/1435607520000.html#comment1488983757025</link>
      <content:encoded>For the code: 
To get the ScriptEngine, is not it something like: 
	ScriptEngine engine = engineManager.getEngineByName(&amp;quot;nashorn&amp;quot;);
rather than 		
	ScriptEngine engine = engineManager.getEngineByName(&amp;quot;JavaScript&amp;quot;);</content:encoded>
      <pubDate>Wed, 08 Mar 2017 14:35:57 GMT</pubDate>
      <guid isPermaLink="false">tag:pieroxy.net,2015-06-29:pieroxy.net/c/1435607520000/1488983757025</guid>
      <dc:date>2017-03-08T14:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: node.js vs Java nashorn</title>
      <link>https://pieroxy.net/blog/2015/06/29/1435607520000.html#comment1476610154738</link>
      <content:encoded>There are several known ways that node can be tricked into taking a performance hit. Another way is to reassign a variable to a different type. However, like eval, it's not something that you often do in production code, if ever. The V8 performance relies upon assumptions which are sound though not infallible.</content:encoded>
      <pubDate>Sun, 16 Oct 2016 09:29:14 GMT</pubDate>
      <guid isPermaLink="false">tag:pieroxy.net,2015-06-29:pieroxy.net/c/1435607520000/1476610154738</guid>
      <dc:date>2016-10-16T09:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: node.js vs Java nashorn</title>
      <link>https://pieroxy.net/blog/2015/06/29/1435607520000.html#comment1464340632442</link>
      <content:encoded>I did test as well, and seems that nashorn is even faster that node, the thing is that jvm initially is slow due some optimization being applied after som few thousands of iterations - i think JIT comes into play.

Btw, try code including eval functions and you will see how node becomes slow.</content:encoded>
      <pubDate>Fri, 27 May 2016 09:17:12 GMT</pubDate>
      <guid isPermaLink="false">tag:pieroxy.net,2015-06-29:pieroxy.net/c/1435607520000/1464340632442</guid>
      <dc:date>2016-05-27T09:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: node.js vs Java nashorn</title>
      <link>https://pieroxy.net/blog/2015/06/29/1435607520000.html#comment1452017438979</link>
      <content:encoded>Minification is done in test.js</content:encoded>
      <pubDate>Tue, 05 Jan 2016 18:10:38 GMT</pubDate>
      <guid isPermaLink="false">tag:pieroxy.net,2015-06-29:pieroxy.net/c/1435607520000/1452017438979</guid>
      <dc:date>2016-01-05T18:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: node.js vs Java nashorn</title>
      <link>https://pieroxy.net/blog/2015/06/29/1435607520000.html#comment1452007972517</link>
      <content:encoded>It looks like it is not minifying the JS code, just executing it in nashorn (basically loading uglify and then loading the test code, but not minifying it).</content:encoded>
      <pubDate>Tue, 05 Jan 2016 15:32:52 GMT</pubDate>
      <guid isPermaLink="false">tag:pieroxy.net,2015-06-29:pieroxy.net/c/1435607520000/1452007972517</guid>
      <dc:date>2016-01-05T15:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: node.js vs Java nashorn</title>
      <link>https://pieroxy.net/blog/2015/06/29/1435607520000.html#comment1449356448262</link>
      <content:encoded>I know I'm late to the party but I'm betting if you tied the Nashorn test to one core it would probably perform on par with node.js.  You're getting bounced between cores which causes a reload of the local cache for the core.  That's not efficient, hence why node.js runs in one core.  This LMAX Disrupter Thread and core affinity article &lt;a href="http://highscalability.com/blog/2015/9/30/strategy-taming-linux-scheduler-jitter-using-cpu-isolation-a.html"&gt;http://highscalability.com/blog/2015/9/30/strategy-taming-linux-scheduler-jitter-using-cpu-isolation-a.html&lt;/a&gt; walks through them trying  to isolate their stuff to one core for this exact reason.  At the end of the day this repo does all the affinity magic &lt;a href="https://github.com/OpenHFT/Java-Thread-Affinity"&gt;https://github.com/OpenHFT/Java-Thread-Affinity&lt;/a&gt;</content:encoded>
      <pubDate>Sat, 05 Dec 2015 23:00:48 GMT</pubDate>
      <guid isPermaLink="false">tag:pieroxy.net,2015-06-29:pieroxy.net/c/1435607520000/1449356448262</guid>
      <dc:date>2015-12-05T23:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: node.js vs Java nashorn</title>
      <link>https://pieroxy.net/blog/2015/06/29/1435607520000.html#comment1448105736426</link>
      <content:encoded>Not much of a shocker. One thing to remeber with Node.js is that V8 is awesome when it comes to arithmetic operations. Numbers can typically be converted to native ints and all processes have native math instructions. Other JS objects however don't have true native equivalents, and their methods don't have native equivalent instructions, so the whole idea of converting them to machine code is a bit a stretch. Strings are somewhat of an exception because chars are after all just ints, and char/string functions are typically some form of arithmetic. Long story short, V8 is able to crunch numbers (and chars) without fluff, just pure raw machine instructions. Dumping 10,000 strings into a database however will show that node.js isn't always quicker then alternatives.</content:encoded>
      <pubDate>Sat, 21 Nov 2015 11:35:36 GMT</pubDate>
      <guid isPermaLink="false">tag:pieroxy.net,2015-06-29:pieroxy.net/c/1435607520000/1448105736426</guid>
      <dc:date>2015-11-21T11:35:36Z</dc:date>
    </item>
  </channel>
</rss>

