Kokizzu
Kokizzu

Reputation: 26908

Can I use a language other than JavaScript in client-side scripting?

I know that IE could run VBScript and JScript, but I want cross-browser things that use another language than JavaScript, so that I wrote this:

 <script src='bla.rb' type='text/ruby'></script>
 <script src='bla.coffee' type='text/coffescript'></script>
 <script src='bla.ics' type='text/icedcoffescript'></script>

It would run normally. How to make these tags works?

Upvotes: 3

Views: 3436

Answers (4)

Anderson Green
Anderson Green

Reputation: 31850

There are many languages that can be compiled into JavaScript, including C, C++, Python, PHP, and several others.

There are also several implementations of virtual machines for other languages in JavaScript, including DoppioJVM for JVM languages and JSIL for .NET programming languages.

Upvotes: 0

user149341
user149341

Reputation:

Ruby: Maybe? Not sure how far along this project is, but it does exist.

(Iced)CoffeeScript: Yes. But you have to load one additional JavaScript file as the CoffeeScript compiler.

Upvotes: 2

user142019
user142019

Reputation:

Python can be used if you compile CPython to JavaScript using Emscripten. Maybe you can do the same with Ruby.

Besides Emscripten, there are languages that compile to JavaScript, such as CoffeeScript and Fay. You could also write your own VM in JavaScript and write a compiler for your favourite language that targets that VM, of course.

In the end, the browser itself can only interpret JavaScript.

Upvotes: 3

ColinE
ColinE

Reputation: 70160

No, you cannot rely on the presence of any of these other languages in the majority of browsers. You can potentially ask a user to instal a new language or plugin, but JavaScript is the only 'universal' client-side scripting language.

Upvotes: 3

Related Questions