When comparing Haxe vs Rust, the Slant community recommends Rust for most people. In the question“What is the best programming language to learn first?” Rust is ranked 21st while Haxe is ranked 32nd. The most important reason people chose Rust is:
Since Rust is statically typed, you can catch multiple errors during compile time. This is extremely helpful with debugging, especially compared with dynamically typed languages that may fail silently during runtime.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
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 Similar to JavaScript and ActionScript 3
The language is very easy to learn for those with background in JavaScript or ActionScript 3.
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 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 Friendly community
Friendly community
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 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 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 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 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 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 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 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 Algebraic data types and pattern matching.
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 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 Type safety for exísting JS libraries
Haxe compiler will check types when using externs for existing libraries.
Pro Available in NPM
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 Create without needing to be limited to a language, target, or commercial ecosystem
Pro Abstracts allows me to create more intative api's without runtime overhead
Pro Catch errors at compile-time
Since Rust is statically typed, you can catch multiple errors during compile time. This is extremely helpful with debugging, especially compared with dynamically typed languages that may fail silently during runtime.
Pro Compiles to machine code allowing for extra efficiency
Rust uses LLVM as a backend, among other things this allows Rust code to compile down to machine languages. This allows developers to write programs that run as efficiently as possible.
Pro Threads without data races
Unique ownership system guarantees a mutable data to be owned and mutated by only one thread at a time, so there's no data race, and this guarantee is checked at compile time statically. Which means easy multi-threading.
Of course, immutable data can be shared among multiple threads freely.
Pro Generics support
You don't have to write same array and dictionary classes hundreds and thousands times for strong type check by compiler.
Pro Built-in concurrency
Rust has built-in support for concurrency.
Pro Supports cross compilation for different architectures
Since Rust 1.8 you can install additional versions of the standard library for different targets using rustup/multirust
.
For example:
$ rustup target add x86_64-unknown-linux-musl
Which then allows for:
$ cargo build --target x86_64-unknown-linux-musl
Pro Makes developers write optimal code
Rust is a modern programming language written around systems. It was designed from the ground up this way. It's language design makes developers write optimal code almost all the time, meaning you don't have to fully know and understand the compiler's source code in order to optimize your program.
Furthermore, Rust does not copy from memory unnecessarily, to give an example: all types move by default and not copy. Even references to types do not copy by default. In other words, setting a reference to another reference destroys the original one unless it's stated otherwise.
Pro Support for macros
When you identify a part of your code which gets repeated often, which you cannot abstract using functions or classes, you can use Rust's built-in Macros.
Pro Official package manager and build tool
Cargo is the official package manager for Rust. It comes with the language and downloads dependencies, compiles packages, and makes and uploads distributable packages
Pro Easy to write understandable code
While not as verbose as Java, it still is much more verbose than languages like Go and Python. This means that the code is very explicit and easy to understand.
Pro Big community
The biggest community contributing to language.
Pro Functional programming
Very easy to create functional with some additional from structure application.
Pro Excellent syntax
Pro Safety
Pro No GC
Pro Low memory usage
Pro Static compiled & statically linked single file output
Pro Extremely fast code execution
Pro Zero-cost futures or Async IO
Cons
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 You need to code interfaces to work with existing JavaScript code
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 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 Long compile times
Way longer to compile than other languages.
Con Low productivity
The compiler is strict, such as ownership and borrowing checkers.
Con Low readability
Harder to read and understand language.
Con Very ugly and verbose syntax
Compared to many languages. One tool needed to be productive is the language to be pleasing and effective, yet Rust friction is as high as its safety.
Con Steep learning curve
Pretty strict and hard to adapt for beginners.
Con Not as useful or productive as advertised.
If really out here wanting to use something besides C/C++, in 98% of use cases, would do just as well or be better off using something other than Rust. Will complete the project faster, would be easier, will be happier, and nearly as safe (use newer language with optional GC).
Con Rust not as safe as it pretends to be
Rust problems:
1) Massive undisclosed usage of unsafe.
2) Massive amounts of memory safety CVEs - see details.
3) Large bloated Rust binaries increase attack surface for exploits.
4) Many corporate types claiming Rust is safe, don't actually program or use it (have some quiet financial interest to push it).
Con Significant time required to understand the language fully
There's the infamous borrow checker for example.
Con Low-level programming language
This means that it encourages the programmer to be very careful in terms of how memory is allocated, etc.
Most applications can run without exceeding the capacity of the server, even with an inefficient dynamic scripting language.