8 ms·
PurpleJS – An alternative to Node.js for Java projects
- gfosco 10y agoWhy don't any of the examples use Java?... Even the examples on GitHub, none of it looks any different than a Node.js project.
- mgkimsal 10y agoBecause it's still javascript, just running on JVM instead of... v8? At least, that's my read of the project.
- gfosco 10y agoOk, that's part of it. This line from the page is what gets me, "create server applications with Javascript but access and use Java libraries" and I think an example of that is very important.
- jsuperman 10y agoActually, the best example of that is already mentioned in the article: "With Enonic XP, the combination of Java and JavaScript is used to speed up the development process and allow frontend developers to implement backend services. I saw that this was a very popular approach to develop software more effectively, and wanted everyone to be able to use the technology for free and in existing investments. PurpleJS was born." PurpleJS is the core of Enonic XP, made available separately as an open source project (well, both are open source).
- partycoder 10y agoAn oversimplified way to describe node.js is: javascript bindings for libuv. purpleJS would be javascript bindings for some Java framework.
- skanga 10y agoCheck here: https://github.com/purplejs/purplejs-examples/tree/master/sysinfo https://github.com/purplejs/purplejs-examples/tree/master/sy...
- cheriot 10y agoThis could be pretty cool. So in theory, all the Java, Scala, etc servers out there can wire up an isomorphic single page app without calling out to a Node process. Once the docs are written... https://github.com/purplejs/purplejs/wiki/Embedding https://github.com/purplejs/purplejs/wiki/Embedding
- premium-concern 10y agoOr you use Scala and Scala.js and just get things done.
- stenrs 10y agoSorry about that. The embedded mode is not yet documented, but I can certainly help you with embedding into existing systems.
- lcfcjs 10y agoGet your JS to run as slow and crappy as a real Java application! :)
- fredliu 10y agoIsn't use case proposed by PurpleJS covered by Vert.x already? Or am I missing anything?
- stenrs 10y agoVert.x is similar. PurpleJS tries to make development of your webapps easier by combining the require-js model and a "sinatra"-way of developing rest endpoints.
- ilaksh 10y agoI didn't see any mention of Rhino. Does he know that existed (exists?)?
- hibbelig 10y agoThis uses Nashorn to execute the Javascript.
- ilaksh 10y agoOh ok so thats the new version then or rewrite? Just seems like he thinks its a new thing even though its been around for many years.
- BoorishBears 10y agoRhino got a poorly documented rewrite and is a pain to use, JDK 8 forward there's Nashorn. Elsewhere I've used J2V8, a very lightweight wrapper around V8
- smashed 10y agoHow does this relate to Nashorn? With something like Avatar-JS [1] you can even run some NodeJS apps without modifications on the JVM. [1] https://avatar-js.java.net https://avatar-js.java.net
- illicium 10y agoSee also Trireme [1], an implementation of Node.js 0.10.32 on the JVM, using Rhino. [1] https://github.com/apigee/trireme https://github.com/apigee/trireme
- desdiv 10y agoIt's built on top of Nashorn[1]. [1] https://github.com/purplejs/purplejs/search?utf8=%E2%9C%93&q=nashorn https://github.com/purplejs/purplejs/search?utf8=%E2%9C%93&q...
- wentoodeep 10y agoOk so no android. Next.
- eropple 10y agoWhy would you want to run this on Android? I'm not seeing the appeal.
- johnhenry 10y agoIs it correct to say that this is like JRuby, but with JavaScript in place of Ruby?
- PedroBatista 10y agoMore like "This is like Sinatra running on the equivalent of JRuby"
- __derek__ 10y agoThis reminded me of Nodyn[1], a Node-compatible JVM implementation, which it appears is no longer actively developed. [1]: https://github.com/nodyn/nodyn#notice https://github.com/nodyn/nodyn#notice
- stenrs 10y agoNo, Nodyn tried to be fully compatible with NodeJs. PurpleJS is just an alternative - the scope is not to be fully compatible. Also Nodyn has it's own implementation of Javascript. PurpleJS uses Nashorn as the Javascript engine.
- iamleppert 10y agoWhy do people think async code is complicated and keep trying to replace it? I think there are just people who will never understand or fully grok the beauty, power and simplicity of functional programming and will always seek to replace it. I feel sorry for them.
- skrebbel 10y ago> Why do people think async code is complicated and keep trying to replace it? As usual, @munificentbob explains it best: http://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ http://journal.stuffwithstuff.com/2015/02/01/what-color-is-y...
- thalesmello 10y agoI particularly don't find the problem it solves appealing. The power of Node comes specifically from its everything async programming model, Javascript is just a detail. So what's the point in taking away the good part, and keep the cumbersome one? If you just want to program a Synchronous server in the JVM,just stick to Java.
- deleted 10y ago[deleted]
- _pmf_ 10y ago> If you just want to program a Synchronous server in the JVM,just stick to Java. And if you want to program an asynchronous server on the JVM in Java, all of the major and minor servers also support an asynchronous model (you merely lose the ability to program against the Servlet API, which pre-3 was bound to threads). There's no reason at all to bring JS in for asynchronous behavior.
- sourcesmith 10y agoThere is also Vert.x which runs on the JVM but is event driven and asynchronous (as well as providing a reactive API) and supports JavaScript (http://vertx.io/docs/vertx-core/js/ http://vertx.io/docs/vertx-core/js/) as one of its languages.
- amelius 10y ago> The power of Node comes specifically from its everything async programming model, Javascript is just a detail. I don't agree. The power of Node comes from being able to run the same code on the browser and the server (without transpiling performance penalties).
- cel1ne 10y agoI hope you don't mean the JVM by "the cumbersome part". It think is unparalleled in performance, garbage-collection, general dev-ops and monitoring capabilities. You can run many different languages on it, all nicely contained within the virtual machine. As far as I know Twitter replaced their Ruby/Rails with Code on top of the JVM for these reasons. Also I don't think it's good to religiously stick to async/"just one thread" and sync/"one thread for everything". The most performant answer depends on the real world scenario and almost always lies somewhere in between.
- diegorbaquero 10y agoInteresting offer, would be great to have some benchmarks comparison to see the value of it. Do you happen to have some?
- jsuperman 10y agoI haven't seen any benchmarks yet, but the framework is actually originally the core engine of the web os / cms Enonic XP. Worth checking out: https://discuss.enonic.com/t/purplejs-an-alternative-to-node-js-for-java-projects/694 https://discuss.enonic.com/t/purplejs-an-alternative-to-node... https://enonic.com/ https://enonic.com/
- stenrs 10y agoNo, sorry, no benchmarks yet. The main focus until now has been to speed up the development process. Right now it's pretty slick when it comes to reloading of resources on-the-fly when changed.
- lisivka 10y agoDoes it use Rhino (to compile JS into bytecode)?
- stenrs 10y agoNo, it's using Nashorn which is bundled with Java 1.8+. It compiles Javascript into JVM bytecode as Rhino, but it's more performant.
- lisivka 10y agoThanks. Last time I looked at JS in Sun Java, it was in interpreter mode only due to license issues, so I always bundled Rhino with my projects to be able to precompile JS code, so it will run faster. But now performance of Nashorn is pretty impressive: https://blogs.oracle.com/nashorn/entry/nashorn_performance_work_in_the https://blogs.oracle.com/nashorn/entry/nashorn_performance_w... .
- tracker1 10y agoI'm just not sure I see the value... and in the end, not sure it will work out any better than the DLR attempts with .Net... It's interesting, just not sure I see the value. The Java runtime is about 60mb to download, then the extras for this... vs Node's runtime download under 14mb with a similar amount of library downloads for a given project. That doesn't include the disconnect from the rest of the JS ecosystem which has centered around npm at this point (at least for the package repository itself, baring the yarn front end).
- andrea_s 10y agoPerhaps that's closer to ClearScript (https://clearscript.codeplex.com/ https://clearscript.codeplex.com/) in the .NET environment - although ClearScript has a broader area of application and supports multiple engines.
- dewiz 10y agoI wonder if LucasArts is happy with that logo :-) The image and the font brought up some good memories. https://en.m.wikipedia.org/wiki/Day_of_the_Tentacle https://en.m.wikipedia.org/wiki/Day_of_the_Tentacle https://images-na.ssl-images-amazon.com/images/I/514Q95XGV8L.jpg https://images-na.ssl-images-amazon.com/images/I/514Q95XGV8L...
- jsuperman 10y agoThey have actually stated on Twitter that the mascot is inspired by the DOTT character and the Java character (Duke): https://twitter.com/purple_js/status/732660360348631040 https://twitter.com/purple_js/status/732660360348631040
- kjsingh 10y agosimple question - can it work with npm dependencies out of box?
- boggydepot 10y agonot out of the box, but the js vm used is based on webkit. for pure js deps, it can probably use them. but maven repo is what you have out of the box which contains all (mostly) the libraries for java
- agentgt 10y agoI have seen several similar things that essentially use existing Java libraries or the libraries themselves offer it (Javascript). * jooby [1] * Vert.x [2] * Rapidoid (I can't find the exact link where JS was used) [3] I'm just not entirely sure why you would trade a language that is generally much safer for one that is known to be problematic at scale particularly since Java 8 has lambdas so you can do callback async style if you like. I mean I suppose you could use typescript but at that point why not stick with Node and if you need JVM stuff just make some sort of microservice to access it from Node. If it is a learning thing than (as Java is complicated) than Clojure is far better option (I'm always amazed how easy it is to learn any Lisp as syntax becomes a non issue). [1]: http://jooby.org/ http://jooby.org/ [2]: http://vertx.io/ http://vertx.io/ [3]: http://www.rapidoid.org/ http://www.rapidoid.org/