How to run a server side JS - javascript

I have a little question here. Is there any way to build a server side JS without any use of external software. The reason for this is I am not able to install any software on the webspace but I wanted to experiment with realtime communication with the server and another user for a game or something like this.
If someone knows a way to establish something like this I would be quite happy to hear about it.
EDIT: Guys NOT NodeJS I AM NOT ALLOWED TO INSTALL ANY OTHER SOFTWARE!

https://cloud.google.com/nodejs/
or
https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction
Those $15 a year webhosts typically don't allow you advanced customization. You need a better web hosting service that allows you CLI access to the server back end.

Running JavaScript on backend requires NodeJS runtime environment. Download it here https://nodejs.org/en/
Alternatively you can can configure an instance on Heroku and run your application there. But I would suggest to try the first one.

No. Javascript is a scripting language that was designed to work within the browser. There's no out of the box solution for you, as Javascript doesn't do server-side out of the box
However, Node.Js (and others) use Chrome's V8 engine to create an event-driven runtime environment which can allow writing server-side code with Javascript. That's your best option

Related

Absolute simplest server-side Javascript mechanism?

I've got a simple Javascript application with a JSON API. Currently it runs in the client, but I'd like to move it from the client to the server. I am accustomed to learning new platforms, but in this case, my time is very limited - so I need to find the absolute simplest way possible.
This should be an easy task, but all I'm finding are solutions that are way overcomplicated:
The application is currently hosted on an extremely basic server. Node.js is not available, and I do not have install privileges. I'll eventually move it to a different server, but I really don't know what will be available there.
Many solutions require installing and running a standalone server. Really? Just to evaluate Javascript server-side and spit out some data?
I can run Python and PHP, and I see that it's possible to call Javascript from inside a Python or PHP script. However, the specific Python solution that I've found also require installing some Python support via pip or easy-install, so probably not an option. Also, this just feels overcomplicated, and I'm concerned about setting myself up for errors such as data conversion or permissions, etc.
Any help?
#Quentin is correct. There is no way to run javascript on a server without a javascript interpreter on the server.
Node.js is not only the most robust and widely used one, it's also the simplest. It is certainly possible to write your own javascript interpreter in PHP or Python, but that would be much more complicated than using Node.js.
Try really hard to find a server solution that allows you to use Node. In the end, it's going to save you (and any other stakeholders interested in the project) a lot of time and money.

CouchDB AJAX interaction

