Compiling to JavaScript: TypeScript vs. Haxe
lars_doucet writes: Released in 2012, Microsoft's TypeScript is perhaps the best-known "compile to JS" language, but it wasn't the first. One of the earliest was Haxe, whose JS target first appeared in 2006. In his illuminating article, TypeScript vs Haxe, Andy Li gives an excellent rundown of the two languages' various merits, but the bottom line is: "Existing JS developers will favor TypeScript as they are more similar in many ways. They can utilize their existing skills immediately. Non-JS developers with backgrounds like Java/C# or even from the functional programming world will appreciate Haxe more since it fixes a lot of weirdness of JS." The full article includes an excellent rundown of the type systems, syntax, scope handling, compilers, and overall language design philosophy.
Why? It's a shit language that's grown way beyond its intended use.
Oh come on. Shitting on javascript is timeless.
Once we have native WebAssembly support in browsers, and a significant percentage of the major websites have moved across to compiling from better languages into WebAssembly, those new sites are going to feel amazingly snappy, and people aren't going to want to use old Javascript sites, because they'll feel janky.
Aaah you are in good fooling this morning, sir!
Given that (a) computers have got vastly faster and (b) javascript engines have got vastly faster and (c) websites keep getting slower and slower, I somehow suspect that the future is not going to be a bright one like the distant past where UI lag was a rare thing.
Here's another thing that irks me. The old "obsolete" X11 style was to have sub-sub-sub windows for damn near everything. Every UI element was in it's own subwindow. Subwindows were on the server, so when you clicked the mouse, it knew which subwindow you hit and sent that message. The modern, not "obsolete" style is to have one window and use pixel addressing.
The former works much, much better in a world of UI and network lag. The common latter means you have the lovely thing where you press, the UI jumps and then processes the click afterwards so you hit the wrong place with sometimes hilaroius concepts.
What's kind of funny is the web is slowly slouching towards a dubious re-inventing of the past 50 years of computing without bothering to learn anything about the old mistakes.
Now I'm going to go back to poking badly documented registers on 4k 8051 microcontroller because frankly the web "technologies" makes that pile of insanity look good.
SJW n. One who posts facts.
I know this is going to get a lot of hate, but JavaScript is really not as bad as people make out. There are some stupid design decisions (mostly around scoping and built-in type consistency) but once you know what these are it is pretty easy to work with them. The main problem I think most people have is that it does not really offer any sort of hand-holding in terms of how you should structure your program. But in a way it is quite beautiful how you can create usable frameworks for OO, imperative, or functional programming with the same language. The problem I mostly see is that people get stuck with a poor design decision, but rather than having to re-factor their object structure (like C# would force you to do), they can just hack in a solution that breaks basically every principle of good programming imaginable. They then dump this solution on the world and declare it is because JavaScript sucks. The real issue is that they are bad programmers who came up with a poor design and then used the (somewhat excessive) flexibility of JavaScript to get them out of a corner. Same thing has happened in C/C++ for years.
I really don't think JavaScript should have become the language of the web, but competent programmers shouldn't listen to all the hate that gets spread around. It is a decent way to introduce yourself to a lot of new programming concepts if you've come from a static OO language background. Once you understand some fundamentals CoffeeScript, TypeScript etc are pretty straight forward and their applicability is obvious.
For what it's worth, if you are doing large programs then something like TypeScript can be very useful. The problem it solves is really an issue with dynamic languages in general though, rather than JavaScript. There are ways to create large maintainable code bases with a dynamic prototypical language, but sometimes the classic OO model just fits a problem better.
How is this post marked flamebait but not the first original one?
Javascript is proving to be one of the most widespread and widely adopted runtimes in the world.
It is cashing cheques that java's ego wrote out.
Compiling to JS is in fact the way most strong typed addicts are able to write javascript without losing their sanity.
Mod Anonymous Coward down to flamebait and leptons to informative please!