By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,693 Members | 1,646 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,693 IT Pros & Developers. It's quick & easy.

JavaScript Complier

P: n/a
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.

Nov 23 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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.

Nov 23 '05 #2

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


Do you need a compiler or a code checker? If the latter, try
http://www.JSLint.com
Nov 23 '05 #3

P: n/a
Luke Matuszewski wrote:
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
Nov 23 '05 #4

P: n/a

Thomas 'PointedEars' Lahn napisal(a):
Luke Matuszewski wrote:
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...der%27s_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.

Nov 23 '05 #5

P: n/a
Douglas Crockford wrote:
Do you need a compiler or a code checker? If the latter,
try http://www.JSLint.com

I've tried to use it with IE, Opera and Mozilla, but the
"jslint" button doesn't do anything. Am I missing something?
JS works in all 3 browsers, my code esecutes as expected.
This is the code I cut and pasted in your page:
http://tinyurl.com/db8v6

Thanks! .:|:.
Nov 23 '05 #6

P: n/a
..:|:. wrote:
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, .:|:.
Nov 23 '05 #7

P: n/a
Luke Matuszewski wrote:
Thomas 'PointedEars' Lahn napisal(a):
Luke Matuszewski wrote:
> 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
Nov 23 '05 #8

P: n/a
shannon wrote:
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/produ.../testdrive.php

Nov 23 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.