Null safety feedback

We would like to get your feedback for the new experimental null safety feature.
What’s good, what’s bad, what’s surprising etc.

Please try it with the latest Haxe and post your feedback in this thread or start a new one with the “null-safety” tag.

I recommend using static extensions like these for nullable values. Tell us, which extensions you use and which are missing.

1 Like


These static extensions look pretty great, but have you noticed these taking a hit to compilation time?

Thank you for all of your hard work! :slight_smile:

No, I haven’t.
What times does compiler show you with --times argument?

I’m sorry I worded that poorly. I haven’t noticed a hit yet either, but my code base is fairly small at the moment and I was just curious if you had any experience testing these with larger projects.

I will let you know if I do run into anything.

On my MacBook Pro (Mid 2015), 2,2 GHz Core i7:
Null safety check for Haxe compiler unit tests takes ~60ms.
Null safety for VSHaxe (Haxe plugin for Visual Studio Code) takes 4ms

You can run your compilation with --times argument. And if null safety takes longer than 1ms, you will see it in the report.

The feature works pretty neat for the most part, however I’ve noticed that it seems to have trouble with the string library. So for example if I compile with strict on my own modules and then call split or substr on a string in my strict module haxe will complain about assigning null values. If I go into the string library and remove the inline from substr and split the error goes away. As you would figure removing the inline causes the whole program to not work as expected…

@csterling4 See [nullsafety] null safety errors in inlined code · Issue #7897 · HaxeFoundation/haxe · GitHub and Add @:nullSafety(Off) to the first argument of Std.isOfType(v, t) by RealyUniqueName · Pull Request #9154 · HaxeFoundation/haxe · GitHub.

Its good that its a known issue. The null feature can really reduce the amount of code you have to write, knowing that a variable actually has a value is great.

1 Like