Settings

Theme

PurpleJS – An alternative to Node.js for Java projects

webagility.com

81 points by thousande 10 years ago · 51 comments

Reader

thalesmello 10 years ago

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.

  • _pmf_ 10 years 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.

  • cel1ne 10 years ago

    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.

  • amelius 10 years 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).

smashed 10 years ago

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

iamleppert 10 years ago

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.

fredliu 10 years ago

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

  • stenrs 10 years ago

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

dewiz 10 years ago

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

agentgt 10 years ago

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/

diegorbaquero 10 years ago

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

tracker1 10 years ago

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

cheriot 10 years ago

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

  • premium-concern 10 years ago

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

  • stenrs 10 years ago

    Sorry about that. The embedded mode is not yet documented, but I can certainly help you with embedding into existing systems.

__derek__ 10 years ago

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

  • stenrs 10 years ago

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

ilaksh 10 years ago

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

  • hibbelig 10 years ago

    This uses Nashorn to execute the Javascript.

    • ilaksh 10 years ago

      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.

      • BoorishBears 10 years ago

        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

gfosco 10 years ago

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.

  • partycoder 10 years ago

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

    purpleJS would be javascript bindings for some Java framework.

  • skanga 10 years ago
  • mgkimsal 10 years ago

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

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

    • gfosco 10 years ago

      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.

      • jsuperman 10 years ago

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

johnhenry 10 years ago

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

lisivka 10 years ago

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

kjsingh 10 years ago

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

  • boggydepot 10 years ago

    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

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection