When comparing Haxe vs Dart, the Slant community recommends Dart for most people. In the question“What is the best programming language to learn first?” Dart is ranked 25th while Haxe is ranked 33rd. The most important reason people chose Dart is:
Dart is a single threaded programming language. So if any piece of code blocks the execution of the program, the program practically freezes. To avoid this Dart makes use of asynchronous operations which let your program run without getting blocked. This is done through Future objects. A Future is an object which represent a means for getting a value at a certain point in the future. A function may invoke a Future and when that happens, two outcomes can be achieved: 1. The function is unable to return a value, so it queues up work to be done and returns an uncompleted Future object. 2. Or later when a value is available to be returned, the Future object completes with that value.
Ranked in these QuestionsQuestion Ranking
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.
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 Pick up errors at compile time
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 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 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 Extremely fast compilation
Haxe can easily compile over 100,000 lines of code to JS in seconds on a mid-spec computer.
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 Large library support. From servers to games.
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
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 Available in NPM
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 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 Abstracts allows me to create more intative api's without runtime overhead
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 Type safety for exísting JS libraries
Haxe compiler will check types when using externs for existing libraries.
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.
Pro Great async language support
Dart is a single threaded programming language. So if any piece of code blocks the execution of the program, the program practically freezes. To avoid this Dart makes use of asynchronous operations which let your program run without getting blocked. This is done through Future objects.
A Future is an object which represent a means for getting a value at a certain point in the future. A function may invoke a Future and when that happens, two outcomes can be achieved:
- The function is unable to return a value, so it queues up work to be done and returns an uncompleted Future object.
- Or later when a value is available to be returned, the Future object completes with that value.
Pro Great standard library
Dart includes a truly comprehensive core library, making it unnecessary to include disparate, external resources for basic functionalities Other than reducing the need to pull in various 3rd-party utilities this also ensures that all Dart code looks and feels the same.
Out of the box, the developer gets core libraries to help with: async, collections, strings, regexps, conversions, formats, file I/O, math, typed data, and more.
In Dart many browser differences (subtle differences and also missing features) are abstracted away or polyfilled. When Dart is transpiled to JS the output works on all supported browsers. There is usually no need to load polyfills or to consider browser differences during development. No need for libraries like jQuery to make the same code work the same on all browsers.
Pro Will be familiar to Java developers
The language will look familiar to Java developers, easing the learning curve.
And yet, while it's similar, it has some nice syntax facilities to avoid common boilerplate code found in Java. Code is terser, yet readable.
Pro No compile time in development
Dartium (Chromium derivative) is a browser with integrated Dart VM, which allows you to run and debug native Dart code during development for short edit-reload cycles. Only for testing on other browsers and deployment is transpiling to JS necessary.
Pro A lot of tools are available to help in developing with Dart
Dart has a lot of tools available which help with developing Dart applications. Some examples of those tools include:
- pub - package and dependency management and build tool
- analyzer - static syntax analysis with linter, quick fixes, autocompletion support for easy IDE integration
- test - powerful and flexible testing framework and test runner
- dev_compiler - generate reusable JS instead of tree-shaken minified JS output (work in progress)
- dartfmt_ - source code formatter
- server-side VM
- observatory - a powerful tool for profiling and debugging running Dart code (for Dartium and Dart server code)
Pro Easy prototyping
Dart has an optional type system which makes Dart a great language for prototyping. It encourages developers to gradually evolve their programs without worrying about types first.
Pro AngularDart 2.0 support
Pro Optional strong mode.
Strong mode applies a more restrictive type system to Dart to address its unsound, surprising behavior in certain cases.
Pro Can compile to efficient machine code
Dart was designed to be as expressive as possible. Ahead-of-time compilers can compile Dart code to efficient machine code. This is especially important when deploying to mobile where you don't want (or can't) use a JIT.
Pro Support of semi-coroutines (generators)
Generators, also known as semicoroutines, are also a generalization of subroutines.
Generators are primarily used to simplify the control of iteration behavior of a loop, the
yield statement in a generator passes a value back to a parent routine.
A generator is very similar to a function that returns an array, in that a generator has a certain number of values. But instead of building and returning an array that contains all the wanted values, a generator returns them one at a time, this saves memory and allows the caller function to start processing the first few values immediately.
Some popular libs like JQuery have maintained externs, for any specific code or lib already in JS you have to write the externs to use it in your haxe application.
Con Bad support in some popular IDEs
While it has great support in Visual Studio Code and Vim for example, it still lacks support in some IDEs such as IntelliJ.
Con No Qt support
There is currently no support for Qt.
Con Full programs only
You can create small utility functions with Haxe, but generally it is a lot more work than with other JS compilers. Haxe is best used when you have a larger project.
Con It's not easy to convince people it's as good as it really is unless you can get them to really try it
Con Dart SDK does not provide standard (out of the box) way to access SQL-based databases on server side
This missing (but very popular) feature requires to use 3rd-party packages developed by the personal enthusiasts or very small groups of enthusiasts, which is not very convenient because they are all very fragmented in terms of content, the essence and capabilities.
Con Small community, little momentum