Programming Questions

  • Newest
  • Popular Tags
  • Ask A Question
  • Javascript outside the web
    I love to use Javascript; I play with it on khanacademy.org, I use it here, I place it into html files. But does Javascript have any other uses besides web development? I guess part of my question would also be "if Java has compilers like Eclipse, does JavaScript have its own compiler? Or is that basically just the web?" Thank you!
    RayMan posted this question on 1/9/15 | javascript, html, web
    Answers
  • +
  • 2
  • -
  • You can make apps for Windows 8, IIRC You can create android/iphone apps You can use JS for Desktop apps You can program video games (impactJS, phaser) but also Unity3D scripting (not really JS, it's unityscript I think, but it's the same) You can make scripts for Google sheets/docs etc. It's used for Chrome/FF extensions aswell (it's for the web, but different)
  • +
  • 1
  • -
  • In Windows 7, you could put "gadgets" on the desktop such as weather or clock or scrolling news. Those gadgets were all written in JavaScript! In DOS and Windows, you can write BAT files which contain shell commands. You can do similar things with JavaScript. You can write a program containing JavaScript code and call it JS. Then when you run the JS code, it performs some task. For example, I have written a JavaScript program that cleans up temporary files on my hard drive. When you are using Excel or Word, you can add little programs to your document which are called macros. Macro scripts can be written in JavaScript, and they can perform various tasks such as sort cells or do some repetitive task that makes the editor's job easier. JavaScript is also found in viruses. A lot of email viruses that are sent are nothing more than a little JavaScript code. Now, a JS file can run without opening a window. If you want your JS program to have a window, you could create a HTA file, which is sort of like a HTML file, but you can do a lot of things on the computer that you cannot do from a HTML file. For example, you cannot read/write files from a HTML file. The browser won't let you do that. But in a HTA file or JS file, you can do that, and you don't need a permission. You just click on the JS file, and it will execute and do whatever it is supposed to do.
  • +
  • 1
  • -
  • I am not sure how to edit my posts, but I just noticed that the JS code I used above was a different code. Here is the appropriate code :P
     WriteToFile("c:\test.txt", "Hello World!");
    
    // Create ASCII text file and write string. Return 0 on success or an error message.
    function WriteToFile(FILENAME, STRING) { try { var FSO = new ActiveXObject("Scripting.FileSystemObject"); var F = FSO.CreateTextFile(FILENAME, true, false); F.Write(STRING); F.Close(); return 0; } catch (e) { return e.message; } }
    
  • +
  • 1
  • -
  • Node.js is pretty cool for writing scripts in JS. I've used it to make multi-player games, but it's not practical to deploy yet--it's too expensive. It gives you all the file-editing, net-accessing powers of a compiled language. Microsoft has developed 'JScript', which is basically javascript, and can be compiled into a stand-alone windows executable or library. "How to: Compile JScript Code from the Command Line" docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2008
  • +
  • 1
  • -
  • All modern web browsers include a compiler for Javascript, which is why it is so ubiquitous on the web. If you would like to use Javascript like other languages off the web, use Node.js. The node.js platform took the V8 javascript engine that Google Chrome uses to compile Javascript and added functionality that makes using Javascript on your desktop feel more like other languages. Some specifically useful things that node.js adds to Javascript are file input and output handling, a REPL (aka read eval print loop, or console), a package manager called npm that allows you to use additional libraries, and the ability to function as a web server (hence it's common use in backend web development).
  • +
  • 1
  • -
  • I was working on 3D Multiplayer game for Android. I was using Unity and you can use C#, Javascript, or Boo. So, Javascript can be applied to several game-engine if you're interested. Just for your info, Unity is an game-engine that help you to create a 3D game easier and it's write once run everywhere. So, Javascipt is very useful.
  • +
  • 0
  • -
  • Hello! If you want to program games you can use JavaScript, for example in Unity3d game engine. It's really good and free 3d game engine for Windows and Mac. If you want to create an android web app you can also use Java Script and HTML together. There are many ways to use Java Script! :) Good luck!
  • +
  • 0
  • -
  • A language doesn't have to be compiled for it to be useful for purposes other than the web. Python, Ruby, PHP, and a bunch of less popular languages are all interpreted ones, with many uses both for back-end web programming, for scientific computing, scripting languages within other applications, and to create full-blown desktop applications. Javascript I haven't seen used much for these purposes, but it certainly can be. This stackoverflow question is probably relevant to you. stackoverflow.com/questions/109399/can-you-do-desktop-development-using-javascript And node.js is a javascript platform for building network applications, which again, I haven't used before.
  • +
  • -1
  • -
  • Here is a little example of a JS file. So, you would take this code and save it as something.js and when you double-click on it, it will create a file called "test.txt." Now, if you rename this program to something.html, then it won't work anymore, because this code cannot run inside a web browser. So, the stuff you can do within a web browser is only a tiny fraction of all the stuff you can do with JavaScript!
    WriteToFile("test.txt", "Hello World!");
    
    function WriteToFile(FILENAME, DATA)
    {
      try
      {
        var fso = new ActiveXObject("Scripting.FileSystemObject");
        var s = fso.CreateFolder(FILENAME, true);
        s.writeline(DATA);
        s.Close();
        return 1;
      }
      catch(err) {}
      return 0;
    }
    
    
    Log in to write an answer.