Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript: Standalone compiler or interpreter for Windows?

What are the JavaScript compilers or interpreters available for Windows?

I read the book Eloquent JavaScript recently. This book introduces the reader to programming using JavaScript as the first language. Sadly, the programs are restricted to run inside the browser embedded in HTML. So, I wonder if it is possible to write JavaScript programs that can be executed standalone.

The compiler or interpreter should be easily available as a pre-compiled binary that can be downloaded and installed by a beginner. He should be able to write simple standalone JavaScript programs that are compiled with this compiler. Additional JavaScript libraries, frameworks, IDEs and debugging support that would work with this compiler would be a plus.

like image 627
Ashwin Nanjappa Avatar asked Apr 21 '11 09:04

Ashwin Nanjappa


People also ask

Does JavaScript use an interpreter or compiler?

JavaScript is an interpreted language, not a compiled language. A program such as C++ or Java needs to be compiled before it is run. The source code is passed through a program called a compiler, which translates it into bytecode that the machine understands and can execute.

Do you need an interpreter for JavaScript?

A JavaScript engine doesn't need both an interpreter and a compiler. There are JS engines that interpret all code, and others that compile all code.

What compiler should I use for JavaScript?

Komodo Edit Komodo Edit is also one of the popular options for JavaScript IDE's. It can be considered as a lower version of Komodo's latest IDE as it simplifies development than ever before. It is a powerful as well as simple edit which supports multiple languages.


1 Answers

Nobody has mentioned yet, window's own javascript compiler: http://msdn.microsoft.com/en-us/library/vstudio/7435xtz6(v=vs.100).aspx

Microsoft (R) JScript Compiler version 8.00.50727
for Microsoft (R) .NET Framework version 2.0.50727
Copyright (C) Microsoft Corporation 1996-2005. All rights reserved.

jsc [options] <source files> [[options] <source files>...]

                         JScript Compiler Options

                           - OUTPUT FILES -
  /out:<file>              Specify name of binary output file
  /t[arget]:exe            Create a console application (default)
  /t[arget]:winexe         Create a windows application
  /t[arget]:library        Create a library assembly
  /platform:<platform>     Limit which platforms this code can run on; must be x86, Itanium, x64, or anycpu, which is the default

                           - INPUT FILES -
  /autoref[+|-]            Automatically reference assemblies based on imported namespaces and fully-qualified names (on by default)
  /lib:<path>              Specify additional directories to search in for references
  /r[eference]:<file list> Reference metadata from the specified assembly file
                           <file list>: <assembly name>[;<assembly name>...]

                           - RESOURCES -
  /win32res:<file>         Specifies Win32 resource file (.res)
  /res[ource]:<info>       Embeds the specified resource
                           <info>: <filename>[,<name>[,public|private]]
  /linkres[ource]:<info>   Links the specified resource to this assembly
                           <info>: <filename>[,<name>[,public|private]]

                           - CODE GENERATION -
  /debug[+|-]              Emit debugging information
  /fast[+|-]               Disable language features to allow better code generation
  /warnaserror[+|-]        Treat warnings as errors
  /w[arn]:<level>          Set warning level (0-4)

                           - MISCELLANEOUS -
  @<filename>              Read response file for more options
  /?                       Display help
  /help                    Display help
  /d[efine]:<symbols>      Define conditional compilation symbol(s)
  /nologo                  Do not display compiler copyright banner
  /print[+|-]              Provide print() function

                           - ADVANCED -
  /codepage:<id>           Use the specified code page ID to open source files
  /lcid:<id>               Use the specified LCID for messages and default code page
  /nostdlib[+|-]           Do not import standard library (mscorlib.dll) and change autoref default to off
  /utf8output[+|-]         Emit compiler output in UTF-8 character encoding
  /versionsafe[+|-]        Specify default for members not marked 'override' or 'hide'

There are usually a couple of copies lying around on any windows install, but they are not usually in the path, so you have to find them.

The compiler is capable of compiling javascript files into executables that can run on any windows machine with .NET installed.

like image 191
Billy Moon Avatar answered Nov 15 '22 16:11

Billy Moon