JavaScript Complier

S

shannon

Hi there,

Does anyone know if you can download a free javascript complier from
the net. I need to check my code for a project.

Thanks Shannon.
 
L

Luke Matuszewski

JavaScript is generally interpreted language, but you may use Rhino
http://www.mozilla.org/rhino/jsc.html (you must know how to invoke java
programs and how to pass a path to Rhino .jar).
It 'compiles' JavaScript files to Java classes which can be run and
therefor tested.
 
T

Thomas 'PointedEars' Lahn

Luke said:
JavaScript is generally interpreted language, [...]

It is not, otherwise it would be too slow for the Web. It is compiled (in
browsers: JIT-compiled) and the resulting byte-code is interpreted by a
Virtual Machine.

SpiderMonkey, Gecko's JavaScript engine written in C (the JavaScript
Reference implementation), compiles (no need for quote characters)
JavaScript source code to JavaScript byte-code to be interpreted by
a JSVM.

<http://developer.mozilla.org/en/docs/SpiderMonkey>

Rhino, written in Java, among other features, can compile JavaScript
source code to both JavaScript byte-code to be interpreted by a JSVM
and Java byte-code to be interpreted by a JVM.

<http://www.mozilla.org/rhino/>


PointedEars
 
L

Luke Matuszewski

Thomas 'PointedEars' Lahn napisal(a):
Luke said:
JavaScript is generally interpreted language, [...]

It is not, otherwise it would be too slow for the Web. It is compiled (in
browsers: JIT-compiled)

You are saying that JavaScript is not interpreted language and then you
states that:
resulting byte-code is interpreted by aVirtual Machine.

In all ECMAScript specs there is NO SUGGESTION on how JavaScript
programs are executed (not a word about Garbage Collector and
JavaScript Virtual Machine). The implementation decides what format and
how it will be executed later.
I mentioned also '''''generally'''' because there is no restriction it
would not be interpreted.
Implementation may decide to produce .exe (PE format file) or .bin (ELF
format file) as a result of compilation, or bytecode to be run on
implementation dependen JSVM (because in specs there is not a word
about format of bytecode, JIT or Hot Swap techniques and other things
like garbage collector algorithms used) but generally there is no need
to. Another case is Java Virtual Machine, which is described in Sun
Specs with Byte Code format - because Java Byte Code is required to run
on platform which has Java Runtime Envirnoment.

As a case of SpiderMonkey - there is no JSVM there - it is embedded
using shared library (or if needed statically linked in C code).

[http://developer.mozilla.org/en/docs/JavaScript_C_Engine_Embedder's_Guide]
<quote>
The engine handles memory allocation for the JS data types and objects
needed to execute scripts, and it cleans up -- garbage collects -- the
data types and objects in memory that it no longer needs.
How Do You Use the Engine?
Generally, you build the JS engine as a shared resource. For example,
the engine is a DLL on Windows and Windows NT, and a shared library on
Unix. Then you link your application to it, and embed JS engine
application programming interface (API) calls in your application.
</quote>

As a result personally i think that Rhino is far more easier to use at
hoc than SpiderMonkey (Rhino only requires the Java Runtime Envirnoment
and nothing else).

BR.
Luke.
 
?

.:|:.

..:|:. said:
I've tried to use it with IE, Opera and Mozilla

Sorry, it's Firefox, not Mozilla.



some more data. When I click "jslint"...

....Opera says:
JSLint, The JavaScript Verifier
http://www.crockford.com/jslint/index.html
Event thread: click
Error:
name: ReferenceError
message: Statement on line 24: Reference to undefined variable: ‘output’
Backtrace:
Line 24 of inline#1 script in http://www.crockford.com/jslint/index.html
document.getElementById(‘output’).innerHTML = r;
Line 1 of script
go();
selectinput();
return false;
At unknown location
[statement source code not available]

....Firefox says
Error: illegal character
Source File: http://www.crockford.com/jslint/index.html
Line: 82, Column: 28
Source Code:
document.getElementById(‘output’).innerHTML = r;


Hope this helps, tanks, .:|:.
 
T

Thomas 'PointedEars' Lahn

Luke said:
Thomas 'PointedEars' Lahn napisal(a):
Luke said:
JavaScript is generally interpreted language, [...]
It is not, otherwise it would be too slow for the Web. It is compiled
(in browsers: JIT-compiled)

You are saying that JavaScript is not interpreted language and then you
states that:

It is not only and not first an interpreted language.
resulting byte-code is interpreted by aVirtual Machine.

In all ECMAScript specs there is NO SUGGESTION on how JavaScript
programs are executed [...]

Of course not, we are talking about JavaScript, not ECMAScript or one
of its other implementations.
As a case of SpiderMonkey - there is no JSVM there - it is embedded
using shared library (or if needed statically linked in C code).

I wonder if the VM could be implemented through that C code. And
I know about JavaScript programs in byte-code used by at least SSJS.


PointedEars
 
W

web.dev

shannon said:
Hi there,

Does anyone know if you can download a free javascript complier from
the net. I need to check my code for a project.

Thanks Shannon.

Is a compiler what you're really looking for? If you're just checking
your code, from what others have already said, JSLint may be what
you're looking for.

http://www.jslint.com

I did come across something more advanced however, and it seems to do a
pretty decent job of catching errors. It's called JS Sorcerer, but it
may do things too advanced for you to understand at this point of time.
If you still want to give it a try, they have an online demo. They
also appear to have an actual compiler if that's what you really
wanted.

http://www.dhitechnologies.com/products/jssorcerer/demo/testdrive.php
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top