Take the 2-minute tour ×

Time and time again I am surprised at how difficult Javascript is to maintain or write proper programs in, mostly because it is so weakly typed. I truly find it akin to writing programs in assembly. Sure, there is some intellisense for it and you can get some tools to make it easier. You can even use things like jQuery to make it more platform independent.

But does there exist some sort of language (strongly-typed) that I could write in, syntax similar to Java or C#, that could "compile" into Javascript? Or perhaps there are tools that would make Javascript strongly-typed, and could detect bugs, that a C# compiler would detect?

I'm not trying to just hate on JS here, but I'm wondering if there is some sort of roadblock that prevents this. Or perhaps doing this would make JS difficult to use in the web.

Edit: While I may have been pointing directly at javascript, I guess my broader question, is there a reason why Javascript is the only game in town? And is there something inherent about client-side code that makes javascript that way it is?

share|improve this question

closed as off-topic by Jimmy Hoffa, user16764, MichaelT, Aaronaught, Corbin March Sep 7 '13 at 4:21


  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – Jimmy Hoffa, user16764, MichaelT, Aaronaught, Corbin March

<insert joke about VSScript as a viable alternative here> –  Servy Sep 6 '13 at 20:25
The only problem with javascript is the people who write it without understanding it. –  Shmiddty Sep 6 '13 at 20:48
@TruthOf42: That has nothing to do with JavaScript, it's a characteristic of all interpreted and/or dynamically-typed languages. There are static compilers for JavaScript (Rhino, V8). Even with a statically-typed language, I usually don't find out about errors until either I run it or the automated tests catch it, and I often don't find out about errors until the testers catch it. What's changed, really? Static typing does catch certain errors but on the other hand, duck typing makes it a whole lot easier to write the tests. –  Aaronaught Sep 6 '13 at 20:50
@Aaronaught And then the java/dotnet camp will come back and say that unit tests are easy to write in a static context if you adhere to good OO principles, and always code to an interface. And round and round we go. The holy war doesn't invalidate the question, like the answers suggest. –  jwrush Sep 7 '13 at 2:13
show 5 more comments

5 Answers

up vote 5 down vote accepted


Not everyone agrees with the premise that JavaScript is terrible, but you certainly aren't the first person to espouse that view. However, your choices are somewhat limited unless you want to "roll your own." I've included a non-exhaustive tour of some better-known options below.

Client-Side Interpreters

You can write client-side scripts in any language that the browser supports. The reason most web applications use JavaScript is because it is (for practical purposes) the only interpreter you can rely on being present—for various values of "rely," and acknowledging the existence of browsers like Lynx and Dillo, or the use of NoScript.

For example, the Tcl/Tk Tclet plugin allows Tcl scripts to be executed by web browsers. See more discussion about Tclet and Safe-Tcl here and here.


For a more comprehensive list of languages that compile to JavaScript, including a list of languages that provide static typing, consult the CoffeeScript wiki. Here are a couple of examples.


If you don't like JavaScript, you may or may not like CoffeeScript. It won't provide you with the strong typing you want, but I can't imagine discussing this class of languages without mentioning it. CoffeeScript uses a sort of Ruby-ish syntax that compiles to JavaScript. It's not Java, and it's not C#...it isn't even Ruby. However, in my opinion it makes some of the sharp edges of JavaScript easier to deal with, although I don't think it fully abstracts away all of JavaScript's syntactical or conceptual idiosyncrasies.


I have absolutely no opinion about it as a platform, but TypeScript might appeal to C# developers. The description on the home page states that:


The examples also indicate that it supports types and classes, but you'll have to vet it yourself to see if it meets whatever criteria you're using to evaluate your options.

share|improve this answer
add comment

dart made some noise about a year ago as an attempt to make something nicer that compiles down to JavaScript. It sounds just like what you're looking for, even if it doesn't go all the way to a Java/C# style statically/(mostly)strongly typed language.

share|improve this answer
It's worth noting that running Dart without its virtual machine requires dart2js to compile it down to JavaScript. –  CodeGnome Sep 6 '13 at 21:17
add comment

Given the increasing popularity of node.js, it doesn't seem like Javascript is going to be replaced or obsolete any time soon.

To directly answer your question, in addition to TypeScript, Dart, etc. there is always JSLint, which provides a validation layer for your JS code.

Further, if frustrated by JavaScript, I highly recommend Douglas Crockford's writings on the subject.

share|improve this answer
add comment

If you are familiar with C# and Visual Studio and like the strong-typness of C#, then definitely TypeScript is the answer for you.

share|improve this answer
add comment

I am with you. I find Javascript pretty hard to learn, and hard to remember.

I would highly recommend CoffeeScript. It is similar to Ruby on syntax, so depending on what server-side framework you are using, it may go along nicely. From what I have read, it is completely and totally awesome! It is definitely something I would like to learn/use someday.

Personally, I use jQuery. I know you tried it already, so it may not be the right thing for you. It meets my needs for just about everything. But I still can read Javascript, and can write basic JS. I would use it for somethings, though; such as form validation, math, etc.

TypeScript and Dart are also viable alternatives, bu I don't know that much about them.

share|improve this answer
jQuery isn't a language, it's a library for JavaScript. –  Aaronaught Sep 6 '13 at 21:41
add comment
