8 ms·
Nodyn – Node.js for the JVM
- JosephRedfern 13y agoAre there any benchmarks of DynJS vs v8? Presumably it's considerably slower, but it'd be interesting to see by what order of magnitude...
- lanceball 13y agoNone published, but your presumption is correct for the time being.
- waterfowl 13y agoDown already?
- mmanfrin 13y agoQuestion from a novice-ish developer: What is the purpose of porting things to the JVM? I had this idea before that porting things like Ruby or Rails to the JVM was meant to offer ruby the advantages of having a java core (better threading, garbage collection, faster). But, as I understand it, Node is faster than JVM languages? What are the other advantages gleaned from porting? e: Thank you guys for the answers, definitely makes a lot more sense now.
- jamesbritt 13y agoJruby lets your ruby code use any Java library and gui toolkit. This is quite useful. Also, if you work at a Java shop having stuff run on the JVM affords a way to sneak in new tech. :)
- moondowner 13y agoIn my opinion (I'm a Java dev), the main benefits are being able to run RoR apps on TorqueBox[1] or some other JRuby server[2] and benefit the clustering, HA and other stuff that go with it; and 'the use of "true" native threads'[3]. [1] http://torquebox.org/ http://torquebox.org/ [2] https://github.com/jruby/jruby/wiki/Servers https://github.com/jruby/jruby/wiki/Servers [3] http://www.restlessprogrammer.com/2013/02/multi-threading-in-jruby.html http://www.restlessprogrammer.com/2013/02/multi-threading-in...
- jmgrosen 13y agoIt seems like a major motivation for this project is to be able to use Java libraries from Javascript (a la Jython). There are a non-negligible number of libraries that only exist for Java, and being able to harness those from JS sounds nice to me, even if it means taking a performance hit.
- mmanfrin 13y agoOhhhh, so one would just make like a node interface for some Java library, and it would be available for use in any JVMNode app? This makes a lot of sense.
- dragonwriter 13y ago> Question from a novice-ish developer: What is the purpose of porting things to the JVM? Interop with the things that already exist in the Java ecosystem. > I had this idea before that porting things like Ruby or Rails to the JVM was meant to offer ruby the advantages of having a java core (better threading, garbage collection, faster). To the extent that those were effects of porting Ruby to the JVM they were mostly secondary, Java interop was the key feature (Rails, BTW, wasn't ported to the JVM, it just runs anywhere you have a functional Ruby implementation -- heck, before Ruby had executable specs, the test for a functional implementation was pretty much "does it run Rails".)
- deleted 13y ago[deleted]
- justinsb 13y agoThe JVM gives you very good JIT, GC, threading, manageability (profiling, debugging, memory inspection etc), scalability to huge machines, a huge ecosystem of software and has basically solved every real-world deployment problem. (Maybe apart from memory utilization!) It is definitely possible to beat the JVM on any one of these facets, but to consistently beat it on all of them is a _lot_ of work. (I'm not sure which benchmark you're referring to where Node beats the JVM, but I suspect it's relatively 'focused'.) To my mind, the idea of porting is that you face a choice: you can recreate the JVM functionality in your own runtime, or you can port to the JVM. Porting to the JVM is certainly non-trivial, but you then get thousands of man-years of work in return. It's certainly worth doing a project to see whether the porting effort pays off; especially if this done concurrently with working on the language's 'native' runtime.
- mmanfrin 13y agoVery thorough answer, thank you :]
- dmpk2k 13y agobut to consistently beat it on all of them is a _lot_ of work. As long as you aren't native, that is. Although that's unrelated to the discussion at large.
- pcwalton 13y agoEven then it's not that easy. A non-optimizing C compiler will have a hard time beating the JVM's slew of optimizations.
- erichocean 13y agoA non-optimizing C compiler Is there a C programmer on the planet that does production builds with a non-optimizing compiler? How is your comparison even remotely relevant to the GP?
- bruceboughton 13y ago
- jonny_eh 13y agoImagine that you just started a new job at a big company. It's a "Java shop". You're allowed to use any technology stack you want for your apps, and all the other apps have APIs, but there's hundreds of useful Java libraries that already exist for talking to these APIs. This would allow you to use NodeJS but still leverage the existing Java libraries, not requiring you to rewrite them.
- pron 13y agoNode is actually much slower than Java. True, the JavaScript implementation on the JVM is slower than V8 (even Nashorn, the new JavaScript engine included in Java 8). Of course, the main motivation is, as others have said, integration with the huge Java ecosystem, but being able to drop down to Java for performance (when you need it) is a lot easier than writing native V8 modules.
- dmpk2k 13y agobut being able to drop down to Java for performance (when you need it) is a lot easier than writing native V8 modules. There's a node-ffi package, although it has some overhead from the call itself. https://github.com/rbranson/node-ffi https://github.com/rbranson/node-ffi
- ww520 13y ago> But, as I understand it, Node is faster than JVM languages? What is the source for that?
- Edmond 13y agoNaive (and mostly ignorant) programmers make a habit of sh*tting on the JVM and the Java platform in general. My usual response regarding the merit of the JVM is this: there is a reason there's jvm on the server, desktop, on your phone, on the rovers on mars and god knows on how many mission critical systems. And no it isn't because of great marketing, which is another common and lame response from JVM detractors. The JVM is an impressive engineering effort and the eco-system spawned by it is currently unrivaled. With the new trend of porting other languages (ruby,python,js..etc) to it, the I see the JVM as the middleware over which most future software would be built.
- peterashford 13y agoAre you really claiming that Node is faster than Java? Source?
- tootie 13y agoNode is more adept at handling many concurrent requests due to its architecture but it's runtime is far slower than the JVM. The vert.x framework that is the basis for this project is based on a similar paradigm to node and is far faster.
- MichaelMoser123 13y agoto run it 'in the cloud'; most hosting places will allow you to run java only, this restriction is in place so that everything will seem secure and divided into neat compartments.
- eweise 13y agoCool and if I combine it with http://www.scala-js.org/ http://www.scala-js.org/ I'll be able to run scala on the jvm.
- vezzy-fnord 13y agoI'm not sure what you meant here, considering Scala already does run on the JVM.
- peter_l_downs 13y agothatsthejoke.gif
- fisherprice 13y agoAnother product without any problem being solved. V8 is in many regards better (especially memory footprint and ramp-up time) or on par. > clear access to Java directly in your Javascript. Who needs this when having access to 50K nom packages?
- jamesgeck0 13y agoI would venture to guess that interoperability with existing projects and services is important to some people. Also, there are Java libraries which are significantly better than their closest corresponding Node package.
- camus2 13y agoWhy would you code in Javascript on the JVM to begin with if you have existing projects and libraries written in java ? that's stupid. If the goal is async IO there is Vert.x and other non blocking servers already. Not even talking about cases when libs require C++ extensions... Can you code in Java on Nodyn? no EDIT : seems to be built upon Vert.x ? you can already code in javascript with Vert.x
- Veratyr 13y agoBut if you code JS for Vert.x, you're restricted to Vert.x for life. This way you write JS for Node and you can run it under either Node or the JVM.
- lanceball 13y ago"that's stupid" is a pretty broad statement. There are many reasons why one may choose to write new software in JS while taking advantage of existing investment in Java. If it doesn't make sense for you, don't do it. But for many it may. As for coding Java on Nodyn, well, yes you can. That's kind of the point in some ways. You can write Java, package it as a jar and access this from Nodyn. Nodyn itself does this for the Buffer implementation. Yes, vert.x already supports JS (I maintain the mod-lang-js, mod-lang-rhino and mod-lang-dynjs language modules for vert.x). The idea behind Nodyn is to provide drop-in Node.js compatibility in the Vert.x environment.
- rubiquity 13y agoI personally have been wanting a way to compile ClojureScript to JavaScript without using the JVM. I'd rather just use the existing Node/v8 installation that I have, especially since I don't use the JVM for anything else. I know this project doesn't do that, I'm just throwing my wants and desires out into the wild and hoping they come alive.
- chc 13y agoDon't forget that ClojureScript macros are written in Clojure. Even if you rewrote the compiler in ClojureScript, it seems like you'd need the JVM to run your Clojure macros (unless you were OK with sacrificing some compatibility).
- matt_heimer 13y agoHow is this different than https://avatar-js.java.net/ https://avatar-js.java.net/ ?
- lanceball 13y agoSame idea, different project.
- moondowner 13y agoAnd different technologies (and possibly different ways of implementation under the hood). Nodyn uses DynJS, this uses Nashorn.
- kybernetikos 13y agoThe focus of avatar-js seems to be to support the avatar project, which seems to be mainly about providing a node like server. At present, there aren't nice binary downloads for anything that can just run node programs, I had to fiddle about a bit to get something I could play with, and even then, only some programs work - npm for example seems to go into a loop. https://github.com/kybernetikos/avatarjs-sandbox/tree/master/Avatarjs-Sandbox https://github.com/kybernetikos/avatarjs-sandbox/tree/master...
- chrisfarms 13y agoTake it this is Rhino under the hood somewhere, or has someone written a new js engine?
- mindcrime 13y agohttp://dynjs.org/ http://dynjs.org/ is, AFAIK, independent of Rhino.
- chrisfarms 13y agoThanks. I'd totally missed that.
- Edmond 13y agoThanks for that pointer, didn't know of this. Also for anyone interested in an easy way to use the JVM for other languages, check out crudzilla.com . It is primarily for web development but has basic editor for other development work.
- qmxtheros 13y agoyup, it's independent, you can get more context on why I created dynjs here: http://blog.qmx.me/the-release/ http://blog.qmx.me/the-release/
- sitkack 13y agoIs there any plan to implement asm.js and JIT to JVM bytecode directly from JS?
- lucian1900 13y agoAfter a cursory look through the source, it would appear that it already JITs to JVM bytecode. asm.js isn't relevant here at all.
- chrisseaton 13y ago
- tylerdavis 13y agoNan Pointer Exception
- bokchoi 13y agoNeat, I hadn't come across DynJS yet. It would be nice if the landing page mentioned how the project is different from Nashorn and Rhino.
- Touche 13y agoAny relation to the Node.jar project?
- SeanDav 13y agoNot in any way trying to troll here, but other than as an intellectual exercise, why on earth would one want to develop in Node on the JVM? Surely Java/Scala/Clojure etc would solve any problem easier and faster than Node on JVM? What am I missing?
- lanceball 13y agoAs the creator of Nodyn, but being late on the draw, I'll just have to echo what everyone else has said here. Java provides a large and rich ecosystem that is either unavailable or prohibitively difficult to bundle into a native runtime. Nodyn is not yet complete, though I'd like to have a release in the next month that is capable of running express.js apps. It is slower than Node.js, but of course I'd like that to change; and with the JVM underneath, beating Node.js on performance is possible. Nodyn is built on top of Vert.x (http://vertx.io http://vertx.io) an asynchronous polyglot platform which excels on the Techempower benchmarks. The javascript runtime is DynJS - a new JS runtime for the JVM which is independent of Oracle. Though it's admittedly slower than Nashorn at the moment, we hope for that to change.
- notastartup 13y agoYes this is what I've been looking for. I gave up trying to get Vert.x running before, but I'm willing to give this a try.
- nl 13y agoGiven the asynchronous programming model that node encourages, how have you found integrating with the traditional Java programming model that most of the Java ecosystem uses?
- RyanZAG 13y agoVert.x has something called a 'worker verticle' that can run blocking IO in a thread pool. You'd communicate with the worker by passing messages on the event bus asynchronously. It makes integrating those kind of services fairly straight forward, but obviously you'd switch to actual async APIs if available.
- egeozcan 13y agoWill it have the concurrency features of Vert.x? I was hoping that jxcore [1] (aka NodeJX) would bring these to node but this seems like a better alternative. [1]: http://jxcore.com/ http://jxcore.com/ edit: > All that with vert.x's powerful clustering technology built right in I think I missed that part. Sorry =)
- frik 13y agoI am still waiting for Node.js on Mozilla Gecko javascript engine (instead of V8). Is someone working on it?
- Kiro 13y agoWhat would the benefit be?
- pritambaral 13y agoApart from "competition"? Mozilla's JS engine has gotten on par with V8.
- moondowner 13y agoWhat's the difference between using Vert.x with DynJS and using Nodyn? Nodyn is ment to be a drop-in replacement for Node.js right?