back to listing index

PurpleJS – An alternative to Node.js for Java projects | Hacker News

[web search]
Original source (news.ycombinator.com)
Tags: java jvm javascript purplejs nodejs libuv
Clipped on: 2016-10-24

Image (Asset 1/2) alt= Hacker News new | threads | comments | show | ask | jobs | submit jaytaylor (2501) | logout
PurpleJS – An alternative to Node.js for Java projects (webagility.com)
79 points by thousande 3 days ago | unvote | flag | hide | past | web | 44 comments | favorite




Image (Asset 2/2) alt=

I 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.


> 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.


There 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/) as one of its languages.

I 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.


I think he meant the js not java. Question about node js, So async model is the good part, js is the bad part, why use js then?

The JVM is nowhere near as flexible as the CLR.

The JVM probably lags behind in some aspects. But it's ecosystem is way larger and not biased towards Windows.

In what way?

The CLR can be used to run C++ code compiled with the C++/CLI (/clr:pure) setting of MSVC. Java apps can even run on the CLR because of IKVM (https://www.nuget.org/packages/IKVM).

Good luck at using pointers in Java.


> 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).


How 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



Ok so no android. Next.

Why would you want to run this on Android? I'm not seeing the appeal.

See also Trireme [1], an implementation of Node.js 0.10.32 on the JVM, using Rhino.

[1] https://github.com/apigee/trireme


Why 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.


> 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-y...


Isn't use case proposed by PurpleJS covered by Vert.x already? Or am I missing anything?

I 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://images-na.ssl-images-amazon.com/images/I/514Q95XGV8L...


They 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

I 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/

[2]: http://vertx.io/

[3]: http://www.rapidoid.org/


Interesting offer, would be great to have some benchmarks comparison to see the value of it. Do you happen to have some?

I 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...

https://enonic.com/


I'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).


Perhaps that's closer to ClearScript (https://clearscript.codeplex.com/) in the .NET environment - although ClearScript has a broader area of application and supports multiple engines.

This 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


Or you use Scala and Scala.js and just get things done.

This 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


I didn't see any mention of Rhino. Does he know that existed (exists?)?

This uses Nashorn to execute the Javascript.

Oh 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.

Rhino 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

Why don't any of the examples use Java?... Even the examples on GitHub, none of it looks any different than a Node.js project.

An oversimplified way to describe node.js is: javascript bindings for libuv.

purpleJS would be javascript bindings for some Java framework.



Because it's still javascript, just running on JVM instead of... v8?

At least, that's my read of the project.


Ok, 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.

Actually, 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).


Is it correct to say that this is like JRuby, but with JavaScript in place of Ruby?

More like "This is like Sinatra running on the equivalent of JRuby"

Does it use Rhino (to compile JS into bytecode)?

simple question - can it work with npm dependencies out of box?

not 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


Get your JS to run as slow and crappy as a real Java application! :)




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: