Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will server-side JavaScript take off? Which implementation is most stable? [closed]

Does anyone see server-side JavaScript taking off? There are a couple of implementations out there, but it all seems to be a bit of a stretch (as in, "doing it BECAUSE WE CAN" type of attitude).

I'm curious to know if anyone actually writes JavaScript for the server-side and what their experiences with it have been to date.

Also, which implementation is generally seen as the most stable?

like image 684
Steve M Avatar asked Aug 20 '08 05:08

Steve M


3 Answers

I like to read Googler Steve Yegge's blog, and recently I came across this article of his where he argues that Mozilla Rhino is a good solution for server-side JS. It's a somewhat sloppy transcript, you might prefer to watch the video of the talk. It also offers a little bit of insight on why he thinks server-side JS is a good idea in the first place (or rather, why he thinks that it's a good idea to use a dynamic language to script Java). I thought the points he makes were convincing, so you might want to check it out.

A while earlier, he also posted something about dynamic languages in general (he's a big fan of them), just in case you were wondering why to use JS at all.

like image 159
Hanno Fietz Avatar answered Nov 18 '22 21:11

Hanno Fietz


Why would you want to process something in Javascript when you can process it in PHP or ASP.NET which are designed specifically for this task?

Perhaps because JavaScript is a more powerful programming language than those two? For example, it has functions as first-class data types and support for closures.

Steve Yegge has blogged about porting Ruby on Rails to server-side JavaScript as an internal project within Google ("Rhino on Rails"). He did it because he likes Rails but using Ruby isn't allowed within Google.

like image 20
John Topley Avatar answered Nov 18 '22 22:11

John Topley


Before it was acquired by Google, JotSpot used server-side JavaScript to let you query their database and display your pages. They used Rhino to do it. CouchDB uses server-side JavaScript to create views of their database.

As you can see from these examples, a great way to use JavaScript on the server is for plugins. One of the reasons it's used is that you can create a very isolated sandbox for people to run their code in. Also, because of the way that JavaScript as a language works, you can provide a user tooling specifically honed to the tasks your users need to complete. If you do this right, users don't need to learn a new language to complete their tasks, a quick glance at your API and examples is enough to get them on their way. Compare this to many of the other languages and you can see why using server-side JavaScript to provide a plugin architecture is so enticing.

A secondary popular solution, one which can be seen through a project like Jaxer, is that a common problem of web applications that do client-side validation is that, since JavaScript is easily bypassed in the browser, validation has to be run once again on the server. A system like Jaxer allows you to write some validation functionality that is reusable between both server and client.

like image 3
pottedmeat Avatar answered Nov 18 '22 23:11

pottedmeat