When comparing TypeScript vs Haxe, the Slant community recommends TypeScript for most people. In the question“What is the best programming language to learn first?”TypeScript is ranked 20th while Haxe is ranked 33rd. The most important reason people chose TypeScript is:

Typescript has optional static typing with support for interfaces and generics, and intelligent type inference.
It makes refactoring large codebases a breeze, and provides many more safeguards for creating stable code.

Pro

Strong typed language

Pro

Strict superset of Javascript

Every existing Javascript program is already a valid TypeScript program giving it the best support for existing libraries, which is particularly useful if you need to integrate with an existing Javascript code base.

Pro

Polyfill for ES6 fat-arrow syntax

Typescript implements the fat arrow syntax, which always maintains the current context for this and is a shorter/more convenient syntax than traditional function definition.

Pro

First party Visual Studio support

As a Microsoft developed project, it has first party Visual Studio support that's on par with its C# support with features like syntax sensitive statement completion.

Pro

Clear roadmap

TypeScript has a clear and defined roadmap with rapid and constant releases.

Pro

Has a repository of high quality TypeScript type definitions for popular libraries

There are many ready to use and high quality TypeScript definitions for popular libraries including jquery, angular, bootstrap, d3, lodash and many-many more.

Pro

Great support for React, integrated typed JSX parsing

Pro

Works well with existing Javascript code

Both can call Javascript code and be called by Javascript code. Making transitioning to the language very easy.

Pro

Compiles to very native looking code

Compiles to simple looking Javascript making it easy to understand what is happening and learn the language (if you already know Javascript).

Pro

Ability to do functional programming

Pro

Compiles to multiple platforms and languages

Haxe allows you to develop for Web, iOS, Android, Blackberry, Windows, OSX, Linux and others, all at once, without the need to switch languages and maintain separate code bases.

This is possible because Haxe can compile to JavaScript, ActionScript, Flash AVM bytecode, C++, Neko, PHP, C# (.NET) and Java.

Support for even more platforms and languages is under development.

Pro

Powerfully expressive but easy to learn

The language was designed to be very expressive with the smallest possible amount of syntactic sugar. There are actually fewer keywords than other languages with similar power.

Pro

Extremely fast compilation

Haxe can easily compile over 100,000 lines of code to JS in seconds on a mid-spec computer.

Pro

Pick up errors at compile time

One big advantage over pure javascript, (or some other languages listed here) is that Haxe will pick up a whole range of errors when you compile, saving you the pain of having to try and debug them later. This includes everything from syntax errors ("Unexpected ;") to type errors ("Class user has no field username. Suggestion: username").

Pro

Ability to use existing JS libraries

Haxe has the ability to use "externs". These are haxe files which describe the usage of existing JS libraries. Get code completion and compile-time-checking for everything from jQuery to Node.js.

Even without externs, native JS code can still be used through untyped code.

Pro

First class code completion

Code completion is built into the compiler and available to the IDE allowing for much smarter code completion that can actually parse and understand the syntax tree.

Pro

Syntactic macros

Syntactic macros allow you to extend compiler features at the syntax tree step. Macros come into play after code is parsed into the abstract syntax tree, and macros allow you to transform it before the rest of the compilation completes.

This provides for immense power, while at the same time scoping the extensibility at a level that is powerful, but well constrained.

Pro

Large library support. From servers to games.

Haxelib (common library repo) and other sources contain large codebases for anything from cryptography to communications. A lot of these are fully cross platform and work with the JavaScript target.

The JavaScript target can be used for everything from node.js server applications (with code completion) to games using either the Flash-like OpenFL library or direct canvas or WebGL programming.

Pro

Code reuse server side and client side

You can use the same classes on the server as you do on the client where applicable. This saves a lot of time.

Pro

Similar to JavaScript and ActionScript 3

The language is very easy to learn for those with background in JavaScript or ActionScript 3.

Pro

Small, readable output

The output that is generated can be trimmed using "dead code elimination" to only include those functions and libraries that are strictly necessary. All code is very readable with only minimal extras for specific functionality.

Small output is good for frontend development as file size is a major concern.

Pro

Established project

Haxe has been around for more than 10 years (since 2005) and whilst not the most popular project, has had continuous growth.

Highly unlikely to disappear or for support to stop.

Pro

Powerful type inference with strong typing

After a type is inferred from its context, it cannot be changed to a new type, and type safety is done at compile time so it stays safe without the extra maintenance required for static typing.

Pro

Algebraic data types and pattern matching.

Pro

Friendly community

Friendly community

Pro

Offload execution to the server with remoting

Using a remoting proxy you can get type safe server to client communications, allowing for remote method execution on the server as if they were part of the client side code.

Pro

Package management like Java

Package tree is just directory tree, it's wonderful!

Pro

Builtin conditional compilation support

Haxe supports conditional compilation, so depending on compiler flags Haxe will include or exlcude sections of your code. Making it easy to have debug and release builds.

Pro

Create without needing to be limited to a language, target, or commercial ecosystem

Pro

Available in NPM

Pro

Type safety for exísting JS libraries

Haxe compiler will check types when using externs for existing libraries.

Pro

Can create complex applications without needing webpack, npm or other crutches

Haxe has the power and expression to not need the npm dependancy hell that is common in js and typescript, bit it's still simple.

Pro

Abstract enums allow constants with exhaustiveness check

You can define constants in an abstract enum and when used in a switch/case statement Haxe checks for exhaustiveness, making sure every constant is covered - with no runtime implication.

Pro

Pro

Ability to skip type checking when calling non Haxe code

You should use externs when calling non Haxe code, but if you just need to call one or two external JS functions, you can skip type checking by calling untyped code.

Ad

Cons

Con

No support for dead code elimination

Typescript compiler does not remove dead code from generated file(s), you have to use external tools to remove unused code after compilation. This is harder to achieve, because Typescript compiler eliminated all type information.

Con

Too similar to Javascript

Presents some advantages compared to Javascript, but because it is designed to be a superset of Javascript, it means all the bad parts of Javascript are still present.

Con

No support for conditional compilation

There is no clean way to have debug and release builds compiled from the same source, where the release version removes all debugging tools and outputs from the generated file(s).

Con

Type checking not enforced by default

You have to use compiler flags to make sure it catches flaws like usage of implicit any, etc.

Con

Type inference coverage is incomplete

The default type when declaring and using a variable is any. For example, the following should break but does not:

It's not easy to convince people it's as good as it really is unless you can get them to really try it

Alternative Products

Each month, over 2.8 million people use Slant to find the best products and share their knowledge. Pick the tags you’re passionate about to get a personalized feed and begin contributing your knowledge.