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

I know that IE could run VBScript and JScript, but I want cross-browser things that use another languag

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?

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?

Share Improve this question edited Jan 12, 2013 at 16:32 user142019 asked Jan 12, 2013 at 7:17 KokizzuKokizzu 26.9k40 gold badges149 silver badges256 bronze badges 7
  • What is your question then? – polin Commented Jan 12, 2013 at 7:18
  • 4 I wouldn't be surprised if there were browsers that you could install new languages in, but if you're looking for a cross-browser solution, then no, you're stuck with Javascript. – Mr Lister Commented Jan 12, 2013 at 7:20
  • 3 @MrLister you could install a language interpreter through Javascript. Javascript is perfectly capable of parsing Ruby. – John Dvorak Commented Jan 12, 2013 at 7:24
  • also see stackoverflow./questions/14180092/… – John Dvorak Commented Jan 12, 2013 at 7:25
  • 1 @MrLister I thought coffeescript was piled server-side to javascript? – John Dvorak Commented Jan 12, 2013 at 7:31
 |  Show 2 more ments

4 Answers 4

Reset to default 3

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.

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

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

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

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 piler.

There are many languages that can be piled 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744115911a4559172.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信