3

Is there any Scala like alternative to JavaScript? I'm looking for language with:

  • Embeded XML
  • Better standard library than classic JavaScript
  • Implicit Conversion
9
  • 1
    I guess he meant implicit conversion Commented Oct 17, 2011 at 20:36
  • 2
    Where do you want to run that code ? Browser, server, desktop, toaster ? Commented Oct 17, 2011 at 20:36
  • In a browser. This language should have DOM support Commented Oct 17, 2011 at 20:38
  • 2
    That means that at the end of the day you'll have to produce . Also note that user-defined implicit conversions (unless intended to be fully dynamic, which introduces notable overhead to pretty much every operation everywhere) require a static type system. Commented Oct 17, 2011 at 20:40
  • 3
    Some typed alternatives in that list: github.com/jashkenas/coffee-script/wiki/… Commented Oct 18, 2011 at 0:44

5 Answers 5

4

There is a project "Scala+GWT" that compiles Scala -> a GWT intermediate target. GWT then presumably compiles it to JavaScript. http://scalagwt.github.com/

Sign up to request clarification or add additional context in comments.

2 Comments

There is a number of projects including a number of statically-typed languages (ghcjs, ocamljs, emscripten, etc.) that target JavaScript as the "machine language" at this point, but they are all in varying stages of maturity. github.com/jashkenas/coffee-script/wiki/…
@Mateusz - It is much, much faster to learn a whole platform than to write one.
2

Not truly matching your requirements, but answering your initial question "Is there any Scala like alternative to JavaScript? ":

If you do not like Ruby/Python/Coffescript, you should perhaps have a look at the technology preview of google's new language Dart: http://www.dartlang.org/

Looks very java-ish on a first glance, but has many niceties that make it feel scalastic too. (But do not make the mistake to approach it as another Scala. Only Scala is Scala!)

Comments

2

I think the best you're going to get is something like CoffeeScript, which ultimately compiles to JavaScript. AFAIK, browsers don't have any other cross-browser client-side language with DOM support.

3 Comments

CoffeeScript is really great, but it is Ruby/Python like. I'm expecting a language with Static Types like Scala.
@Mateusz Javascript is a dynamic lanaguage, so why impose static typing in some middle stage if it will inevitably get converted to dynamic? You can't possibly get any performance benefits from static typing in that case. Which other benefits you may be looking for I just don't see. Looking for a dynamic language with a similar type system seems much more reasonable to me.
Static typing can find more errors during compilation/parse than dynamicly-typed language.
1

There's also a Fantom language. On the main page of its site which it says: Write code portable to the Java VM, .NET CLR, and JavaScript in the browser.

Comments

1

Scala.js might be what you are looking for:

"Scala.js compiles Scala code to JavaScript, allowing you to write your Web application entirely in Scala!"

Site: http://www.scala-js.org/

Github: https://github.com/scala-js/scala-js

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.