What is the benefit of desiging a language strongly typed? Like haxe itself?

Haxe is strongly typed language. What are the benefits though? I see it increases the amount of code programmers need to write and have to mention every type for almost every line of code they write.
Some benefits I hear are

  1. It helps compiler to sort variables in proper categories and thus the code compiles faster.

  2. It may probably help the IDE to make code more readable.

  3. It helps reducing the possible bugs like null pointer ( but how exactly? Cannot I just verify the variable by null comparison always?)

Are there more benefits?

No they don’t. :slight_smile: https://haxe.org/manual/type-system-type-inference.html

1 Like

Linting is a huge benefit

The number of times I’ve spent hours (or days!) searching for bugs caused by dynamic (untyped) code is shameful

I find it much quicker to let the compiler tell me where my application breaks than to find out (or not find out) at runtime


Use Haxe for a few months and then see if your question still makes sense likely usage will change your viewpoint significantly and you will not be so keen to go back to the language you used to use.

Oh here’s another reason

Hmm. But especially looking at Javascript vs Typescript ( which is known for it’s type specification ) w.r.t javascript,

Typescript seems to be consuming more energy,time and memory than Javascript?

In short, there are compile-time benefits to having a strictly typed language, and there are runtime benefits possible only by having a strict language. Advances in performance in JavaScript is only possible by turning “static enough” code into a static representation at runtime. I wonder whether this test omits possible ordinary user use-cases (like a full game is very different than a single math algorithm) however TypeScript gains no runtime performance benefits because it still is JavaScript at the end of the day. That is interesting though because I have seen 15% performance gains anecdotally using Haxe to compile to JavaScript over hand-written JavaScript due to being more compatible with V8 runtime optimizations. Perhaps it’s an issue of ES6 vs ES5 performance

Another benefit is code completion. If the type is declared, methods and properties associated with that type can be accessed instantly via code completion in a decent IDE. Arguments for methods usually require specific types too, and this again would be available via code completion and hinting.

That is a massive time saver.

1 Like