I'm writing a CouchDB sample. My intention is to write a web app using AJAX and deploy it in the tomcat environment. As I use the CouchDB I would like to know the way to interact with the CouchDB server. However there were few examples but I have few concerns over that.
1) As my application is deployed in a web server is it possible to connect with a CouchDB outside? Many examples uses apps which are deployed in CouchApp or Couch environment itself.
2) If so will it end up with cross domain issues. I found this in here
Connection AJAX, CouchDB and JavaScript
However will this be a problem? Is this the correct way to achieve this?
3) To omit above issues is it possible to use some server side javascript implementation as an example Rhino?
http://www.mozilla.org/rhino/doc.html
4) If I use Rhino above it wont allow many java script libraries to use. How do I interact with CouchDB then? Do I have to invoke native Javascript? Cant I use something like JQuery?
5) What are the best libraries for client side to achieve my goal?
Your help is appreciated.
Thank you
Based on your need to use tomcat, I would just recommend using ektorp (http://ektorp.org/). Just think of ektorp like a jdbc driver. No need to do ajax from the user interface, or no need to use javascript from java in your server.
Ektorp also lets you annotate your java classes with the javascript couchdb needs to make views. see the example here: http://ektorp.org/reference_documentation.html#d100e753
Hope that helps.

Can I use SproutCore without Ruby?

SproutCore is said to be a JavaScript framework, so how to use it entirely without Ruby (actually with PHP or Java) on server side?
the build tools are written in ruby. Unless you want to roll your own I don't think you will be able to do things like build your client side code or use sc-server without ruby.
That said, the build tools are just a set of tools to help you develop. SC doesn't care what you have on the server. As long as your server returns json, you are good to go.
In fact, you can build a lot of your client side functionality without the server using fixtures
http://wiki.sproutcore.com/DataStore-Using+Fixtures
As hvgotcodes said, for development you'll need Ruby for the build tools. However, there are also some node.js tools available if you'd rather go that route. Furthermore, there is strong interest in making a build tools binary. This would allow SC development without having to install Ruby locally.

Getting Server-side Javascript to work for me

I am wondering how to install a Javascript runtime engine to work with an Apache HTTP server. My aim is to run server-side Javascript.
Thanks in advance for any help!
I think you may have to clarify why you want to do this.
If you're just looking to execute JavaScript code, Rhino will get you the ability to run javascript within a Java application. However, since its not in a web browser you won't have any access to any sort of DOM.
Other than that, JavaScript is mostly a language that was intended to run in a web browser on the client.

Totally JavaScript Web Stack - Middleware, Webserver, DB suggestions?

I'm currently looking for a new web stack to build a hobby project on and would like it to be powered by JavaScript. I've had a quick look at Nitro, NarwhalJS etc. but was wondering if anyone had any solid recommendations or experience of an entire end-to-end javascript/json architecture ( jquery, middleware, standard libraries, db etc.) that they could share.
I'd prefer it to be a stack that you think is going to grow and is actively being looked after, documentation, community of nice like-minded individuals etc.
Thanks in advance.
Caveat: This answer somewhat fails to meet your basic requirement of personal experience with the resources listed. :-)
Off-the-cuff, there's Jaxer from Aptana and Chrome Server (which, despite the name, isn't related to Google Chrome AFAIK). Speaking of Chrome, though, there's an Apache CGI module that supports server-side scripting using JavaScript via Google's V8 engine, but that doesn't help you much with DB connectivity and such.
I'll also plug Java and Rhino, which I have used a bit. Via Rhino, you can compile JavaScript into Java bytecode (which, if you're using the Sun runtime, is JIT-compiled to machine code by Hotspot). That means you can run JavaScript in any servlet container (Tomcat, Resin, etc.). The joy here is that all of the huge array of goodies available for Java is instantly available to you via JavaScript -- so, MySQL connectors, image manipulation libraries, just about anything you can imagine. It's also amazingly easy to access those resources from JavaScript via Rhino. To give you an idea:
importPackage(java.io);
var f = new FileWriter("test.txt");
f.write("Testing 1 2 3");
f.close();
...and we've just written a file on the server via JavaScript, using Java's java.io.FileWriter class. You can also execute dynamic scripts at runtime via the javax.script package, which (for JavaScript) uses Rhino under the covers, although I'm not immediately coming up with a use case for doing that. :-)
For the database part of the stack:
Couchdb uses JSON and REST to store data in a document format. It uses PUT,DELETE for storage - I'm not sure how that would work with Javascript.
Helma should work well as a web server layer. It streamlines the use of Rhino as the web tier logic language.
I'm building a new service called PageForest that helps developers write totally client-side javascript programs, with PageForest providing storage and user management. Here's a sample page:
http://pfsamples.googlecode.com/svn/trunk/SAMTable/index.html#mckoss_16
This is still a work in progress, but I'd love to get some feedback on the approach. You can find more samples at the pfsamples.googlecode.com site.
Check out JScript / Windows Scripting Host(wsh) and possibly HTA's. HTA's can actually be served via a webserver and act as a locally running application with extended rights. If you want pure web development you can use WSH and some IIS tweaking to process server requests on the back end with pure javascript code in a WSF file. WSH also provides access to the file system, ODBC compliant databases and a slew of other COM exposed applications via the ActiveX model. We're not talking blazing speed, but you're programming in javascript to begin with.
Here are some links on the "stack"
http://msdn.microsoft.com/en-us/library/ms536496(VS.85).aspx
http://msdn.microsoft.com/en-us/library/15x4407c(VS.85).aspx
How about using
GWT-Spring-Hibernate-MYSql

Categories